Back to Nx

Remove Nx Tsconfig Paths Webpack Plugin Import

packages/webpack/src/migrations/update-23-0-0/remove-nx-tsconfig-paths-webpack-plugin-import.md

23.0.01.7 KB
Original Source

Rewrite NxTsconfigPathsWebpackPlugin Imports to the @nx/webpack/tsconfig-paths-plugin Sub-path

The deprecated re-export of NxTsconfigPathsWebpackPlugin from @nx/webpack is removed in v23. The migration rewrites both ES module imports and CJS require() calls to use the @nx/webpack/tsconfig-paths-plugin sub-path. Imports that combine the deprecated symbol with other named imports are split into two declarations so the rest of the original import still resolves from @nx/webpack. Aliases (as Plugin, : Plugin) are preserved.

Sample Code Changes

ES module import.

Before
ts
import { NxTsconfigPathsWebpackPlugin } from '@nx/webpack';

export default { plugins: [new NxTsconfigPathsWebpackPlugin()] };
After
ts
import { NxTsconfigPathsWebpackPlugin } from '@nx/webpack/tsconfig-paths-plugin';

export default { plugins: [new NxTsconfigPathsWebpackPlugin()] };

ES module import combined with other named imports.

Before
ts
import { NxTsconfigPathsWebpackPlugin, NxAppWebpackPlugin } from '@nx/webpack';
After
ts
import { NxTsconfigPathsWebpackPlugin } from '@nx/webpack/tsconfig-paths-plugin';
import { NxAppWebpackPlugin } from '@nx/webpack';

CJS require().

Before
js
const { NxTsconfigPathsWebpackPlugin } = require('@nx/webpack');
After
js
const {
  NxTsconfigPathsWebpackPlugin,
} = require('@nx/webpack/tsconfig-paths-plugin');