Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taro 2.2.11与原生小程序混合开发 使用addChunkPages 打包后分包页面空白 #8650

Open
wangkefu opened this issue Feb 5, 2021 · 2 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x

Comments

@wangkefu
Copy link

wangkefu commented Feb 5, 2021

相关平台

微信小程序

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

复现步骤

taro与原生小程序混合开发,在packageC里写入原生小程序的页面,在config/index中配置wepackchain和addChunkPages, 抽离出C包里的公共文件,执行np run dev:weapp后小程序能正常打开 但是进入分包页面页面空白,控制台查看wxml没有加载出来,且没有任何报错信息

mini: {
       webpackChain(chain, webpack) {
            chain.merge({
               optimization: {
                  splitChunks: {
                    cacheGroups: {
                           "packageC/subCommon":{
                              name: "packageC/subCommon",
                              priority: 1000,
                             test(module) {
                             if (
                                 /src[\\/]packageC[\\/]utils/.test(module.resource)
                           ) {
                             return true;
                            }
                },
              },
                     }
                  }
              }
          })
      })
}



addChunkPages(pages, pagesNames) {
       pages.set("packageC/pages/edit_post/edit_post", ["packageC/subCommon"]);
    },

期望结果

分包页面也能正常打开

实际结果

空白

环境信息

👽 Taro v2.2.11


  Taro CLI 2.2.11 environment info:
    System:
      OS: macOS 10.14
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.3.1 - /usr/local/bin/node
      npm: 6.14.10 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 2.2.11 => 2.2.11 
      @tarojs/components: 2.2.11 => 2.2.11 
      @tarojs/mini-runner: 2.2.11 => 2.2.11 
      @tarojs/plugin-babel: 2.2.11 => 2.2.11 
      @tarojs/plugin-csso: 2.2.11 => 2.2.11 
      @tarojs/plugin-sass: 2.2.11 => 2.2.11 
      @tarojs/plugin-uglify: ^2.2.7 => 2.2.10 
      @tarojs/redux: 2.2.11 => 2.2.11 
      @tarojs/redux-h5: 2.2.11 => 2.2.11 
      @tarojs/router: 2.2.11 => 2.2.11 
      @tarojs/taro: 2.2.11 => 2.2.11 
      @tarojs/taro-alipay: 2.2.11 => 2.2.11 
      @tarojs/taro-h5: 2.2.11 => 2.2.11 
      @tarojs/taro-swan: 2.2.11 => 2.2.11 
      @tarojs/taro-tt: 2.2.11 => 2.2.11 
      @tarojs/taro-weapp: 2.2.11 => 2.2.11 
      @tarojs/webpack-runner: 2.2.11 => 2.2.11 
      eslint-config-taro: 2.2.11 => 2.2.11 
      eslint-plugin-taro: 2.2.11 => 2.2.11 
      nerv-devtools: ^1.5.7 => 1.5.7 
      nervjs: ^1.5.7 => 1.5.7 
      taro-ui: ^2.2.1 => 2.3.4 
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x labels Feb 5, 2021
@wangkefu
Copy link
Author

没人吗

@jianmo-lc
Copy link

我这边也遇到了相同的问题,我看了下打包出来的代码,在你这个例子中,taro虽然在packageC/pages/edit_post/edit_post页面依赖了packageC/subCommon模块,但是packageC/pages/edit_post/edit_post页面根本就没有引入packageC/subCommon模块。假如你手动在页面文件顶部require一下,代码应该就能跑起来了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-2 Version - 2.x
Projects
None yet
Development

No branches or pull requests

2 participants