diff --git a/lib/import-export-visitor.js b/lib/import-export-visitor.js index 383307973..ea9fc4797 100644 --- a/lib/import-export-visitor.js +++ b/lib/import-export-visitor.js @@ -34,8 +34,6 @@ IEVp.reset = function (rootPath, codeOrNull, options) { this.modifyAST = !! getOption(options, "ast"); this.parse = getOption(options, "parse"); this.nextKey = 0; - this.importMethod = getOption(options, "generateLegacyModuleImport") - ? "import" : "importSync"; return this; }; @@ -408,8 +406,7 @@ IEVp.visitImportDeclaration = function (path) { parts.push(toModuleImport( this._getSourceString(decl), computeSpecifierMap(decl.specifiers), - this.makeUniqueKey(), - this.importMethod + this.makeUniqueKey() )); this.hoistImports(path, parts.join("")); @@ -420,11 +417,7 @@ IEVp.visitImportDeclaration = function (path) { IEVp.visitExportAllDeclaration = function (path) { const decl = path.getValue(); const parts = [ - this.pad( - "module." + this.importMethod + "(", - decl.start, - decl.source.start - ), + this.pad("module.importSync(", decl.start, decl.source.start), this._getSourceString(decl), this.pad( ",{'*':(v,k)=>{exports[k]=v;}}," + @@ -567,8 +560,7 @@ IEVp.visitExportNamedDeclaration = function (path) { this.hoistExports(path, toModuleImport( this._getSourceString(decl), specifierMap, - this.makeUniqueKey(), - this.importMethod + this.makeUniqueKey() )); } else { @@ -671,8 +663,8 @@ function addToSpecifierMap(map, __ported, local) { return map; } -function toModuleImport(source, specifierMap, uniqueKey, importMethod) { - const parts = ["module.", importMethod, "(", source]; +function toModuleImport(source, specifierMap, uniqueKey) { + const parts = ["module.importSync(", source]; const importedNames = specifierMap ? Object.keys(specifierMap) : null; const nameCount = importedNames ? importedNames.length : 0; diff --git a/lib/options.js b/lib/options.js index b82060666..6aabbb15a 100644 --- a/lib/options.js +++ b/lib/options.js @@ -6,7 +6,6 @@ const defaultCompileOptions = { ast: false, force: false, generateLetDeclarations: false, - generateLegacyModuleImport: false, get parse () { return require("./parsers/default.js").parse; } diff --git a/test/compiler-tests.js b/test/compiler-tests.js index be3a3b075..c655b5c6c 100644 --- a/test/compiler-tests.js +++ b/test/compiler-tests.js @@ -68,26 +68,6 @@ describe("compiler", function () { ).code.indexOf("var foo;"), 0); }); - it("should respect options.generateLegacyModuleImport", function () { - import { compile } from "../lib/compiler.js"; - - function check(code) { - var legacy = compile(code, { - generateLegacyModuleImport: true - }).code; - assert.notStrictEqual(legacy.indexOf("module.import("), -1); - } - - check('import foo from "./foo"'); - check('import { a, b as c } from "./foo"'); - check('import * as ns from "./foo"'); - check('import "./foo"'); - - // These exports are really imports behind the scenes. - check('export { a, b as c } from "./foo"'); - check('export * from "./foo"'); - }); - it("should allow pre-parsed ASTs via options.parse", function () { import { compile } from "../lib/compiler.js"; import { parse } from "../lib/parsers/default.js";