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
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ function migrateTargetOptions(
delete buildTarget.configurations?.['development']?.['tsConfig'];
}

if (ngPackageConfig?.dest && typeof buildTarget.options['outputPath'] !== 'string') {
buildTarget.options['outputPath'] = join(projectDir, ngPackageConfig.dest);
if (typeof buildTarget.options['outputPath'] !== 'string') {
// `ng-packagr` writes to `dist` within the package directory when `dest` is not set.
buildTarget.options['outputPath'] = join(projectDir, ngPackageConfig?.dest ?? 'dist');
}

if (ngPackageConfig?.assets?.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ describe('Migration to use the library builder', () => {
expect(newTree.exists('/projects/my-lib/ng-package.json')).toBe(false);
});

it('should keep the default ng-packagr output path when dest is not set', async () => {
tree.overwrite(
'/projects/my-lib/ng-package.json',
JSON.stringify({ lib: { entryFile: 'src/public-api.ts' } }),
);

const newTree = await schematicRunner.runSchematic(schematicName, {}, tree);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { projects } = newTree.readJson('/angular.json') as any;
expect(projects['my-lib'].architect['build'].options.outputPath).toBe('projects/my-lib/dist');
});

it('should migrate @angular/build:ng-packagr and promote tsConfig from development configuration', async () => {
const angularJson = JSON.parse(tree.readContent('/angular.json'));
angularJson.projects['my-lib'].architect.build = {
Expand Down
Loading