taro
taro copied to clipboard
使用splitChunks已成功提取文件,但是app.js报错Cannot read property 'mount' of null
相关平台
微信小程序
小程序基础库: 2.30.3 使用框架: React
复现步骤
- 添加外部依赖文件,提取外部依赖文件单独打包
- 在app.js 引用该文件,地址为项目中文件对应地址
chain.merge({
optimization: {
splitChunks: {
cacheGroups: {
timWx: {
test: /\/src\/utils\/abc\.js$/,
name: "abc",
chunks: "all",
enforce: true,
},
},
},
}
})
期望结果
无相关报错
实际结果
app.js报错Cannot read property 'mount' of null
环境信息
Taro CLI 3.6.5 environment info:
System:
OS: macOS 13.0.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 14.21.1 - ~/.nvm/versions/node/v14.21.1/bin/node
npm: 6.14.17 - ~/.nvm/versions/node/v14.21.1/bin/npm
npmPackages:
@tarojs/cli: 3.5.12 => 3.5.12
@tarojs/components: 3.5.12 => 3.5.12
@tarojs/plugin-framework-react: 3.5.12 => 3.5.12
@tarojs/react: 3.5.12 => 3.5.12
@tarojs/runtime: 3.5.12 => 3.5.12
@tarojs/taro: 3.5.12 => 3.5.12
@tarojs/webpack5-runner: 3.5.12 => 3.5.12
babel-preset-taro: 3.5.12 => 3.5.12
eslint-config-taro: 3.5.12 => 3.5.12
react: ^16.10.0 => 16.14.0
hello 我也遇到了这个问题,请问解决了吗
+1,有解决吗?
解决了吗
有人解决吗,急 @TomatoesMan
已解决,在cacheGroups添加两个参数default、defaultVendors
cacheGroups: {
default: false,
defaultVendors: false,
common: {
name: 'common',
minChunks: 2,
priority: 1
},
vendors: {
name: 'vendors',
minChunks: 2,
test: module => /[\\/]node_modules[\\/]/.test(module.resource),
priority: 99
},
taro: {
name: 'taro',
test: module => /@tarojs[\\/][a-z]+/.test(module.context),
priority: 100
}
}