1
+ import { pathToFileURL } from 'node:url' ;
1
2
import count from '../es-modules/stateful.mjs' ;
2
3
3
4
@@ -24,28 +25,28 @@ export function load(url, context, next) {
24
25
format : 'module' ,
25
26
} ) ;
26
27
27
- if ( url === 'esmHook/badReturnVal.mjs' ) return 'export function returnShouldBeObject() {}' ;
28
+ if ( url . endsWith ( 'esmHook/badReturnVal.mjs' ) ) return 'export function returnShouldBeObject() {}' ;
28
29
29
- if ( url === 'esmHook/badReturnFormatVal.mjs' ) return {
30
+ if ( url . endsWith ( 'esmHook/badReturnFormatVal.mjs' ) ) return {
30
31
format : Array ( 0 ) ,
31
32
source : '' ,
32
33
}
33
- if ( url === 'esmHook/unsupportedReturnFormatVal.mjs' ) return {
34
+ if ( url . endsWith ( 'esmHook/unsupportedReturnFormatVal.mjs' ) ) return {
34
35
format : 'foo' , // Not one of the allowable inputs: no translator named 'foo'
35
36
source : '' ,
36
37
}
37
38
38
- if ( url === 'esmHook/badReturnSourceVal.mjs' ) return {
39
+ if ( url . endsWith ( 'esmHook/badReturnSourceVal.mjs' ) ) return {
39
40
format : 'module' ,
40
41
source : Array ( 0 ) ,
41
42
}
42
43
43
- if ( url === 'esmHook/preknownFormat.pre' ) return {
44
+ if ( url . endsWith ( 'esmHook/preknownFormat.pre' ) ) return {
44
45
format : context . format ,
45
46
source : `const msg = 'hello world'; export default msg;`
46
47
} ;
47
48
48
- if ( url === 'esmHook/virtual.mjs' ) return {
49
+ if ( url . endsWith ( 'esmHook/virtual.mjs' ) ) return {
49
50
format : 'module' ,
50
51
source : `export const message = 'Woohoo!'.toUpperCase();` ,
51
52
} ;
@@ -62,7 +63,7 @@ export function resolve(specifier, context, next) {
62
63
63
64
if ( specifier . startsWith ( 'esmHook' ) ) return {
64
65
format,
65
- url : specifier ,
66
+ url : pathToFileURL ( specifier ) . href ,
66
67
importAssertions : context . importAssertions ,
67
68
} ;
68
69
0 commit comments