Skip to content

Commit 17fd0ad

Browse files
committed
fix(@angular-devkit/build-angular): update ssr option definition
This commits updates the `ssr` application builder option definition. The main change is that now the option does not accept the entry-point as a value. Instead it should be passed in the `entry` suboption. Example ```json "ssr": { "entry": "server.ts" } ``` This change in this option is important to allow us in the future to add additional sub options. Like potentially a `platform` or `target`.
1 parent 4784155 commit 17fd0ad

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

goldens/public-api/angular_devkit/build_angular/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface ApplicationBuilderOptions {
4747
server?: string;
4848
serviceWorker?: ServiceWorker_2;
4949
sourceMap?: SourceMapUnion_2;
50-
ssr?: ServiceWorker_2;
50+
ssr?: SsrUnion;
5151
statsJson?: boolean;
5252
stylePreprocessorOptions?: StylePreprocessorOptions_2;
5353
styles?: StyleElement_2[];

packages/angular_devkit/build_angular/src/builders/application/options.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ export async function normalizeOptions(
210210
let ssrOptions;
211211
if (options.ssr === true) {
212212
ssrOptions = {};
213-
} else if (typeof options.ssr === 'string') {
213+
} else if (typeof options.ssr === 'object') {
214+
const { entry } = options.ssr;
215+
214216
ssrOptions = {
215-
entry: path.join(workspaceRoot, options.ssr),
217+
entry: entry && path.join(workspaceRoot, entry),
216218
};
217219
}
218220

packages/angular_devkit/build_angular/src/builders/application/schema.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,14 @@
447447
"description": "Enable the server bundles to be written to disk."
448448
},
449449
{
450-
"type": "string",
451-
"description": "The server entry-point that when executed will spawn the web server."
450+
"type": "object",
451+
"properties": {
452+
"entry": {
453+
"type": "string",
454+
"description": "The server entry-point that when executed will spawn the web server."
455+
}
456+
},
457+
"additionalProperties": false
452458
}
453459
]
454460
},

packages/angular_devkit/build_angular/src/builders/application/tests/options/ssr_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2727
harness.useTarget('build', {
2828
...BASE_OPTIONS,
2929
server: 'src/main.server.ts',
30-
ssr: 'src/server.ts',
30+
ssr: { entry: 'src/server.ts' },
3131
});
3232

3333
const { result } = await harness.executeOnce();
@@ -43,7 +43,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
4343
harness.useTarget('build', {
4444
...BASE_OPTIONS,
4545
server: 'src/main.server.ts',
46-
ssr: '/file.mjs',
46+
ssr: { entry: '/file.mjs' },
4747
});
4848

4949
const { result } = await harness.executeOnce();

packages/schematics/angular/ssr/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ function updateApplicationBuilderWorkspaceConfigRule(
116116
buildTarget.options = {
117117
...buildTarget.options,
118118
prerender: true,
119-
ssr: join(normalize(projectRoot), 'server.ts'),
119+
ssr: {
120+
entry: join(normalize(projectRoot), 'server.ts'),
121+
},
120122
};
121123
});
122124
}

0 commit comments

Comments
 (0)