Skip to content

Commit

Permalink
fix(vite): issue with dev mode and deoptimized deps (fixes #1246) (#1358
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Anber committed Sep 27, 2023
1 parent f0254d9 commit 2350972
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-baboons-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@linaria/vite': patch
---

Fix an issue with deoptimized deps and dev mode. Fixes #1246
6 changes: 6 additions & 0 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
* returns transformed code without template literals and attaches generated source maps
*/

import { existsSync } from 'fs';
import path from 'path';

import { createFilter } from '@rollup/pluginutils';
import type { FilterPattern } from '@rollup/pluginutils';
import type { ModuleNode, Plugin, ResolvedConfig, ViteDevServer } from 'vite';
import { optimizeDeps } from 'vite';

import {
transform,
Expand Down Expand Up @@ -131,6 +133,10 @@ export default function linaria({
return null;
}

if (!existsSync(resolvedId)) {
await optimizeDeps(config);
}

return resolvedId;
}

Expand Down

0 comments on commit 2350972

Please sign in to comment.