Skip to content

fix(@angular/cli): skip CLI version check for migrate-only updates#32942

Open
maruthang wants to merge 2 commits intoangular:mainfrom
maruthang:fix-30696-migrate-only-version
Open

fix(@angular/cli): skip CLI version check for migrate-only updates#32942
maruthang wants to merge 2 commits intoangular:mainfrom
maruthang:fix-30696-migrate-only-version

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

@maruthang maruthang commented Apr 6, 2026

Summary

  • When running ng update @angular/cli --name=use-application-builder, the CLI fetched and installed the latest version (e.g., v20) as a temporary CLI, even though migrate-only mode operates on the currently installed package version
  • This caused incompatible packages to be installed (e.g., @angular/build@20 on an Angular 18/19 project)
  • The fix adds !options.migrateOnly to the CLI version check condition, skipping it when using --name or --migrate-only since migrations run against the installed version

Closes #30696

Test plan

  • Run ng update @angular/cli --name=use-application-builder on an Angular 19 project — should use the installed CLI, not fetch latest
  • Run ng update @angular/cli (without --name) — should still check for newer CLI version as before
  • Run ng update @angular/cli --migrate-only — should skip CLI version check

The dev server was ignoring the `sourceMap` configuration from angular.json,
always injecting inline source maps into all served files. This affected both
CSS (hardcoded `devSourcemap: true`) and JavaScript (prebundle transformer
hardcoded `sourcemap: true`), causing 2-3x file size inflation even when
source maps were explicitly disabled.

The fix passes the normalized `scripts` and `styles` source map settings
through to the Vite configuration, so that `css.devSourcemap` and the
prebundle transformer respect the user's `sourceMap` setting.

Closes angular#31331
When running `ng update @angular/cli --name=use-application-builder`,
the CLI would fetch and install the latest version (e.g., v20) as a
temporary CLI to perform the update, even though migrate-only mode
operates on the currently installed package version. This caused
incompatible packages to be installed (e.g., @angular/build@20 on
an Angular 18/19 project).

The fix skips the CLI version check when in migrate-only mode
(--name or --migrate-only), since migrations run against the
installed version and don't need a different CLI version.

Closes angular#30696
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces granular sourcemap configuration for the Vite dev server, specifically adding support for style sourcemaps, and updates the ng update command to skip version checks during migrate-only operations. Feedback indicates that the current implementation might inadvertently disable CSS sourcemaps by default, which would be a regression in developer experience. Additionally, it was noted that the JavaScriptTransformer for third-party dependencies should use the thirdPartySourcemaps setting instead of scriptsSourcemaps to ensure logical consistency and maintain existing behavior for prebundled files.

Comment on lines +149 to +153
const {
vendor: thirdPartySourcemaps,
scripts: scriptsSourcemaps,
styles: stylesSourcemaps,
} = normalizeSourceMaps(browserOptions.sourceMap ?? false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Defaulting sourceMap to false here (via ?? false) causes stylesSourcemaps to be false by default. Since stylesSourcemaps is now used to control devSourcemap in the Vite server (which was previously hardcoded to true), this change disables CSS sourcemaps by default in ng serve. To maintain the existing developer experience where CSS sourcemaps are enabled by default even if not explicitly configured in the build options, consider using a default that preserves this behavior for styles.

Suggested change
const {
vendor: thirdPartySourcemaps,
scripts: scriptsSourcemaps,
styles: stylesSourcemaps,
} = normalizeSourceMaps(browserOptions.sourceMap ?? false);
const {
vendor: thirdPartySourcemaps,
scripts: scriptsSourcemaps,
styles: stylesSourcemaps,
} = normalizeSourceMaps(browserOptions.sourceMap ?? { styles: true });
References
  1. When refactoring code that handles configuration properties, ensure that any implicit type validation previously performed is still maintained, especially if the configuration is guaranteed to be type-safe by an upstream process.

// In a development environment the additional scope information does not
// have a negative effect unlike production where final output size is relevant.
{ sourcemap: true, jit: true, thirdPartySourcemaps },
{ sourcemap: scriptsSourcemaps, jit: true, thirdPartySourcemaps },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The JavaScriptTransformer created here is specifically intended for prebundling third-party dependencies (as noted in the comment on line 186). Using scriptsSourcemaps (which corresponds to the application's script sourcemap setting) as the primary sourcemap toggle is logically incorrect for this purpose; it should use thirdPartySourcemaps to correctly respect the configuration for dependencies. Additionally, changing this from a hardcoded true to a variable that defaults to false (when sourceMap is undefined) disables sourcemaps for prebundled files by default, which is a regression in the development experience.

Suggested change
{ sourcemap: scriptsSourcemaps, jit: true, thirdPartySourcemaps },
{ sourcemap: thirdPartySourcemaps, jit: true, thirdPartySourcemaps },
References
  1. When refactoring code that handles configuration properties, ensure that any implicit type validation previously performed is still maintained, especially if the configuration is guaranteed to be type-safe by an upstream process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running the optional angular build migration installs incompatible version of @angular/build

1 participant