@@ -121,13 +121,22 @@ window['${DYNAMIC_IMPORT_REPLACEMENT}'] = ${DYNAMIC_IMPORT_REPLACEMENT};`;
121
121
break ;
122
122
}
123
123
}
124
- self . importedExternalsSyntax [ name ] = `import ${
125
- defaultSpecifier !== null
126
- ? `${ defaultSpecifier } ${ specificSpecifiers . length > 0 ? ',' : '' } `
127
- : ''
128
- } ${
129
- specificSpecifiers . length > 0 ? `{${ specificSpecifiers . join ( ',' ) } }` : ''
130
- } from '${ name } ';`;
124
+
125
+ const multipleSpecifiers = specificSpecifiers . length > 0 ;
126
+ if ( defaultSpecifier !== null ) {
127
+ if ( multipleSpecifiers ) {
128
+ self . importedExternalsSyntax [
129
+ name
130
+ ] = `import ${ defaultSpecifier } ,{${ specificSpecifiers . join ( ',' ) } } from '${ name } ';` ;
131
+ } else {
132
+ self . importedExternalsSyntax [ name ] = `import ${ defaultSpecifier } from '${ name } ';` ;
133
+ }
134
+ } else if ( multipleSpecifiers ) {
135
+ self . importedExternalsSyntax [ name ] = `import {${ specificSpecifiers . join (
136
+ ',' ,
137
+ ) } } from '${ name } ';`;
138
+ }
139
+
131
140
source . remove ( ...range ) ;
132
141
133
142
self . importedExternalsLocalNames = self . importedExternalsLocalNames . concat (
@@ -162,9 +171,9 @@ window['${DYNAMIC_IMPORT_REPLACEMENT}'] = ${DYNAMIC_IMPORT_REPLACEMENT};`;
162
171
const source = new MagicString ( code ) ;
163
172
const program = parse ( code ) ;
164
173
165
- Object . values ( this . importedExternalsSyntax ) . forEach ( importedExternalSyntax =>
166
- source . prepend ( importedExternalSyntax ) ,
167
- ) ;
174
+ for ( const importedExternalSyntax of Object . values ( this . importedExternalsSyntax ) ) {
175
+ source . prepend ( importedExternalSyntax ) ;
176
+ }
168
177
169
178
walk . simple ( program , {
170
179
Identifier ( node : Identifier ) {
0 commit comments