@@ -12,7 +12,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
1212 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
1313 '--input-type=module' ,
1414 '--eval' ,
15- ' import \' nonexistent/file.mjs\'' ,
15+ ` import " nonexistent/file.mjs"` ,
1616 ] ) ;
1717
1818 assert . strictEqual ( code , 1 ) ;
@@ -44,7 +44,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
4444 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
4545 '--input-type=module' ,
4646 '--eval' ,
47- 'import \' esmHook/badReturnVal.mjs\' ' ,
47+ 'import " esmHook/badReturnVal.mjs" ' ,
4848 ] ) ;
4949
5050 assert . strictEqual ( code , 1 ) ;
@@ -60,7 +60,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
6060 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
6161 '--input-type=module' ,
6262 '--eval' ,
63- 'import \' esmHook/format.false\' ' ,
63+ 'import " esmHook/format.false" ' ,
6464 ] ) ;
6565
6666 assert . strictEqual ( code , 1 ) ;
@@ -75,7 +75,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
7575 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
7676 '--input-type=module' ,
7777 '--eval' ,
78- 'import \' esmHook/format.true\' ' ,
78+ 'import " esmHook/format.true" ' ,
7979 ] ) ;
8080
8181 assert . strictEqual ( code , 1 ) ;
@@ -91,7 +91,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
9191 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
9292 '--input-type=module' ,
9393 '--eval' ,
94- 'import \' esmHook/badReturnFormatVal.mjs\' ' ,
94+ 'import " esmHook/badReturnFormatVal.mjs" ' ,
9595 ] ) ;
9696
9797 assert . strictEqual ( code , 1 ) ;
@@ -107,7 +107,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
107107 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
108108 '--input-type=module' ,
109109 '--eval' ,
110- 'import \' esmHook/unsupportedReturnFormatVal.mjs\' ' ,
110+ 'import " esmHook/unsupportedReturnFormatVal.mjs" ' ,
111111 ] ) ;
112112
113113 assert . strictEqual ( code , 1 ) ;
@@ -123,7 +123,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
123123 fixtures . fileURL ( '/es-module-loaders/hooks-custom.mjs' ) ,
124124 '--input-type=module' ,
125125 '--eval' ,
126- 'import \' esmHook/badReturnSourceVal.mjs\' ' ,
126+ 'import " esmHook/badReturnSourceVal.mjs" ' ,
127127 ] ) ;
128128
129129 assert . strictEqual ( code , 1 ) ;
@@ -140,7 +140,7 @@ describe('Loader hooks throwing errors', { concurrency: true }, () => {
140140 '--input-type=module' ,
141141 '--eval' ,
142142 `import assert from 'node:assert';
143- Promise.allSettled([
143+ await Promise.allSettled([
144144 import('nonexistent/file.mjs'),
145145 import('${ fixtures . fileURL ( '/es-modules/file.unknown' ) } '),
146146 import('esmHook/badReturnVal.mjs'),
@@ -170,7 +170,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
170170 '--input-type=module' ,
171171 '--eval' ,
172172 `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' ) } ')
174174 .then((parsedModule) => {
175175 assert.strictEqual(typeof parsedModule, 'object');
176176 assert.strictEqual(parsedModule.namedExport, 'named-export');
@@ -191,7 +191,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
191191 '--input-type=module' ,
192192 '--eval' ,
193193 `import assert from 'node:assert';
194- import('${ fixtures . fileURL ( '/es-modules/file.ext' ) } ')
194+ await import('${ fixtures . fileURL ( '/es-modules/file.ext' ) } ')
195195 .then((parsedModule) => {
196196 assert.strictEqual(typeof parsedModule, 'object');
197197 const { default: defaultExport } = parsedModule;
@@ -215,7 +215,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
215215 '--input-type=module' ,
216216 '--eval' ,
217217 `import assert from 'node:assert';
218- import('esmHook/preknownFormat.pre')
218+ await import('esmHook/preknownFormat.pre')
219219 .then((parsedModule) => {
220220 assert.strictEqual(typeof parsedModule, 'object');
221221 assert.strictEqual(parsedModule.default, 'hello world');
@@ -236,7 +236,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
236236 '--input-type=module' ,
237237 '--eval' ,
238238 `import assert from 'node:assert';
239- import('esmHook/virtual.mjs')
239+ await import('esmHook/virtual.mjs')
240240 .then((parsedModule) => {
241241 assert.strictEqual(typeof parsedModule, 'object');
242242 assert.strictEqual(typeof parsedModule.default, 'undefined');
@@ -258,7 +258,7 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
258258 '--input-type=module' ,
259259 '--eval' ,
260260 `import assert from 'node:assert';
261- import('${ fixtures . fileURL ( '/es-modules/stateful.mjs' ) } ')
261+ await import('${ fixtures . fileURL ( '/es-modules/stateful.mjs' ) } ')
262262 .then(({ default: count }) => {
263263 assert.strictEqual(count(), 1);
264264 });` ,
@@ -269,4 +269,20 @@ describe('Loader hooks parsing modules', { concurrency: true }, () => {
269269 assert . strictEqual ( stdout , '' ) ;
270270 assert . strictEqual ( stderr , '' ) ;
271271 } ) ;
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+ } ) ;
272288} ) ;
0 commit comments