Skip to content

Commit

Permalink
refactor(@angular-devkit/build-angular): accept boolean and string in…
Browse files Browse the repository at this point in the history
… `ssr` option

This is to align with the `serviceWorker` option.
  • Loading branch information
alan-agius4 committed Sep 15, 2023
1 parent 9291dda commit 5a204b8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/angular/ssr/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function updateApplicationBuilderWorkspaceConfigRule(
}

prodConfig.prerender = true;
(prodConfig.ssr ??= {}).entry = join(normalize(projectRoot), 'server.ts');
prodConfig.ssr = join(normalize(projectRoot), 'server.ts');
});
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,9 @@ export async function normalizeOptions(
let ssrOptions;
if (options.ssr === true) {
ssrOptions = {};
} else if (typeof options.ssr === 'object') {
const { entry } = options.ssr;

} else if (typeof options.ssr === 'string') {
ssrOptions = {
entry: entry && path.join(workspaceRoot, entry),
entry: path.join(workspaceRoot, options.ssr),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,8 @@
"description": "Enable the server bundles to be written to disk."
},
{
"type": "object",
"properties": {
"entry": {
"type": "string",
"description": "The server entry-point that when executed will spawn the web server."
}
},
"additionalProperties": false
"type": "string",
"description": "The server entry-point that when executed will spawn the web server."
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
harness.useTarget('build', {
...BASE_OPTIONS,
server: 'src/main.server.ts',
ssr: {
entry: 'src/server.ts',
},
ssr: 'src/server.ts',
});

const { result } = await harness.executeOnce();
Expand All @@ -45,9 +43,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
harness.useTarget('build', {
...BASE_OPTIONS,
server: 'src/main.server.ts',
ssr: {
entry: '/file.mjs',
},
ssr: '/file.mjs',
});

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

0 comments on commit 5a204b8

Please sign in to comment.