@@ -12,7 +12,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
12
12
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
13
13
'--input-type=module' ,
14
14
'--eval' ,
15
- ' import \' nonexistent/file.mjs\'' ,
15
+ ` import " nonexistent/file.mjs"` ,
16
16
] ) ;
17
17
18
18
assert . strictEqual ( code , 1 ) ;
@@ -44,7 +44,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
44
44
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
45
45
'--input-type=module' ,
46
46
'--eval' ,
47
- 'import \' esmHook/badReturnVal.mjs\' ' ,
47
+ 'import " esmHook/badReturnVal.mjs" ' ,
48
48
] ) ;
49
49
50
50
assert . strictEqual ( code , 1 ) ;
@@ -60,7 +60,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
60
60
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
61
61
'--input-type=module' ,
62
62
'--eval' ,
63
- 'import \' esmHook/format.false\' ' ,
63
+ 'import " esmHook/format.false" ' ,
64
64
] ) ;
65
65
66
66
assert . strictEqual ( code , 1 ) ;
@@ -75,7 +75,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
75
75
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
76
76
'--input-type=module' ,
77
77
'--eval' ,
78
- 'import \' esmHook/format.true\' ' ,
78
+ 'import " esmHook/format.true" ' ,
79
79
] ) ;
80
80
81
81
assert . strictEqual ( code , 1 ) ;
@@ -91,7 +91,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
91
91
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
92
92
'--input-type=module' ,
93
93
'--eval' ,
94
- 'import \' esmHook/badReturnFormatVal.mjs\' ' ,
94
+ 'import " esmHook/badReturnFormatVal.mjs" ' ,
95
95
] ) ;
96
96
97
97
assert . strictEqual ( code , 1 ) ;
@@ -107,7 +107,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
107
107
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
108
108
'--input-type=module' ,
109
109
'--eval' ,
110
- 'import \' esmHook/unsupportedReturnFormatVal.mjs\' ' ,
110
+ 'import " esmHook/unsupportedReturnFormatVal.mjs" ' ,
111
111
] ) ;
112
112
113
113
assert . strictEqual ( code , 1 ) ;
@@ -123,7 +123,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
123
123
fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
124
124
'--input-type=module' ,
125
125
'--eval' ,
126
- 'import \' esmHook/badReturnSourceVal.mjs\' ' ,
126
+ 'import " esmHook/badReturnSourceVal.mjs" ' ,
127
127
] ) ;
128
128
129
129
assert . strictEqual ( code , 1 ) ;
@@ -140,7 +140,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
140
140
'--input-type=module' ,
141
141
'--eval' ,
142
142
`import assert from 'node:assert';
143
- Promise.allSettled([
143
+ await Promise.allSettled([
144
144
import('nonexistent/file.mjs'),
145
145
import('${ fixtures . fileURL ( '/es-modules/file.unknown' ) } '),
146
146
import('esmHook/badReturnVal.mjs'),
@@ -170,7 +170,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
170
170
'--input-type=module' ,
171
171
'--eval' ,
172
172
`import assert from 'node:assert';
173
- import('${ fixtures . fileURL ( '/es-module-loaders/js-as-esm.js' ) } ')
173
+ await import('${ fixtures . fileURL ( '/es-module-loaders/js-as-esm.js' ) } ')
174
174
.then((parsedModule) => {
175
175
assert.strictEqual(typeof parsedModule, 'object');
176
176
assert.strictEqual(parsedModule.namedExport, 'named-export');
@@ -191,7 +191,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
191
191
'--input-type=module' ,
192
192
'--eval' ,
193
193
`import assert from 'node:assert';
194
- import('${ fixtures . fileURL ( '/es-modules/file.ext' ) } ')
194
+ await import('${ fixtures . fileURL ( '/es-modules/file.ext' ) } ')
195
195
.then((parsedModule) => {
196
196
assert.strictEqual(typeof parsedModule, 'object');
197
197
const { default: defaultExport } = parsedModule;
@@ -215,7 +215,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
215
215
'--input-type=module' ,
216
216
'--eval' ,
217
217
`import assert from 'node:assert';
218
- import('esmHook/preknownFormat.pre')
218
+ await import('esmHook/preknownFormat.pre')
219
219
.then((parsedModule) => {
220
220
assert.strictEqual(typeof parsedModule, 'object');
221
221
assert.strictEqual(parsedModule.default, 'hello world');
@@ -236,7 +236,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
236
236
'--input-type=module' ,
237
237
'--eval' ,
238
238
`import assert from 'node:assert';
239
- import('esmHook/virtual.mjs')
239
+ await import('esmHook/virtual.mjs')
240
240
.then((parsedModule) => {
241
241
assert.strictEqual(typeof parsedModule, 'object');
242
242
assert.strictEqual(typeof parsedModule.default, 'undefined');
@@ -258,7 +258,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
258
258
'--input-type=module' ,
259
259
'--eval' ,
260
260
`import assert from 'node:assert';
261
- import('${ fixtures . fileURL ( '/es-modules/stateful.mjs' ) } ')
261
+ await import('${ fixtures . fileURL ( '/es-modules/stateful.mjs' ) } ')
262
262
.then(({ default: count }) => {
263
263
assert.strictEqual(count(), 1);
264
264
});` ,
@@ -269,4 +269,20 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
269
269
assert . strictEqual ( stdout , '' ) ;
270
270
assert . strictEqual ( stderr , '' ) ;
271
271
} ) ;
272
+
273
+ it ( 'ensures that user loaders are not bound to the internal loader' , async ( ) => {
274
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
275
+ '--no-warnings' ,
276
+ '--experimental-loader' ,
277
+ fixtures . fileURL ( '/es-module-loaders/loader-this-value-inside-hook-functions.mjs' ) ,
278
+ '--input-type=module' ,
279
+ '--eval' ,
280
+ `;` , // Actual test is inside the loader module.
281
+ ] ) ;
282
+
283
+ assert . strictEqual ( code , 0 ) ;
284
+ assert . strictEqual ( signal , null ) ;
285
+ assert . strictEqual ( stdout , '' ) ;
286
+ assert . strictEqual ( stderr , '' ) ;
287
+ } ) ;
272
288
} ) ;
0 commit comments