diff --git a/goldens/public-api/angular_devkit/build_angular/index.md b/goldens/public-api/angular_devkit/build_angular/index.md index 1b25ec2e56c7..fbd5c2266cc2 100644 --- a/goldens/public-api/angular_devkit/build_angular/index.md +++ b/goldens/public-api/angular_devkit/build_angular/index.md @@ -47,7 +47,7 @@ export interface ApplicationBuilderOptions { server?: string; serviceWorker?: ServiceWorker_2; sourceMap?: SourceMapUnion_2; - ssr?: ServiceWorker_2; + ssr?: SsrUnion; statsJson?: boolean; stylePreprocessorOptions?: StylePreprocessorOptions_2; styles?: StyleElement_2[]; diff --git a/packages/angular_devkit/build_angular/src/builders/application/options.ts b/packages/angular_devkit/build_angular/src/builders/application/options.ts index 0f3b2d63aab5..88ee9d8e9db2 100644 --- a/packages/angular_devkit/build_angular/src/builders/application/options.ts +++ b/packages/angular_devkit/build_angular/src/builders/application/options.ts @@ -210,9 +210,11 @@ export async function normalizeOptions( let ssrOptions; if (options.ssr === true) { ssrOptions = {}; - } else if (typeof options.ssr === 'string') { + } else if (typeof options.ssr === 'object') { + const { entry } = options.ssr; + ssrOptions = { - entry: path.join(workspaceRoot, options.ssr), + entry: entry && path.join(workspaceRoot, entry), }; } diff --git a/packages/angular_devkit/build_angular/src/builders/application/schema.json b/packages/angular_devkit/build_angular/src/builders/application/schema.json index 32d4c0e3cbc5..625f2998f2ab 100644 --- a/packages/angular_devkit/build_angular/src/builders/application/schema.json +++ b/packages/angular_devkit/build_angular/src/builders/application/schema.json @@ -447,8 +447,14 @@ "description": "Enable the server bundles to be written to disk." }, { - "type": "string", - "description": "The server entry-point that when executed will spawn the web server." + "type": "object", + "properties": { + "entry": { + "type": "string", + "description": "The server entry-point that when executed will spawn the web server." + } + }, + "additionalProperties": false } ] }, diff --git a/packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts b/packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts index e1f7b74c2ddf..2caef3e3e14f 100644 --- a/packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts @@ -27,7 +27,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { harness.useTarget('build', { ...BASE_OPTIONS, server: 'src/main.server.ts', - ssr: 'src/server.ts', + ssr: { entry: 'src/server.ts' }, }); const { result } = await harness.executeOnce(); @@ -43,7 +43,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { harness.useTarget('build', { ...BASE_OPTIONS, server: 'src/main.server.ts', - ssr: '/file.mjs', + ssr: { entry: '/file.mjs' }, }); const { result } = await harness.executeOnce(); diff --git a/packages/schematics/angular/ssr/index.ts b/packages/schematics/angular/ssr/index.ts index 433de59993c5..52fbcb9f4093 100644 --- a/packages/schematics/angular/ssr/index.ts +++ b/packages/schematics/angular/ssr/index.ts @@ -116,7 +116,9 @@ function updateApplicationBuilderWorkspaceConfigRule( buildTarget.options = { ...buildTarget.options, prerender: true, - ssr: join(normalize(projectRoot), 'server.ts'), + ssr: { + entry: join(normalize(projectRoot), 'server.ts'), + }, }; }); }