@@ -21,6 +21,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
2121 ) {
2222 super ( request , originModule , sourceOrder , parserScope ) ;
2323 this . id = id === null ? null : `${ id } ` ;
24+ this . redirectedId = undefined ;
2425 this . name = name ;
2526 this . range = range ;
2627 this . strictExportPresence = strictExportPresence ;
@@ -35,11 +36,15 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
3536 return "harmony import specifier" ;
3637 }
3738
39+ get _id ( ) {
40+ return this . redirectedId || this . id ;
41+ }
42+
3843 getReference ( ) {
39- if ( ! this . module ) return null ;
44+ if ( ! this . _module ) return null ;
4045 return new DependencyReference (
41- this . module ,
42- this . id && ! this . namespaceObjectAsContext ? [ this . id ] : true ,
46+ this . _module ,
47+ this . _id && ! this . namespaceObjectAsContext ? [ this . _id ] : true ,
4348 false
4449 ) ;
4550 }
@@ -65,7 +70,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
6570 }
6671
6772 _getErrors ( ) {
68- const importedModule = this . module ;
73+ const importedModule = this . _module ;
6974 if ( ! importedModule ) {
7075 return ;
7176 }
@@ -74,11 +79,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
7479 // It's not an harmony module
7580 if (
7681 this . originModule . buildMeta . strictHarmonyModule &&
77- this . id !== "default"
82+ this . _id !== "default"
7883 ) {
7984 // In strict harmony modules we only support the default export
80- const exportName = this . id
81- ? `the named export '${ this . id } '`
85+ const exportName = this . _id
86+ ? `the named export '${ this . _id } '`
8287 : "the namespace object" ;
8388 return [
8489 new HarmonyLinkingError (
@@ -89,20 +94,20 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
8994 return ;
9095 }
9196
92- if ( ! this . id ) {
97+ if ( ! this . _id ) {
9398 return ;
9499 }
95100
96- if ( importedModule . isProvided ( this . id ) !== false ) {
101+ if ( importedModule . isProvided ( this . _id ) !== false ) {
97102 // It's provided or we are not sure
98103 return ;
99104 }
100105
101106 // We are sure that it's not provided
102107 const idIsNotNameMessage =
103- this . id !== this . name ? ` (imported as '${ this . name } ')` : "" ;
108+ this . _id !== this . name ? ` (imported as '${ this . name } ')` : "" ;
104109 const errorMessage = `"export '${
105- this . id
110+ this . _id
106111 } '${ idIsNotNameMessage } was not found in '${ this . userRequest } '`;
107112 return [ new HarmonyLinkingError ( errorMessage ) ] ;
108113 }
@@ -114,10 +119,10 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
114119
115120 updateHash ( hash ) {
116121 super . updateHash ( hash ) ;
117- const importedModule = this . module ;
118- hash . update ( ( importedModule && this . id ) + "" ) ;
122+ const importedModule = this . _module ;
123+ hash . update ( ( importedModule && this . _id ) + "" ) ;
119124 hash . update (
120- ( importedModule && this . id && importedModule . isUsed ( this . id ) ) + ""
125+ ( importedModule && this . _id && importedModule . isUsed ( this . _id ) ) + ""
121126 ) ;
122127 hash . update (
123128 ( importedModule &&
@@ -129,6 +134,11 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
129134 importedModule . used + JSON . stringify ( importedModule . usedExports ) ) + ""
130135 ) ;
131136 }
137+
138+ disconnect ( ) {
139+ super . disconnect ( ) ;
140+ this . redirectedId = undefined ;
141+ }
132142}
133143
134144HarmonyImportSpecifierDependency . Template = class HarmonyImportSpecifierDependencyTemplate extends HarmonyImportDependency . Template {
@@ -140,9 +150,9 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
140150
141151 getContent ( dep , runtime ) {
142152 const exportExpr = runtime . exportFromImport ( {
143- module : dep . module ,
153+ module : dep . _module ,
144154 request : dep . request ,
145- exportName : dep . id ,
155+ exportName : dep . _id ,
146156 originModule : dep . originModule ,
147157 asiSafe : dep . shorthand ,
148158 isCall : dep . call ,
0 commit comments