Skip to content

Commit 62d5138

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular-devkit/build-angular): only include vendor sourcemaps when using the dev-server when the option is enabled
Prior to this change the vendor sourcemaps option was not being considered when in the vite JavaScript transformation pipeline. (cherry picked from commit 451903e)
1 parent 5772abc commit 62d5138

File tree

1 file changed

+13
-2
lines changed
  • packages/angular_devkit/build_angular/src/builders/dev-server

1 file changed

+13
-2
lines changed

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { JavaScriptTransformer } from '../../tools/esbuild/javascript-transforme
2222
import { createRxjsEsmResolutionPlugin } from '../../tools/esbuild/rxjs-esm-resolution-plugin';
2323
import { getFeatureSupport, transformSupportedBrowsersToTargets } from '../../tools/esbuild/utils';
2424
import { createAngularLocaleDataPlugin } from '../../tools/vite/i18n-locale-plugin';
25+
import { normalizeSourceMaps } from '../../utils';
2526
import { renderPage } from '../../utils/server-rendering/render-page';
2627
import { getSupportedBrowsers } from '../../utils/supported-browsers';
2728
import { getIndexOutputFile } from '../../utils/webpack-browser-config';
@@ -103,12 +104,14 @@ export async function* serveWithVite(
103104
browserOptions.forceI18nFlatOutput = true;
104105
}
105106

107+
const { vendor: thirdPartySourcemaps } = normalizeSourceMaps(browserOptions.sourceMap ?? false);
108+
106109
// Setup the prebundling transformer that will be shared across Vite prebundling requests
107110
const prebundleTransformer = new JavaScriptTransformer(
108111
// Always enable JIT linking to support applications built with and without AOT.
109112
// In a development environment the additional scope information does not
110113
// have a negative effect unlike production where final output size is relevant.
111-
{ sourcemap: true, jit: true, thirdPartySourcemaps: true },
114+
{ sourcemap: true, jit: true, thirdPartySourcemaps },
112115
1,
113116
true,
114117
);
@@ -235,6 +238,7 @@ export async function* serveWithVite(
235238
target,
236239
extensions?.middleware,
237240
transformers?.indexHtml,
241+
thirdPartySourcemaps,
238242
);
239243

240244
server = await createServer(serverConfiguration);
@@ -402,6 +406,7 @@ export async function setupServer(
402406
target: string[],
403407
extensionMiddleware?: Connect.NextHandleFunction[],
404408
indexHtmlTransformer?: (content: string) => Promise<string>,
409+
thirdPartySourcemaps = false,
405410
): Promise<InlineConfig> {
406411
const proxy = await loadProxyConfiguration(
407412
serverOptions.workspaceRoot,
@@ -480,6 +485,7 @@ export async function setupServer(
480485
ssr: true,
481486
prebundleTransformer,
482487
target,
488+
thirdPartySourcemaps,
483489
}),
484490
},
485491
plugins: [
@@ -735,6 +741,7 @@ export async function setupServer(
735741
ssr: false,
736742
prebundleTransformer,
737743
target,
744+
thirdPartySourcemaps,
738745
}),
739746
};
740747

@@ -802,17 +809,21 @@ function getDepOptimizationConfig({
802809
target,
803810
prebundleTransformer,
804811
ssr,
812+
thirdPartySourcemaps,
805813
}: {
806814
disabled: boolean;
807815
exclude: string[];
808816
include: string[];
809817
target: string[];
810818
prebundleTransformer: JavaScriptTransformer;
811819
ssr: boolean;
820+
thirdPartySourcemaps: boolean;
812821
}): DepOptimizationConfig {
813822
const plugins: ViteEsBuildPlugin[] = [
814823
{
815-
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}`,
824+
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${
825+
thirdPartySourcemaps ? '-vendor-sourcemap' : ''
826+
}`,
816827
setup(build) {
817828
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
818829
return {

0 commit comments

Comments
 (0)