@@ -138,7 +138,6 @@ class Hooks {
138
138
139
139
/**
140
140
* Collect custom/user-defined module loader hook(s).
141
- * After all hooks have been collected, the global preload hook(s) must be initialized.
142
141
* @param {string } url Custom loader specifier
143
142
* @param {Record<string, unknown> } exports
144
143
* @param {any } [data] Arbitrary data to be passed from the custom loader (user-land)
@@ -501,8 +500,6 @@ class HooksProxy {
501
500
AtomicsWait ( this . #lock, WORKER_TO_MAIN_THREAD_NOTIFICATION , 0 ) ;
502
501
const response = this . #worker. receiveMessageSync ( ) ;
503
502
if ( response == null || response . message . status === 'exit' ) { return ; }
504
- const { preloadScripts } = this . #unwrapMessage( response ) ;
505
- this . #executePreloadScripts( preloadScripts ) ;
506
503
}
507
504
508
505
this . #isReady = true ;
@@ -619,63 +616,6 @@ class HooksProxy {
619
616
importMetaInitialize ( meta , context , loader ) {
620
617
this . #importMetaInitializer( meta , context , loader ) ;
621
618
}
622
-
623
- #executePreloadScripts( preloadScripts ) {
624
- for ( let i = 0 ; i < preloadScripts . length ; i ++ ) {
625
- const { code, port } = preloadScripts [ i ] ;
626
- const { compileFunction } = require ( 'vm' ) ;
627
- const preloadInit = compileFunction (
628
- code ,
629
- [ 'getBuiltin' , 'port' , 'setImportMetaCallback' ] ,
630
- {
631
- filename : '<preload>' ,
632
- } ,
633
- ) ;
634
- let finished = false ;
635
- let replacedImportMetaInitializer = false ;
636
- let next = this . #importMetaInitializer;
637
- const { BuiltinModule } = require ( 'internal/bootstrap/realm' ) ;
638
- // Calls the compiled preload source text gotten from the hook
639
- // Since the parameters are named we use positional parameters
640
- // see compileFunction above to cross reference the names
641
- try {
642
- FunctionPrototypeCall (
643
- preloadInit ,
644
- globalThis ,
645
- // Param getBuiltin
646
- ( builtinName ) => {
647
- if ( StringPrototypeStartsWith ( builtinName , 'node:' ) ) {
648
- builtinName = StringPrototypeSlice ( builtinName , 5 ) ;
649
- } else if ( ! BuiltinModule . canBeRequiredWithoutScheme ( builtinName ) ) {
650
- throw new ERR_UNKNOWN_BUILTIN_MODULE ( builtinName ) ;
651
- }
652
- if ( BuiltinModule . canBeRequiredByUsers ( builtinName ) ) {
653
- return require ( builtinName ) ;
654
- }
655
- throw new ERR_UNKNOWN_BUILTIN_MODULE ( builtinName ) ;
656
- } ,
657
- // Param port
658
- port ,
659
- // setImportMetaCallback
660
- ( fn ) => {
661
- if ( finished || typeof fn !== 'function' ) {
662
- throw new ERR_INVALID_ARG_TYPE ( 'fn' , fn ) ;
663
- }
664
- replacedImportMetaInitializer = true ;
665
- const parent = next ;
666
- next = ( meta , context ) => {
667
- return fn ( meta , context , parent ) ;
668
- } ;
669
- } ,
670
- ) ;
671
- } finally {
672
- finished = true ;
673
- if ( replacedImportMetaInitializer ) {
674
- this . #importMetaInitializer = next ;
675
- }
676
- }
677
- }
678
- }
679
619
}
680
620
ObjectSetPrototypeOf ( HooksProxy . prototype , null ) ;
681
621
0 commit comments