Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nstepien
force-pushed
the
fix-dev-stylesheet-dependencies
branch
from
October 15, 2026 17:15
9e4f41d to
b08a6fb
Compare
nstepien
changed the base branch from
plugin-audit-follow-ups
to
fix-cyclic-interpolation-hang
October 15, 2026 17:15
3 tasks done
nstepien
force-pushed
the
fix-dev-stylesheet-dependencies
branch
from
October 15, 2026 17:40
b08a6fb to
ba578b6
Compare
nstepien
force-pushed
the
fix-cyclic-interpolation-hang
branch
from
October 15, 2026 17:40
f4740c2 to
3cdc545
Compare
4 tasks done
nstepien
added a commit
that referenced
this pull request
Oct 16, 2026
To resolve a class name imported from another module, a module's transform waits for `this.load()` of that module, which runs that module's transform. When two modules interpolate each other's class names, each transform waited for the other to finish, and the build never completed. ## Changes - Track which module each running transform is waiting for (`pendingLoads`), and skip loading a module whose transform is already waiting for the current one, directly or through other transforms (`isWaitingFor`). That module's transform parsed it before resolving anything, so its exported values come from the cache. - Only loads that would close a cycle are skipped. Transforms that run concurrently without waiting for each other still wait for the loads they need, so they register their stylesheets as before. - Within a cycle, the module whose load was skipped has not registered its stylesheet yet, so its importer cannot import that stylesheet ahead of its own. Every rule is still emitted, in the order the other module imports them. #100, stacked on top, extracts the skipped module's stylesheet on demand. ## Tests - New fixtures `cycle-a.ts` and `cycle-b.ts`, whose CSS interpolates each other's class names. A Vite build of them timed out before this change and now completes with both rules. - A three-module cycle (A → B → C → A) also builds, with all three rules when the package is not `sideEffects: false`. - All existing snapshots pass, including the cross-module interpolations. ## Test plan - [x] `node --run format:check`, `lint`, `typecheck`, `build` - [x] `node --run test`: 16/16 against the source and against the built `dist` (`CI=true`) - [x] The new test times out without the fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
When a module's CSS interpolates a class name imported from another module, that module's stylesheet is imported first to keep the cascade order. The plugin relied on `this.load()` to transform the imported module and register its stylesheet, but Vite's dev server only runs transform hooks there when a plugin's `load` hook returned the code. The first transform of an importer then lacked the import, injecting its CSS before the CSS it references. When the imported module has not been transformed yet, which also happens in builds when its load is skipped to avoid a cycle, extract its stylesheet from source under the same content-hash ID its own transform registers later. That on-demand extraction only resolves values: it loads no modules, collects no stylesheets, and leaves warnings to the module's own transform, so it can neither recurse nor wait for the transform it runs in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nstepien
force-pushed
the
fix-dev-stylesheet-dependencies
branch
from
October 16, 2026 01:21
96b2f88 to
c7012f4
Compare
#102 changed the CSS of the cycle fixtures, and with it their stylesheet IDs. Merging its branch into this one updated this snapshot, but GitHub restacked this branch onto the squash-merged #102 by replaying only its own commit, which dropped that merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nstepien
added a commit
that referenced
this pull request
Oct 16, 2026
The comments suggested that the load populates the parse cache, which made `pendingLoads` look unnecessary. The values come from the parse either way: the load waits for the imported module's transform to register its stylesheet. Also document that Vite's dev server does not transform modules loaded this way, and why #100's workaround was dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
Closing: the dev server order this restores only decides specificity ties, the README doesn't promise it, and Vite's dev server doesn't transform modules loaded through |
nstepien
added a commit
that referenced
this pull request
Oct 16, 2026
…ev server (#104) The dev server only calls `buildEnd` when it closes, so the plugin's caches outlive edits. Editing a module whose values or class names another module's CSS interpolates could leave that CSS stale until the server restarted: - The cached parse of the edited module was reused until ecij transformed that module again, which never happens for a module without `css`, like a tokens file. Importers transformed again kept its old values. - Importers transformed again before the edited module still imported its previous stylesheet, which kept its previous CSS on the page. - Vite reuses the transforms of the modules that statically import an edited module, only updating their imports. This did not happen when the module was first loaded through ecij's `this.load()`, which registers it under its file path rather than its URL, but it did when the app requested the module before its importers, for example by also importing it elsewhere. Their CSS was then not extracted again at all. Builds are not affected: `buildEnd` clears the caches after each build, including in watch mode. ## Changes - `transform` records the modules that interpolate each module's values in `dependentsPerFile`. - `watchChange` forgets the parse of the edited module and the stylesheet IDs that change with it: its own, and those of the modules that interpolate its values. Modules transformed again before these no longer import their previous stylesheets. The extracted CSS stays, as cached transforms may still import it. - The Vite-only `hotUpdate` hook adds the modules that interpolate the edited module's values to the update, as if they were edited, and the modules that interpolate their class names, as they import their stylesheets. The declarations keep Rolldown's `Plugin` type, and Rolldown ignores the hook. - From #100, which was closed: the comment at the `this.load()` call and AGENTS.md now say that the load waits for the imported module to register its stylesheet, as the values come from its parse either way, and that Vite's dev server does not transform modules loaded this way, which is not worth working around. ## Tests - New dev server tests edit copies of new fixtures, created next to them: `card.ts` interpolates a class name of `button.ts`, which interpolates a color from `tokens.ts`. Each test requests them before their importers, edits `tokens.ts` or `button.ts`, and lets the server's file watcher pick up the edit. `card.ts` is then requested first and must no longer import the previous stylesheet of `button.ts`, whose new stylesheet must have the new CSS. - The dev server helper, from #100, returns a disposable server. As the copies are inside this package, `ecij` resolves without an alias, and `.gitignore` covers copies left behind by an interrupted run. ## Test plan - [x] `node --run format:check`, `lint`, `typecheck`, `build` - [x] `node --run test`: 18/18 against the source and against the built `dist` (`CI=true`) - [x] The new tests fail without the `hotUpdate` hook, when it only adds the direct dependents, and without each deletion in `watchChange` or the dependency recording - [x] The dev server tests passed 30 runs in a row on Windows, and 18 more with six suites running at once 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- 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.
When a module's CSS interpolates a class name imported from another module, the plugin imports that module's stylesheet first, so the referenced CSS comes before the CSS that uses it. It relied on
this.load()running the imported module's transform hook, which registers that stylesheet. Vite's dev server only does so when a plugin'sloadhook returned the module's code, which is never the case for files on disk. So the first transform of an importer lacked the import, and its CSS was injected before the CSS it references. Builds were not affected.Changes
extractStylesheetextracts its stylesheet from source and registers it under the same content-hash ID that the module's own transform registers later, so both point at the same virtual stylesheet. This also covers builds where Stop builds from hanging on mutually interpolated class names #102 skips a load to break a cycle.registerStylesheet, keyed by the module ID without its query, which is whatresolveValuelooks up.Tests
imported-style.tsbefore its own, and that stylesheet is served before its module is requested. The fixtures from Stop builds from hanging on mutually interpolated class names #102, whose CSS interpolates each other's class names, import both stylesheets. Both tests fail without the fix.Test plan
node --run format:check,lint,typecheck,buildnode --run test: 18/18 against the source and against the builtdist(CI=true)🤖 Generated with Claude Code