This repository was archived by the owner on Mar 19, 2026. It is now read-only.
forked from vitejs/vite
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathhmrModuleRunner.ts
More file actions
63 lines (54 loc) · 1.6 KB
/
hmrModuleRunner.ts
File metadata and controls
63 lines (54 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { createHotContext } from './client'
declare const __FULL_BUNDLE_MODE__: boolean
if (__FULL_BUNDLE_MODE__) {
class DevRuntime {
modules: Record<string, { exports: any }> = {}
static getInstance() {
// @ts-expect-error __rolldown_runtime__
let instance = globalThis.__rolldown_runtime__
if (!instance) {
instance = new DevRuntime()
// @ts-expect-error __rolldown_runtime__
globalThis.__rolldown_runtime__ = instance
}
return instance
}
createModuleHotContext(moduleId: string) {
return createHotContext(moduleId)
}
applyUpdates(_boundaries: string[]) {
//
}
registerModule(
id: string,
module: { exports: Record<string, () => unknown> },
) {
this.modules[id] = module
}
loadExports(id: string) {
const module = this.modules[id]
if (module) {
return module.exports
} else {
console.warn(`Module ${id} not found`)
return {}
}
}
// __esmMin
// @ts-expect-error need to add typing
createEsmInitializer = (fn, res) => () => (fn && (res = fn((fn = 0))), res)
// __commonJSMin
// @ts-expect-error need to add typing
createCjsInitializer = (cb, mod) => () => (
mod || cb((mod = { exports: {} }).exports, mod), mod.exports
)
// @ts-expect-error it is exits
__toESM = __toESM
// @ts-expect-error it is exits
__toCommonJS = __toCommonJS
// @ts-expect-error it is exits
__export = __export
}
// @ts-expect-error __rolldown_runtime__
globalThis.__rolldown_runtime__ ||= new DevRuntime()
}