File tree 5 files changed +27
-6
lines changed
dev_fixtures_do_not_merge
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() {
60
60
cwd = 'file:///' ;
61
61
}
62
62
63
+ const keyedExportsList = [ ] ;
64
+
63
65
// A separate loader instance is necessary to avoid cross-contamination
64
66
// between internal Node.js and userland. For example, a module with internal
65
67
// state (such as a counter) should be independent.
66
68
const internalEsmLoader = new ESMLoader ( ) ;
67
69
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
+ }
74
81
75
82
// Hooks must then be added to external/public loader
76
83
// (so they're triggered in userland)
You can’t perform that action at this time.
0 commit comments