File tree Expand file tree Collapse file tree 11 files changed +27
-35
lines changed Expand file tree Collapse file tree 11 files changed +27
-35
lines changed Original file line number Diff line number Diff line change @@ -1271,7 +1271,7 @@ impl CliFactory {
12711271 } else {
12721272 deno_resolver:: loader:: AllowJsonImports :: WithAttribute
12731273 } ,
1274- require_modules : options. require_modules ( ) . unwrap_or_default ( ) ,
1274+ require_modules : options. require_modules ( ) ? ,
12751275 } ,
12761276 ) ) )
12771277 } )
Original file line number Diff line number Diff line change @@ -883,6 +883,8 @@ impl LibMainWorker {
883883 self . worker . evaluate_module ( id) . await ?;
884884 self . worker . run_event_loop ( false ) . await ?;
885885 }
886+ // Even though we load as ESM here, these files will be forced to be loaded as CJS
887+ // because of checks in get_known_mode_with_is_script
886888 for require_module_url in self . require_modules . iter ( ) {
887889 let id = self . worker . preload_side_module ( require_module_url) . await ?;
888890 self . worker . evaluate_module ( id) . await ?;
Original file line number Diff line number Diff line change @@ -1089,12 +1089,6 @@ pub async fn run(
10891089 . map ( |key| root_dir_url. join ( key) . unwrap ( ) )
10901090 . collect :: < Vec < _ > > ( ) ;
10911091
1092- let require_modules = metadata
1093- . require_modules
1094- . iter ( )
1095- . map ( |key| root_dir_url. join ( key) . unwrap ( ) )
1096- . collect :: < Vec < _ > > ( ) ;
1097-
10981092 let mut worker = worker_factory. create_main_worker (
10991093 WorkerExecutionMode :: Run ,
11001094 permissions,
Original file line number Diff line number Diff line change @@ -2,5 +2,9 @@ console.log("main_multiple.ts starts");
22
33console . log ( `First: ${ globalThis . __first__ } ` ) ;
44console . log ( `Second: ${ globalThis . __second__ } ` ) ;
5+ console . log ( `First filename: ${ globalThis . __first_filename__ } ` ) ;
6+ console . log ( `Second filename: ${ globalThis . __second_filename__ } ` ) ;
7+ console . log ( `First dirname: ${ globalThis . __first_dirname__ } ` ) ;
8+ console . log ( `Second dirname: ${ globalThis . __second_dirname__ } ` ) ;
59
610console . log ( "main_multiple.ts finished" ) ;
Original file line number Diff line number Diff line change 11require_first.js loading
2+ require_first.js platform: [WILDCARD]
23require_second.js loading
4+ require_second.js path separator: [WILDCARD]
35main_multiple.ts starts
46First: first
57Second: second
8+ First filename: [WILDCARD]require_first.js
9+ Second filename: [WILDCARD]require_second.js
10+ First dirname: [WILDCARD]require_modules_multiple
11+ Second dirname: [WILDCARD]require_modules_multiple
612main_multiple.ts finished
Original file line number Diff line number Diff line change 11console . log ( "require_first.js loading" ) ;
2+
3+ const os = require ( "node:os" ) ;
4+
5+ console . log ( `require_first.js platform: ${ os . platform ( ) } ` ) ;
6+
27globalThis . __first__ = "first" ;
8+ globalThis . __first_filename__ = __filename ;
9+ globalThis . __first_dirname__ = __dirname ;
Original file line number Diff line number Diff line change 11console . log ( "require_second.js loading" ) ;
2+
3+ const path = require ( "node:path" ) ;
4+
5+ console . log ( `require_second.js path separator: ${ path . sep } ` ) ;
6+
27globalThis . __second__ = "second" ;
8+ globalThis . __second_filename__ = __filename ;
9+ globalThis . __second_dirname__ = __dirname ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments