fix: "Cannot read properties of undefined (reading 'get')" in ModuleLoader triggered by CSS import #19577
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.
Description
We are using Vite's
loadConfigFromFile
(runner mode) to load a TS file. We are aware that this is not 100% as intended, but it works fine and we do it at our own risk.This TS file also loads a CSS file, which breaks the runner mode. A simple change, which I think makes sense anyway, fixes the problem.
To reproduce I created this StackBlitz: https://stackblitz.com/edit/vitejs-vite-yl98c3fh?file=package.json
You can
pnpm load-with-css
to see the problem:I understand that you probably don't want to support the use case we have here and that it may break in the future, but I think the resulting fix still makes sense without all this context.