mirror of
https://github.com/denoland/deno.git
synced 2024-12-12 18:42:18 -05:00
617eeabe83
This commit adds CJS and ESM Node resolvers to the "--compat" mode. The functionality is spread across "cli/compat" module and Node compatibility layer in "deno_std/node"; this stems from the fact that ES module resolution can only be implemented in Rust as it needs to directly integrated with "deno_core"; however "deno_std/node" already provided CJS module resolution. Currently this resolution is only active when running a files using "deno run --compat --unstable <filename>", and is not available in other subcommands, which will be changed in follow up commits.
31 lines
766 B
Rust
31 lines
766 B
Rust
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use crate::itest;
|
|
use test_util as util;
|
|
|
|
itest!(globals {
|
|
args: "run --compat --unstable --allow-read --allow-env compat/globals.ts",
|
|
output: "compat/globals.out",
|
|
});
|
|
|
|
itest!(fs_promises {
|
|
args: "run --compat --unstable -A compat/fs_promises.mjs",
|
|
output: "compat/fs_promises.out",
|
|
});
|
|
|
|
itest!(node_prefix_fs_promises {
|
|
args: "run --compat --unstable -A compat/node_fs_promises.mjs",
|
|
output: "compat/fs_promises.out",
|
|
});
|
|
|
|
#[test]
|
|
fn globals_in_repl() {
|
|
let (out, _err) = util::run_and_collect_output_with_args(
|
|
true,
|
|
vec!["repl", "--compat", "--unstable", "--quiet"],
|
|
Some(vec!["global == window"]),
|
|
None,
|
|
false,
|
|
);
|
|
assert!(out.contains("true"));
|
|
}
|