-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
refactor: use builder in build
#18432
refactor: use builder in build
#18432
Conversation
@patak-dev @bluwy What do you think about this one? |
packages/vite/src/node/build.ts
Outdated
if (selectedEnvironmentName && selectedEnvironmentName !== environmentName) | ||
continue |
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 this would be more clear with a condition out of the for loop:
function setupEnvironment(environmentName, environmentConfig) {
const environment = await environmentConfig.build.createEnvironment(
environmentName,
environmentConfig,
)
await environment.init()
environments[environmentName] = environment
}
if (selectedEnvironmentName) {
setupEnvironment(selectedEnvironmentName, config)
}
else {
// ... current for loop using setupEnvironment(environmentName, environmentConfig)
}
This approach looks good to me! Thanks Sapphi for exploring this option. I was thinking we could move some props later on from |
I like this approach too, so IIUC the programmatic API to reflect Once |
Yes.
I think yes. |
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.
Thanks again Sapphi! I prefer this option to just removing entireApp
. Just a note again that if we go with this one, we are already deciding that at one point we would like to remove build()
and being able to "build a part of an app". Or we can still change our mind and accept a small breaking change for people that used builder: {}
if we need to introduce entireApp
. I'm fine with this.
Description
Alternative to #18028
builder.entireApp
and usebuilder: {}
/builder: undefined
(this one can be discussed separately if needed)build
and use that from the CLIThis makes the
createBuilder
a bit complicated but the overall code size is smaller and improves CLI-JS API symmetry.Migration Plans
This PR does not change any behavior. Later on we make
builder: { sharedConfigBuild: true }
to be the default and remove the codes related to the legacy builder.--app
or settingbuilder: {}
in the config--app
but that change is not necessary (we should just ignore the flag)build
commandcreateBuilder
createBuilder
frombuild