Skip to content

Commit b528c3b

Browse files
authored
feat: vitest deps.experimentalOptimizer (#170)
1 parent ec3032a commit b528c3b

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

packages/plugin-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# Changelog
2+
13
## Unreleased
24

5+
- Support [Vitest deps.experimentalOptimizer](https://vitest.dev/config/#deps-experimentaloptimizer)
6+
37
## 4.0.0 (2023-04-20)
48

59
This major version include a revamp of options:

packages/plugin-react/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
125125
devBase = config.base
126126
projectRoot = config.root
127127
isProduction = config.isProduction
128-
skipFastRefresh = isProduction || config.command === 'build'
128+
skipFastRefresh =
129+
isProduction ||
130+
config.command === 'build' ||
131+
(!!process.env.TEST && !process.env.VITE_TEST_HMR)
129132

130133
if ('jsxPure' in opts) {
131134
config.logger.warnOnce(

playground/vitestGlobalSetup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const DIR = path.join(os.tmpdir(), 'vitest_playwright_global_setup')
99
let browserServer: BrowserServer | undefined
1010

1111
export async function setup(): Promise<void> {
12+
process.env.VITE_TEST_HMR = 'true' // To force HMR transformation in test environment
1213
process.env.NODE_ENV = process.env.VITE_TEST_BUILD
1314
? 'production'
1415
: 'development'

0 commit comments

Comments
 (0)