Skip to content

fix: escape dependency paths in CJS and UMD output - #11076

Merged
hyfdev merged 1 commit into
fix/arbitrary-import-propertiesfrom
fix/escape-dependency-specifiers
Oct 2, 2026
Merged

hyfdev merged 1 commit into
fix/arbitrary-import-propertiesfrom
fix/escape-dependency-specifiers

Conversation

@hyfdev

@hyfdev hyfdev commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Dependency paths containing quotes or backslashes can generate invalid JavaScript or load a different module in CJS and UMD output. Preserve the exact path in require() calls and UMD AMD dependency arrays.

For a mapped path containing a literal backslash followed by n, the generated call changes from:

require("a\nb");

to:

require("a\\nb");

Serialize each dependency path as a complete string literal using the same escaping utility as ESM imports. This covers external imports, external star re-exports, and references to shared CJS chunks.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-escape-dependency-specifiers-rolldown-rs.voidzero-docs.workers.dev (commit d16323a)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://11f066b9-rolldown-rs.voidzero-docs.workers.dev d16323a 2026-10-02T04:06:08.900Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://83b4e270-rolldown-rs.voidzero-docs.workers.dev 56adeaf 2026-10-02T03:46:07.098Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://7e8e47d1-rolldown-rs.voidzero-docs.workers.dev f472b2b 2026-10-02T03:17:19.717Z Visit the dashboard ↗

@hyfdev
hyfdev added this pull request to stack #11078 October 2, 2026 03:17
@hyfdev
hyfdev force-pushed the fix/escape-dependency-specifiers branch from f472b2b to 56adeaf Compare October 2, 2026 03:43
@hyfdev
hyfdev force-pushed the fix/escape-dependency-specifiers branch from 56adeaf to d16323a Compare October 2, 2026 04:03
@hyfdev
hyfdev marked this pull request as ready for review October 2, 2026 04:21
Copilot AI balanced review requested due to automatic review settings October 2, 2026 04:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The escaping changes consistently use the established serializer and include comprehensive behavioral coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Escapes dependency paths correctly in generated CJS and UMD output.

Changes:

  • Serialize dependency paths as complete JavaScript string literals.
  • Cover external imports, star re-exports, and shared chunks with behavioral tests.
  • Update the UMD output assertion for double-quoted dependencies.
File Description
crates/​rolldown/​src/​ecmascript/​format/​cjs.rs Escapes CJS dependency paths.
crates/​rolldown/​src/​ecmascript/​format/​umd.rs Escapes AMD and CJS UMD dependencies.
crates/​rolldown/​src/​utils/​chunk/​render_chunk_exports.rs Escapes star re-export paths.
packages/​rolldown/​tests/​behaviors/​dependency-path-escaping.test.ts Adds path-preservation coverage.
packages/​rolldown/​tests/​fixtures/​builtin-plugin/​esm-external-require-plugin/​umd-output/​_config.ts Updates expected UMD syntax.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codspeed

codspeed Bot commented Oct 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/escape-dependency-specifiers (d16323a) with main (f647b4e)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on fix/arbitrary-import-properties (d2b4b4f) during the generation of this report, so main (f647b4e) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@hyfdev
hyfdev merged commit 3905e6d into fix/export-rendering-diagnostics Oct 2, 2026
53 of 64 checks passed
@hyfdev
hyfdev deleted the fix/escape-dependency-specifiers branch October 2, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants