Skip to content

Commit

Permalink
fix(angular): handle @nguniversal/builders and remove empty plugin op…
Browse files Browse the repository at this point in the history
…tions interface
  • Loading branch information
leosvelperez authored and jaysoo committed Sep 13, 2024
1 parent da2abd8 commit 89aa6d4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/angular/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import * as posix from 'node:path/posix';
import { hashObject } from 'nx/src/devkit-internals';
import { workspaceDataDirectory } from 'nx/src/utils/cache-directory';

export interface AngularPluginOptions {}

type AngularProjects = Record<
string,
Pick<ProjectConfiguration, 'projectType' | 'sourceRoot' | 'targets'>
Expand Down Expand Up @@ -53,9 +51,15 @@ const knownExecutors = {
]),
devServer: new Set(['@angular-devkit/build-angular:dev-server']),
extractI18n: new Set(['@angular-devkit/build-angular:extract-i18n']),
prerender: new Set(['@angular-devkit/build-angular:prerender']),
prerender: new Set([
'@angular-devkit/build-angular:prerender',
'@nguniversal/builders:prerender',
]),
server: new Set(['@angular-devkit/build-angular:server']),
serveSsr: new Set(['@angular-devkit/build-angular:ssr-dev-server']),
serveSsr: new Set([
'@angular-devkit/build-angular:ssr-dev-server',
'@nguniversal/builders:ssr-dev-server',
]),
test: new Set(['@angular-devkit/build-angular:karma']),
};

Expand All @@ -72,7 +76,7 @@ function writeProjectsToCache(
writeJsonFile(cachePath, results);
}

export const createNodesV2: CreateNodesV2<AngularPluginOptions> = [
export const createNodesV2: CreateNodesV2<{}> = [
'**/angular.json',
async (configFiles, options, context) => {
const optionsHash = hashObject(options);
Expand All @@ -97,7 +101,7 @@ export const createNodesV2: CreateNodesV2<AngularPluginOptions> = [

async function createNodesInternal(
configFilePath: string,
options: AngularPluginOptions,
options: {} | undefined,
context: CreateNodesContextV2,
projectsCache: Record<string, AngularProjects>
): Promise<CreateNodesResult> {
Expand All @@ -121,7 +125,6 @@ async function createNodesInternal(
projectsCache[hash] ??= await buildAngularProjects(
configFilePath,
angularWorkspaceRoot,
options,
context
);

Expand All @@ -131,7 +134,6 @@ async function createNodesInternal(
async function buildAngularProjects(
configFilePath: string,
angularWorkspaceRoot: string,
options: AngularPluginOptions,
context: CreateNodesContextV2
): Promise<AngularProjects> {
const projects: Record<string, AngularProjects[string] & { root: string }> =
Expand Down Expand Up @@ -444,7 +446,11 @@ function updatePrerenderTarget(
// it must exist since we collected it when processing it
const target = projects[projectName].targets[targetName];

target.metadata.help.example.options = { discoverRoutes: false };
target.metadata.help.example.options =
getAngularJsonProjectTargets(angularJson.projects[projectName])[targetName]
.builder === '@angular-devkit/build-angular:prerender'
? { discoverRoutes: false }
: { guessRoutes: false };

const { inputs, outputs } = getBrowserAndServerTargetInputsAndOutputs(
projectName,
Expand Down

0 comments on commit 89aa6d4

Please sign in to comment.