@@ -297,22 +297,22 @@ export async function loadModuleInternal(pathCx : PathContext, options : Options
297
297
* Create a cjs module
298
298
* @internal
299
299
*/
300
- export function createModule ( filename : string , source : string , options : Options ) : Module {
300
+ export function createModule ( refPath : string , source : string , options : Options ) : Module {
301
301
302
302
const { moduleCache, pathHandlers : { resolve } , getResource } = options ;
303
303
304
- const require = function ( path : string ) {
304
+ const require = function ( relPath : string ) {
305
305
306
- const { id } = getResource ( { refPath : filename , relPath : path } , options ) ;
306
+ const { id } = getResource ( { refPath, relPath } , options ) ;
307
307
if ( id in moduleCache )
308
308
return moduleCache [ id ] ;
309
309
310
310
throw new Error ( `${ id } not found in moduleCache` ) ;
311
311
}
312
312
313
- const import_ = async function ( path : string ) {
313
+ const import_ = async function ( relPath : string ) {
314
314
315
- return await loadModuleInternal ( { refPath : filename , relPath : path } , options ) ;
315
+ return await loadModuleInternal ( { refPath, relPath } , options ) ;
316
316
}
317
317
318
318
const module = {
@@ -321,7 +321,7 @@ export function createModule(filename : string, source : string, options : Optio
321
321
322
322
// see https://github.com/nodejs/node/blob/a46b21f556a83e43965897088778ddc7d46019ae/lib/internal/modules/cjs/loader.js#L195-L198
323
323
// see https://github.com/nodejs/node/blob/a46b21f556a83e43965897088778ddc7d46019ae/lib/internal/modules/cjs/loader.js#L1102
324
- Function ( 'exports' , 'require' , 'module' , '__filename' , '__dirname' , 'import_' , source ) . call ( module . exports , module . exports , require , module , filename , resolve ( { refPath : filename , relPath : '.' } ) , import_ ) ;
324
+ Function ( 'exports' , 'require' , 'module' , '__filename' , '__dirname' , 'import_' , source ) . call ( module . exports , module . exports , require , module , refPath , resolve ( { refPath, relPath : '.' } ) , import_ ) ;
325
325
326
326
return module ;
327
327
}
@@ -348,9 +348,9 @@ export async function createJSModule(source : string, moduleSourceType : boolean
348
348
* Just load and cache given dependencies.
349
349
* @internal
350
350
*/
351
- export async function loadDeps ( filename : string , deps : string [ ] , options : Options ) : Promise < void > {
351
+ export async function loadDeps ( refPath : string , deps : string [ ] , options : Options ) : Promise < void > {
352
352
353
- await Promise . all ( deps . map ( dep => loadModuleInternal ( { refPath : filename , relPath : dep } , options ) ) )
353
+ await Promise . all ( deps . map ( relPath => loadModuleInternal ( { refPath, relPath } , options ) ) )
354
354
}
355
355
356
356
0 commit comments