无法将System.js添加到我的打字稿项目中

问题描述

我有一个现有的打字稿项目,现在我想在其中使用一些库。它已配置为生成outputFile,因此我需要设置模块:“ System”,这已经完成了两次。此外,我还在index.html上添加了systemJS。但是有一个很大的问题-每当我尝试导入js文件时,使用systemjs效果都很好-我可以使用在其中声明的所有函数,依此类推。但是,当我在文件中包含任何导入(例如,从“ someconst”导入{A})时,systemjs就会停止处理大量错误消息

Uncaught ReferenceError: System is not defined
Uncaught (in promise) TypeError: hello.init is not a function
Uncaught TypeError: Cannot read property 'apply' of null
    at window.onerror (common.js:143)

这是我在index.html中添加systemjs的方式:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.20.1/system.js" integrity="sha512-7srDmqummlvkixi8/FhTwAQCedVevJFHf9toA+c7CuCuP3dQxVhP7hPm05hkbGDHyDbwWdLCEg/AhO21Wb375Q==" crossorigin="anonymous">
</script>

<script>
    System.import('js/map.js').then(function (hello) {
        hello.init();
        console.log(hello)
    });

</script>

这是我的map.ts,然后将其编译成js / map.js 从“ sometext”导入{A}

function init() {
   console.log(A);
}

我用来测试导入的sometext.js:

export const A = "AAABBBCCC"

还有我的tsconfig

{
  "compileOnSave": true,"compilerOptions": {
    "noImplicitAny": false,"noEmitOnError": true,"removeComments": false,"sourceMap": true,"module": "System","target": "es5","outFile": "../../wwwroot/js/map.js"
  },"exclude": [
  ]
}

我在做什么错?似乎systemjs可以完美运行,但是当我导入任何东西时,它就会崩溃。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)