Taro: beta5升级到v3.0.0正式版后,在development下vendor.js体积多了400k

Created on 1 Jul 2020  ·  6Comments  ·  Source: NervJS/taro

问题描述
beta5升级到v3.0.0正式版后,在development下vendor.js体积多了400k

复现步骤

  1. yarn add @taro/cli & taro update project v3.0.0
  2. 相比v3.0.0-beta5的development下主包体积大了400多k,导致无法预览
  3. 比较两个版本后的vendor.js会发现多了以下诸多模块(可能列的不完全)
var COMMENT_KEYS = exports.COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];

  1. 本地package.json
"dependencies": {
        "@babel/runtime": "^7.7.7",
        "@tarojs/components": "3.0.0",
        "@tarojs/react": "3.0.0",
        "@tarojs/runtime": "3.0.0",
        "@tarojs/taro": "3.0.0",
        "mobx": "^5.15.4",
        "mobx-react": "^6.2.2",
        "react": "^16.10.0",
        "react-dom": "^16.10.0",
        "taro-ui": "3.0.0-alpha.2"
    },
    "devDependencies": {
        "@babel/core": "^7.8.0",
        "@tarojs/cli": "3.0.0",
        "@tarojs/mini-runner": "3.0.0",
        "@tarojs/webpack-runner": "3.0.0",
        "@types/react": "^16.0.0",
        "@types/webpack-env": "^1.13.6",
        "babel-preset-taro": "3.0.0",
        "eslint": "^6.8.0",
        "eslint-config-taro": "3.0.0",
        "eslint-plugin-import": "^2.12.0",
        "eslint-plugin-react": "^7.8.2",
        "eslint-plugin-react-hooks": "^1.6.1",
        "stylelint": "9.3.0"
    }

期望行为
正式版和beta5版本相当的打包体积

报错信息

正式版比beta5同等条件下多了四百多k的大小

系统信息
Taro CLI 3.0.0 environment info:
System:
OS: macOS 10.14.6
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.8.1 - /usr/local/bin/node
Yarn: 1.22.4 - ~/.yarn/bin/yarn
npm: 6.10.2 - /usr/local/bin/npm
npmPackages:
@tarojs/cli: 3.0.0 => 3.0.0
@tarojs/components: 3.0.0 => 3.0.0
@tarojs/mini-runner: 3.0.0 => 3.0.0
@tarojs/react: 3.0.0 => 3.0.0
@tarojs/runtime: 3.0.0 => 3.0.0
@tarojs/taro: 3.0.0 => 3.0.0
@tarojs/webpack-runner: 3.0.0 => 3.0.0
babel-preset-taro: 3.0.0 => 3.0.0
eslint-config-taro: 3.0.0 => 3.0.0
react: ^16.10.0 => 16.13.1
taro-ui: 3.0.0-alpha.2 => 3.0.0-alpha.2
npmGlobalPackages:
typescript: 3.2.2

补充信息
[可选]

A-runtime P-0 V-3

Most helpful comment

@mercer08 @tarojs/runtime 使用了 @babel/typesisBooleanLiteral 方法,然后 @babel/types 又把整个 lodash 引了进来。

下个版本将去掉 @babel/types 依赖,感谢反馈!

All 6 comments

使用 webpack-bundle-analyzer 分析看看

我从2升级到3,主包体积增加了1300k,
刚刚看了一下,初始项目就有1400k

image

@Chen-jj
分析结果显示总共只有1.2M,但是开发者工具显示2077k
image

@Chen-jj 上面是v3.0.0-rc5,下面是v3.0.2,比较了一下似乎是多出了lodash和core-js的部分
3 0 0-rc5
3 0 2

@YES-Lee 是不是包括 source-map 了

@mercer08 @tarojs/runtime 使用了 @babel/typesisBooleanLiteral 方法,然后 @babel/types 又把整个 lodash 引了进来。

下个版本将去掉 @babel/types 依赖,感谢反馈!

Was this page helpful?
0 / 5 - 0 ratings