Repository navigation
Conversation
linyiru
force-pushed
the
fix/9994-filename-substitution-diagnostics
branch
from
June 27, 2026 20:36
0366e61 to
db68e7b
Compare
…ntext (rolldown#9994) When an emitted or dynamically imported chunk resolves to a module outside the input base (e.g. inside node_modules), its derived `[name]` becomes a relative `../...` path that rolldown rejects with INVALID_OPTION. The error previously exposed only the offending string, so users couldn't tell which file or plugin caused it. Thread the chunk's facade module id and module ids through `FilenameTemplate::render` so the error now names the source module, adds an actionable hint, and populates `error.id` / `error.ids` (the latter also fixes errors not exposing `ids` while warnings already did). Also normalize away the new `id`/`ids` fields in the rollup-tests compatibility harness (`compareError`), since Rollup's INVALID_OPTION errors carry no ids.
linyiru
force-pushed
the
fix/9994-filename-substitution-diagnostics
branch
from
June 27, 2026 20:44
786040e to
99b5995
Compare
linyiru
marked this pull request as ready for review
June 27, 2026 22:05
linyiru
requested review from
IWANABETHATGUY,
hyfdev,
sapphi-red and
shulaoda
as code owners
June 27, 2026 22:05
Merging this PR will not alter performance
Comparing Footnotes
|
This was referenced Jul 22, 2026
IWANABETHATGUY
pushed a commit
that referenced
this pull request
Jul 23, 2026
## Description Fixes #9994. Rolldown accepts a path-like `name` for an emitted chunk and only fails later during rendering, with an `INVALID_OPTION` error that carries no plugin or hook attribution and blames the `chunkFileNames` pattern even when the pattern contains no `[name]`. Full diagnosis with repros: #9994 (comment) Asset names are already rejected at emit time by the native `FileEmitter`, but the failure surfaces with `pluginCode: 'INVALID_OPTION'` instead of rollup's `VALIDATION_ERROR`, which is why rollup's `invalid-asset-name` tests sat in the ignored list. Rollup rejects both synchronously inside `emitFile()`, so the failure surfaces with `plugin`, `hook`, `code: 'PLUGIN_ERROR'` and `pluginCode: 'VALIDATION_ERROR'` pointing at the plugin that emitted it. This PR ports that behavior to the JS plugin context: `emitFile` validates `fileName || name` with rollup's `isPathFragment` predicate and throws rollup's message. Because it throws inside the hook, the error picks up plugin and hook attribution with no extra plumbing. Chunks gain validation they previously lacked; assets gain rollup's error shape. ## Alternatives explored #9995 enriches the render time error with chunk context, which is complementary rather than overlapping: it covers name sources that never pass through the JS `emitFile`. Extending the existing native `FileEmitter` asset validation to chunks would also work, but the synchronous throw semantics and the hook error wrapping that provides attribution live on the JS side, and rollup's own tests assert the synchronous behavior and the `VALIDATION_ERROR` plugin code. ## Tests The existing `plugin/context/emit-file-invalid-name` fixture gains the chunk case and a subdirectory-name negative case (`sub/dir/asset.txt` still works). The second commit un-ignores rollup's `emit-file@invalid-asset-name` and `emit-file@invalid-asset-name3` in `ignored-by-unsupported-features.md`, which assert exactly this behavior including `pluginCode: 'VALIDATION_ERROR'`. Both pass, including the Windows drive letter variant, which validates the name string regardless of host OS. Full JS suite and the rollup compatibility suite are green locally, with a baseline run on main confirming no behavior change outside the new validation.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9994.
A build (e.g. a Qwik app) can fail with:
The error exposed only the offending string — no hint about which module/chunk/plugin produced it, which is exactly the issue's complaint ("the error doesn't indicate where the problem originates").
Root cause
An emitted or dynamically-imported chunk whose module resolves outside the input base (e.g. inside
node_modules) gets a derived[name]like../node_modules/...(generate_stage'sp.relative(input_base)), whichFilenameTemplate::renderthen rejects viais_path_fragment. The diagnostic dropped all the chunk context the call site already had.Changes
RollupPreRenderedChunk) intoFilenameTemplate::rendervia a borrowedFilenameSubstitutionContext— only materialized on the error path, so the common (successful) path stays allocation-free.INVALID_OPTIONmessage now:The "[name]" was derived from module: …emitFile'sname/chunkFileNameserror.id/error.ids(RollupLog interface) so the offending module is programmatically accessible. This also fixes an inconsistency where warnings exposedidsbut errors did not.Before / After
error.iderror.ids+ messageTests
filename_template.rscovering the enriched message + chunk context.tests/invalid-filename-substitution.test.ts) assertingerrors[0].id/errors[0].idsand the message, via a virtual-module reproduction.Disclosure: this PR was prepared with the assistance of Claude Code (AI). The author reviewed, built, and verified all changes locally (clippy, rustfmt, Rust unit tests, and the JS integration test all pass).
🤖 Generated with Claude Code