-
Notifications
You must be signed in to change notification settings - Fork 480
feat: add rolldown-vite
features
#760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
btea
wants to merge
1
commit into
main
Choose a base branch
from
feat/rolldown-vite-feat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,9 @@ const FEATURE_FLAGS = [ | |
'playwright', | ||
'eslint', | ||
'prettier', | ||
'eslint-with-oxlint', | ||
'eslint-with-prettier', | ||
'oxlint', | ||
'rolldown-vite', | ||
] as const | ||
|
||
const FEATURE_OPTIONS = [ | ||
|
@@ -76,6 +77,20 @@ const FEATURE_OPTIONS = [ | |
value: 'prettier', | ||
label: language.needsPrettier.message, | ||
}, | ||
{ | ||
value: 'experimental features', | ||
label: language.needExperimenttal.message, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needExperimenttal -> needExperimental (or needsExperimental maybe?) |
||
}, | ||
] as const | ||
const EXPERIMENTAL_FEATURE_OPTIONS = [ | ||
{ | ||
value: 'oxlint', | ||
label: language.needsOxlint.message, | ||
}, | ||
{ | ||
value: 'rolldown-vite', | ||
label: language.needsRolldownVite.message, | ||
}, | ||
] as const | ||
|
||
type PromptResult = { | ||
|
@@ -84,7 +99,7 @@ type PromptResult = { | |
packageName?: string | ||
features?: (typeof FEATURE_OPTIONS)[number]['value'][] | ||
e2eFramework?: 'cypress' | 'nightwatch' | 'playwright' | ||
experimentOxlint?: boolean | ||
experimentFeatures?: (typeof EXPERIMENTAL_FEATURE_OPTIONS)[number]['value'][] | ||
} | ||
|
||
function isValidPackageName(projectName) { | ||
|
@@ -177,12 +192,14 @@ Available feature flags: | |
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 | ||
|
@@ -232,7 +249,7 @@ async function init() { | |
packageName: defaultProjectName, | ||
features: [], | ||
e2eFramework: undefined, | ||
experimentOxlint: false, | ||
experimentFeatures: [], | ||
} | ||
|
||
intro( | ||
|
@@ -322,31 +339,30 @@ async function init() { | |
) | ||
} | ||
|
||
if (result.features.includes('eslint')) { | ||
result.experimentOxlint = await unwrapPrompt( | ||
confirm({ | ||
message: language.needsOxlint.message, | ||
initialValue: false, | ||
if (result.features.includes('experimental features')) { | ||
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' | ||
|
@@ -374,6 +390,13 @@ async function init() { | |
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') | ||
|
||
|
@@ -471,7 +494,7 @@ async function init() { | |
} | ||
|
||
// Render ESLint config | ||
if (needsEslint) { | ||
if (needsEslint || needsOxlint) { | ||
renderEslint(root, { | ||
needsTypeScript, | ||
needsOxlint, | ||
|
@@ -492,6 +515,11 @@ async function init() { | |
render('config/prettier') | ||
} | ||
|
||
// use rolldown-vite if the feature is enabled | ||
if (needsRolldownVite) { | ||
replaceVite() | ||
} | ||
|
||
// Render code template. | ||
// prettier-ignore | ||
const codeTemplate = | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,17 @@ | |
} | ||
}, | ||
"needsOxlint": { | ||
"message": "Installer Oxlint pour un linting plus rapide\u00a0? (expérimental)" | ||
"message": "Oxlint (expérimental)" | ||
}, | ||
"needExperimenttal": { | ||
"message": "Activer les fonctionnalités expérimentales" | ||
}, | ||
"needsExperimentalFeatures": { | ||
"message": "Sélectionnez les fonctionnalités expérimentales à inclure:", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: needs a non breaking space before colon: |
||
"hint": "(↑/↓ pour naviguer, espace pour sélectionner, a pour tout sélectionner, entrée pour confirmer)" | ||
}, | ||
"needsRolldownVite": { | ||
"message": "rolldown-vite (expérimental)" | ||
}, | ||
"errors": { | ||
"operationCancelled": "Operation annulée" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use a dash instead of a space?
experimental-features
?