File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
packages/instrument-bundler/src Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,16 @@ export function transformImports(code: string) {
2727 moduleSpecifier,
2828 startIndex : _startIndex
2929 } of parseImports ( code ) ) {
30- if ( isDynamicImport ) {
31- continue ;
32- }
3330 const endIndex = _endIndex + indexDiff ;
3431 const startIndex = _startIndex + indexDiff ;
3532 const source = code . slice ( startIndex , endIndex ) ;
36- const replacement = `const ${ transformImportClause ( importClause ! ) } = await __import(${ moduleSpecifier . code } )` ;
33+
34+ let replacement : string ;
35+ if ( isDynamicImport ) {
36+ replacement = source . replace ( / ^ i m p o r t \( / , '__import(' ) ;
37+ } else {
38+ replacement = `const ${ transformImportClause ( importClause ! ) } = await __import(${ moduleSpecifier . code } )` ;
39+ }
3740 indexDiff += replacement . length - source . length ;
3841 code = code . slice ( 0 , startIndex ) + replacement + code . slice ( endIndex , code . length ) ;
3942 }
You can’t perform that action at this time.
0 commit comments