@@ -31,7 +31,6 @@ interface GlobalCLIOptions {
3131}
3232
3333interface BuilderCLIOptions {
34- environment ?: string
3534 app ?: boolean
3635}
3736
@@ -113,9 +112,7 @@ function cleanBuilderCLIOptions<Options extends BuilderCLIOptions>(
113112 options : Options ,
114113) : Omit < Options , keyof BuilderCLIOptions > {
115114 const ret = { ...options }
116- delete ret . environment
117115 delete ret . app
118-
119116 return ret
120117}
121118
@@ -281,14 +278,14 @@ cli
281278 )
282279 . option ( '-w, --watch' , `[boolean] rebuilds when modules have changed on disk` )
283280 . option ( '--environment [name]' , `[string] build a single environment` )
284- . option ( '--app' , `[boolean] build all the environments ` )
281+ . option ( '--app' , `[boolean] same as builder.entireApp ` )
285282 . action (
286283 async (
287284 root : string ,
288285 options : BuildEnvironmentOptions & BuilderCLIOptions & GlobalCLIOptions ,
289286 ) => {
290287 filterDuplicateOptions ( options )
291- const { build , createBuilder } = await import ( './build' )
288+ const { createBuilder , buildEnvironment } = await import ( './build' )
292289
293290 const buildOptions : BuildEnvironmentOptions = cleanGlobalCLIOptions (
294291 cleanBuilderCLIOptions ( options ) ,
@@ -305,22 +302,21 @@ cli
305302 }
306303
307304 try {
308- if ( options . app || options . environment ) {
309- const builder = await createBuilder ( config )
310- if ( options . environment ) {
311- const environment = builder . environments [ options . environment ]
312- if ( ! environment ) {
313- throw new Error (
314- `The environment ${ options . environment } isn't configured.` ,
315- )
316- }
317- await builder . build ( environment )
318- } else {
319- // --app: build all environments
320- await builder . buildApp ( )
321- }
305+ const builder = await createBuilder ( config )
306+ // TODO: Backward compatibility with lib and single environment build
307+ // Ideally we would move to only building the entire app with this command
308+ if ( builder . config . build . lib ) {
309+ await buildEnvironment (
310+ builder . config ,
311+ builder . environments . client ,
312+ builder . config . build . lib ,
313+ )
314+ } else if ( builder . config . builder . entireApp || options . app ) {
315+ await builder . buildApp ( )
322316 } else {
323- await build ( config )
317+ const ssr = ! ! builder . config . build . ssr
318+ const environment = builder . environments [ ssr ? 'ssr' : 'client' ]
319+ await builder . build ( environment )
324320 }
325321 } catch ( e ) {
326322 createLogger ( options . logLevel ) . error (
0 commit comments