myFile.js被检测为寄存器但未执行

时间:2016-11-22 23:31:17

标签: javascript angular typescript systemjs jspm

我使用jspm& RollupSystemJS通过以下方式构建我的WebApp: jspm build myFile dist/myFile.js --minify

当我尝试使用SystemJS

加载myFile.js时
<script src="/jspm_packages/system.src.js"></script>
<script src="/jspm.config.js"></script>
<script>
  // `myFile` is mapped to npm:myFile@1.23.4
  SystemJS.import('myFile').catch(function (e) {
    console.log("Error with SystemJS.import myFile.js", e );
  });
</script>

我收到错误:myFile.js detected as register but didn't execute.

(SystemJS) http://localhost:3000/jspm_packages/npm/myFile@1.23.4/myFile.js detected as register but didn't execute. Error: 
  ...(call stack)...
Error loading http://localhost:3000/jspm_packages/npm/myFile@1.23.4/myFile.js

1 个答案:

答案 0 :(得分:0)

由于使用了jspm build,因此意味着result is able to stand alone。此外,未指定--formatthe default is umd

register是SystemJS的模块格式。要解决此问题,请手动设置或覆盖格式。以下是使用jspm

的示例
// package.json
...
"jspm": {
  ...
  "overrides": {
    ...
    "npm:myFile@1.23.4": {
      "meta": {
        "myFile.js": {
          "format": "global"
        }
      }
    },
    ...
  }
}