@@ -22,6 +22,7 @@ import { JavaScriptTransformer } from '../../tools/esbuild/javascript-transforme
22
22
import { createRxjsEsmResolutionPlugin } from '../../tools/esbuild/rxjs-esm-resolution-plugin' ;
23
23
import { getFeatureSupport , transformSupportedBrowsersToTargets } from '../../tools/esbuild/utils' ;
24
24
import { createAngularLocaleDataPlugin } from '../../tools/vite/i18n-locale-plugin' ;
25
+ import { normalizeSourceMaps } from '../../utils' ;
25
26
import { renderPage } from '../../utils/server-rendering/render-page' ;
26
27
import { getSupportedBrowsers } from '../../utils/supported-browsers' ;
27
28
import { getIndexOutputFile } from '../../utils/webpack-browser-config' ;
@@ -103,12 +104,14 @@ export async function* serveWithVite(
103
104
browserOptions . forceI18nFlatOutput = true ;
104
105
}
105
106
107
+ const { vendor : thirdPartySourcemaps } = normalizeSourceMaps ( browserOptions . sourceMap ?? false ) ;
108
+
106
109
// Setup the prebundling transformer that will be shared across Vite prebundling requests
107
110
const prebundleTransformer = new JavaScriptTransformer (
108
111
// Always enable JIT linking to support applications built with and without AOT.
109
112
// In a development environment the additional scope information does not
110
113
// 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 } ,
112
115
1 ,
113
116
true ,
114
117
) ;
@@ -235,6 +238,7 @@ export async function* serveWithVite(
235
238
target ,
236
239
extensions ?. middleware ,
237
240
transformers ?. indexHtml ,
241
+ thirdPartySourcemaps ,
238
242
) ;
239
243
240
244
server = await createServer ( serverConfiguration ) ;
@@ -402,6 +406,7 @@ export async function setupServer(
402
406
target : string [ ] ,
403
407
extensionMiddleware ?: Connect . NextHandleFunction [ ] ,
404
408
indexHtmlTransformer ?: ( content : string ) => Promise < string > ,
409
+ thirdPartySourcemaps = false ,
405
410
) : Promise < InlineConfig > {
406
411
const proxy = await loadProxyConfiguration (
407
412
serverOptions . workspaceRoot ,
@@ -480,6 +485,7 @@ export async function setupServer(
480
485
ssr : true ,
481
486
prebundleTransformer,
482
487
target,
488
+ thirdPartySourcemaps,
483
489
} ) ,
484
490
} ,
485
491
plugins : [
@@ -735,6 +741,7 @@ export async function setupServer(
735
741
ssr : false ,
736
742
prebundleTransformer,
737
743
target,
744
+ thirdPartySourcemaps,
738
745
} ) ,
739
746
} ;
740
747
@@ -802,17 +809,21 @@ function getDepOptimizationConfig({
802
809
target,
803
810
prebundleTransformer,
804
811
ssr,
812
+ thirdPartySourcemaps,
805
813
} : {
806
814
disabled : boolean ;
807
815
exclude : string [ ] ;
808
816
include : string [ ] ;
809
817
target : string [ ] ;
810
818
prebundleTransformer : JavaScriptTransformer ;
811
819
ssr : boolean ;
820
+ thirdPartySourcemaps : boolean ;
812
821
} ) : DepOptimizationConfig {
813
822
const plugins : ViteEsBuildPlugin [ ] = [
814
823
{
815
- name : `angular-vite-optimize-deps${ ssr ? '-ssr' : '' } ` ,
824
+ name : `angular-vite-optimize-deps${ ssr ? '-ssr' : '' } ${
825
+ thirdPartySourcemaps ? '-vendor-sourcemap' : ''
826
+ } `,
816
827
setup ( build ) {
817
828
build . onLoad ( { filter : / \. [ c m ] ? j s $ / } , async ( args ) => {
818
829
return {
0 commit comments