Skip to content

Commit efd7a58

Browse files
committed
chore: clean up require tests
1 parent 335adb4 commit efd7a58

File tree

11 files changed

+27
-35
lines changed

11 files changed

+27
-35
lines changed

cli/factory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
})

cli/lib/worker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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?;

cli/rt/run.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff 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,

tests/specs/run/require_modules_multiple/main_multiple.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@ console.log("main_multiple.ts starts");
22

33
console.log(`First: ${globalThis.__first__}`);
44
console.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

610
console.log("main_multiple.ts finished");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
require_first.js loading
2+
require_first.js platform: [WILDCARD]
23
require_second.js loading
4+
require_second.js path separator: [WILDCARD]
35
main_multiple.ts starts
46
First: first
57
Second: 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
612
main_multiple.ts finished
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
console.log("require_first.js loading");
2+
3+
const os = require("node:os");
4+
5+
console.log(`require_first.js platform: ${os.platform()}`);
6+
27
globalThis.__first__ = "first";
8+
globalThis.__first_filename__ = __filename;
9+
globalThis.__first_dirname__ = __dirname;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
console.log("require_second.js loading");
2+
3+
const path = require("node:path");
4+
5+
console.log(`require_second.js path separator: ${path.sep}`);
6+
27
globalThis.__second__ = "second";
8+
globalThis.__second_filename__ = __filename;
9+
globalThis.__second_dirname__ = __dirname;

tests/specs/run/require_modules_node/__test__.jsonc

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/specs/run/require_modules_node/main_node.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/specs/run/require_modules_node/node.out

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)