@@ -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 = [
@@ -76,6 +77,20 @@ const FEATURE_OPTIONS = [
76
77
value : 'prettier' ,
77
78
label : language . needsPrettier . message ,
78
79
} ,
80
+ {
81
+ value : 'experimental features' ,
82
+ label : language . needExperimenttal . message ,
83
+ } ,
84
+ ] as const
85
+ const EXPERIMENTAL_FEATURE_OPTIONS = [
86
+ {
87
+ value : 'oxlint' ,
88
+ label : language . needsOxlint . message ,
89
+ } ,
90
+ {
91
+ value : 'rolldown-vite' ,
92
+ label : language . needsRolldownVite . message ,
93
+ } ,
79
94
] as const
80
95
81
96
type PromptResult = {
@@ -84,7 +99,7 @@ type PromptResult = {
84
99
packageName ?: string
85
100
features ?: ( typeof FEATURE_OPTIONS ) [ number ] [ 'value' ] [ ]
86
101
e2eFramework ?: 'cypress' | 'nightwatch' | 'playwright'
87
- experimentOxlint ?: boolean
102
+ experimentFeatures ?: ( typeof EXPERIMENTAL_FEATURE_OPTIONS ) [ number ] [ 'value' ] [ ]
88
103
}
89
104
90
105
function isValidPackageName ( projectName ) {
@@ -177,12 +192,14 @@ Available feature flags:
177
192
If used without ${ cyan ( '--vitest' ) } , it will also add Nightwatch Component Testing.
178
193
--eslint
179
194
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
195
--eslint-with-prettier (Deprecated in favor of ${ cyan ( '--eslint --prettier' ) } )
183
196
Add Prettier for code formatting in addition to ESLint.
184
197
--prettier
185
198
Add Prettier for code formatting.
199
+ --oxlint
200
+ Add Oxlint for code quality and formatting.
201
+ --rolldown-vite
202
+ Use Rolldown Vite instead of Vite for building the project.
186
203
187
204
Unstable feature flags:
188
205
--tests, --with-tests
@@ -232,7 +249,7 @@ async function init() {
232
249
packageName : defaultProjectName ,
233
250
features : [ ] ,
234
251
e2eFramework : undefined ,
235
- experimentOxlint : false ,
252
+ experimentFeatures : [ ] ,
236
253
}
237
254
238
255
intro (
@@ -322,31 +339,30 @@ async function init() {
322
339
)
323
340
}
324
341
325
- if ( result . features . includes ( 'eslint' ) ) {
326
- result . experimentOxlint = await unwrapPrompt (
327
- confirm ( {
328
- message : language . needsOxlint . message ,
329
- initialValue : false ,
342
+ if ( result . features . includes ( 'experimental features' ) ) {
343
+ result . experimentFeatures = await unwrapPrompt (
344
+ multiselect ( {
345
+ message : `${ language . needsExperimentalFeatures . message } ${ dim ( language . needsExperimentalFeatures . hint ) } ` ,
346
+ // @ts -expect-error @clack/prompt's type doesn't support readonly array yet
347
+ options : EXPERIMENTAL_FEATURE_OPTIONS ,
348
+ required : false ,
330
349
} ) ,
331
350
)
332
351
}
333
352
}
334
353
335
- const { features } = result
354
+ const { features , experimentFeatures } = result
336
355
337
356
const needsTypeScript = argv . ts || argv . typescript || features . includes ( 'typescript' )
338
357
const needsJsx = argv . jsx || features . includes ( 'jsx' )
339
358
const needsRouter = argv . router || argv [ 'vue-router' ] || features . includes ( 'router' )
340
359
const needsPinia = argv . pinia || features . includes ( 'pinia' )
341
360
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' )
361
+ const needsEslint = argv . eslint || argv [ 'eslint-with-prettier' ] || features . includes ( 'eslint' )
347
362
const needsPrettier =
348
363
argv . prettier || argv [ 'eslint-with-prettier' ] || features . includes ( 'prettier' )
349
- const needsOxlint = argv [ 'eslint-with-oxlint' ] || result . experimentOxlint
364
+ const needsOxlint = experimentFeatures . includes ( 'oxlint' ) || argv [ 'oxlint' ]
365
+ const needsRolldownVite = experimentFeatures . includes ( 'rolldown-vite' ) || argv [ 'rolldown-vite' ]
350
366
351
367
const { e2eFramework } = result
352
368
const needsCypress = argv . cypress || argv . tests || e2eFramework === 'cypress'
@@ -374,6 +390,13 @@ async function init() {
374
390
const templateDir = path . resolve ( templateRoot , templateName )
375
391
renderTemplate ( templateDir , root , callbacks )
376
392
}
393
+ const replaceVite = ( ) => {
394
+ const content = fs . readFileSync ( path . resolve ( root , 'package.json' ) , 'utf-8' )
395
+ const json = JSON . parse ( content )
396
+ // Replace `vite` with `rolldown-vite` if the feature is enabled
397
+ json . devDependencies . vite = 'npm:rolldown-vite@latest'
398
+ fs . writeFileSync ( path . resolve ( root , 'package.json' ) , JSON . stringify ( json , null , 2 ) )
399
+ }
377
400
// Render base template
378
401
render ( 'base' )
379
402
@@ -471,7 +494,7 @@ async function init() {
471
494
}
472
495
473
496
// Render ESLint config
474
- if ( needsEslint ) {
497
+ if ( needsEslint || needsOxlint ) {
475
498
renderEslint ( root , {
476
499
needsTypeScript,
477
500
needsOxlint,
@@ -492,6 +515,11 @@ async function init() {
492
515
render ( 'config/prettier' )
493
516
}
494
517
518
+ // use rolldown-vite if the feature is enabled
519
+ if ( needsRolldownVite ) {
520
+ replaceVite ( )
521
+ }
522
+
495
523
// Render code template.
496
524
// prettier-ignore
497
525
const codeTemplate =
0 commit comments