使用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
},
网友评论