Repository navigation
Conversation
…gram Under vite dev, a <style> edit in a non-entry module never reached the page, because the program's whole stylesheet came only on the entry and the plugin recompiles CSS per file. Under Vitest's fsModuleCache, a cached entry left builds empty, so the next changed dependency threw "no program built so far contains it".
This branch has not been deployed
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.
Two dev-time bugs in the Vite front end (
compiler/vite.mjs), both found while building a ReactiveScript template on@solidjs/vite-plugin3.0.0-next.57, Vite 8.3.8 and Vitest 5.1.vite dev, editing a<style>block in a non-entry.rxmodule never reaches the page: not on the hot update, not after a reload, not in a new tab. Only a server restart shows the new CSS. Production builds are correct.fsModuleCacheon (the default in Vitest 5), the firstvitest runafter editing a non-entry.rxfile fails with…/Guestbook.rx is imported as an .rx dependency, but no program built so far contains it.Root cause
The front end returned the whole program's stylesheet only from the entry's
compile(css: !dep && file === entry ? out.css : ""). The plugin'shotUpdaterecompiles CSS only for the file that changed, by its plain path with no?rx-dep. So the front end built the changed dependency as an entry of its own, and the stylesheet the page actually loads (App.rx?solid-tsrx-css) was never refreshed.Vitest keys each cached transform on that module's id and source alone. When it serves the entry from the cache,
compilenever runs for the entry, sobuildsis empty, and the next dependency request that misses the cache has no program to come from.What changed
compile_linkedrecords each module's own share of the stylesheet (Compiled::module_css), andapp()returns it asmodules[path].css. The program-widecssthatrxc compilewrites is unchanged.compilereturnsm.cssfor every module, entry or dependency. Solid's plugin then gives each.rxmodule its own CSS module, as it does for.tsrx, so a style edit hot-updates. A module shared by two programs now links its stylesheet once instead of once per program.?rx-deprequest finds no program in memory,containing()scans the.rxfiles under the plugin'srootfor line-startimport … from "./x.rx"statements. It then builds the files that reach the module through imports (top-level files first) and uses the first program that holds it. If those programs hold it but don't compile, it reports their diagnostics instead of the "no program" error. The scan runs only on that miss.Carrying the entry in the dependency id (
?rx-dep&entry=…) was the other option. It would give a module shared by two programs two ids and two instances, which breaks the one-module rule that thesharedtest checks.Verification
With
SOLID_VITE_PLUGINset to an installed@solidjs/vite-plugin3.0.0-next.57:node compiler/test/vite.mjs: 16 pass, 0 fail. Two new blocks:styles (dev): a dependency's<style>color, checked after the edit, after a reload and in a new page. It fails onmain(after the edit: color rgb(0, 0, 0)).cold dependency: a fresh front end compilesshop/catalog.rx?rx-depwith no entry compiled first, with a commented-out import that would otherwise look like a cycle. The code must match a warm compile, and a broken dependency must report its diagnostics. It fails onmainwith the "no program built so far" error.node compiler/test/node.mjsandcargo test --releasepass.Counter.rxstyle edit shows the new color after the edit, after a reload and in a new tab. Before, the color stayed black in all three.fsModuleCacheon,vitest run, then an edit toGuestbook.rx, thenvitest runpasses both runs. Before, the second run failed.The two existing dev blocks now open
server.resolvedUrls.local[0]. The hard-coded127.0.0.1failed on macOS, where Vite listens onlocalhost(::1).Left open
set.order..rx. Usage is tracked by bare name across the program, so one module's edit can change another module's compiled code: addingguess products := []inshop/ui.rxchangescatalog.rx's output. A cachedcatalog.rxcan then be stale. The front end can't add to Vitest's cache key. That needs@solidjs/vite-pluginto register adefineCacheKeyGeneratorfromconfigureVitestwith a program-wide key for.rxmodules. Until then,fsModuleCache: falsestays the safe setting for.rxprojects.root, so an entry outside it (a monorepo package) is not found.🤖 Generated with Claude Code