dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.14k stars 3.63k forks source link

vue-cli创建Vue2项目,编译到微信小程序时卡住不动 #4261

Open CrescentSine opened 1 year ago

CrescentSine commented 1 year ago

问题描述 使用vue-cli创建Vue2项目,编译到微信小程序时,控制台卡死在”开始编译当前项目至 mp-weixin 平台...“不动。 其实webpack已经因为vue-cli-plugin-uni中的代码崩溃掉了。

问题原因 Webpack编译uniapp项目时,webpack/lib/Compilation.js脚本可能会产生出name为null的chunk; 该chunk被webpack/lib/optimize/SplitChunksPlugin处理时,会调用从@dcloudio/vue-cli-plugin-uni/lib/split-chunks.js中第80行传入的函数来判断是否进行分割,因其name为null而产生运行时错误崩溃。

预期结果 希望能正常打包

系统信息:

Environment Info:

System: OS: Windows 10 CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-1260P Binaries: Node: 18.7.0 - ~\AppData\Local\nvs\default\node.EXE Yarn: 1.22.19 - ~\AppData\Local\nvs\default\yarn.CMD npm: 8.15.0 - ~\AppData\Local\nvs\default\npm.CMD Browsers: Edge: 44.22621.1413.0 npmPackages: @dcloudio/types: ^3.3.2 => 3.3.2 @dcloudio/uni-app: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-app-plus: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-automator: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-cli-i18n: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-cli-shared: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-h5: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-helper-json: * => 1.0.13 @dcloudio/uni-i18n: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-migration: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-360: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-alipay: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-baidu: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-jd: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-kuaishou: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-lark: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-qq: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-toutiao: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-vue: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-weixin: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-mp-xhs: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-quickapp-native: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-quickapp-webview: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-stacktracey: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-stat: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/uni-template-compiler: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/vue-cli-plugin-uni: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/webpack-uni-mp-loader: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @dcloudio/webpack-uni-pages-loader: ^2.0.2-3070320230222001 => 2.0.2-3070320230222001 @hap-toolkit/dsl-vue: 0.6.13 @volar/vue-language-core: 1.2.0 @volar/vue-typescript: 1.2.0 @vue/babel-helper-vue-jsx-merge-props: 1.4.0 @vue/babel-helper-vue-transform-on: 1.0.2 @vue/babel-plugin-jsx: 1.1.1 @vue/babel-plugin-transform-vue-jsx: 1.4.0 @vue/babel-preset-app: 5.0.8 @vue/babel-preset-jsx: 1.4.0 @vue/babel-sugar-composition-api-inject-h: 1.4.0 @vue/babel-sugar-composition-api-render-instance: 1.4.0 @vue/babel-sugar-functional-vue: 1.4.0 @vue/babel-sugar-inject-h: 1.4.0 @vue/babel-sugar-v-model: 1.4.0 @vue/babel-sugar-v-on: 1.4.0 @vue/cli-overlay: 5.0.8 @vue/cli-plugin-babel: ~5.0.0 => 5.0.8 @vue/cli-plugin-router: 5.0.8 @vue/cli-plugin-typescript: ~5.0.8 => 5.0.8 @vue/cli-plugin-vuex: 5.0.8 @vue/cli-service: ~5.0.0 => 5.0.8 @vue/cli-shared-utils: 5.0.8 @vue/compiler-core: 3.2.47 @vue/compiler-dom: 3.2.47 @vue/compiler-sfc: 3.2.47 @vue/compiler-ssr: 3.2.47 @vue/component-compiler-utils: 3.3.0 @vue/composition-api: ^1.7.1 => 1.7.1 @vue/reactivity: 3.2.47 @vue/reactivity-transform: 3.2.47 @vue/runtime-core: 3.2.47 @vue/runtime-dom: ^3.2.47 => 3.2.47 @vue/shared: ^3.2.47 => 3.2.47 @vue/web-component-wrapper: 1.3.0 unplugin-vue2-script-setup: ^0.11.3 => 0.11.3 vue: >= 2.6.14 < 2.7 => 2.6.14 vue-hot-reload-api: 2.3.4 vue-loader: 17.0.1 (17.0.1) vue-style-loader: 4.1.3 vue-template-compiler: >= 2.6.14 < 2.7 => 2.6.14 vue-template-es2015-compiler: 1.9.1 vue-tsc: ^1.2.0 => 1.2.0 vuex: ^3.6.2 => 3.6.2 npmGlobalPackages: @vue/cli: Not Found

补充信息 我搜到split-chunks.js中81行和248行是相同的写法,希望开发者一并评估可能导致webpack崩溃的风险,并一并修复。 以及我不知搜索字符串"node-modules"(中间是连字符而非下划线)以及只判断结果的写法,是否为0能否在所有环境达成该函数预期的目标,希望开发者可以对此进行评估。

CrescentSine commented 1 year ago

因为网卡了,发布重复