Skip to content

Commit 7eb919e

Browse files
authored
chore: swtich to rolldown bundling (experimental) (#2067)
* chore: swtich to rolldown bundling * fix * fix: rolldown errors * fix: wrong exporting * fix: output dist files * fix: generate stub file * fix: add type definition generating script with oxc-transform * chore: drop unnecesary scripts * fix: isolatedDeclaration build errors for oxc * fix: export lite module for petite-vue-i18n * fix: update stubs * fix: update from rollup config * fix: vue-i18n type generation * chore: ignore format and lint * fix: refactor codes * fix: bundle dts files * chore: add ci for rolldown build * fix: dts scripts * fix: update deps * chore: disable e2e for rolldown * chore: refactor rollup building
1 parent b2ab7fd commit 7eb919e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2370
-788
lines changed

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,41 @@ jobs:
7878
path: packages/*/dist
7979
key: build-vue-i18n-os-${{ matrix.os }}-${{ github.sha }}
8080

81+
build-rolldown:
82+
name: Build with rolldown
83+
strategy:
84+
matrix:
85+
os: [ubuntu-latest, windows-latest, macos-latest]
86+
node: [18]
87+
88+
runs-on: ${{ matrix.os }}
89+
90+
steps:
91+
- name: Checkout codes
92+
uses: actions/checkout@v4
93+
94+
- name: Enable corepack
95+
run: corepack enable
96+
97+
- name: Setup node
98+
uses: actions/setup-node@v4
99+
with:
100+
node-version: ${{ matrix.node }}
101+
cache: 'pnpm'
102+
103+
- name: Install dependencies
104+
run: pnpm install --no-frozen-lockfile
105+
106+
- name: Build codes
107+
run: |
108+
pnpm build:rolldown --withTypes
109+
110+
- name: Cache dist
111+
uses: actions/cache@v4
112+
with:
113+
path: packages/*/dist
114+
key: build-rolldown-vue-i18n-os-${{ matrix.os }}-${{ github.sha }}
115+
81116
test-unit:
82117
name: Unit test
83118
strategy:
@@ -147,3 +182,44 @@ jobs:
147182

148183
- name: Run e2e tests
149184
run: pnpm test:e2e
185+
186+
# test-e2e-rolldown:
187+
# name: E2E test for rolldown build
188+
189+
# needs:
190+
# - build-rolldown
191+
192+
# strategy:
193+
# matrix:
194+
# os: [ubuntu-latest, windows-latest, macos-latest]
195+
# node: [18.19, 20, 22]
196+
197+
# runs-on: ${{ matrix.os }}
198+
199+
# steps:
200+
# - name: Checkout codes
201+
# uses: actions/checkout@v4
202+
203+
# - name: Enable corepack
204+
# run: corepack enable
205+
206+
# - name: Setup node
207+
# uses: actions/setup-node@v4
208+
# with:
209+
# node-version: ${{ matrix.node }}
210+
# cache: 'pnpm'
211+
212+
# - name: Install dependencies
213+
# run: pnpm install --no-frozen-lockfile
214+
215+
# - name: Install Playwright
216+
# run: pnpm playwright-core install chromium
217+
218+
# - name: Restore dist cache
219+
# uses: actions/cache@v4
220+
# with:
221+
# path: packages/*/dist
222+
# key: build-rolldown-vue-i18n-os-${{ matrix.os }}-${{ github.sha }}
223+
224+
# - name: Run e2e tests
225+
# run: pnpm test:e2e

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ docs
44
coverage
55
tsconfig.json
66
api-extractor.json
7-
README.md
7+
README.md
8+
temp

api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@
303303
*
304304
* DEFAULT VALUE: "warning"
305305
*/
306-
"logLevel": "warning",
306+
"logLevel": "none", /* FIXME: Change to "warning" */
307307

308308
/**
309309
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ export default [
9393
'**/test/**',
9494
'**/examples/**',
9595
'shim.d.ts',
96+
'temp/**',
9697
'.eslintcache',
9798
'.eslintrc.cjs',
99+
'packages/*/vite.config.ts',
98100
'packages/*/index.js',
101+
'packages/vue-i18n-core/petite.js',
99102
'docsgen.config.js',
100103
'scripts/api/*.js'
101104
]

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"bench:simple-jit-aot": "node --expose-gc ./benchmark/simple-jit-aot.mjs",
2525
"build": "tsx ./scripts/build.ts",
2626
"build:explorer": "pnpm --filter @intlify/message-format-explorer build",
27+
"build:rolldown": "tsx ./scripts/build-rolldown.ts",
2728
"build:size": "pnpm build && run-p build:size-*",
2829
"build:size-core": "pnpm --filter @intlify/size-check-core build",
2930
"build:size-petite-vue-i18n": "pnpm --filter @intlify/size-check-petite-vue-i18n build",
@@ -84,16 +85,18 @@
8485
"@eslint/js": "^9.9.1",
8586
"@intlify/core-base": "workspace:*",
8687
"@intlify/message-compiler": "workspace:*",
88+
"@intlify/vue-i18n-core": "workspace:*",
8789
"@microsoft/api-extractor": "7.15.2",
90+
"@rolldown/plugin-node-polyfills": "^1.0.0",
8891
"@rollup/plugin-commonjs": "^25.0.0",
8992
"@rollup/plugin-json": "^6.0.0",
9093
"@rollup/plugin-node-resolve": "^15.0.2",
9194
"@rollup/plugin-replace": "^5.0.2",
9295
"@rollup/plugin-terser": "^0.4.3",
9396
"@secretlint/secretlint-rule-preset-recommend": "^3.1.0",
97+
"@swc/core": "^1.10.4",
9498
"@textlint-rule/textlint-rule-no-unmatched-pair": "^2.0.0",
9599
"@types/eslint": "^9.6.1",
96-
"@types/js-yaml": "^4.0.5",
97100
"@types/jsdom": "^21.1.1",
98101
"@types/node": "^22.10.3",
99102
"@types/rc": "^1.2.4",
@@ -106,25 +109,28 @@
106109
"eslint-config-prettier": "^9.1.0",
107110
"eslint-plugin-vue": "^9.28.0",
108111
"execa": "^9.3.0",
112+
"fast-glob": "^3.3.3",
109113
"fixpack": "^4.0.0",
110114
"get-port-please": "^3.1.2",
111115
"globals": "^15.9.0",
112-
"globby": "^14.0.1",
113-
"js-yaml": "^4.1.0",
114116
"jsdom": "^24.0.0",
115117
"lint-staged": "^15.2.2",
116118
"listhen": "^1.7.2",
119+
"magic-string": "^0.30.17",
117120
"markdown-table": "^3.0.4",
118121
"mitata": "^1.0.20",
119122
"npm-run-all2": "^7.0.0",
120123
"opener": "^1.5.2",
121-
"pathe": "^1.1.2",
124+
"oxc-parser": "^0.44.0",
125+
"oxc-transform": "^0.44.0",
122126
"picocolors": "^1.0.0",
123127
"pkg-pr-new": "^0.0.37",
124128
"playwright-core": "^1.45.3",
125129
"prettier": "^3.3.3",
126130
"rc": "^1.2.8",
131+
"rolldown": "1.0.0-beta.1",
127132
"rollup": "^4.21.2",
133+
"rollup-plugin-dts": "^6.1.1",
128134
"rollup-plugin-node-builtins": "^2.1.2",
129135
"rollup-plugin-node-globals": "^1.4.0",
130136
"rollup-plugin-typescript2": "^0.36.0",
@@ -150,7 +156,7 @@
150156
"trash-cli": "^6.0.0",
151157
"tslib": "^2.6.2",
152158
"tsx": "^4.11.2",
153-
"typescript": "^5.5.3",
159+
"typescript": "^5.6.3",
154160
"typescript-eslint": "^8.4.0",
155161
"vitepress": "1.5.0",
156162
"vitest": "^2.1.5",

packages/core-base/src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ export interface CoreInternalContext {
333333
* Intlify core-base version
334334
* @internal
335335
*/
336-
export const VERSION = __VERSION__
336+
export const VERSION: string = __VERSION__
337337

338338
export const NOT_REOSLVED = -1
339339

packages/core-base/src/datetime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export function datetime<
295295
}
296296

297297
/** @internal */
298-
export const DATETIME_FORMAT_OPTIONS_KEYS = [
298+
export const DATETIME_FORMAT_OPTIONS_KEYS: string[] = [
299299
'localeMatcher',
300300
'weekday',
301301
'era',

packages/core-base/src/devtools.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ export function initI18nDevTools(
3030
})
3131
}
3232

33-
export const translateDevTools =
33+
export const translateDevTools: ReturnType<typeof createDevToolsHook> =
3434
/* #__PURE__*/ createDevToolsHook('function:translate')
3535

36-
function createDevToolsHook(hook: IntlifyDevToolsHooks) {
36+
function createDevToolsHook(
37+
hook: IntlifyDevToolsHooks
38+
): (
39+
payloads: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks]
40+
) => void | null {
3741
return (payloads: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks]) =>
3842
devtools && devtools.emit(hook, payloads)
3943
}

packages/core-base/src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { BaseError } from '@intlify/shared'
88
export interface CoreError extends BaseError {}
99

1010
export const CoreErrorCodes = {
11-
INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT, // 17
11+
INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT as number, // 17
1212
INVALID_DATE_ARGUMENT: 18,
1313
INVALID_ISO_DATE_ARGUMENT: 19,
1414
NOT_SUPPORT_NON_STRING_MESSAGE: 20,

packages/core-base/src/fallbacker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function getLocale<Messages, Message>(
3535
let _resolveLocale: string
3636

3737
/** @internal */
38-
export function resolveLocale(locale: Locale | LocaleDetector) {
38+
export function resolveLocale(locale: Locale | LocaleDetector): string {
3939
if (isString(locale)) {
4040
return locale
4141
} else {

0 commit comments

Comments
 (0)