-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test,esm: validate more edge cases for dynamic imports
PR-URL: #46059 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
- Loading branch information
Showing
8 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/fixtures/es-module-loaders/never-settling-resolve-step/loader.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function resolve(specifier, context, next) { | ||
if (specifier === 'never-settle-resolve') return new Promise(() => {}); | ||
if (specifier === 'never-settle-load') return { __proto__: null, shortCircuit: true, url: 'never-settle:///' }; | ||
return next(specifier, context); | ||
} | ||
|
||
export function load(url, context, next) { | ||
if (url === 'never-settle:///') return new Promise(() => {}); | ||
return next(url, context); | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/es-module-loaders/never-settling-resolve-step/never-load.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const neverSettlingDynamicImport = import('never-settle-load'); | ||
|
||
console.log('should be output'); | ||
|
||
neverSettlingDynamicImport.then(() => process.exit(1)); |
5 changes: 5 additions & 0 deletions
5
test/fixtures/es-module-loaders/never-settling-resolve-step/never-load.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const neverSettlingDynamicImport = import('never-settle-load'); | ||
|
||
console.log('should be output'); | ||
|
||
await neverSettlingDynamicImport; |
7 changes: 7 additions & 0 deletions
7
test/fixtures/es-module-loaders/never-settling-resolve-step/never-resolve.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const neverSettlingDynamicImport = import('never-settle-resolve'); | ||
|
||
console.log('should be output'); | ||
|
||
neverSettlingDynamicImport.then(() => process.exit(1)); |
5 changes: 5 additions & 0 deletions
5
test/fixtures/es-module-loaders/never-settling-resolve-step/never-resolve.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const neverSettlingDynamicImport = import('never-settle-resolve'); | ||
|
||
console.log('should be output'); | ||
|
||
await neverSettlingDynamicImport; |
7 changes: 7 additions & 0 deletions
7
test/fixtures/es-module-loaders/never-settling-resolve-step/race.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
Promise.race([ | ||
import('never-settle-resolve'), | ||
import('never-settle-load'), | ||
import('node:process'), | ||
]).then(result => console.log(result.default === process)); |
7 changes: 7 additions & 0 deletions
7
test/fixtures/es-module-loaders/never-settling-resolve-step/race.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const result = await Promise.race([ | ||
import('never-settle-resolve'), | ||
import('never-settle-load'), | ||
import('node:process'), | ||
]); | ||
|
||
console.log(result.default === process); |