Skip to content

Commit 5fc674a

Browse files
committed
fix: remove builder.entireApp
1 parent 51bb168 commit 5fc674a

4 files changed

Lines changed: 10 additions & 54 deletions

File tree

docs/guide/api-environment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ The callback is queued and it will wait for the current update to be resolved be
956956
957957
In the CLI, calling `vite build` and `vite build --ssr` will still build the client only and ssr only environments for backward compatibility.
958958
959-
When `builder.entireApp` is `true` (or when calling `vite build --app`), `vite build` will opt-in into building the entire app instead. This would later on become the default in a future major. A `ViteBuilder` instance will be created (build-time equivalent to a `ViteDevServer`) to build all configured environments for production. By default the build of environments is run in series respecting the order of the `environments` record. A framework or user can further configure how the environments are built using:
959+
When calling `vite build --app` or the `createBuilder()` API, Vite will opt into building the entire app instead. This would later on become the default in a future major. A `ViteBuilder` instance will be created (build-time equivalent to a `ViteDevServer`) to build all configured environments for production. By default the build of environments is run in series respecting the order of the `environments` record. A framework or user can further configure how the environments are built using:
960960
961961
```js
962962
export default {

docs/guide/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ vite build [root]
6969
| `-f, --filter <filter>` | Filter debug logs (`string`) |
7070
| `-m, --mode <mode>` | Set env mode (`string`) |
7171
| `-h, --help` | Display available CLI options |
72-
| `--app` | Build all environments, same as `builder.entireApp` (`boolean`, experimental) |
72+
| `--app` | Build all environments, same as `(await createBuilder()).buildApp()` (`boolean`, experimental) |
7373

7474
## Others
7575

packages/vite/src/node/build.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,6 @@ export async function build(
521521
}
522522
}
523523
const config = await resolveConfigToBuild(inlineConfig, patchConfig)
524-
return buildWithResolvedConfig(config)
525-
}
526-
527-
/**
528-
* @internal used to implement `vite build` for backward compatibility
529-
*/
530-
export async function buildWithResolvedConfig(
531-
config: ResolvedConfig,
532-
): Promise<RollupOutput | RollupOutput[] | RollupWatcher> {
533524
const environmentName = config.build.ssr ? 'ssr' : 'client'
534525
const environment = await config.environments[
535526
environmentName
@@ -538,7 +529,7 @@ export async function buildWithResolvedConfig(
538529
return buildEnvironment(environment)
539530
}
540531

541-
export function resolveConfigToBuild(
532+
function resolveConfigToBuild(
542533
inlineConfig: InlineConfig = {},
543534
patchConfig?: (config: ResolvedConfig) => void,
544535
patchPlugins?: (resolvedPlugins: Plugin[]) => void,
@@ -1503,7 +1494,6 @@ export interface ViteBuilder {
15031494
export interface BuilderOptions {
15041495
sharedConfigBuild?: boolean
15051496
sharedPlugins?: boolean
1506-
entireApp?: boolean
15071497
buildApp?: (builder: ViteBuilder) => Promise<void>
15081498
}
15091499

@@ -1519,7 +1509,6 @@ export function resolveBuilderOptions(
15191509
return {
15201510
sharedConfigBuild: options.sharedConfigBuild ?? false,
15211511
sharedPlugins: options.sharedPlugins ?? false,
1522-
entireApp: options.entireApp ?? false,
15231512
buildApp: options.buildApp ?? defaultBuildApp,
15241513
}
15251514
}
@@ -1533,17 +1522,6 @@ export async function createBuilder(
15331522
inlineConfig: InlineConfig = {},
15341523
): Promise<ViteBuilder> {
15351524
const config = await resolveConfigToBuild(inlineConfig)
1536-
return createBuilderWithResolvedConfig(inlineConfig, config)
1537-
}
1538-
1539-
/**
1540-
* Used to implement the `vite build` command without resolving the config twice
1541-
* @internal
1542-
*/
1543-
export async function createBuilderWithResolvedConfig(
1544-
inlineConfig: InlineConfig,
1545-
config: ResolvedConfig,
1546-
): Promise<ViteBuilder> {
15471525
const environments: Record<string, BuildEnvironment> = {}
15481526

15491527
const builder: ViteBuilder = {

packages/vite/src/node/cli.ts

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { performance } from 'node:perf_hooks'
44
import { cac } from 'cac'
55
import colors from 'picocolors'
66
import { VERSION } from './constants'
7-
import type { BuildEnvironmentOptions, ResolvedBuildOptions } from './build'
7+
import type { BuildEnvironmentOptions } from './build'
88
import type { ServerOptions } from './server'
99
import type { CLIShortcut } from './shortcuts'
1010
import type { LogLevel } from './logger'
1111
import { createLogger } from './logger'
1212
import { resolveConfig } from './config'
13-
import type { InlineConfig, ResolvedConfig } from './config'
13+
import type { InlineConfig } from './config'
1414

1515
const cli = cac('vite')
1616

@@ -279,14 +279,14 @@ cli
279279
`[boolean] force empty outDir when it's outside of root`,
280280
)
281281
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
282-
.option('--app', `[boolean] same as builder.entireApp`)
282+
.option('--app', `[boolean] same as \`(await createBuilder()).buildApp()\``)
283283
.action(
284284
async (
285285
root: string,
286286
options: BuildEnvironmentOptions & BuilderCLIOptions & GlobalCLIOptions,
287287
) => {
288288
filterDuplicateOptions(options)
289-
const build = await import('./build')
289+
const { build, createBuilder } = await import('./build')
290290

291291
const buildOptions: BuildEnvironmentOptions = cleanGlobalCLIOptions(
292292
cleanBuilderCLIOptions(options),
@@ -301,35 +301,13 @@ cli
301301
logLevel: options.logLevel,
302302
clearScreen: options.clearScreen,
303303
build: buildOptions,
304-
...(options.app ? { builder: { entireApp: true } } : {}),
305304
}
306-
const patchConfig = (resolved: ResolvedConfig) => {
307-
if (resolved.builder.entireApp) {
308-
return
309-
}
310-
// Until the ecosystem updates to use `environment.config.build` instead of `config.build`,
311-
// we need to make override `config.build` for the current environment.
312-
// We can deprecate `config.build` in ResolvedConfig and push everyone to upgrade, and later
313-
// remove the default values that shouldn't be used at all once the config is resolved
314-
const environmentName = resolved.build.ssr ? 'ssr' : 'client'
315-
;(resolved.build as ResolvedBuildOptions) = {
316-
...resolved.environments[environmentName].build,
317-
}
318-
}
319-
const config = await build.resolveConfigToBuild(
320-
inlineConfig,
321-
patchConfig,
322-
)
323-
324-
if (config.builder.entireApp) {
325-
const builder = await build.createBuilderWithResolvedConfig(
326-
inlineConfig,
327-
config,
328-
)
305+
if (options.app) {
306+
const builder = await createBuilder(inlineConfig)
329307
await builder.buildApp()
330308
} else {
331309
// Single environment (client or ssr) build or library mode build
332-
await build.buildWithResolvedConfig(config)
310+
await build(inlineConfig)
333311
}
334312
} catch (e) {
335313
createLogger(options.logLevel).error(

0 commit comments

Comments
 (0)