美文网首页
single-spa 微前端项目引入dva

single-spa 微前端项目引入dva

作者: 书中自有颜如玉__ | 来源:发表于2019-11-27 17:24 被阅读0次

使用systemjs动态模块加载时,报错

Uncaught main: Application 'main' died in status LOADING_SOURCE_CODE: Unable to resolve bare specifier "vendor_library" from http://localhost:9001/singleSpaEntry.js
at throwBare (http://localhost:9000/system.js:9029:11)
at resolveImportMap (http://localhost:9000/system.js:9025:67)
at http://localhost:9000/system.js:9577:14
at async Promise.all (index 0)

报错原因是我webpack打包为AMD模块文件,引入dva后,编译出来的文件

define("main", ["vendor_library"]...

多了"vendor_library",具体为什么还不知道;但是改为UMD模块后,可以启动了。
解决办法:
webpack中output.libraryTarget由amd改为umd。

 output: {
    filename: '[name].js',
    publicPath: APP_NAME + '/',
    path: path.resolve(__dirname, '../../release/' + APP_NAME),
    libraryTarget: 'umd',
    library: APP_NAME
  },

相关文章

网友评论

      本文标题:single-spa 微前端项目引入dva

      本文链接:https://www.haomeiwen.com/subject/tbxmwctx.html