diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-09-19 18:37:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 18:37:36 -0700 |
commit | f1ba26661346a83b6e7fe5e7ffeed4553a9571ae (patch) | |
tree | 2aaa1c5fa8896b0dddb3219f627f32e3ad73afcc /tests/specs | |
parent | 5bcea1a9f4eb95cd764047869a17ed74df8f60d1 (diff) |
fix(node): Don't error out if we fail to statically analyze CJS re-export (#25748)
Fixes rsbuild running in deno.
You can look at the test to see what was failing, the gist is that we
were trying to statically analyze the re-exports of a CJS script, and if
we couldn't find the source for the re-exported file we would fail.
Instead, we should just treat these as if they were too dynamic to
analyze, and let it fail (or succeed) at runtime. This aligns with
node's behavior.
Diffstat (limited to 'tests/specs')
4 files changed, 20 insertions, 0 deletions
diff --git a/tests/specs/run/cjs_reexport_non_analyzable/__test__.jsonc b/tests/specs/run/cjs_reexport_non_analyzable/__test__.jsonc new file mode 100644 index 000000000..81f29b685 --- /dev/null +++ b/tests/specs/run/cjs_reexport_non_analyzable/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "tempDir": true, + "steps": [ + { + "args": "run -A main.ts", + "output": "" + } + ] +} diff --git a/tests/specs/run/cjs_reexport_non_analyzable/deno.json b/tests/specs/run/cjs_reexport_non_analyzable/deno.json new file mode 100644 index 000000000..fde86a1ef --- /dev/null +++ b/tests/specs/run/cjs_reexport_non_analyzable/deno.json @@ -0,0 +1,3 @@ +{ + "nodeModulesDir": "manual" +} diff --git a/tests/specs/run/cjs_reexport_non_analyzable/main.ts b/tests/specs/run/cjs_reexport_non_analyzable/main.ts new file mode 100644 index 000000000..a9e32af4e --- /dev/null +++ b/tests/specs/run/cjs_reexport_non_analyzable/main.ts @@ -0,0 +1,3 @@ +import assert from "./node_modules/foo.cjs"; + +assert.equal(1 + 1, 2); diff --git a/tests/specs/run/cjs_reexport_non_analyzable/node_modules/foo.cjs b/tests/specs/run/cjs_reexport_non_analyzable/node_modules/foo.cjs new file mode 100644 index 000000000..924d8a96a --- /dev/null +++ b/tests/specs/run/cjs_reexport_non_analyzable/node_modules/foo.cjs @@ -0,0 +1,5 @@ +try { + module.exports = require("nonexistent"); +} catch(_e) { + module.exports = require("assert"); +} |