NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.49k stars 4.79k forks source link

vendors 包超过500kb,导致开发者工具es6 =>es5失效;window桌面版小程序报错 #9573

Open YellowPure opened 3 years ago

YellowPure commented 3 years ago

相关平台

微信小程序

小程序基础库: 2.17.0 使用框架: React

复现步骤

开启开发者工具的es6转es5,当vendors体积大于500kb时,window桌面版小程序报错

期望结果

可自定义commonchunks 的name,希望由splitchunks中具体的chunksName生成

实际结果

目前commonChunks Name为代码中defaultCommonChunks 静态变量而来,无法和splitchunks中Name匹配

环境信息

Taro CLI 3.2.8 environment info:
    System:
      OS: macOS 11.4
      Shell: 3.1.2 - /usr/local/bin/fish
    Binaries:
      Node: 14.9.0 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.8 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.2.8 => 3.2.8 
      @tarojs/components: 3.2.8 => 3.2.8 
      @tarojs/mini-runner: 3.2.8 => 3.2.8 
      @tarojs/react: 3.2.8 => 3.2.8 
      @tarojs/runtime: 3.2.8 => 3.2.8 
      @tarojs/taro: 3.2.8 => 3.2.8 
      @tarojs/webpack-runner: 3.2.8 => 3.2.8 
      babel-preset-taro: 3.2.8 => 3.2.8 
      eslint-config-taro: 3.2.8 => 3.2.8 
      react: ^16.10.0 => 16.14.0 
      taro-ui: 3.0.0-alpha.3 => 3.0.0-alpha.3
Dunqing commented 3 years ago

commonChunks不是可以自己配置吗?

YellowPure commented 3 years ago

目前我项目中


cacheGroups: {
common: {
name: 'common',
minChunks: 2,
priority: 1
},
vendors2: {
name: 'vendors2',
test: /[\\/]node_modules[\\/](taro-ui|crypto-es|)[\\/]/,
priority: 20,
enforce: true,
reuseExistingChunk: true
},
vendors3: {
name: 'vendors3',
test: /[\\/]node_modules[\\/](mobx|mobx-react|mobx-react-lite|elliptic|
react-reconciler|browserify-sign|browserify-rsa|)[\\/]/,
priority: 20,
enforce: true,
reuseExistingChunk: true
},
vendors: {
name: 'vendors',
minChunks: 2,
test: module => {
return /[\\/]node_modules[\\/]/.test(module.resource);
},
// maxSize: 900000,
priority: 10
},
taro: {
name: 'taro',
test: module => {
return taroBaseReg.test(module.context);
},
priority: 100
}
}

commonChunks: commonChunks => {
console.log('commonChunks', commonChunks);
commonChunks.push('vendors2', 'vendors3');
return commonChunks;
}
这样手动去设置chunk,我希望能通过cacheGroup时能通过maxSize分包,此时commonchunks
应该是不固定的吧?请问有方案可以满足此场景吗

dengqing ***@***.***> 于2021年7月14日周三 下午8:00写道:

> commonChunks不是可以自己配置吗?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/NervJS/taro/issues/9573#issuecomment-879831186>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABN2XRT7CB6GTLIOX4UX243TXV37LANCNFSM47AU5JNQ>
> .
>
Dunqing commented 3 years ago

动态的好像不行,把react、taro、mobx 主要几个大库拆出来应该不会大于500k了吧

YellowPure commented 3 years ago

对,但是需要手动拆包,没法用maxSize这样 相当于开发者要手动控制 我看taro好像在迭代这块

dengqing @.***> 于2021年7月15日周四 上午9:47写道:

动态的好像不行,把react、taro、mobx 主要几个大库拆出来应该不会大于500k了吧

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NervJS/taro/issues/9573#issuecomment-880324966, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABN2XRSNC5RV6MRPZCHGEG3TXY423ANCNFSM47AU5JNQ .