Repository navigation
Parse modules as the language the bundler assigned them - #125
Merged
Merged
Conversation
A .js file with JSX, assigned the jsx module type, failed to parse as JavaScript, which left its templates untransformed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
nstepien
marked this pull request as ready for review
November 4, 2026 02:25
nstepien
added a commit
that referenced
this pull request
Nov 4, 2026
main reshaped the code this branch builds on since the last merge, so the merge ports the branch onto main's design again: - The scope visitor is shared across parses (#109), so the callbacks for raw TypeScript bindings and `export default` join it, and the default export is recorded through its visit state. - Imported modules are resolved, loaded, and parsed once per transform through main's loadImportedModule (#124), which now also skips external modules, keys modules by moduleKey, and records dependencies by file. - Modules are parsed as the language the bundler assigned them through main's parseLangOf (#125), which this branch had too. - extractCssFromCode keeps main's single pass (#114), and hotUpdate its early return, with this branch's handling of query variants. - readModuleCode moved to module level, as consistent-function-scoping is on since #109. Tests: the inline snapshots of this branch's tests follow Rolldown's new module comments (`// path` instead of `//#region path` and `//#endregion`), with no other change. The dev server test of virtual modules uses main's shared getCode and getStylesheets helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
ecij parsed the module it transforms as the language its file extension implies, ignoring the module type the bundler assigned it. Rolldown parses a
.jsfile with JSX as JSX when configured withmoduleTypes: { '.js': 'jsx' }, but ecij failed to parse it and silently left its templates untransformed. The output kept the rawcsscall, which throws at runtime, and no CSS or warning came out.transformnow parses the module asmeta.moduleTypewhen that is a language the parser accepts (js,jsx,ts, ortsx), and otherwise falls back to the file extension. The modules that interpolated values come from are still read from disk and parsed by their extension..jsfixture with JSX through plain Rolldown withmoduleTypes: { '.js': 'jsx' }. On main, its output keeps thecsstemplate and no stylesheet is extracted.AGENTS.mddescribes how the module is parsed.Vite users see no change. Vite compiles TypeScript and JSX to JavaScript before ecij runs, and passes
moduleType: 'js'along with that code, both in builds and in the dev server. A Vite build of react-data-grid'ssrcis byte-for-byte identical to main's, source maps included. The fix is for Rolldown and tsdown users with custommoduleTypes.This is ported from #68, which passes
meta.moduleTypeto the parser the same way.The uncovered lines are unchanged. The fallback for a module type that isn't a language, like
json, is the one new branch the tests don't reach.🤖 Generated with Claude Code