@nx/js - Migrations
The @nx/js plugin provides various migrations to help you migrate to newer versions of js projects within your Nx workspace. Below is a complete reference for all available migrations.
22.0.x
remove-external-options-from-js-executors
Version: 22.0.0-beta.0
Remove the deprecated external
and externalBuildTargets
options from the @nx/js:swc
and @nx/js:tsc
executors.
Remove the external
and externalBuildTargets
Options from the @nx/js:swc
and @nx/js:tsc
Executors
Remove the deprecated external
and externalBuildTargets
options from the @nx/js:swc
and @nx/js:tsc
executors. These options were used for inlining dependencies, which was an experimental feature and has been deprecated for a long time. The migration only removes the options from the project configuration and target defaults. If you rely on inlining dependencies, you need to make sure they are all buildable or use a different build tool that supports bundling.
Sample Code Changes
Remove external
and externalBuildTargets
from the @nx/js:swc
or @nx/js:tsc
executor options in project configuration.
Before
{ "targets": { "build": { "executor": "@nx/js:swc", "options": { "main": "libs/my-lib/src/index.ts", "outputPath": "dist/libs/my-lib", "tsConfig": "libs/my-lib/tsconfig.lib.json", "external": ["react", "react-dom"], "externalBuildTargets": ["build"] } } }}
After
{ "targets": { "build": { "executor": "@nx/js:swc", "options": { "main": "libs/my-lib/src/index.ts", "outputPath": "dist/libs/my-lib", "tsConfig": "libs/my-lib/tsconfig.lib.json" } } }}
Remove external
and externalBuildTargets
from the @nx/js:swc
or @nx/js:tsc
executor target defaults in nx.json
.
Before
{ "targetDefaults": { "@nx/js:swc": { "options": { "main": "{projectRoot}/src/index.ts", "outputPath": "dist/{projectRoot}", "tsConfig": "{projectRoot}/tsconfig.lib.json", "external": "all", "externalBuildTargets": ["build"] } } }}
After
{ "targetDefaults": { "@nx/js:swc": { "options": { "main": "{projectRoot}/src/index.ts", "outputPath": "dist/{projectRoot}", "tsConfig": "{projectRoot}/tsconfig.lib.json" } } }}
21.5.x
migrate-development-custom-condition
Version: 21.5.0-beta.2
Migrate the legacy ‘development’ custom condition to a workspace-unique custom condition name.
Migrate development
custom condition to unique workspace-specific name
Replace the TypeScript development
custom condition with a unique workspace-specific name to avoid conflicts when consuming packages in other workspaces.
Examples
The migration will update the custom condition name in both tsconfig.base.json
and all workspace package.json files that use the development
custom condition:
Before
{ "compilerOptions": { "customConditions": ["development"] }}
After
{ "compilerOptions": { "customConditions": ["@my-org/source"] // assuming the root package.json name is `@my-org/source` }}
The migration also updates package.json
files that use the development
condition in their exports
field and point to TypeScript files:
Before
{ "name": "@myorg/my-lib", "exports": { ".": { "development": "./src/index.ts", "default": "./dist/index.js" } }}
After
{ "name": "@myorg/my-lib", "exports": { ".": { "@my-org/source": "./src/index.ts", "default": "./dist/index.js" } }}
If the custom condition is not set to ["development"]
or the package.json
’s exports
field doesn’t point to TypeScript files, the migration will not modify the configuration:
Before
{ "name": "@myorg/my-lib", "exports": { ".": { "development": "./dist/index.js", "default": "./dist/index.js" } }}
After
{ "name": "@myorg/my-lib", "exports": { ".": { "development": "./dist/index.js", "default": "./dist/index.js" } }}
21.5.0-package-updates
Version: 21.5.0-beta.2
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
typescript | ~5.9.2 | Updated only |
21.2.x
21.2.0-package-updates
Version: 21.2.0-beta.0
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
typescript | ~5.8.2 | Updated only |
20.7.x
20.7.1-beta.0-package-updates
Version: 20.7.1-beta.0
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
@swc/cli | ~0.6.0 | Updated only |
20.5.x
20.5.0-package-updates
Version: 20.5.0-beta.3
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
verdaccio | ^6.0.5 | Updated only |
20.4.x
20.4.0-package-updates
Version: 20.4.0-beta.1
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
typescript | ~5.7.2 | Updated only |
20.2.x
20.2.0-package-updates
Version: 20.2.0-beta.5
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
typescript | ~5.6.2 | Updated only |
19.5.x
19.5.1-package-updates
Version: 19.5.0-beta.1
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
typescript | ~5.5.2 | Updated only |
19.2.x
19.2.0-package-updates
Version: 19.2.0-beta.0
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
@swc/core | ~1.5.7 | Updated only |
@swc/helpers | ~0.5.11 | Updated only |
@swc-node/register | ~1.9.1 | Updated only |
19.0.x
19.0.0-package-updates
Version: 19.0.0-beta.0
Packages
The following packages will be updated:
Name | Version | Always add to package.json |
---|---|---|
@swc/cli | ~0.3.12 | Updated only |