Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): cache server build #13933

Merged
merged 1 commit into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,7 +2,9 @@ import type { Tree } from '@nrwl/devkit';
import {
joinPathFragments,
readProjectConfiguration,
readWorkspaceConfiguration,
updateProjectConfiguration,
updateWorkspaceConfiguration,
} from '@nrwl/devkit';
import type { Schema } from '../schema';

Expand Down Expand Up @@ -72,4 +74,18 @@ export function updateProjectConfig(tree: Tree, schema: Schema) {
};

updateProjectConfiguration(tree, schema.project, projectConfig);

const workspaceConfig = readWorkspaceConfiguration(tree);
if (
workspaceConfig.tasksRunnerOptions?.default &&
!workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations.includes(
'server'
)
) {
workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations = [
...workspaceConfig.tasksRunnerOptions.default.options.cacheableOperations,
'server',
];
updateWorkspaceConfiguration(tree, workspaceConfig);
}
}
18 changes: 18 additions & 0 deletions packages/angular/src/generators/setup-ssr/setup-ssr.spec.ts
@@ -1,4 +1,5 @@
import {
NxJsonConfiguration,
readJson,
readProjectConfiguration,
updateProjectConfiguration,
Expand Down Expand Up @@ -130,6 +131,23 @@ describe('setupSSR', () => {
for (const [dep, version] of Object.entries(devDeps)) {
expect(packageJson.devDependencies[dep]).toEqual(version);
}
const nxJson = readJson<NxJsonConfiguration>(tree, 'nx.json');
expect(nxJson.tasksRunnerOptions).toMatchInlineSnapshot(`
Object {
"default": Object {
"options": Object {
"cacheableOperations": Array [
"build",
"lint",
"test",
"e2e",
"server",
],
},
"runner": "nx/tasks-runners/default",
},
}
`);
});

it('should use fileReplacements if they already exist', async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/generators/setup-ssr/setup-ssr.ts
Expand Up @@ -168,7 +168,9 @@ export async function setupSsrGenerator(tree: Tree, options: Schema) {
const workspace = readWorkspaceConfiguration(tree);
if (
workspace.tasksRunnerOptions?.default &&
!workspace.tasksRunnerOptions.default.options.cacheableOperations['server']
!workspace.tasksRunnerOptions.default.options.cacheableOperations.includes(
'server'
)
) {
workspace.tasksRunnerOptions.default.options.cacheableOperations = [
...workspace.tasksRunnerOptions.default.options.cacheableOperations,
Expand Down