@@ -39,8 +39,9 @@ const FEATURE_FLAGS = [
39
39
'playwright' ,
40
40
'eslint' ,
41
41
'prettier' ,
42
- 'eslint-with-oxlint' ,
43
42
'eslint-with-prettier' ,
43
+ 'oxlint' ,
44
+ 'rolldown-vite' ,
44
45
] as const
45
46
46
47
const FEATURE_OPTIONS = [
@@ -77,14 +78,24 @@ const FEATURE_OPTIONS = [
77
78
label : language . needsPrettier . message ,
78
79
} ,
79
80
] as const
81
+ const EXPERIMENTAL_FEATURE_OPTIONS = [
82
+ {
83
+ value : 'oxlint' ,
84
+ label : language . needsOxlint . message ,
85
+ } ,
86
+ {
87
+ value : 'rolldown-vite' ,
88
+ label : language . needsRolldownVite . message ,
89
+ } ,
90
+ ] as const
80
91
81
92
type PromptResult = {
82
93
projectName ?: string
83
94
shouldOverwrite ?: boolean
84
95
packageName ?: string
85
96
features ?: ( typeof FEATURE_OPTIONS ) [ number ] [ 'value' ] [ ]
86
97
e2eFramework ?: 'cypress' | 'nightwatch' | 'playwright'
87
- experimentOxlint ?: boolean
98
+ experimentFeatures ?: ( typeof EXPERIMENTAL_FEATURE_OPTIONS ) [ number ] [ 'value' ] [ ]
88
99
}
89
100
90
101
function isValidPackageName ( projectName ) {
@@ -177,12 +188,14 @@ Available feature flags:
177
188
If used without ${ cyan ( '--vitest' ) } , it will also add Nightwatch Component Testing.
178
189
--eslint
179
190
Add ESLint for code quality.
180
- --eslint-with-oxlint
181
- Add ESLint for code quality, and use Oxlint to speed up the linting process.
182
191
--eslint-with-prettier (Deprecated in favor of ${ cyan ( '--eslint --prettier' ) } )
183
192
Add Prettier for code formatting in addition to ESLint.
184
193
--prettier
185
194
Add Prettier for code formatting.
195
+ --oxlint
196
+ Add Oxlint for code quality and formatting.
197
+ --rolldown-vite
198
+ Use Rolldown Vite instead of Vite for building the project.
186
199
187
200
Unstable feature flags:
188
201
--tests, --with-tests
@@ -232,7 +245,7 @@ async function init() {
232
245
packageName : defaultProjectName ,
233
246
features : [ ] ,
234
247
e2eFramework : undefined ,
235
- experimentOxlint : false ,
248
+ experimentFeatures : [ ] ,
236
249
}
237
250
238
251
intro (
@@ -321,32 +334,28 @@ async function init() {
321
334
} ) ,
322
335
)
323
336
}
324
-
325
- if ( result . features . includes ( 'eslint' ) ) {
326
- result . experimentOxlint = await unwrapPrompt (
327
- confirm ( {
328
- message : language . needsOxlint . message ,
329
- initialValue : false ,
330
- } ) ,
331
- )
332
- }
337
+ result . experimentFeatures = await unwrapPrompt (
338
+ multiselect ( {
339
+ message : `${ language . needsExperimentalFeatures . message } ${ dim ( language . needsExperimentalFeatures . hint ) } ` ,
340
+ // @ts -expect-error @clack/prompt's type doesn't support readonly array yet
341
+ options : EXPERIMENTAL_FEATURE_OPTIONS ,
342
+ required : false ,
343
+ } ) ,
344
+ )
333
345
}
334
346
335
- const { features } = result
347
+ const { features , experimentFeatures } = result
336
348
337
349
const needsTypeScript = argv . ts || argv . typescript || features . includes ( 'typescript' )
338
350
const needsJsx = argv . jsx || features . includes ( 'jsx' )
339
351
const needsRouter = argv . router || argv [ 'vue-router' ] || features . includes ( 'router' )
340
352
const needsPinia = argv . pinia || features . includes ( 'pinia' )
341
353
const needsVitest = argv . vitest || argv . tests || features . includes ( 'vitest' )
342
- const needsEslint =
343
- argv . eslint ||
344
- argv [ 'eslint-with-oxlint' ] ||
345
- argv [ 'eslint-with-prettier' ] ||
346
- features . includes ( 'eslint' )
354
+ const needsEslint = argv . eslint || argv [ 'eslint-with-prettier' ] || features . includes ( 'eslint' )
347
355
const needsPrettier =
348
356
argv . prettier || argv [ 'eslint-with-prettier' ] || features . includes ( 'prettier' )
349
- const needsOxlint = argv [ 'eslint-with-oxlint' ] || result . experimentOxlint
357
+ const needsOxlint = experimentFeatures . includes ( 'oxlint' ) || argv [ 'oxlint' ]
358
+ const needsRolldownVite = experimentFeatures . includes ( 'rolldown-vite' ) || argv [ 'rolldown-vite' ]
350
359
351
360
const { e2eFramework } = result
352
361
const needsCypress = argv . cypress || argv . tests || e2eFramework === 'cypress'
@@ -374,6 +383,13 @@ async function init() {
374
383
const templateDir = path . resolve ( templateRoot , templateName )
375
384
renderTemplate ( templateDir , root , callbacks )
376
385
}
386
+ const replaceVite = ( ) => {
387
+ const content = fs . readFileSync ( path . resolve ( root , 'package.json' ) , 'utf-8' )
388
+ const json = JSON . parse ( content )
389
+ // Replace `vite` with `rolldown-vite` if the feature is enabled
390
+ json . devDependencies . vite = 'npm:rolldown-vite@latest'
391
+ fs . writeFileSync ( path . resolve ( root , 'package.json' ) , JSON . stringify ( json , null , 2 ) )
392
+ }
377
393
// Render base template
378
394
render ( 'base' )
379
395
@@ -471,7 +487,7 @@ async function init() {
471
487
}
472
488
473
489
// Render ESLint config
474
- if ( needsEslint ) {
490
+ if ( needsEslint || needsOxlint ) {
475
491
renderEslint ( root , {
476
492
needsTypeScript,
477
493
needsOxlint,
@@ -492,6 +508,11 @@ async function init() {
492
508
render ( 'config/prettier' )
493
509
}
494
510
511
+ // use rolldown-vite if the feature is enabled
512
+ if ( needsRolldownVite ) {
513
+ replaceVite ( )
514
+ }
515
+
495
516
// Render code template.
496
517
// prettier-ignore
497
518
const codeTemplate =
0 commit comments