【发布时间】:2018-08-21 03:34:49
【问题描述】:
这是基于this functional demo。
我看到 SystemJS 0.21.4 将未命名的模块作为空对象导入。
// define('a', [], function () { return 'A'; });
SystemJS.import('a.js')
.then(m => console.log(m.default, '<- a')) // "A"
// define('b', [], function () { return 'B'; });
SystemJS.import('b.js')
.then(m => console.log(m.default, '<- b')) // {}
// define([], function () { return 'A'; });
SystemJS.import('a-anon.js')
.then(m => console.log(m.default, '<- a-anon')) // "A"
// define([], function () { return 'B'; });
SystemJS.import('b-anon.js')
.then(m => console.log(m.default, '<- b-anon')) // "B"
由于某种原因,a.js 正确导入为“A”,但b.js 导入为空对象(而不是“B”)。如果我重新排序它们以便首先导入 b.js,我会看到相反的情况——b 正确导入而 a 没有正确导入。
这里发生了什么?这是一个错误吗?我是否错误地使用了 SystemJS/AMD?
交叉发布from Github
【问题讨论】: