Back to Nx

Update Module Resolution

packages/angular/src/migrations/update-21-2-0/update-module-resolution.md

22.7.11.1 KB
Original Source

Update moduleResolution to bundler in TypeScript configurations

Updates the TypeScript moduleResolution option to 'bundler' for improved compatibility with modern package resolution algorithms used by bundlers like Webpack, Vite, and esbuild.

Examples

The migration will update TypeScript configuration files in your workspace to use the 'bundler' module resolution strategy:

Before
json
{
  "compilerOptions": {
    "module": "es2020",
    "moduleResolution": "node"
  }
}
After
json
{
  "compilerOptions": {
    "module": "es2020",
    "moduleResolution": "bundler"
  }
}

If the moduleResolution is already set to 'bundler' or the module is set to 'preserve', the migration will not modify the configuration:

Before
json
{
  "compilerOptions": {
    "module": "preserve",
    "moduleResolution": "node"
  }
}
After
json
{
  "compilerOptions": {
    "module": "preserve",
    "moduleResolution": "node"
  }
}