@@ -4,7 +4,7 @@ import assert from 'node:assert';
4
4
import { execPath } from 'node:process' ;
5
5
import { describe , it } from 'node:test' ;
6
6
7
- describe ( 'Loader hooks' , ( ) => {
7
+ describe ( 'Loader hooks' , { concurrency : true } , ( ) => {
8
8
it ( 'are called with all expected arguments' , async ( ) => {
9
9
const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
10
10
'--no-warnings' ,
@@ -23,4 +23,94 @@ describe('Loader hooks', () => {
23
23
assert . match ( lines [ 2 ] , / { " u r l " : " f i l e : \/ \/ \/ .* \/ e x p e r i m e n t a l \. j s o n " , " f o r m a t " : " t e s t " , " s h o r t C i r c u i t " : t r u e } / ) ;
24
24
assert . match ( lines [ 3 ] , / { " s o u r c e " : { " t y p e " : " B u f f e r " , " d a t a " : \[ .* \] } , " f o r m a t " : " j s o n " , " s h o r t C i r c u i t " : t r u e } / ) ;
25
25
} ) ;
26
+
27
+ describe ( 'should handle never-settling hooks in ESM files' , { concurrency : true } , ( ) => {
28
+ it ( 'top-level await of a never-settling resolve' , async ( ) => {
29
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
30
+ '--no-warnings' ,
31
+ '--experimental-loader' ,
32
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
33
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/never-resolve.mjs' ) ,
34
+ ] ) ;
35
+
36
+ assert . strictEqual ( stderr , '' ) ;
37
+ assert . match ( stdout , / ^ s h o u l d b e o u t p u t \r ? \n $ / ) ;
38
+ assert . strictEqual ( code , 13 ) ;
39
+ assert . strictEqual ( signal , null ) ;
40
+ } ) ;
41
+
42
+ it ( 'top-level await of a never-settling load' , async ( ) => {
43
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
44
+ '--no-warnings' ,
45
+ '--experimental-loader' ,
46
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
47
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/never-load.mjs' ) ,
48
+ ] ) ;
49
+
50
+ assert . strictEqual ( stderr , '' ) ;
51
+ assert . match ( stdout , / ^ s h o u l d b e o u t p u t \r ? \n $ / ) ;
52
+ assert . strictEqual ( code , 13 ) ;
53
+ assert . strictEqual ( signal , null ) ;
54
+ } ) ;
55
+
56
+
57
+ it ( 'top-level await of a race of never-settling hooks' , async ( ) => {
58
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
59
+ '--no-warnings' ,
60
+ '--experimental-loader' ,
61
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
62
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/race.mjs' ) ,
63
+ ] ) ;
64
+
65
+ assert . strictEqual ( stderr , '' ) ;
66
+ assert . match ( stdout , / ^ t r u e \r ? \n $ / ) ;
67
+ assert . strictEqual ( code , 0 ) ;
68
+ assert . strictEqual ( signal , null ) ;
69
+ } ) ;
70
+ } ) ;
71
+
72
+ describe ( 'should handle never-settling hooks in CJS files' , { concurrency : true } , ( ) => {
73
+ it ( 'never-settling resolve' , async ( ) => {
74
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
75
+ '--no-warnings' ,
76
+ '--experimental-loader' ,
77
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
78
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/never-resolve.cjs' ) ,
79
+ ] ) ;
80
+
81
+ assert . strictEqual ( stderr , '' ) ;
82
+ assert . match ( stdout , / ^ s h o u l d b e o u t p u t \r ? \n $ / ) ;
83
+ assert . strictEqual ( code , 0 ) ;
84
+ assert . strictEqual ( signal , null ) ;
85
+ } ) ;
86
+
87
+
88
+ it ( 'never-settling load' , async ( ) => {
89
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
90
+ '--no-warnings' ,
91
+ '--experimental-loader' ,
92
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
93
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/never-load.cjs' ) ,
94
+ ] ) ;
95
+
96
+ assert . strictEqual ( stderr , '' ) ;
97
+ assert . match ( stdout , / ^ s h o u l d b e o u t p u t \r ? \n $ / ) ;
98
+ assert . strictEqual ( code , 0 ) ;
99
+ assert . strictEqual ( signal , null ) ;
100
+ } ) ;
101
+
102
+ it ( 'race of never-settling hooks' , async ( ) => {
103
+ const { code, signal, stdout, stderr } = await spawnPromisified ( execPath , [
104
+ '--no-warnings' ,
105
+ '--experimental-loader' ,
106
+ fixtures . fileURL ( 'es-module-loaders/never-settling-resolve-step/loader.mjs' ) ,
107
+ fixtures . path ( 'es-module-loaders/never-settling-resolve-step/race.cjs' ) ,
108
+ ] ) ;
109
+
110
+ assert . strictEqual ( stderr , '' ) ;
111
+ assert . match ( stdout , / ^ t r u e \r ? \n $ / ) ;
112
+ assert . strictEqual ( code , 0 ) ;
113
+ assert . strictEqual ( signal , null ) ;
114
+ } ) ;
115
+ } ) ;
26
116
} ) ;
0 commit comments