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

Diff for: .github/workflows/ci.yml

+76
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

Diff for: .prettierignore

+2-1
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

Diff for: api-extractor.json

+1-1
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),

Diff for: eslint.config.mjs

+3
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
]

Diff for: package.json

+11-5
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",

Diff for: packages/core-base/src/context.ts

+1-1
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

Diff for: packages/core-base/src/datetime.ts

+1-1
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',

Diff for: packages/core-base/src/devtools.ts

+6-2
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
}

Diff for: packages/core-base/src/errors.ts

+1-1
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,

Diff for: packages/core-base/src/fallbacker.ts

+1-1
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 {

Diff for: packages/core-base/src/format.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function formatMessagePart<Message = string>(
163163

164164
const PROPS_TYPE = ['t', 'type']
165165

166-
export function resolveType(node: Node) {
166+
export function resolveType(node: Node): ReturnType<typeof resolveProps> {
167167
return resolveProps<NodeTypes>(node, PROPS_TYPE)
168168
}
169169

Diff for: packages/core-base/src/index.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import { initFeatureFlags } from './misc'
22

3-
export {
3+
export { createCompileError } from '@intlify/message-compiler'
4+
export type {
45
CompileError,
56
CompileErrorCodes,
6-
createCompileError,
77
ResourceNode
88
} from '@intlify/message-compiler'
99
export * from './compilation'
1010
export * from './context'
1111
export * from './datetime'
1212
export * from './devtools'
13-
export {
14-
CORE_ERROR_CODES_EXTEND_POINT,
15-
CoreError,
16-
CoreErrorCodes,
17-
createCoreError
18-
} from './errors'
13+
export { CORE_ERROR_CODES_EXTEND_POINT, createCoreError } from './errors'
14+
export type { CoreError, CoreErrorCodes } from './errors'
1915
export * from './fallbacker'
2016
export * from './number'
2117
export * from './resolver'

Diff for: packages/core-base/src/number.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export function number<
290290
}
291291

292292
/** @internal */
293-
export const NUMBER_FORMAT_OPTIONS_KEYS = [
293+
export const NUMBER_FORMAT_OPTIONS_KEYS: string[] = [
294294
'localeMatcher',
295295
'style',
296296
'currency',

Diff for: packages/core-base/src/warnings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const CoreWarnCodes = {
1010
EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: 7
1111
} as const
1212

13-
export const CORE_WARN_CODES_EXTEND_POINT = 8
13+
export const CORE_WARN_CODES_EXTEND_POINT: number = 8
1414

1515
export type CoreWarnCodes = (typeof CoreWarnCodes)[keyof typeof CoreWarnCodes]
1616

Diff for: packages/format-explorer/src/theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,4 @@ export default {
241241
'editorCursor.foreground': '#AEAFAD',
242242
'editorWhitespace.foreground': '#4B4E55'
243243
}
244-
}
244+
} as const

Diff for: packages/message-compiler/src/errors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const CompileErrorCodes = {
4848
// Special value for higher-order compilers to pick up the last code
4949
// to avoid collision of error codes.
5050
// This should always be kept as the last item.
51-
export const COMPILE_ERROR_CODES_EXTEND_POINT = 17
51+
export const COMPILE_ERROR_CODES_EXTEND_POINT: number = 17
5252

5353
export type CompileErrorCodes =
5454
(typeof CompileErrorCodes)[keyof typeof CompileErrorCodes]

Diff for: packages/message-compiler/src/mangler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ERROR_DOMAIN = 'minifier'
1919

2020
/* eslint-disable @typescript-eslint/no-explicit-any */
2121

22-
export function mangle(node: Node) {
22+
export function mangle(node: Node): void {
2323
node.t = node.type
2424

2525
switch (node.type) {

Diff for: packages/message-compiler/src/scanner.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export interface Scanner {
1616
export const CHAR_SP = ' '
1717
export const CHAR_CR = '\r'
1818
export const CHAR_LF = '\n'
19-
export const CHAR_LS = String.fromCharCode(0x2028)
20-
export const CHAR_PS = String.fromCharCode(0x2029)
19+
export const CHAR_LS: ReturnType<typeof String.fromCharCode> =
20+
String.fromCharCode(0x2028)
21+
export const CHAR_PS: ReturnType<typeof String.fromCharCode> =
22+
String.fromCharCode(0x2029)
2123

2224
export function createScanner(str: string): Scanner {
2325
const _buf = str

Diff for: packages/petite-vue-i18n/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"dependencies": {
3838
"@intlify/core-base": "workspace:*",
3939
"@intlify/shared": "workspace:*",
40+
"@intlify/vue-i18n-core": "workspace:*",
4041
"@vue/devtools-api": "^6.5.0"
4142
},
4243
"devDependencies": {

0 commit comments

Comments
 (0)