@@ -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 { loadEsmModule } from '../../utils/load-esm' ;
26
27
import { renderPage } from '../../utils/server-rendering/render-page' ;
27
28
import { getSupportedBrowsers } from '../../utils/supported-browsers' ;
@@ -104,12 +105,14 @@ export async function* serveWithVite(
104
105
browserOptions . forceI18nFlatOutput = true ;
105
106
}
106
107
108
+ const { vendor : thirdPartySourcemaps } = normalizeSourceMaps ( browserOptions . sourceMap ?? false ) ;
109
+
107
110
// Setup the prebundling transformer that will be shared across Vite prebundling requests
108
111
const prebundleTransformer = new JavaScriptTransformer (
109
112
// Always enable JIT linking to support applications built with and without AOT.
110
113
// In a development environment the additional scope information does not
111
114
// have a negative effect unlike production where final output size is relevant.
112
- { sourcemap : true , jit : true , thirdPartySourcemaps : true } ,
115
+ { sourcemap : true , jit : true , thirdPartySourcemaps } ,
113
116
1 ,
114
117
true ,
115
118
) ;
@@ -237,6 +240,7 @@ export async function* serveWithVite(
237
240
browserOptions . loader as EsbuildLoaderOption | undefined ,
238
241
extensions ?. middleware ,
239
242
transformers ?. indexHtml ,
243
+ thirdPartySourcemaps ,
240
244
) ;
241
245
242
246
server = await createServer ( serverConfiguration ) ;
@@ -405,6 +409,7 @@ export async function setupServer(
405
409
prebundleLoaderExtensions : EsbuildLoaderOption | undefined ,
406
410
extensionMiddleware ?: Connect . NextHandleFunction [ ] ,
407
411
indexHtmlTransformer ?: ( content : string ) => Promise < string > ,
412
+ thirdPartySourcemaps = false ,
408
413
) : Promise < InlineConfig > {
409
414
const proxy = await loadProxyConfiguration (
410
415
serverOptions . workspaceRoot ,
@@ -484,6 +489,7 @@ export async function setupServer(
484
489
prebundleTransformer,
485
490
target,
486
491
loader : prebundleLoaderExtensions ,
492
+ thirdPartySourcemaps,
487
493
} ) ,
488
494
} ,
489
495
plugins : [
@@ -740,6 +746,7 @@ export async function setupServer(
740
746
prebundleTransformer,
741
747
target,
742
748
loader : prebundleLoaderExtensions ,
749
+ thirdPartySourcemaps,
743
750
} ) ,
744
751
} ;
745
752
@@ -810,6 +817,7 @@ function getDepOptimizationConfig({
810
817
prebundleTransformer,
811
818
ssr,
812
819
loader,
820
+ thirdPartySourcemaps,
813
821
} : {
814
822
disabled : boolean ;
815
823
exclude : string [ ] ;
@@ -818,10 +826,13 @@ function getDepOptimizationConfig({
818
826
prebundleTransformer : JavaScriptTransformer ;
819
827
ssr : boolean ;
820
828
loader ?: EsbuildLoaderOption ;
829
+ thirdPartySourcemaps : boolean ;
821
830
} ) : DepOptimizationConfig {
822
831
const plugins : ViteEsBuildPlugin [ ] = [
823
832
{
824
- name : `angular-vite-optimize-deps${ ssr ? '-ssr' : '' } ` ,
833
+ name : `angular-vite-optimize-deps${ ssr ? '-ssr' : '' } ${
834
+ thirdPartySourcemaps ? '-vendor-sourcemap' : ''
835
+ } `,
825
836
setup ( build ) {
826
837
build . onLoad ( { filter : / \. [ c m ] ? j s $ / } , async ( args ) => {
827
838
return {
0 commit comments