From be97170a193e8cecc5ce03ecd3c1d0add4a06bf7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 25 Oct 2023 14:39:00 -0400 Subject: feat(unstable): ability to `npm install` then `deno run main.ts` (#20967) This PR adds a new unstable "bring your own node_modules" (BYONM) functionality currently behind a `--unstable-byonm` flag (`"unstable": ["byonm"]` in a deno.json). This enables users to run a separate install command (ex. `npm install`, `pnpm install`) then run `deno run main.ts` and Deno will respect the layout of the node_modules directory as setup by the separate install command. It also works with npm/yarn/pnpm workspaces. For this PR, the behaviour is opted into by specifying `--unstable-byonm`/`"unstable": ["byonm"]`, but in the future we may make this the default behaviour as outlined in https://github.com/denoland/deno/issues/18967#issuecomment-1761248941 This is an extremely rough initial implementation. Errors are terrible in this and the LSP requires frequent restarts. Improvements will be done in follow up PRs. --- .../conditional-exports-strict/1.0.0/cjs/index.cjs | 3 +++ .../conditional-exports-strict/1.0.0/esm/client/bar.js | 3 +++ .../conditional-exports-strict/1.0.0/esm/client/foo.js | 3 +++ .../conditional-exports-strict/1.0.0/esm/client/index.js | 3 +++ .../conditional-exports-strict/1.0.0/esm/client/m.js | 3 +++ .../conditional-exports-strict/1.0.0/esm/index.js | 3 +++ .../@denotest/conditional-exports-strict/1.0.0/foo.js | 3 +++ .../conditional-exports-strict/1.0.0/package.json | 16 ++++++++++++++++ .../conditional-exports/1.0.0/esm/client/bar.js | 2 +- .../conditional-exports/1.0.0/esm/client/foo.js | 2 +- .../conditional-exports/1.0.0/esm/client/index.js | 2 +- .../@denotest/conditional-exports/1.0.0/esm/client/m.js | 2 +- .../npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.cts | 1 + .../npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.mts | 1 + 14 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/cjs/index.cjs create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/bar.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/foo.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/index.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/m.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/index.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/foo.js create mode 100644 cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/package.json create mode 100644 cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.cts create mode 100644 cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.mts (limited to 'cli/tests/testdata') diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/cjs/index.cjs b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/cjs/index.cjs new file mode 100644 index 000000000..16895e48c --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/cjs/index.cjs @@ -0,0 +1,3 @@ +module.exports = { + hello: "from cjs" +}; \ No newline at end of file diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/bar.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/bar.js new file mode 100644 index 000000000..1474f5d29 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/bar.js @@ -0,0 +1,3 @@ +export default { + hello: "from esm client bar", +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/foo.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/foo.js new file mode 100644 index 000000000..bb5284b15 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/foo.js @@ -0,0 +1,3 @@ +export default { + hello: "from esm client foo", +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/index.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/index.js new file mode 100644 index 000000000..dc1ec197d --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/index.js @@ -0,0 +1,3 @@ +export default { + hello: "from esm client", +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/m.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/m.js new file mode 100644 index 000000000..fec6807ac --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/client/m.js @@ -0,0 +1,3 @@ +export default { + hello: "from esm client m", +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/index.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/index.js new file mode 100644 index 000000000..38dae7d93 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/esm/index.js @@ -0,0 +1,3 @@ +export default { + hello: "from esm", +} \ No newline at end of file diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/foo.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/foo.js new file mode 100644 index 000000000..6060c8a67 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/foo.js @@ -0,0 +1,3 @@ +export default { + hello: "from foo", +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/package.json new file mode 100644 index 000000000..3576e48f8 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports-strict/1.0.0/package.json @@ -0,0 +1,16 @@ +{ + "name": "@denotest/conditional-exports-strict", + "version": "1.0.0", + "type": "module", + "exports": { + ".": { + "types": "./types/src/index.d.ts", + "require": "./cjs/index.cjs", + "import": "./esm/index.js" + }, + "./client": { + "types": "./types/src/client/index.d.ts", + "import": "./esm/client/index.js" + } + } +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/bar.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/bar.js index 12352639d..1474f5d29 100644 --- a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/bar.js +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/bar.js @@ -1,3 +1,3 @@ export default { hello: "from esm client bar", -} \ No newline at end of file +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/foo.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/foo.js index 1ab5baf1b..bb5284b15 100644 --- a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/foo.js +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/foo.js @@ -1,3 +1,3 @@ export default { hello: "from esm client foo", -} \ No newline at end of file +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/index.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/index.js index 86f246be4..dc1ec197d 100644 --- a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/index.js +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/index.js @@ -1,3 +1,3 @@ export default { hello: "from esm client", -} \ No newline at end of file +} diff --git a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/m.js b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/m.js index 40e769031..fec6807ac 100644 --- a/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/m.js +++ b/cli/tests/testdata/npm/registry/@denotest/conditional-exports/1.0.0/esm/client/m.js @@ -1,3 +1,3 @@ export default { hello: "from esm client m", -} \ No newline at end of file +} diff --git a/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.cts b/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.cts new file mode 100644 index 000000000..f969ba996 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.cts @@ -0,0 +1 @@ +export function getKind(): string; diff --git a/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.mts b/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.mts new file mode 100644 index 000000000..f969ba996 --- /dev/null +++ b/cli/tests/testdata/npm/registry/@denotest/dual-cjs-esm/1.0.0/main.d.mts @@ -0,0 +1 @@ +export function getKind(): string; -- cgit v1.2.3