Skip to content

Commit

Permalink
fix(angular): honor buildableProjectDepsInPackageJsonType in angula… (
Browse files Browse the repository at this point in the history
#4760)

Fixes the angular:package builder to honor the `buildableProjectDepsInPackageJsonType` setting. It was previously ignored.
  • Loading branch information
mhodgson committed Feb 19, 2021
1 parent 95848ca commit 5ee2874
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
10 changes: 10 additions & 0 deletions docs/angular/api-angular/executors/ng-packagr-lite.md
Expand Up @@ -6,6 +6,16 @@ Properties can be configured in angular.json when defining the executor, or when

## Properties

### buildableProjectDepsInPackageJsonType

Default: `peerDependencies`

Type: `string`

Possible values: `dependencies`, `peerDependencies`

When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`

### project

Type: `string`
Expand Down
10 changes: 10 additions & 0 deletions docs/node/api-angular/executors/ng-packagr-lite.md
Expand Up @@ -7,6 +7,16 @@ Read more about how to use executors and the CLI here: https://nx.dev/node/guide

## Properties

### buildableProjectDepsInPackageJsonType

Default: `peerDependencies`

Type: `string`

Possible values: `dependencies`, `peerDependencies`

When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`

### project

Type: `string`
Expand Down
10 changes: 10 additions & 0 deletions docs/react/api-angular/executors/ng-packagr-lite.md
Expand Up @@ -7,6 +7,16 @@ Read more about how to use executors and the CLI here: https://nx.dev/react/guid

## Properties

### buildableProjectDepsInPackageJsonType

Default: `peerDependencies`

Type: `string`

Possible values: `dependencies`, `peerDependencies`

When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`

### project

Type: `string`
Expand Down
7 changes: 3 additions & 4 deletions e2e/angular/src/angular-library.test.ts
Expand Up @@ -148,7 +148,7 @@ import { names } from '@nrwl/devkit';
checkFilesExist(`dist/libs/${childLib}/package.json`);
});

it('should properly add references to any dependency into the parent package.json', () => {
it('aaashould properly add references to any dependency into the parent package.json', () => {
runCLI(`build ${childLib}`);
runCLI(`build ${childLib2}`);
runCLI(`build ${parentLib}`);
Expand All @@ -160,11 +160,10 @@ import { names } from '@nrwl/devkit';
);

const jsonFile = readJson(`dist/libs/${parentLib}/package.json`);
// expect(jsonFile.dependencies).toEqual({ tslib: '^2.0.0' });

expect(jsonFile.dependencies['tslib']).toEqual('^2.0.0');
expect(jsonFile.dependencies[`@${proj}/${childLib}`]).toBeDefined();
expect(jsonFile.dependencies[`@${proj}/${childLib2}`]).toBeDefined();
expect(jsonFile.peerDependencies[`@${proj}/${childLib}`]).toBeDefined();
expect(jsonFile.peerDependencies[`@${proj}/${childLib2}`]).toBeDefined();
expect(jsonFile.peerDependencies['@angular/common']).toBeDefined();
expect(jsonFile.peerDependencies['@angular/core']).toBeDefined();
});
Expand Down
6 changes: 6 additions & 0 deletions packages/angular/src/builders/ng-packagr-lite/schema.json
Expand Up @@ -21,6 +21,12 @@
"type": "boolean",
"description": "Update buildable project dependencies in package.json",
"default": true
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When updateBuildableProjectDepsInPackageJson is true, this adds dependencies to either `peerDependencies` or `dependencies`",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
}
},
"additionalProperties": false,
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/src/builders/package/package.impl.ts
Expand Up @@ -90,7 +90,8 @@ export function createLibraryBuilder(
updateBuildableProjectPackageJsonDependencies(
context,
target,
dependencies
dependencies,
options.buildableProjectDepsInPackageJsonType
);
}
}),
Expand Down

0 comments on commit 5ee2874

Please sign in to comment.