From 617eeabe8369d7bfca7951d1cd55ac58ede1f9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 18 Oct 2021 19:36:28 +0200 Subject: feat(unstable): Node CJS and ESM resolvers for compat mode (#12424) 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 ", and is not available in other subcommands, which will be changed in follow up commits. --- cli/compat/testdata/basic_deps/node_modules/bar/bar.js | 1 + cli/compat/testdata/basic_deps/node_modules/bar/package.json | 6 ++++++ cli/compat/testdata/basic_deps/node_modules/foo/foo.js | 1 + cli/compat/testdata/basic_deps/node_modules/foo/package.json | 8 ++++++++ 4 files changed, 16 insertions(+) create mode 100644 cli/compat/testdata/basic_deps/node_modules/bar/bar.js create mode 100644 cli/compat/testdata/basic_deps/node_modules/bar/package.json create mode 100644 cli/compat/testdata/basic_deps/node_modules/foo/foo.js create mode 100644 cli/compat/testdata/basic_deps/node_modules/foo/package.json (limited to 'cli/compat/testdata/basic_deps/node_modules') diff --git a/cli/compat/testdata/basic_deps/node_modules/bar/bar.js b/cli/compat/testdata/basic_deps/node_modules/bar/bar.js new file mode 100644 index 000000000..98e51675e --- /dev/null +++ b/cli/compat/testdata/basic_deps/node_modules/bar/bar.js @@ -0,0 +1 @@ +export const BAR = 123; diff --git a/cli/compat/testdata/basic_deps/node_modules/bar/package.json b/cli/compat/testdata/basic_deps/node_modules/bar/package.json new file mode 100644 index 000000000..c2043f610 --- /dev/null +++ b/cli/compat/testdata/basic_deps/node_modules/bar/package.json @@ -0,0 +1,6 @@ +{ + "name": "bar", + "version": "0.1.2", + "type": "module", + "exports": "./bar.js" +} diff --git a/cli/compat/testdata/basic_deps/node_modules/foo/foo.js b/cli/compat/testdata/basic_deps/node_modules/foo/foo.js new file mode 100644 index 000000000..0026acc8e --- /dev/null +++ b/cli/compat/testdata/basic_deps/node_modules/foo/foo.js @@ -0,0 +1 @@ +import "bar"; diff --git a/cli/compat/testdata/basic_deps/node_modules/foo/package.json b/cli/compat/testdata/basic_deps/node_modules/foo/package.json new file mode 100644 index 000000000..376dae81e --- /dev/null +++ b/cli/compat/testdata/basic_deps/node_modules/foo/package.json @@ -0,0 +1,8 @@ +{ + "name": "foo", + "type": "module", + "exports": "./foo.js", + "dependencies": { + "bar": "0.1.2" + } +} -- cgit v1.2.3