Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): update ssr option definition
Browse files Browse the repository at this point in the history
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`.

(cherry picked from commit 17fd0ad)
  • Loading branch information
alan-agius4 committed Oct 19, 2023
1 parent 855c5b0 commit 6c3d7d1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/angular_devkit/build_angular/index.md
Expand Up @@ -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[];
Expand Down
Expand Up @@ -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),
};
}

Expand Down
Expand Up @@ -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
}
]
},
Expand Down
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion packages/schematics/angular/ssr/index.ts
Expand Up @@ -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'),
},
};
});
}
Expand Down

0 comments on commit 6c3d7d1

Please sign in to comment.