Skip to content

Commit 80becf4

Browse files
committed
wip: full bundle dev env
1 parent fe02144 commit 80becf4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/vite/src/node/server/environments/fullBundleEnvironment.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export class MemoryFiles {
6262

6363
export class FullBundleDevEnvironment extends DevEnvironment {
6464
private state: BundleState = { type: 'initial' }
65+
private invalidateCalledModules = new Set<string>()
6566

6667
watchFiles = new Set<string>()
6768
memoryFiles = new MemoryFiles()
@@ -160,6 +161,8 @@ export class FullBundleDevEnvironment extends DevEnvironment {
160161
patched: this.state.patched,
161162
}
162163
return
164+
} finally {
165+
this.invalidateCalledModules.clear()
163166
}
164167

165168
if (hmrOutput.every((output) => output.type === 'Noop')) {
@@ -189,13 +192,20 @@ export class FullBundleDevEnvironment extends DevEnvironment {
189192
firstInvalidatedBy: string
190193
}): void {
191194
;(async () => {
195+
if (this.invalidateCalledModules.has(m.path)) {
196+
debug?.(
197+
`${this.state.type.toUpperCase()}: invalidate received, but ignored because it was already invalidated`,
198+
)
199+
return
200+
}
201+
192202
if (
193203
this.state.type === 'initial' ||
194204
this.state.type === 'bundling' ||
195205
this.state.type === 'bundle-error'
196206
) {
197207
debug?.(
198-
`${this.state.type.toUpperCase()}: invalidate received, but ignored`,
208+
`${this.state.type.toUpperCase()}: invalidate received, but ignored because the state type has changed`,
199209
)
200210
return
201211
}
@@ -212,6 +222,7 @@ export class FullBundleDevEnvironment extends DevEnvironment {
212222
bundle: this.state.bundle,
213223
patched: this.state.patched,
214224
}
225+
this.invalidateCalledModules.add(m.path)
215226

216227
let hmrOutput: HmrOutput
217228
try {
@@ -430,7 +441,7 @@ export class FullBundleDevEnvironment extends DevEnvironment {
430441
path: boundary.boundary,
431442
acceptedPath: boundary.acceptedVia,
432443
firstInvalidatedBy,
433-
timestamp: 0,
444+
timestamp: Date.now(),
434445
}
435446
})
436447
this.hot.send({

0 commit comments

Comments
 (0)