-
-
Notifications
You must be signed in to change notification settings - Fork 9
feat: rolldown vite full bundle mode #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rolldown-vite
Are you sure you want to change the base?
Changes from all commits
0d4d6c0
25f3e0e
f183472
c57d182
2bbb201
cf9e3cc
6390882
804a636
809c553
2715861
bba3e73
0a5a51a
8a6293d
d47db7c
065e406
947ec1e
2cf5ff5
4452731
f3fe74d
c90d37b
f9c4c9f
01ed745
2e990e6
86e5869
0294228
0768736
8a0f40c
7aba832
3d991d9
0d4f34c
9278245
647fba4
3909c8b
9f4cdc5
23d8d36
cb6710f
5e9a7ca
cff15fb
7966b11
1aafd0d
d3feb62
e75f4e9
9b34da0
60b406e
c509336
b2493f2
10b6a47
532b4f0
c1d2a74
bbb1def
662fbb7
064c268
28ad636
c404332
6d4a115
4d51f1d
955a7ab
930092e
7976768
09e498e
bac444e
7ade2bc
eb361ca
467b118
bd44ee2
950428b
9c7f704
80f53db
acd2c41
f03bc47
bdb70a9
f7dc0b7
9f56cb8
01090e0
a28f815
bfb953f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,8 @@ | |
"format": "prettier --write --cache .", | ||
"lint": "eslint --cache .", | ||
"typecheck": "tsc -p scripts --noEmit && pnpm -r --parallel run typecheck", | ||
"test": "pnpm test-unit && pnpm test-serve && pnpm test-build", | ||
"test": "pnpm test-unit && pnpm test-serve && pnpm run test-full-bundle-mode && pnpm test-build", | ||
"test-full-bundle-mode": "VITE_TEST_FULL_BUNDLE_MODE=1 vitest run -c vitest.config.e2e.ts", | ||
"test-serve": "vitest run -c vitest.config.e2e.ts", | ||
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", | ||
"test-unit": "vitest run", | ||
|
@@ -98,6 +99,7 @@ | |
"packageManager": "[email protected]", | ||
"pnpm": { | ||
"overrides": { | ||
"vitest>vite": "npm:vite@^6.2.6", | ||
"vite": "workspace:rolldown-vite@*" | ||
}, | ||
"patchedDependencies": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,10 +75,7 @@ describe('transformCjsImport', () => { | |
), | ||
).toBe( | ||
'import __vite__cjsImport0_react from "./node_modules/.vite/deps/react.js"; ' + | ||
'const react = ((m) => m?.__esModule ? m : {\n' + | ||
'\t...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {},\n' + | ||
'\tdefault: m\n' + | ||
'})(__vite__cjsImport0_react)', | ||
'const react = ((m) => m?.__esModule ? m : { ...typeof m === "object" && !Array.isArray(m) || typeof m === "function" ? m : {}, default: m })(__vite__cjsImport0_react)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is wired for it coudle be success at rolldown-vite branch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably caused by the |
||
) | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, I think it's good to have the types exposed from rolldown so that we can use it like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.