Back to Nx

Migrate Development Custom Condition

packages/js/src/migrations/update-21-5-0/migrate-development-custom-condition.md

22.7.11.8 KB
Original Source

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
json
{
  "compilerOptions": {
    "customConditions": ["development"]
  }
}
After
json
{
  "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
json
{
  "name": "@myorg/my-lib",
  "exports": {
    ".": {
      "development": "./src/index.ts",
      "default": "./dist/index.js"
    }
  }
}
After
json
{
  "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
json
{
  "name": "@myorg/my-lib",
  "exports": {
    ".": {
      "development": "./dist/index.js",
      "default": "./dist/index.js"
    }
  }
}
After
json
{
  "name": "@myorg/my-lib",
  "exports": {
    ".": {
      "development": "./dist/index.js",
      "default": "./dist/index.js"
    }
  }
}