File tree Expand file tree Collapse file tree 5 files changed +27
-6
lines changed
dev_fixtures_do_not_merge Expand file tree Collapse file tree 5 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 1+ import symbol from 'yyy/lib.mjs' ;
2+
3+ console . log ( `main` , symbol ) ;
Original file line number Diff line number Diff line change 1+ console . log ( `lib` ) ;
2+
3+ export default 42 ;
Original file line number Diff line number Diff line change 1+ export async function resolve ( specifier , context , defaultResolve ) {
2+ console . log ( `loader-a` , { specifier} ) ;
3+ return defaultResolve ( specifier . replace ( / ^ x x x \/ / , `./` ) ) ;
4+ }
Original file line number Diff line number Diff line change 1+ export async function resolve ( specifier , context , defaultResolve ) {
2+ console . log ( `loader-b` , { specifier} ) ;
3+ return defaultResolve ( specifier . replace ( / ^ y y y \/ / , `./` ) ) ;
4+ }
Original file line number Diff line number Diff line change @@ -60,17 +60,24 @@ async function initializeLoader() {
6060 cwd = 'file:///' ;
6161 }
6262
63+ const keyedExportsList = [ ] ;
64+
6365 // A separate loader instance is necessary to avoid cross-contamination
6466 // between internal Node.js and userland. For example, a module with internal
6567 // state (such as a counter) should be independent.
6668 const internalEsmLoader = new ESMLoader ( ) ;
6769
68- // Importation must be handled by internal loader to avoid poluting userland
69- const keyedExportsList = await internalEsmLoader . import (
70- customLoaders ,
71- pathToFileURL ( cwd ) . href ,
72- ObjectCreate ( null ) ,
73- ) ;
70+ for ( const customLoader of customLoaders ) {
71+ // Importation must be handled by internal loader to avoid poluting userland
72+ const keyedExportsSublist = await internalEsmLoader . import (
73+ [ customLoader ] ,
74+ pathToFileURL ( cwd ) . href ,
75+ ObjectCreate ( null ) ,
76+ ) ;
77+
78+ await internalEsmLoader . addCustomLoaders ( keyedExportsSublist ) ;
79+ keyedExportsList . push ( ...keyedExportsSublist ) ;
80+ }
7481
7582 // Hooks must then be added to external/public loader
7683 // (so they're triggered in userland)
You can’t perform that action at this time.
0 commit comments