Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/angular/build/src/builders/dev-server/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ export async function* serveWithVite(
browserOptions.forceI18nFlatOutput = true;
}

const { vendor: thirdPartySourcemaps, scripts: scriptsSourcemaps } = normalizeSourceMaps(
browserOptions.sourceMap ?? false,
);
const {
vendor: thirdPartySourcemaps,
scripts: scriptsSourcemaps,
styles: stylesSourcemaps,
} = normalizeSourceMaps(browserOptions.sourceMap ?? false);
Comment on lines +149 to +153
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.


if (scriptsSourcemaps && browserOptions.server) {
// https://un5zrke0g2qx6zm5.julianrbryant.com/api/process.html#processsetsourcemapsenabledval
Expand Down Expand Up @@ -184,7 +186,7 @@ export async function* serveWithVite(
// Always enable JIT linking to support applications built with and without AOT.
// 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.

1,
);

Expand Down Expand Up @@ -428,6 +430,7 @@ export async function* serveWithVite(
extensions?.middleware,
transformers?.indexHtml,
thirdPartySourcemaps,
stylesSourcemaps,
);

server = await createServer(serverConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export async function setupServer(
extensionMiddleware?: Connect.NextHandleFunction[],
indexHtmlTransformer?: (content: string) => Promise<string>,
thirdPartySourcemaps = false,
stylesSourcemaps = true,
): Promise<InlineConfig> {
const { normalizePath } = await import('vite');

Expand Down Expand Up @@ -175,7 +176,7 @@ export async function setupServer(
// We use custom as we do not rely on Vite's htmlFallbackMiddleware and indexHtmlMiddleware.
appType: 'custom',
css: {
devSourcemap: true,
devSourcemap: stylesSourcemaps,
},
// Ensure custom 'file' loader build option entries are handled by Vite in application code that
// reference third-party libraries. Relative usage is handled directly by the build and not Vite.
Expand Down
4 changes: 3 additions & 1 deletion packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs

// Check if the current installed CLI version is older than the latest compatible version.
// Skip when running `ng update` without a package name as this will not trigger an actual update.
if (!disableVersionCheck && options.packages?.length) {
// Also skip when using migrate-only mode (--name or --migrate-only) since migrations run
// against the currently installed package version, not a remote one.
if (!disableVersionCheck && options.packages?.length && !options.migrateOnly) {
const cliVersionToInstall = await checkCLIVersion(
options.packages,
logger,
Expand Down
Loading