Repository navigation
Keep ecij's modules out of Vitest's file system module cache - #122
Merged
Merged
Conversation
Vitest 5 reuses cached transforms across runs without calling transform, which registers the stylesheets, so a rerun failed to resolve them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Drop the fallback to Vitest 4.1's experimental_defineCacheKeyGenerator. Co-Authored-By: Claude Opus 5.5 <[email protected]>
configureVitest calls defineCacheKeyGenerator, which Vitest 4.1 lacks, so package managers now reject ecij there instead of Vitest failing at startup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adding vitest/config to the types of tsconfig.src.json loads its augmentation of Vite's Plugin interface, so the plugin picks both of its Vite hooks from that one type. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The helper no longer assigns the disposer to the Vitest instance. 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.
Vitest 5 turns on
fsModuleCacheby default. It stores transformed modules on disk and reuses them in later runs without callingtransform, which is where ecij registers the stylesheet of each module. On the second run, a module that usescssimports a stylesheet that nothing registered, and its tests fail:react-data-grid had to turn
fsModuleCacheoff because of this. Vitest 5.1.0 fails the same way, as the cache works as documented: it keys a module on its own content, ID, and environment config, and plugins whose output depends on more should opt out with a cache key generator. ecij's output depends on more: the stylesheets live in the plugin's memory, and the CSS can interpolate values imported from other modules.configureVitestdefines a cache key generator that keeps every module referencingecijout of the cache, like thecodefilter oftransform. Other modules stay cached. It doesn't applyincludeandexclude, because their glob strings would need a matcher the plugin doesn't have, so an excluded module that mentionsecijisn't cached either.Plugintype, whichvitest/configextends withconfigureVitestoncetsconfig.src.jsonlists it intypes.dist/index.d.tsreferences neither Vite nor Vitest.vitestis an optional peer dependency (^5.0.0), as Vitest 4.1 has nodefineCacheKeyGenerator. npm now rejects ecij in a Vitest 4.1 project (ERESOLVE), where Vitest would otherwise fail at startup withTypeError: defineCacheKeyGenerator is not a function. The README says ecij requires Vitest 5 or later. The Vite Plugin Registry does not track Vitest, so the plugin card doesn't change.editsfixtures twice, each time with a new Vitest instance and plugin, like a new process. Without the hook, the second run fails with the error above.AGENTS.mdsays why the hook and the peer dependency exist.In a clone of react-data-grid's main with
fsModuleCache: falseremoved and this branch packed,vpr cipasses,lib/is identical to the build with the published 0.6.0, andvp test ssr.testpasses twice in a row. With the published 0.6.0, its second run fails withCannot find module '/src/utils/renderMeasuringCells.tsx.3c530dba.css'.🤖 Generated with Claude Code