-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
开启treeShaking后 构建h5出现两份 #638
Comments
目前是这样的,这个不影响实际运行效果 |
新的问题 开启treeshaking后 request showLoading等一大堆api显示未实现 构建后的工程直接无法运行 估计把你们自己的基础库都丢了 |
测试没重现问题,你的项目使用了 |
你调用这些 api 的方式是什么?是 uni.request 这样调用的吗 |
那storage应该没问题的才对吧 showLoading我也是加了promisify封装 |
你可以弄一个简单的工程验证下,理论上是这样的 |
额不行,还是显示那些api未实现,storage的api只有这里用了 用在vuex插件里vuex-persistedstate |
你可以把测试工程放到 GitHub 上或上传 ask 社区,贴一下地址,我来验证下:https://ask.dcloud.net.cn/explore/ |
你的这些 api 的封装是在 node_modules 里边?如果是的话,可以 npm update 一下,已修复 node-modules 未被扫描的问题 |
不是 就是我的业务代码里的 在store里 使用vuex插件内 |
已经知道问题所在了 我的项目是cli创建的 在你们出treeshaking前的事 babel.config没更新 if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) { const isWin = /^win/.test(process.platform) const normalizePath = path => (isWin ? path.replace(/\/g, '/') : path) const input = normalizePath(process.env.UNI_INPUT_DIR) process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui'] 这是现在的 if (process.env.UNI_OPT_TREESHAKINGNG) { if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_USING_V8) { const isWin = /^win/.test(process.platform); const normalizePath = path => (isWin ? path.replace(/\/g, '/') : path); const input = normalizePath(process.env.UNI_INPUT_DIR); process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']; |
问题描述
开启treeShaking后,运行npm run build:h5,先出现一份index.js chunk-vendor.js 然后出现第二份哈希值的 html内引用指向第二份,关闭treeshaking后就没问题
复现步骤
[复现问题的步骤]
[或者可以直接贴源代码]
预期结果
[使用简洁清晰的语言描述你希望生效的预期结果]
实际结果
![image](https://user-images.githubusercontent.com/16952163/62683115-4c020080-b9f0-11e9-97d5-b45fb23a458f.png)
[这里请贴上你的报错截图或文字]
系统信息:
Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz
Binaries:
Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.10.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.18362.267.0
npmPackages:
@dcloudio/uni-app-plus: * => 0.0.249
@dcloudio/uni-app-plus-nvue: 0.0.1
@dcloudio/uni-app-plus-nvue-v8: 0.0.1
@dcloudio/uni-cli-shared: * => 0.2.983
@dcloudio/uni-h5: * => 0.7.4
@dcloudio/uni-mp-alipay: * => 0.0.823
@dcloudio/uni-mp-baidu: * => 0.0.853
@dcloudio/uni-mp-qq: * => 0.0.107
@dcloudio/uni-mp-toutiao: * => 0.0.347
@dcloudio/uni-mp-weixin: * => 0.0.969
@dcloudio/uni-template-compiler: * => 0.9.181
@dcloudio/vue-cli-plugin-hbuilderx: latest => 1.0.131
@dcloudio/vue-cli-plugin-uni: latest => 0.9.511
@dcloudio/vue-cli-plugin-uni-optimize: latest => 0.1.6
@dcloudio/webpack-uni-mp-loader: * => 0.3.639
@dcloudio/webpack-uni-nvue-loader: 0.0.1
@dcloudio/webpack-uni-pages-loader: * => 0.2.866
@vue/babel-helper-vue-jsx-merge-props: 1.0.0
@vue/babel-plugin-transform-vue-jsx: 1.0.0
@vue/babel-preset-app: 3.10.0
@vue/babel-preset-jsx: 1.1.0
@vue/babel-sugar-functional-vue: 1.0.0
@vue/babel-sugar-inject-h: 1.0.0
@vue/babel-sugar-v-model: 1.0.0
@vue/babel-sugar-v-on: 1.1.0
@vue/cli-overlay: 3.10.0
@vue/cli-plugin-babel: 3.5.1 => 3.5.1
@vue/cli-service: ^3.9.0 => 3.10.0
@vue/cli-shared-utils: 3.10.0
@vue/component-compiler-utils: 2.6.0 (3.0.0)
@vue/preload-webpack-plugin: 1.1.1
@vue/web-component-wrapper: 1.2.0
mpvue-page-factory: 1.0.1
mpvue-template-compiler: 1.0.13
uni-h5-vue: 2.6.10
uni-mp-vue: 2.6.10
vue: ^2.6.10 => 2.6.10
vue-hot-reload-api: 2.3.3
vue-loader: 15.7.1
vue-router: 3.0.1
vue-style-loader: 4.1.2
vue-template-compiler: ^2.6.10 => 2.6.10
vue-template-es2015-compiler: 1.9.1
vuex: ^3.0.1 => 3.1.1
vuex-persistedstate: ^2.5.4 => 2.5.4
npmGlobalPackages:
@vue/cli: Not Found
补充信息
[可选]
[根据你的分析,出现这个问题的原因可能在哪里?]
The text was updated successfully, but these errors were encountered: