-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone
Milestone
Description
TypeScript Version: 3.8.3
Search Terms:
dynamic import, system, outFile
Code
index.ts
import * as foo from "./mod1";
(async () => {
const foo1 = await import("./mod1");
console.log(foo, foo1);
})();mod1.ts
export const foo = "foo";$ tsc index.ts --outFile bundle.js --module system --target esnext
or
$ tsc index.ts --outFile bundle.js --module amd --target esnext
Expected behavior:
With System, it is expected that the dynamic import() statement would be converted to import("mod1") instead of staying as import("./mod1") since all modules are now registered with absolute specifiers instead of resolved specifiers. This is mostly because the compiler determines what the specifiers are named, and shouldn't presume relative resolution can be applied by the loader.
Actual behavior:
for System module
System.register("mod1", [], function (exports_1, context_1) {
"use strict";
var foo;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
exports_1("foo", foo = "foo");
}
};
});
System.register("index", ["mod1"], function (exports_2, context_2) {
"use strict";
var foo;
var __moduleName = context_2 && context_2.id;
return {
setters: [
function (foo_1) {
foo = foo_1;
}
],
execute: function () {
(async () => {
const foo1 = await context_2.import("./mod1");
console.log(foo, foo1);
})();
}
};
});cc/ @guybedford
Metadata
Metadata
Assignees
Labels
Fix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone