Skip to content

Commit ad4c216

Browse files
s00dcursoragent
andcommitted
fix(module): bridge unplugin Vite 8 Plugin types for Nuxt kit
Cast defineI18nRoute `.vite()` for addVitePlugin across Vite 7/8; widen catalog unplugin to 1||2||3. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4585976 commit ad4c216

14 files changed

Lines changed: 59 additions & 51 deletions

File tree

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ catalog:
9494
globby: ^14.1.0
9595
glob: ^11.0.1
9696
ufo: ^1.5.4
97-
unplugin: ^3.3.0
97+
unplugin: ^1.16.1 || ^2.0.0 || ^3.3.0
9898
serve: ^14.2.0
9999
wrangler: ^3.109.1
100100
vue-final-modal: ^4.5.5

scripts/src/perf/config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ export function buildProfile(locales: number, keys: number): PerfRuntimeProfile
5858
}
5959
}
6060

61-
export function resolvePerfArgs(input: {
62-
locales: string
63-
keys: string
64-
only: string
65-
runs: string
66-
skipStress: boolean
67-
}): ResolvedPerfArgs {
61+
export function resolvePerfArgs(input: { locales: string; keys: string; only: string; runs: string; skipStress: boolean }): ResolvedPerfArgs {
6862
const locales = Number(input.locales)
6963
const keys = Number(input.keys)
7064
const runs = Number(input.runs)

scripts/src/perf/progress.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ export function formatEta(seconds: number): string {
1212
return s > 0 ? `~${m}m ${s}s` : `~${m}m`
1313
}
1414

15-
export function estimateWallSeconds(opts: {
16-
runs: number
17-
fixtures: number
18-
skipStress: boolean
19-
}): number {
15+
export function estimateWallSeconds(opts: { runs: number; fixtures: number; skipStress: boolean }): number {
2016
const perFixture = BUILD_HINT_SECONDS + (opts.skipStress ? 0 : AUTOCANNON_SECONDS + ARTILLERY_SECONDS + COOLDOWN_SECONDS)
2117
return opts.runs * opts.fixtures * perFixture + 30 // generate + report
2218
}
@@ -42,7 +38,9 @@ export class PerfProgress {
4238
console.log(`\n── Performance plan ──`)
4339
console.log(` order: each fixture × ${opts.runs} consecutive run(s) (not interleaved)`)
4440
console.log(` fixtures: ${opts.labels.join(' → ')}`)
45-
console.log(` stress: ${opts.skipStress ? 'skipped' : `autocannon ${AUTOCANNON_SECONDS}s + artillery ${ARTILLERY_SECONDS}s (6s warm-up + 60s main)`}`)
41+
console.log(
42+
` stress: ${opts.skipStress ? 'skipped' : `autocannon ${AUTOCANNON_SECONDS}s + artillery ${ARTILLERY_SECONDS}s (6s warm-up + 60s main)`}`,
43+
)
4644
console.log(` steps: ${total} · rough wall ETA ${formatEta(eta)}`)
4745
console.log(`──────────────────────\n`)
4846
return new PerfProgress(total)

scripts/src/perf/report.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ export function printConsoleReport(results: FixtureRunResult[], args: ResolvedPe
165165
const s = result.stress
166166
console.log(`### Stress detail — ${result.label}`)
167167
console.log(`- Artillery RPS: ${s.requestsPerSecond?.toFixed(2) ?? 'N/A'}`)
168-
console.log(`- Artillery latency avg/p95/p99: ${s.responseTimeAvg?.toFixed(2)} / ${s.responseTimeP95?.toFixed(2)} / ${s.responseTimeP99?.toFixed(2)} ms`)
168+
console.log(
169+
`- Artillery latency avg/p95/p99: ${s.responseTimeAvg?.toFixed(2)} / ${s.responseTimeP95?.toFixed(2)} / ${s.responseTimeP99?.toFixed(2)} ms`,
170+
)
169171
console.log(`- Autocannon RPS: ${s.autocannon?.requests.average.toFixed(2) ?? 'N/A'}`)
170172
console.log(
171173
`- Autocannon latency avg/p50/p95/p99: ${s.autocannon?.latency.average.toFixed(2)} / ${s.autocannon?.latency.p50.toFixed(2)} / ${s.autocannon?.latency.p97_5.toFixed(2)} / ${s.autocannon?.latency.p99.toFixed(2)} ms`,
@@ -227,7 +229,12 @@ function displayLabel(id: FixtureId, label: string): string {
227229
}
228230

229231
/** Write charts + full markdown from already-averaged results. */
230-
export async function writeDocsReport(write: (c: string) => void, results: FixtureRunResult[], runs: number, profile: PerfRuntimeProfile): Promise<void> {
232+
export async function writeDocsReport(
233+
write: (c: string) => void,
234+
results: FixtureRunResult[],
235+
runs: number,
236+
profile: PerfRuntimeProfile,
237+
): Promise<void> {
231238
const note = meanNote(runs)
232239
const byId = Object.fromEntries(results.map((r) => [r.id, r])) as Record<FixtureId, FixtureRunResult>
233240

scripts/src/perf/stress.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ async function waitForServer(port: number, timeout = 30000): Promise<void> {
4242
})
4343
}
4444

45-
export async function runAutocannonTest(port: number, progress?: PerfProgress, duration = AUTOCANNON_SECONDS, connections = 10): Promise<AutocannonResult> {
45+
export async function runAutocannonTest(
46+
port: number,
47+
progress?: PerfProgress,
48+
duration = AUTOCANNON_SECONDS,
49+
connections = 10,
50+
): Promise<AutocannonResult> {
4651
ensureTempDir()
4752
progress?.note(`Autocannon: ${connections} connections × ${duration}s → http://localhost:${port}`)
4853
const stopBeat = progress?.heartbeat('autocannon', duration)

scripts/src/perf/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export type FixtureAlias = 'plain' | 'i18n' | 'micro'
9393
export type FixtureOnly = FixtureAlias | 'all'
9494
export type FixtureId = 'plain-nuxt' | 'i18n' | 'i18n-micro'
9595

96-
9796
export interface LocaleDef {
9897
code: string
9998
iso: string

src/module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,12 @@ declare module '#i18n-internal/payload-source' {
696696
nuxt.hook('build:before', () => addDataRoutes([] as NuxtPage[]))
697697
}
698698

699+
// unplugin@3 types `.vite()` against Vite 8; Nuxt kit still expects Vite 7 Plugin — runtime-compatible.
699700
addVitePlugin(
700701
createDefineI18nRoutePlugin({
701702
buildDir: nuxt.options.buildDir,
702703
rootDirs,
703-
}).vite(),
704+
}).vite() as Parameters<typeof addVitePlugin>[0],
704705
)
705706

706707
const { pluralTemplate, strategyTemplate, configTemplate } = templates

test/fixtures/i18n-micro/locales/generate.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ for (const pageName of PERF_PAGE_NAMES) {
4141
for (const locale of PERF_LOCALE_CODES) {
4242
fs.writeFileSync(path.join(localesRoot, `${locale}.json`), JSON.stringify(generateRootTranslations(locale)))
4343
for (const pageName of PERF_PAGE_NAMES) {
44-
fs.writeFileSync(
45-
path.join(pagesRoot, pageName, `${locale}.json`),
46-
JSON.stringify(generateTranslationsForPage(pageName, locale)),
47-
)
44+
fs.writeFileSync(path.join(pagesRoot, pageName, `${locale}.json`), JSON.stringify(generateTranslationsForPage(pageName, locale)))
4845
}
4946
}
5047

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Auto-generated by `pnpm -C scripts cli performance` — do not edit.
22
export const locales = [
33
{
4-
"code": "en",
5-
"iso": "en_US"
4+
code: 'en',
5+
iso: 'en_US',
66
},
77
{
8-
"code": "de",
9-
"iso": "de_DE"
8+
code: 'de',
9+
iso: 'de_DE',
1010
},
1111
{
12-
"code": "ru",
13-
"iso": "ru_RU"
12+
code: 'ru',
13+
iso: 'ru_RU',
1414
},
1515
{
16-
"code": "fr",
17-
"iso": "fr_FR"
18-
}
16+
code: 'fr',
17+
iso: 'fr_FR',
18+
},
1919
]

0 commit comments

Comments
 (0)