Drop unnecessary dynamic import redeclaration in AMD
Instead of assigning the import a name and them declaring a new variabled referencing that name, output the import already with the destination name, since we know there must be no collisions because these IDs are also generated.
This commit is contained in:
@@ -87,7 +87,11 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
var key = t.getSpecifierName(specifier);
|
||||
var ref = this._push(node);
|
||||
|
||||
if (t.isImportBatchSpecifier(specifier) || _.contains(this.file.dynamicImports, node)) {
|
||||
if (_.contains(this.file.dynamicImports, node)) {
|
||||
// Prevent unnecessary renaming of dynamic imports.
|
||||
this.ids[node.source.value] = key;
|
||||
return;
|
||||
} else if (t.isImportBatchSpecifier(specifier)) {
|
||||
// import * as bar from "foo";
|
||||
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
|
||||
// import foo from "foo";
|
||||
|
||||
Reference in New Issue
Block a user