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

微信小程序不支持workers分包配置 #4589

Closed
GHkmmm opened this issue Nov 9, 2023 · 5 comments
Closed

微信小程序不支持workers分包配置 #4589

GHkmmm opened this issue Nov 9, 2023 · 5 comments

Comments

@GHkmmm
Copy link

GHkmmm commented Nov 9, 2023

问题描述
使用uniapp在mainfest.json中,按照下面配置workers是无效的,但是微信小程序官方是支持这种配置的

{
  ...
  "mp-weixin": {
    "workers": {
      "path": "workers",
      "isSubpackage": true
    }
  }
}

image-20231109102554079

复现步骤

执行npm run dev:mp-weixin报错

预期结果
项目正常启动

实际结果

 ERROR  ValidationError: CopyPlugin Invalid Options

options.2 should be string
options.2 should have required property 'from'
options.2 should match some schema in anyOf

ValidationError: CopyPlugin Invalid Options

options.2 should be string
options.2 should have required property 'from'
options.2 should match some schema in anyOf

    at validateOptions (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/schema-utils/src/validateOptions.js:32:11)
    at new CopyPlugin (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/copy-webpack-plugin/dist/index.js:26:30)
    at /Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@dcloudio/vue-cli-plugin-uni/lib/configure-webpack.js:256:20
    at /Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/lib/Service.js:251:21
    at Array.forEach (<anonymous>)
    at Service.resolveWebpackConfig (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/lib/Service.js:248:30)
    at PluginAPI.resolveWebpackConfig (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/lib/PluginAPI.js:132:25)
    at module.exports (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/lib/commands/build/resolveAppConfig.js:46:14)
    at getWebpackConfig (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@dcloudio/vue-cli-plugin-uni/commands/build.js:89:88)
    at getWebpackConfigs (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@dcloudio/vue-cli-plugin-uni/commands/build.js:122:13)
    at build (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@dcloudio/vue-cli-plugin-uni/commands/build.js:161:26)
    at /Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@dcloudio/vue-cli-plugin-uni/commands/build.js:80:11
    at Service.run (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/lib/Service.js:230:12)
    at Object.<anonymous> (/Users/guoming/Desktop/develop/project/trace/client/trace-uni/node_modules/@vue/cli-service/bin/vue-cli-service.js:36:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! trace-uni@3.5.11 build:mp-weixin: `cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the trace-uni@3.5.11 build:mp-weixin script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/guoming/.npm/_logs/2023-11-09T02_17_34_405Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

系统信息:

  • 发行平台: 微信小程序

  • uni-app版本

    uni-app v3.8.7
    uni-app cli v2.0.2-3080720230703001
    
    Environment Info:
    
      System:
        OS: macOS 13.4.1
        CPU: (8) x64 Apple M1
      Binaries:
        Node: 14.21.1 - /usr/local/bin/node
        Yarn: 1.22.19 - /usr/local/bin/yarn
        npm: 6.14.17 - /usr/local/bin/npm
      Browsers:
        Chrome: 119.0.6045.105
        Firefox: Not Found
        Safari: 16.5.1
      npmPackages:
        @dcloudio/types: ^3.0.4 => 3.0.19 
        @dcloudio/uni-app: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-app-plus: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-app-plus-nvue:  0.0.1 
        @dcloudio/uni-app-plus-nvue-v8:  0.0.1 
        @dcloudio/uni-automator: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-cli-i18n: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-cli-shared: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-h5: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-helper-json: * => 1.0.13 
        @dcloudio/uni-i18n: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-migration: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-360: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-alipay: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-baidu: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-jd: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-kuaishou: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-lark: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-qq: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-toutiao: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-vue: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-weixin: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-mp-xhs: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-quickapp-native: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-quickapp-webview: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-stacktracey: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-stat: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-template-compiler: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/uni-ui: ^1.4.20 => 1.4.23 
        @dcloudio/vue-cli-plugin-hbuilderx: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/vue-cli-plugin-uni: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/vue-cli-plugin-uni-optimize: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/webpack-uni-mp-loader: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @dcloudio/webpack-uni-nvue-loader:  0.0.1 
        @dcloudio/webpack-uni-pages-loader: 2.0.2-3080720230703001 => 2.0.2-3080720230703001 
        @hap-toolkit/dsl-vue:  0.6.13 
        @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:  4.5.19 
        @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:  4.5.19 
        @vue/cli-plugin-babel: ~4.5.17 => 4.5.19 
        @vue/cli-plugin-router:  4.5.19 
        @vue/cli-plugin-typescript: ~4.5.11 => 4.5.19 
        @vue/cli-plugin-vuex:  4.5.19 
        @vue/cli-service: ~4.5.17 => 4.5.19 
        @vue/cli-shared-utils:  4.5.19 
        @vue/compiler-sfc:  2.7.14 
        @vue/component-compiler-utils:  3.3.0 (3.3.0)
        @vue/composition-api:  1.7.0 
        @vue/devtools-api:  6.0.0-beta.15 
        @vue/preload-webpack-plugin:  1.1.2 
        @vue/reactivity:  3.0.5 
        @vue/shared: ^3.0.0 => 3.2.45 
        @vue/web-component-wrapper:  1.3.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.11 => 2.7.14 
        vue-class-component:  7.2.6 
        vue-hot-reload-api:  2.3.4 
        vue-loader:  15.10.1 (16.8.3, 15.10.1)
        vue-property-decorator: ^8.0.0 => 8.5.1 
        vue-router:  3.0.1 
        vue-style-loader:  4.1.3 (4.1.3)
        vue-template-compiler: ^2.6.11 => 2.7.14 (2.7.14)
        vue-template-es2015-compiler:  1.9.1 
        vue3:  1.0.0 
        vuex: ^3.2.0 => 3.6.2 (3.6.2)
        vuex-class: ^0.3.2 => 0.3.2 
        vuex-module-decorators: ^2.0.0 => 2.0.0 
      npmGlobalPackages:
        @vue/cli: Not Found

补充信息
报错应该是因为workers只支持配置字符串,实际上应该支持配置对象。

@yurj26
Copy link
Contributor

yurj26 commented Nov 23, 2023

参考文档,放在pagess.json文件里。

@yurj26 yurj26 closed this as completed Nov 23, 2023
@GHkmmm
Copy link
Author

GHkmmm commented Dec 4, 2023

参考文档,放在pagess.json文件里。

已在pages.json中配置,但最终打包的目录没有包含workers
image

image image

@yurj26
Copy link
Contributor

yurj26 commented Dec 15, 2023

抱歉,我之前回答有误,还是需要配置在mainfest.json中,该问题后续会修复。

临时解决方案:替换文件node_modules/@dcloudio/uni-mp-weixin/lib/中。

@GrapevineLin
Copy link

抱歉,我之前回答有误,还是需要配置在mainfest.json中,该问题后续会修复。

临时解决方案:替换文件node_modules/@dcloudio/uni-mp-weixin/lib/中。

reopen一下吗

@yurj26 yurj26 reopened this Jan 22, 2024
@yurj26
Copy link
Contributor

yurj26 commented Jan 30, 2024

4.0.2024012711-alpha 已修复

@yurj26 yurj26 closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants