我使用jspm
& Rollup
或SystemJS
通过以下方式构建我的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
答案 0 :(得分:0)
由于使用了jspm build
,因此意味着result is able to stand alone。此外,未指定--format
,the default is umd。
register
是SystemJS的模块格式。要解决此问题,请手动设置或覆盖格式。以下是使用jspm
:
// package.json
...
"jspm": {
...
"overrides": {
...
"npm:myFile@1.23.4": {
"meta": {
"myFile.js": {
"format": "global"
}
}
},
...
}
}