Skip to content

Commit 4a45254

Browse files
committed
fix: patch rolldown module runner changes
1 parent bbd745b commit 4a45254

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

packages/vite/src/client/hmrModuleRunner.ts

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,9 @@ if (__FULL_BUNDLE_MODE__) {
2525
//
2626
}
2727

28-
registerModule(
29-
id: string,
30-
esmExportGettersOrCjsExports: Record<string, unknown>,
31-
meta: { cjs?: boolean } = {},
32-
) {
33-
const exports = {}
34-
Object.keys(esmExportGettersOrCjsExports).forEach((key) => {
35-
if (
36-
Object.prototype.hasOwnProperty.call(
37-
esmExportGettersOrCjsExports,
38-
key,
39-
)
40-
) {
41-
if (meta.cjs) {
42-
Object.defineProperty(exports, key, {
43-
enumerable: true,
44-
get: () => esmExportGettersOrCjsExports[key],
45-
})
46-
} else {
47-
Object.defineProperty(exports, key, {
48-
enumerable: true,
49-
get: esmExportGettersOrCjsExports[key],
50-
})
51-
}
52-
}
53-
})
54-
if (this.modules[id]) {
55-
this.modules[id] = {
56-
exports,
57-
}
58-
} else {
59-
// If the module is not in the cache, we need to register it.
60-
this.modules[id] = {
61-
exports,
62-
}
28+
registerModule(id: string, exports: Record<string, () => unknown>) {
29+
this.modules[id] = {
30+
exports,
6331
}
6432
}
6533

@@ -81,6 +49,12 @@ if (__FULL_BUNDLE_MODE__) {
8149
createCjsInitializer = (cb, mod) => () => (
8250
mod || cb((mod = { exports: {} }).exports, mod), mod.exports
8351
)
52+
// @ts-expect-error it is exits
53+
__toESM = __toESM
54+
// @ts-expect-error it is exits
55+
__toCommonJS = __toCommonJS
56+
// @ts-expect-error it is exits
57+
__export = __export
8458
}
8559

8660
// @ts-expect-error __rolldown_runtime__

0 commit comments

Comments
 (0)