@@ -46,10 +46,9 @@ formatProviders.set('cjs', async (url) => {
46
46
// through normal resolution
47
47
formatProviders . set ( 'native' , async ( url ) => {
48
48
const ctx = createDynamicModule ( [ 'default' ] , url , ( reflect ) => {
49
- debug ( `Loading CJSModule ${ url . pathname } ` ) ;
50
- const CJSModule = require ( 'module' ) ;
51
- const pathname = internalURLModule . getPathFromURL ( url ) ;
52
- ctx . reflect . exports . default . set ( CJSModule . _load ( pathname ) ) ;
49
+ debug ( `Loading NativeModule ${ url . pathname } ` ) ;
50
+ const exports = NativeModule . require ( url . pathname ) ;
51
+ reflect . exports . default . set ( exports ) ;
53
52
} ) ;
54
53
return ctx . module ;
55
54
} ) ;
@@ -66,31 +65,24 @@ formatProviders.set('json', async (url) => {
66
65
67
66
// TODO: make this native binary handling only
68
67
formatProviders . set ( 'binary' , async ( url ) => {
69
- const source = `${ await asyncReadFile ( url ) } ` ;
70
68
const ctx = createDynamicModule ( [ 'default' ] , url , ( reflect ) => {
71
- debug ( `Loading JSONModule ${ url . pathname } ` ) ;
72
- const json = JSON . parse ( source ) ;
73
- ctx . reflect . exports . default . set ( json ) ;
69
+ debug ( `Loading CJSModule ${ url . pathname } ` ) ;
70
+ const CJSModule = require ( 'module' ) ;
71
+ const pathname = internalURLModule . getPathFromURL ( url ) ;
72
+ ctx . reflect . exports . default . set ( CJSModule . _load ( pathname ) ) ;
74
73
} ) ;
75
74
return ctx . module ;
76
75
} ) ;
77
76
78
- function normalizeBaseURL ( baseURLOrString ) {
79
- if ( baseURLOrString instanceof URL ) return baseURLOrString ;
80
- if ( typeof baseURLOrString === 'string' ) return new URL ( baseURLOrString ) ;
81
- return undefined ;
82
- }
83
-
84
77
exports . resolve = resolve ;
85
- function resolve ( specifier , parentURLOrString ) {
78
+ function resolve ( specifier , parentURL ) {
86
79
if ( NativeModule . nonInternalExists ( specifier ) ) {
87
80
return {
88
81
url : new URL ( `node:${ specifier } ` ) ,
89
82
format : 'native'
90
83
} ;
91
84
}
92
85
93
- const parentURL = normalizeBaseURL ( parentURLOrString ) ;
94
86
let url = search ( specifier , parentURL ) ;
95
87
96
88
if ( url . protocol !== 'file:' ) {
0 commit comments