Skip to content

Commit 5a204b8

Browse files
committed
refactor(@angular-devkit/build-angular): accept boolean and string in ssr option
This is to align with the `serviceWorker` option.
1 parent 9291dda commit 5a204b8

File tree

4 files changed

+7
-19
lines changed

4 files changed

+7
-19
lines changed

packages/angular/ssr/schematics/ng-add/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function updateApplicationBuilderWorkspaceConfigRule(
109109
}
110110

111111
prodConfig.prerender = true;
112-
(prodConfig.ssr ??= {}).entry = join(normalize(projectRoot), 'server.ts');
112+
prodConfig.ssr = join(normalize(projectRoot), 'server.ts');
113113
});
114114
};
115115
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,9 @@ export async function normalizeOptions(
197197
let ssrOptions;
198198
if (options.ssr === true) {
199199
ssrOptions = {};
200-
} else if (typeof options.ssr === 'object') {
201-
const { entry } = options.ssr;
202-
200+
} else if (typeof options.ssr === 'string') {
203201
ssrOptions = {
204-
entry: entry && path.join(workspaceRoot, entry),
202+
entry: path.join(workspaceRoot, options.ssr),
205203
};
206204
}
207205

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,8 @@
452452
"description": "Enable the server bundles to be written to disk."
453453
},
454454
{
455-
"type": "object",
456-
"properties": {
457-
"entry": {
458-
"type": "string",
459-
"description": "The server entry-point that when executed will spawn the web server."
460-
}
461-
},
462-
"additionalProperties": false
455+
"type": "string",
456+
"description": "The server entry-point that when executed will spawn the web server."
463457
}
464458
]
465459
},

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2727
harness.useTarget('build', {
2828
...BASE_OPTIONS,
2929
server: 'src/main.server.ts',
30-
ssr: {
31-
entry: 'src/server.ts',
32-
},
30+
ssr: 'src/server.ts',
3331
});
3432

3533
const { result } = await harness.executeOnce();
@@ -45,9 +43,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
4543
harness.useTarget('build', {
4644
...BASE_OPTIONS,
4745
server: 'src/main.server.ts',
48-
ssr: {
49-
entry: '/file.mjs',
50-
},
46+
ssr: '/file.mjs',
5147
});
5248

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

0 commit comments

Comments
 (0)