Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: call createFileOnlyEntry() only for CSS deps, fix #4150 #4267

Merged
merged 12 commits into from Jul 20, 2021
12 changes: 11 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Expand Up @@ -191,9 +191,19 @@ export function cssPlugin(config: ResolvedConfig): Plugin {
if (deps) {
// record deps in the module graph so edits to @import css can trigger
// main import to hot update

paraboul marked this conversation as resolved.
Show resolved Hide resolved
const depModules = new Set(
[...deps].map((file) => moduleGraph.createFileOnlyEntry(file))
await Promise.all(
[...deps].map(async (file) =>
cssLangRE.test(file)
? moduleGraph.createFileOnlyEntry(file)
: moduleGraph.ensureEntryFromUrl(
await fileToUrl(file, config, this)
)
)
paraboul marked this conversation as resolved.
Show resolved Hide resolved
)
)

paraboul marked this conversation as resolved.
Show resolved Hide resolved
moduleGraph.updateModuleInfo(
thisModule,
depModules,
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/server/moduleGraph.ts
Expand Up @@ -179,6 +179,7 @@ export class ModuleGraph {

const mod = new ModuleNode(url)
mod.file = file

paraboul marked this conversation as resolved.
Show resolved Hide resolved
fileMappedModules.add(mod)
return mod
}
Expand Down