'playwright',
'eslint',
'prettier',
- 'eslint-with-oxlint',
'eslint-with-prettier',
+ 'oxlint',
+ 'rolldown-vite',
] as const
const FEATURE_OPTIONS = [
label: language.needsPrettier.message,
},
] as const
+const EXPERIMENTAL_FEATURE_OPTIONS = [
+ {
+ value: 'oxlint',
+ label: language.needsOxlint.message,
+ },
+ {
+ value: 'rolldown-vite',
+ label: language.needsRolldownVite.message,
+ },
+] as const
type PromptResult = {
projectName?: string
packageName?: string
features?: (typeof FEATURE_OPTIONS)[number]['value'][]
e2eFramework?: 'cypress' | 'nightwatch' | 'playwright'
- experimentOxlint?: boolean
+ experimentFeatures?: (typeof EXPERIMENTAL_FEATURE_OPTIONS)[number]['value'][]
}
function isValidPackageName(projectName) {
If used without ${cyan('--vitest')}, it will also add Nightwatch Component Testing.
--eslint
Add ESLint for code quality.
- --eslint-with-oxlint
- Add ESLint for code quality, and use Oxlint to speed up the linting process.
--eslint-with-prettier (Deprecated in favor of ${cyan('--eslint --prettier')})
Add Prettier for code formatting in addition to ESLint.
--prettier
Add Prettier for code formatting.
+ --oxlint
+ Add Oxlint for code quality and formatting.
+ --rolldown-vite
+ Use Rolldown Vite instead of Vite for building the project.
Unstable feature flags:
--tests, --with-tests
packageName: defaultProjectName,
features: [],
e2eFramework: undefined,
- experimentOxlint: false,
+ experimentFeatures: [],
}
intro(
}),
)
}
-
- if (result.features.includes('eslint')) {
- result.experimentOxlint = await unwrapPrompt(
- confirm({
- message: language.needsOxlint.message,
- initialValue: false,
- }),
- )
- }
+ result.experimentFeatures = await unwrapPrompt(
+ multiselect({
+ message: `${language.needsExperimentalFeatures.message} ${dim(language.needsExperimentalFeatures.hint)}`,
+ // @ts-expect-error @clack/prompt's type doesn't support readonly array yet
+ options: EXPERIMENTAL_FEATURE_OPTIONS,
+ required: false,
+ }),
+ )
}
- const { features } = result
+ const { features, experimentFeatures } = result
const needsTypeScript = argv.ts || argv.typescript || features.includes('typescript')
const needsJsx = argv.jsx || features.includes('jsx')
const needsRouter = argv.router || argv['vue-router'] || features.includes('router')
const needsPinia = argv.pinia || features.includes('pinia')
const needsVitest = argv.vitest || argv.tests || features.includes('vitest')
- const needsEslint =
- argv.eslint ||
- argv['eslint-with-oxlint'] ||
- argv['eslint-with-prettier'] ||
- features.includes('eslint')
+ const needsEslint = argv.eslint || argv['eslint-with-prettier'] || features.includes('eslint')
const needsPrettier =
argv.prettier || argv['eslint-with-prettier'] || features.includes('prettier')
- const needsOxlint = argv['eslint-with-oxlint'] || result.experimentOxlint
+ const needsOxlint = experimentFeatures.includes('oxlint') || argv['oxlint']
+ const needsRolldownVite = experimentFeatures.includes('rolldown-vite') || argv['rolldown-vite']
const { e2eFramework } = result
const needsCypress = argv.cypress || argv.tests || e2eFramework === 'cypress'
const templateDir = path.resolve(templateRoot, templateName)
renderTemplate(templateDir, root, callbacks)
}
+ const replaceVite = () => {
+ const content = fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8')
+ const json = JSON.parse(content)
+ // Replace `vite` with `rolldown-vite` if the feature is enabled
+ json.devDependencies.vite = 'npm:rolldown-vite@latest'
+ fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(json, null, 2))
+ }
// Render base template
render('base')
}
// Render ESLint config
- if (needsEslint) {
+ if (needsEslint || needsOxlint) {
renderEslint(root, {
needsTypeScript,
needsOxlint,
render('config/prettier')
}
+ // use rolldown-vite if the feature is enabled
+ if (needsRolldownVite) {
+ replaceVite()
+ }
+
// Render code template.
// prettier-ignore
const codeTemplate =