Closed guaizi149 closed 1 year ago
H5
浏览器版本: Chrome 62 使用框架: React
执行taro init,然后执行npm run build:h5
未使用的包被treeshaking掉
未使用的包依然被打包到了产物中 项目初始化后,直接执行npm run build:h5。 可以看到很多未使用的包, 像taro-video-control_3, mobile-detect等均被打包进了产物中
Taro CLI 3.5.7 environment info: System: OS: macOS 10.15.7 Shell: 5.7.1 - /bin/zsh Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.0/bin/yarn npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm npmPackages: @tarojs/cli: 3.5.7 => 3.5.7 @tarojs/components: 3.5.7 => 3.5.7 @tarojs/helper: 3.5.7 => 3.5.7 @tarojs/plugin-framework-react: 3.5.7 => 3.5.7 @tarojs/plugin-platform-alipay: 3.5.7 => 3.5.7 @tarojs/plugin-platform-jd: 3.5.7 => 3.5.7 @tarojs/plugin-platform-qq: 3.5.7 => 3.5.7 @tarojs/plugin-platform-swan: 3.5.7 => 3.5.7 @tarojs/plugin-platform-tt: 3.5.7 => 3.5.7 @tarojs/plugin-platform-weapp: 3.5.7 => 3.5.7 @tarojs/react: 3.5.7 => 3.5.7 @tarojs/router: 3.5.7 => 3.5.7 @tarojs/runtime: 3.5.7 => 3.5.7 @tarojs/shared: 3.5.7 => 3.5.7 @tarojs/taro: 3.5.7 => 3.5.7 @tarojs/taro-h5: 3.5.7 => 3.5.7 @tarojs/webpack5-runner: 3.5.7 => 3.5.7 babel-preset-taro: 3.5.7 => 3.5.7 eslint-config-taro: 3.5.7 => 3.5.7 react: ^18.0.0 => 18.2.0 npmGlobalPackages: typescript: 4.8.4
mobile-detect 在 taro-router 中使用,taro-video 是懒加载引入,在未使用时并不会影响应用加载体验,如有特殊场景请参考文档
mobile-detect
相关平台
H5
浏览器版本: Chrome 62 使用框架: React
复现步骤
执行taro init,然后执行npm run build:h5
期望结果
未使用的包被treeshaking掉
实际结果
未使用的包依然被打包到了产物中 项目初始化后,直接执行npm run build:h5。 可以看到很多未使用的包, 像taro-video-control_3, mobile-detect等均被打包进了产物中
环境信息