taro icon indicating copy to clipboard operation
taro copied to clipboard

使用splitChunks已成功提取文件,但是app.js报错Cannot read property 'mount' of null

Open zhilianbi520 opened this issue 1 year ago • 3 comments

相关平台

微信小程序

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

复现步骤

  1. 添加外部依赖文件,提取外部依赖文件单独打包
  2. 在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 

zhilianbi520 avatar Apr 26 '23 07:04 zhilianbi520

hello 我也遇到了这个问题,请问解决了吗

TomatoesMan avatar May 10 '23 01:05 TomatoesMan

+1,有解决吗?

diamont1001 avatar Jun 29 '23 11:06 diamont1001

解决了吗

jamninetyfive avatar Jan 19 '24 03:01 jamninetyfive

有人解决吗,急 @TomatoesMan

imccode avatar Mar 28 '24 03:03 imccode

已解决,在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
          }
        }

imccode avatar Apr 01 '24 02:04 imccode