From 560ad0331bf99a2564f53201cd086ff902901bfe Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 9 Sep 2024 17:35:41 -0400 Subject: fix(node/byonm): do not accidentally resolve bare node built-ins (#25543) This was accidentally enabled in byonm, but it requires the `--unstable-bare-node-builtins` flag. Closes #25358 --- tests/specs/run/node_prefix_missing/__test__.jsonc | 35 ++++++++++++++++++++++ tests/specs/run/node_prefix_missing/byonm/has.out | 1 + tests/specs/run/node_prefix_missing/byonm/has.ts | 3 ++ .../run/node_prefix_missing/byonm/missing.out | 3 ++ .../specs/run/node_prefix_missing/byonm/missing.ts | 3 ++ .../run/node_prefix_missing/byonm/package.json | 2 ++ tests/specs/run/node_prefix_missing/config.json | 3 ++ .../run/node_prefix_missing/feature_enabled.out | 2 ++ tests/specs/run/node_prefix_missing/main.ts | 3 ++ tests/specs/run/node_prefix_missing/main.ts.out | 3 ++ 10 files changed, 58 insertions(+) create mode 100644 tests/specs/run/node_prefix_missing/__test__.jsonc create mode 100644 tests/specs/run/node_prefix_missing/byonm/has.out create mode 100644 tests/specs/run/node_prefix_missing/byonm/has.ts create mode 100644 tests/specs/run/node_prefix_missing/byonm/missing.out create mode 100644 tests/specs/run/node_prefix_missing/byonm/missing.ts create mode 100644 tests/specs/run/node_prefix_missing/byonm/package.json create mode 100644 tests/specs/run/node_prefix_missing/config.json create mode 100644 tests/specs/run/node_prefix_missing/feature_enabled.out create mode 100644 tests/specs/run/node_prefix_missing/main.ts create mode 100644 tests/specs/run/node_prefix_missing/main.ts.out (limited to 'tests/specs/run/node_prefix_missing') diff --git a/tests/specs/run/node_prefix_missing/__test__.jsonc b/tests/specs/run/node_prefix_missing/__test__.jsonc new file mode 100644 index 000000000..305020ed9 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/__test__.jsonc @@ -0,0 +1,35 @@ +{ + "tests": { + "basic": { + "args": "run --quiet main.ts", + "output": "main.ts.out", + "exitCode": 1 + }, + "unstable_bare_node_builtins_enabled": { + "args": "run --unstable-bare-node-builtins main.ts", + "output": "feature_enabled.out" + }, + "unstable_bare_node_builtins_enbaled_by_env": { + "args": "run main.ts", + "envs": { + "DENO_UNSTABLE_BARE_NODE_BUILTINS": "1" + }, + "output": "feature_enabled.out" + }, + "enabled_by_config": { + "args": "run --config=config.json main.ts", + "output": "feature_enabled.out" + }, + "byonm_missing": { + "cwd": "byonm", + "exitCode": 1, + "args": "run missing.ts", + "output": "byonm/missing.out" + }, + "byonm_has": { + "cwd": "byonm", + "args": "run has.ts", + "output": "byonm/has.out" + } + } +} diff --git a/tests/specs/run/node_prefix_missing/byonm/has.out b/tests/specs/run/node_prefix_missing/byonm/has.out new file mode 100644 index 000000000..e223dcff5 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/byonm/has.out @@ -0,0 +1 @@ +[Function: writeFile] diff --git a/tests/specs/run/node_prefix_missing/byonm/has.ts b/tests/specs/run/node_prefix_missing/byonm/has.ts new file mode 100644 index 000000000..a52c1e3f0 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/byonm/has.ts @@ -0,0 +1,3 @@ +import fs from "node:fs"; + +console.log(fs.writeFile); diff --git a/tests/specs/run/node_prefix_missing/byonm/missing.out b/tests/specs/run/node_prefix_missing/byonm/missing.out new file mode 100644 index 000000000..4129e79a5 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/byonm/missing.out @@ -0,0 +1,3 @@ +error: Relative import path "fs" not prefixed with / or ./ or ../ + hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). + at file:///[WILDLINE]/missing.ts:1:16 diff --git a/tests/specs/run/node_prefix_missing/byonm/missing.ts b/tests/specs/run/node_prefix_missing/byonm/missing.ts new file mode 100644 index 000000000..c5c1885a2 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/byonm/missing.ts @@ -0,0 +1,3 @@ +import fs from "fs"; + +console.log(fs.writeFile); diff --git a/tests/specs/run/node_prefix_missing/byonm/package.json b/tests/specs/run/node_prefix_missing/byonm/package.json new file mode 100644 index 000000000..2c63c0851 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/byonm/package.json @@ -0,0 +1,2 @@ +{ +} diff --git a/tests/specs/run/node_prefix_missing/config.json b/tests/specs/run/node_prefix_missing/config.json new file mode 100644 index 000000000..72f40aaf3 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/config.json @@ -0,0 +1,3 @@ +{ + "unstable": ["bare-node-builtins"] +} diff --git a/tests/specs/run/node_prefix_missing/feature_enabled.out b/tests/specs/run/node_prefix_missing/feature_enabled.out new file mode 100644 index 000000000..3eff4bc32 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/feature_enabled.out @@ -0,0 +1,2 @@ +[WILDCARD]Warning Resolving "fs" as "node:fs" at file:///[WILDCARD]/main.ts:1:16. If you want to use a built-in Node module, add a "node:" prefix. +[Function: writeFile] diff --git a/tests/specs/run/node_prefix_missing/main.ts b/tests/specs/run/node_prefix_missing/main.ts new file mode 100644 index 000000000..c5c1885a2 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/main.ts @@ -0,0 +1,3 @@ +import fs from "fs"; + +console.log(fs.writeFile); diff --git a/tests/specs/run/node_prefix_missing/main.ts.out b/tests/specs/run/node_prefix_missing/main.ts.out new file mode 100644 index 000000000..48b4e37e2 --- /dev/null +++ b/tests/specs/run/node_prefix_missing/main.ts.out @@ -0,0 +1,3 @@ +error: Relative import path "fs" not prefixed with / or ./ or ../ + hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). + at file:///[WILDCARD]/main.ts:1:16 -- cgit v1.2.3