Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/generated/manifests/new-nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,16 @@
}
},
"migrations": {
"/technologies/angular/api/migrations/set-tsconfig-option": {
"description": "Set the 'tsConfig' option to build and test targets to help with Angular migration issues.",
"file": "generated/packages/angular/migrations/set-tsconfig-option.json",
"hidden": false,
"name": "set-tsconfig-option",
"version": "21.5.0-beta.0",
"originalFilePath": "/packages/angular",
"path": "/technologies/angular/api/migrations/set-tsconfig-option",
"type": "migration"
},
"/technologies/angular/api/migrations/21.4.0-ngrx-package-updates": {
"description": "",
"file": "generated/packages/angular/migrations/21.4.0-ngrx-package-updates.json",
Expand Down
10 changes: 10 additions & 0 deletions docs/generated/packages-metadata.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "set-tsconfig-option",
"version": "21.5.0-beta.0",
"description": "Set the 'tsConfig' option to build and test targets to help with Angular migration issues.",
"factory": "./src/migrations/update-21-5-0/set-tsconfig-option",
"implementation": "/packages/angular/src/migrations/update-21-5-0/set-tsconfig-option.ts",
"aliases": [],
"hidden": false,
"path": "/packages/angular",
"schema": null,
"type": "migration",
"examplesFile": "#### Set `tsConfig` option for build and test targets\n\n- Set the `tsConfig` option in the target options for library build executors. It moves the value from the target `development` configuration and it doesn't set it if the option is already set.\n- Set `tsconfig.spec.json` as the `tsConfig` option in the target options for the `@nx/jest:jest` executor. It only does it if the file exists and the options is not already set.\n\n#### Examples\n\nThe migration will move the `tsConfig` option for library build executors (`@nx/angular:ng-packagr-lite` and `@nx/angular:package`) from the `development` configuration to the target options if it's not already set:\n\n{% tabs %}\n{% tab label=\"Before\" %}\n\n```json {% fileName=\"libs/lib1/project.json\" highlightLines=[\"7\"] %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:ng-packagr-lite\",\n \"configurations\": {\n \"development\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.dev.json\"\n }\n }\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"After\" %}\n\n```json {% fileName=\"libs/lib1/project.json\" highlightLines=[\"6\",\"9\"] %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:ng-packagr-lite\",\n \"options\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.dev.json\"\n },\n \"configurations\": {\n \"development\": {}\n }\n }\n }\n}\n```\n\n{% /tab %}\n{% /tabs %}\n\nThe migration will set the `tsConfig` option for the `@nx/jest:jest` executor when the `tsconfig.spec.json` file exists and the option is not already set:\n\n{% tabs %}\n{% tab label=\"Before\" %}\n\n```json {% fileName=\"apps/app1/project.json\" %}\n{\n \"targets\": {\n \"test\": {\n \"executor\": \"@nx/jest:jest\"\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"After\" %}\n\n```json {% fileName=\"apps/app1/project.json\" highlightLines=[\"6\"] %}\n{\n \"targets\": {\n \"test\": {\n \"executor\": \"@nx/jest:jest\",\n \"options\": {\n \"tsConfig\": \"apps/app1/tsconfig.spec.json\"\n }\n }\n }\n}\n```\n\n{% /tab %}\n{% /tabs %}\n\nIf the `tsConfig` option is already set in the target options, the migration will not modify the configuration:\n\n{% tabs %}\n{% tab label=\"Before\" %}\n\n```json {% fileName=\"libs/lib1/project.json\" highlightLines=[\"6\", \"10\"] %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:ng-packagr-lite\",\n \"options\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.json\"\n },\n \"configurations\": {\n \"development\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.dev.json\"\n }\n }\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"After\" %}\n\n```json {% fileName=\"libs/lib1/project.json\" highlightLines=[\"6\", \"10\"] %}\n{\n \"targets\": {\n \"build\": {\n \"executor\": \"@nx/angular:ng-packagr-lite\",\n \"options\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.json\"\n },\n \"configurations\": {\n \"development\": {\n \"tsConfig\": \"libs/lib1/tsconfig.lib.dev.json\"\n }\n }\n }\n }\n}\n```\n\n{% /tab %}\n{% /tabs %}\n"
}
6 changes: 6 additions & 0 deletions docs/generated/packages/jest/executors/jest.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
"type": "string",
"$default": { "$source": "argv", "index": 0 }
},
"tsConfig": {
"description": "The path to the TypeScript configuration file, relative to the workspace root. Note this is only metadata used by Angular migrations. This executor does not use it.",
"type": "string",
"x-completion-type": "file",
"x-completion-glob": "tsconfig.*.json"
},
"setupFile": {
"description": "The name of a setup file used by Jest.",
"type": "string",
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@
},
"description": "Update the @angular/cli package version to ~20.1.0.",
"factory": "./src/migrations/update-21-3-0/update-angular-cli"
},
"set-tsconfig-option": {
"version": "21.5.0-beta.0",
"description": "Set the 'tsConfig' option to build and test targets to help with Angular migration issues.",
"factory": "./src/migrations/update-21-5-0/set-tsconfig-option"
}
},
"packageJsonUpdates": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`app --minimal should generate a correct setup when --bundler=rspack and ssr 1`] = `
"
Expand Down Expand Up @@ -942,6 +942,7 @@ exports[`app nested should create project configs 1`] = `
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "my-dir/my-app/jest.config.ts",
"tsConfig": "my-dir/my-app/tsconfig.spec.json",
},
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}",
Expand Down Expand Up @@ -1058,6 +1059,7 @@ exports[`app not nested should create project configs 1`] = `
"executor": "@nx/jest:jest",
"options": {
"jestConfig": "my-app/jest.config.ts",
"tsConfig": "my-app/tsconfig.spec.json",
},
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}",
Expand Down
5 changes: 2 additions & 3 deletions packages/angular/src/generators/library/lib/add-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ export async function addProject(
outputs: ['{workspaceRoot}/dist/{projectRoot}'],
options: {
project: `${libraryOptions.projectRoot}/ng-package.json`,
tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
},
configurations: {
production: {
tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.prod.json`,
},
development: {
tsConfig: `${libraryOptions.projectRoot}/tsconfig.lib.json`,
},
development: {},
},
defaultConfiguration: 'production',
};
Expand Down
132 changes: 132 additions & 0 deletions packages/angular/src/migrations/update-21-5-0/set-tsconfig-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#### Set `tsConfig` option for build and test targets

- Set the `tsConfig` option in the target options for library build executors. It moves the value from the target `development` configuration and it doesn't set it if the option is already set.
- Set `tsconfig.spec.json` as the `tsConfig` option in the target options for the `@nx/jest:jest` executor. It only does it if the file exists and the options is not already set.

#### Examples

The migration will move the `tsConfig` option for library build executors (`@nx/angular:ng-packagr-lite` and `@nx/angular:package`) from the `development` configuration to the target options if it's not already set:

{% tabs %}
{% tab label="Before" %}

```json {% fileName="libs/lib1/project.json" highlightLines=["7"] %}
{
"targets": {
"build": {
"executor": "@nx/angular:ng-packagr-lite",
"configurations": {
"development": {
"tsConfig": "libs/lib1/tsconfig.lib.dev.json"
}
}
}
}
}
```

{% /tab %}

{% tab label="After" %}

```json {% fileName="libs/lib1/project.json" highlightLines=["6","9"] %}
{
"targets": {
"build": {
"executor": "@nx/angular:ng-packagr-lite",
"options": {
"tsConfig": "libs/lib1/tsconfig.lib.dev.json"
},
"configurations": {
"development": {}
}
}
}
}
```

{% /tab %}
{% /tabs %}

The migration will set the `tsConfig` option for the `@nx/jest:jest` executor when the `tsconfig.spec.json` file exists and the option is not already set:

{% tabs %}
{% tab label="Before" %}

```json {% fileName="apps/app1/project.json" %}
{
"targets": {
"test": {
"executor": "@nx/jest:jest"
}
}
}
```

{% /tab %}

{% tab label="After" %}

```json {% fileName="apps/app1/project.json" highlightLines=["6"] %}
{
"targets": {
"test": {
"executor": "@nx/jest:jest",
"options": {
"tsConfig": "apps/app1/tsconfig.spec.json"
}
}
}
}
```

{% /tab %}
{% /tabs %}

If the `tsConfig` option is already set in the target options, the migration will not modify the configuration:

{% tabs %}
{% tab label="Before" %}

```json {% fileName="libs/lib1/project.json" highlightLines=["6", "10"] %}
{
"targets": {
"build": {
"executor": "@nx/angular:ng-packagr-lite",
"options": {
"tsConfig": "libs/lib1/tsconfig.lib.json"
},
"configurations": {
"development": {
"tsConfig": "libs/lib1/tsconfig.lib.dev.json"
}
}
}
}
}
```

{% /tab %}

{% tab label="After" %}

```json {% fileName="libs/lib1/project.json" highlightLines=["6", "10"] %}
{
"targets": {
"build": {
"executor": "@nx/angular:ng-packagr-lite",
"options": {
"tsConfig": "libs/lib1/tsconfig.lib.json"
},
"configurations": {
"development": {
"tsConfig": "libs/lib1/tsconfig.lib.dev.json"
}
}
}
}
}
```

{% /tab %}
{% /tabs %}
Loading
Loading