Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/public-api/angular/build/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export type ExtractI18nBuilderOptions = {
// @public
export type NgPackagrBuilderOptions = {
poll?: number;
project: string;
project?: string;
tsConfig?: string;
watch?: boolean;
};
Expand Down
18 changes: 11 additions & 7 deletions packages/angular/build/src/builders/ng-packagr/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function* execute(
// Purge old build disk cache.
await purgeStaleBuildCache(context);

const root = context.workspaceRoot;
const workspaceRoot = context.workspaceRoot;
let packager;
try {
packager = (await import('ng-packagr')).ngPackagr();
Expand All @@ -47,18 +47,22 @@ export async function* execute(
throw error;
}

packager.forProject(resolve(root, options.project));

if (options.tsConfig) {
packager.withTsConfig(resolve(root, options.tsConfig));
}

const projectName = context.target?.project;
if (!projectName) {
throw new Error('The builder requires a target.');
}

const metadata = await context.getProjectMetadata(projectName);
const ngPackagrConfig = options.project
? join(workspaceRoot, options.project)
: join(workspaceRoot, (metadata.root as string | undefined) ?? '', 'ng-package.json');

packager.forProject(ngPackagrConfig);

if (options.tsConfig) {
packager.withTsConfig(resolve(workspaceRoot, options.tsConfig));
}

const { enabled: cacheEnabled, path: cacheDirectory } = normalizeCacheOptions(
metadata,
context.workspaceRoot,
Expand Down
3 changes: 1 addition & 2 deletions packages/angular/build/src/builders/ng-packagr/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@
"description": "Enable and define the file watching poll time period in milliseconds."
}
},
"additionalProperties": false,
"required": ["project"]
"additionalProperties": false
}
3 changes: 0 additions & 3 deletions packages/schematics/angular/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ function addLibToWorkspaceFile(
build: {
builder: Builders.BuildNgPackagr,
defaultConfiguration: 'production',
options: {
project: `${projectRoot}/ng-package.json`,
},
configurations: {
production: {
tsConfig: `${projectRoot}/tsconfig.lib.prod.json`,
Expand Down
1 change: 0 additions & 1 deletion packages/schematics/angular/library/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ describe('Library Schematic', () => {
const project = config.projects.foo;
expect(project.root).toEqual('foo');
const { options, configurations } = project.architect.build;
expect(options.project).toEqual('foo/ng-package.json');
expect(configurations.production.tsConfig).toEqual('foo/tsconfig.lib.prod.json');

const libTsConfig = getJsonFileContent(tree, '/foo/tsconfig.lib.json');
Expand Down