Skip to content

Commit 54f21aa

Browse files
committed
wip: full bundle mode compat
1 parent 7517103 commit 54f21aa

File tree

5 files changed

+166
-154
lines changed

5 files changed

+166
-154
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
]
7272
},
7373
"pnpm": {
74+
"overrides": {
75+
"vitest>vite": "npm:vite@^6.2.6",
76+
"vite": "https://pkg.pr.new/vitejs/rolldown-vite@107"
77+
},
7478
"packageExtensions": {
7579
"generouted": {
7680
"peerDependencies": {

packages/common/refresh-runtime.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,9 @@ function predicateOnExport(ignoredExports, moduleExports, predicate) {
632632
for (const key in moduleExports) {
633633
if (key === '__esModule') continue
634634
if (ignoredExports.includes(key)) continue
635-
const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
636-
if (desc && desc.get) return key
635+
// TODO: Not sure why need this. The esm module live binding always is getter, look like the browser is not.
636+
// const desc = Object.getOwnPropertyDescriptor(moduleExports, key)
637+
// if (desc && desc.get) return key
637638
if (!predicate(key, moduleExports[key])) return key
638639
}
639640
return true

packages/common/refresh-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof
8181
newCode = `${sharedHead}${newCode}
8282
8383
if (import.meta.hot && !inWebWorker) {
84-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
84+
import.meta.hot.getExports().then((currentExports) => {
8585
RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(
8686
id,
8787
)}, currentExports);

packages/plugin-react/src/index.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
113113
| ((options: ReactBabelOptions, context: ReactBabelHookContext) => void)
114114
| undefined
115115
let staticBabelOptions: ReactBabelOptions | undefined
116-
116+
let base: string | undefined
117117
// Support patterns like:
118118
// - import * as React from 'react';
119119
// - import React from 'react';
@@ -155,6 +155,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
155155
}
156156
},
157157
configResolved(config) {
158+
base = config.base
158159
projectRoot = config.root
159160
isProduction = config.isProduction
160161
skipFastRefresh =
@@ -332,15 +333,22 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
332333
)
333334
}
334335
},
335-
transformIndexHtml(_, config) {
336-
if (!skipFastRefresh)
337-
return [
338-
{
339-
tag: 'script',
340-
attrs: { type: 'module' },
341-
children: getPreambleCode(config.server!.config.base),
342-
},
343-
]
336+
transformIndexHtml: {
337+
handler() {
338+
if (!skipFastRefresh)
339+
return [
340+
{
341+
tag: 'script',
342+
attrs: { type: 'module' },
343+
// !!! Rolldown vite full bunlde module break changes, config.server is invalid
344+
// children: getPreambleCode(config.server!.config.base),
345+
children: getPreambleCode(base!),
346+
},
347+
]
348+
},
349+
// Rolldown vite full bunlde module break changes.
350+
// Changed it to make sure the inject module could be bundled
351+
order: 'pre',
344352
},
345353
}
346354

0 commit comments

Comments
 (0)