美文网首页微前端
single-spa使用systemjs

single-spa使用systemjs

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

systemjs Github
如果能访问外网

<script src='https://unpkg.com/systemjs@4.1.0/dist/system.js'></script>
<script src='https://unpkg.com/systemjs@4.1.0/dist/extras/amd.js'></script>
<script src='https://unpkg.com/systemjs@4.1.0/dist/extras/named-exports.js'></script>
<script src='https://unpkg.com/systemjs@4.1.0/dist/extras/use-default.js'></script>

安装:

npm install systemjs

我的项目不能访问外网,所以配置webpack作为entry入口文件,最后会随主文件一起自动导入到index.html中

const systemjsBasePath = '../../node_modules/systemjs/dist/';
...
entry: {
    system: systemjsBasePath + 'system.js',
    amd: systemjsBasePath + 'extras/amd.js',
    named_exports: systemjsBasePath + 'extras/named-exports.js',
    use_default: systemjsBasePath + 'extras/use-default.js'
},

使用:

window.SystemJS = window.System;
export async function loadApp(name, hash, appURL) {
  singleSpa.registerApplication(
    name,
    () => SystemJS.import(appURL),
    hashPrefix(hash)
  );
}

相关文章

网友评论

    本文标题:single-spa使用systemjs

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