Repository navigation
Update the CSS of modules that depend on edited modules in the Vite dev server - #104
Merged
Merged
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-stale-css
branch
from
October 16, 2026 01:21
af5bac5 to
fc2922e
Compare
…ev server - `watchChange` forgets the parse of an edited module, which the dev server kept until it closed: editing a module that ecij does not transform, like a tokens file, left the CSS of its importers unchanged. It also forgets the stylesheet IDs that change with it, so that the modules transformed again first do not import previous stylesheets. - Vite reuses the transforms of the modules that statically import an edited module, only updating their imports. The new `hotUpdate` hook adds the modules whose CSS interpolates its values to the update, along with the modules that interpolate their class names, which import their stylesheets. - The new dev server test edits copies of its fixtures in a temporary directory and emits the changes itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
nstepien
changed the base branch from
fix-dev-stylesheet-dependencies
to
main
October 16, 2026 14:21
nstepien
force-pushed
the
fix-dev-stale-css
branch
from
October 16, 2026 14:21
07dab69 to
a6c31cb
Compare
3 tasks done
A generator yields each dependent and then its dependents, as the no-map-spread lint rule rejects spreading them into an array in flatMap. Iterator helpers and Set methods need Node 22. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 189918c. The loops read better until Iterator.concat can join each dependent with its dependents. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test now edits copies of its fixtures created next to them with mkdtempDisposable, where ecij resolves to this package without an alias, and lets the server's file watcher pick up the edits. The dev server helper returns a disposable server instead of taking a callback, and the test polls with expect.poll instead of vi.waitFor. Each edit is its own case, starting from card.ts importing the stylesheet of button.ts, so that polling for card.ts to stop importing it waits for the edit. In a single sequence, card.ts no longer imports any stylesheet of button.ts after the first edit, so the poll for the second edit passed before the server picked it up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AGENTS.md keeps the decision not to work around the dev server's stylesheet order, without its history. Co-Authored-By: Claude Opus 5.5 <[email protected]>
They also import its stylesheet, whose ID changes with its CSS, like card.ts when button.ts is edited. The comment only said that their own CSS may change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nstepien
added a commit
that referenced
this pull request
Oct 17, 2026
main took in the first slice of this PR (#79) and solved several of its other problems differently since August, so the merge ports the rest of this branch onto main's design instead of keeping both: - Values, class names included, come from the parse of each module, and const initializers resolve lazily (#79). Re-exports, `export *`, default and namespace imports, and `export default` resolve through the same evaluator, with ESM precedence and ambiguity. - Cycles are handled by main's pendingLoads and isWaitingFor (#102), so the wait graph, the deferred same-file passes, and the import-last ordering are gone, along with the guard against inlining the class names of skipped templates, which needed the imported modules' transforms. - Class names are IIFEs (#87, #98), so `moduleSideEffects: true` is gone. - Vite's dev server keeps main's behavior (#104) and does not transform imported modules through transformRequest. There, the code of modules that no file holds comes from their `load` hooks. - UNREADABLE_MODULE and UNPARSEABLE_MODULE are gone: a module whose code cannot be read exports nothing, and modules are parsed as the language Rolldown assigned them. - Kept: raw TypeScript bindings, `meta.moduleType` parsing, prologue-safe imports, query-variant module identity, skipping external modules, and resolving each import once per transform. Tests: main's suite, plus this branch's tests of the kept features, with new cases for the paths that no fixture reached. The tests of the removed behavior, and the cycle test that main already has, are dropped. basic.input.ts is restored for main's inlineConst tests, and this branch's barrel.ts is now barrel-index.ts. 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.
The dev server only calls
buildEndwhen 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:css, like a tokens file. Importers transformed again kept its old values.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:
buildEndclears the caches after each build, including in watch mode.Changes
transformrecords the modules that interpolate each module's values independentsPerFile.watchChangeforgets 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.hotUpdatehook 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'sPlugintype, and Rolldown ignores the hook.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
card.tsinterpolates a class name ofbutton.ts, which interpolates a color fromtokens.ts. Each test requests them before their importers, editstokens.tsorbutton.ts, and lets the server's file watcher pick up the edit.card.tsis then requested first and must no longer import the previous stylesheet ofbutton.ts, whose new stylesheet must have the new CSS.ecijresolves without an alias, and.gitignorecovers copies left behind by an interrupted run.Test plan
node --run format:check,lint,typecheck,buildnode --run test: 18/18 against the source and against the builtdist(CI=true)hotUpdatehook, when it only adds the direct dependents, and without each deletion inwatchChangeor the dependency recording🤖 Generated with Claude Code