Skip to content

Commit

Permalink
feat(misc): deprecate executor options to generate package.json for l…
Browse files Browse the repository at this point in the history
…ibraries (#17923)
  • Loading branch information
leosvelperez authored Jul 11, 2023
1 parent 8be6558 commit 95a2256
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 68 deletions.
12 changes: 5 additions & 7 deletions docs/generated/packages/angular/executors/ng-packagr-lite.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
},
{
"name": "Updating Project Dependencies for Buildable Library",
"keys": [
"project",
"updateBuildableProjectDepsInPackageJson",
"buildableProjectDepsInPackageJsonType"
]
"keys": ["project"]
}
],
"properties": {
Expand All @@ -43,13 +39,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"tailwindConfig": {
"type": "string",
Expand Down
10 changes: 5 additions & 5 deletions docs/generated/packages/angular/executors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
{
"name": "Updating Project Dependencies for Publishable Library",
"keys": [
"project",
"updateBuildableProjectDepsInPackageJson",
"buildableProjectDepsInPackageJsonType"
"project"
]
}
],
Expand All @@ -46,7 +44,8 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
Expand All @@ -55,7 +54,8 @@
"dependencies",
"peerDependencies"
],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"tailwindConfig": {
"type": "string",
Expand Down
6 changes: 4 additions & 2 deletions docs/generated/packages/js/executors/swc.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
Expand Down
6 changes: 4 additions & 2 deletions docs/generated/packages/js/executors/tsc.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
Expand Down
22 changes: 6 additions & 16 deletions docs/generated/packages/rollup/executors/rollup.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
"description": "Packages a library for different web usages (ESM, CommonJS).",
"cli": "nx",
"type": "object",
"presets": [
{
"name": "Including Dependencies in package.json",
"keys": [
"main",
"outputPath",
"project",
"tsConfig",
"buildableProjectDepsInPackageJsonType",
"updateBuildableProjectDepsInPackageJson"
]
}
],
"properties": {
"project": {
"type": "string",
Expand Down Expand Up @@ -84,13 +71,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Update buildable project dependencies in `package.json`.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"rollupConfig": {
"oneOf": [
Expand Down Expand Up @@ -203,7 +192,8 @@
]
}
},
"examplesFile": "{% tabs %}\n{% tab label=\"Including Dependencies\" %}\nTo include dependencies in the output `package.json`, the dependencies must be installed as a **dependencies** in the root `package.json`\n\n```json {% fileName=\"package.json\" %}\n{\n \"dependencies\": {\n \"some-dependency\": \"^1.0.0\"\n }\n}\n```\n\nTo have dependencies in the be listed in the final `package.json` of your project, set the `updateBuildableProjectDepsInPackageJson` option to `true`. After than dependencies will be added to the `peerDependencies` field of the output `package.json`. You can use `buildableProjectDepsInPackageJsonType` option to change which field the dependencies are output to.\n\n```json {% fileName=\"project.json\" %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"buildableProjectDepsInPackageJsonType\": \"dependencies\",\n \"updateBuildableProjectDepsInPackageJson\": true\n }\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Using `babelUpwardRootMode`\" %}\n\nCopying from the [Babel documentation](https://babeljs.io/docs/config-files#root-babelconfigjson-file):\n\n> [...] if you are running your Babel compilation process from within a subpackage, you need to tell Babel where to look for the config. There are a few ways to do that, but the recommended way is the \"rootMode\" option with \"upward\", which will make Babel search from the working directory upward looking for your babel.config.json file, and will use its location as the \"root\" value.\n\nSetting `babelUpwardRootMode` to `true` in your `project.json` will set `rootMode` option to `upward` in the Babel config. You may want the `upward` mode in a monorepo when projects must apply their individual `.babelrc` file. We recommend that you don't set it at all, so it will use the default to `false` as the `upward` mode brings additional complexity to the build process.\n\n```json\n//...\n\"my-app\": {\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"babelUpwardRootMode\": true,\n //...\n },\n //...\n },\n //...\n },\n //...\n}\n```\n\nWhen `babelUpwardRootMode` is `true`, Babel will look for a root `babel.config.json` at the root of the workspace, which should look something like this to include all packages:\n\n```json\n{ \"babelrcRoots\": [\"*\"] }\n```\n\nThen for each package, you must have a `.babelrc` file that will be applied to that package. For example:\n\n```json\n{\n \"presets\": [\"@babel/preset-env\", \"@babel/preset-typescript\"]\n}\n```\n\nAll packages will use its own `.babelrc` file, thus you must ensure the right presets and plugins are set in each config file. This behavior can lead to build discrepancies between packages, so we recommend that you don't set `babelUpwardRootMode` at all.\n\n```treeview\n├── packages\n│ ├── a\n│ │ └── .babelrc\n│ └── b\n│ └── .babelrc\n└── babel.config.json\n```\n\nIn workspace above, if `a` imports `b`, it will apply the config `packages/b/.babelrc` and not apply its own `packages/a/.babelrc` to `b`. Anything in `babel.config.json` will apply to all packages.\n\n{% /tab %}\n\n{% /tabs %}\n"
"examplesFile": "{% tabs %}\n{% tab label=\"Including Dependencies\" %}\nTo include dependencies in the output `package.json`, the dependencies must be installed as a **dependencies** in the root `package.json`\n\n```json {% fileName=\"package.json\" %}\n{\n \"dependencies\": {\n \"some-dependency\": \"^1.0.0\"\n }\n}\n```\n\nTo have dependencies in the be listed in the final `package.json` of your project, set the `updateBuildableProjectDepsInPackageJson` option to `true`. After than dependencies will be added to the `peerDependencies` field of the output `package.json`. You can use `buildableProjectDepsInPackageJsonType` option to change which field the dependencies are output to.\n\n```json {% fileName=\"project.json\" %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"buildableProjectDepsInPackageJsonType\": \"dependencies\",\n \"updateBuildableProjectDepsInPackageJson\": true\n }\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Using `babelUpwardRootMode`\" %}\n\nCopying from the [Babel documentation](https://babeljs.io/docs/config-files#root-babelconfigjson-file):\n\n> [...] if you are running your Babel compilation process from within a subpackage, you need to tell Babel where to look for the config. There are a few ways to do that, but the recommended way is the \"rootMode\" option with \"upward\", which will make Babel search from the working directory upward looking for your babel.config.json file, and will use its location as the \"root\" value.\n\nSetting `babelUpwardRootMode` to `true` in your `project.json` will set `rootMode` option to `upward` in the Babel config. You may want the `upward` mode in a monorepo when projects must apply their individual `.babelrc` file. We recommend that you don't set it at all, so it will use the default to `false` as the `upward` mode brings additional complexity to the build process.\n\n```json\n//...\n\"my-app\": {\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n \"babelUpwardRootMode\": true,\n //...\n },\n //...\n },\n //...\n },\n //...\n}\n```\n\nWhen `babelUpwardRootMode` is `true`, Babel will look for a root `babel.config.json` at the root of the workspace, which should look something like this to include all packages:\n\n```json\n{ \"babelrcRoots\": [\"*\"] }\n```\n\nThen for each package, you must have a `.babelrc` file that will be applied to that package. For example:\n\n```json\n{\n \"presets\": [\"@babel/preset-env\", \"@babel/preset-typescript\"]\n}\n```\n\nAll packages will use its own `.babelrc` file, thus you must ensure the right presets and plugins are set in each config file. This behavior can lead to build discrepancies between packages, so we recommend that you don't set `babelUpwardRootMode` at all.\n\n```treeview\n├── packages\n│ ├── a\n│ │ └── .babelrc\n│ └── b\n│ └── .babelrc\n└── babel.config.json\n```\n\nIn workspace above, if `a` imports `b`, it will apply the config `packages/b/.babelrc` and not apply its own `packages/a/.babelrc` to `b`. Anything in `babel.config.json` will apply to all packages.\n\n{% /tab %}\n\n{% /tabs %}\n",
"presets": []
},
"description": "Bundle a package using Rollup.",
"aliases": [],
Expand Down
12 changes: 5 additions & 7 deletions packages/angular/src/executors/ng-packagr-lite/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
},
{
"name": "Updating Project Dependencies for Buildable Library",
"keys": [
"project",
"updateBuildableProjectDepsInPackageJson",
"buildableProjectDepsInPackageJsonType"
]
"keys": ["project"]
}
],
"properties": {
Expand All @@ -40,13 +36,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"tailwindConfig": {
"type": "string",
Expand Down
10 changes: 10 additions & 0 deletions packages/angular/src/executors/package/schema.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
export interface BuildAngularLibraryExecutorOptions {
project: string;
/**
* @deprecated Configure the project to use the `@nx/dependency-checks` ESLint
* rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).
* It will be removed in v17.
*/
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
tailwindConfig?: string;
tsConfig?: string;
/**
* @deprecated Configure the project to use the `@nx/dependency-checks` ESLint
* rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).
* It will be removed in v17.
*/
updateBuildableProjectDepsInPackageJson?: boolean;
watch?: boolean;
}
12 changes: 5 additions & 7 deletions packages/angular/src/executors/package/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
},
{
"name": "Updating Project Dependencies for Publishable Library",
"keys": [
"project",
"updateBuildableProjectDepsInPackageJson",
"buildableProjectDepsInPackageJsonType"
]
"keys": ["project"]
}
],
"properties": {
Expand All @@ -40,13 +36,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"tailwindConfig": {
"type": "string",
Expand Down
9 changes: 8 additions & 1 deletion packages/esbuild/src/executors/esbuild/esbuild.impl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dotenv/config';
import * as chalk from 'chalk';
import type { ExecutorContext } from '@nx/devkit';
import { cacheDir, joinPathFragments, logger } from '@nx/devkit';
import { cacheDir, joinPathFragments, logger, stripIndents } from '@nx/devkit';
import {
copyAssets,
copyPackageJson,
Expand Down Expand Up @@ -74,6 +74,13 @@ export async function* esbuildExecutor(

let packageJsonResult;
if (options.generatePackageJson) {
if (context.projectGraph.nodes[context.projectName].type !== 'app') {
logger.warn(
stripIndents`The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.
For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).`
);
}

const cpjOptions: CopyPackageJsonOptions = {
...options,
// TODO(jack): make types generate with esbuild
Expand Down
6 changes: 4 additions & 2 deletions packages/js/src/executors/swc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
Expand Down
6 changes: 4 additions & 2 deletions packages/js/src/executors/tsc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
"updateBuildableProjectDepsInPackageJson": {
"type": "boolean",
"description": "Whether to update the buildable project dependencies in the build output package.json.",
"default": false
"default": false,
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"buildableProjectDepsInPackageJsonType": {
"type": "string",
"description": "When `updateBuildableProjectDepsInPackageJson` is `true`, this adds dependencies to either `peerDependencies` or `dependencies`.",
"enum": ["dependencies", "peerDependencies"],
"default": "peerDependencies"
"default": "peerDependencies",
"x-deprecated": "Configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks). It will be removed in v17."
},
"external": {
"description": "A list projects to be treated as external. This feature is experimental",
Expand Down
Loading

1 comment on commit 95a2256

@vercel
Copy link

@vercel vercel bot commented on 95a2256 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.