99Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1010exports . executeBuild = void 0 ;
1111const source_file_cache_1 = require ( "../../tools/esbuild/angular/source-file-cache" ) ;
12- const application_code_bundle_1 = require ( "../../tools/esbuild/application-code-bundle" ) ;
1312const budget_stats_1 = require ( "../../tools/esbuild/budget-stats" ) ;
1413const bundler_context_1 = require ( "../../tools/esbuild/bundler-context" ) ;
1514const bundler_execution_result_1 = require ( "../../tools/esbuild/bundler-execution-result" ) ;
1615const commonjs_checker_1 = require ( "../../tools/esbuild/commonjs-checker" ) ;
17- const global_scripts_1 = require ( "../../tools/esbuild/global-scripts" ) ;
18- const global_styles_1 = require ( "../../tools/esbuild/global-styles" ) ;
1916const license_extractor_1 = require ( "../../tools/esbuild/license-extractor" ) ;
2017const utils_1 = require ( "../../tools/esbuild/utils" ) ;
2118const bundle_calculator_1 = require ( "../../utils/bundle-calculator" ) ;
@@ -24,11 +21,11 @@ const copy_assets_1 = require("../../utils/copy-assets");
2421const supported_browsers_1 = require ( "../../utils/supported-browsers" ) ;
2522const execute_post_bundle_1 = require ( "./execute-post-bundle" ) ;
2623const i18n_1 = require ( "./i18n" ) ;
27- // eslint-disable-next-line max-lines-per-function
24+ const setup_bundling_1 = require ( "./setup-bundling" ) ;
2825async function executeBuild ( options , context , rebuildState ) {
29- const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, serverEntryPoint, assets, cacheOptions, prerenderOptions, appShellOptions, ssrOptions, } = options ;
26+ const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, prerenderOptions, } = options ;
27+ // TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
3028 const browsers = ( 0 , supported_browsers_1 . getSupportedBrowsers ) ( projectRoot , context . logger ) ;
31- const target = ( 0 , utils_1 . transformSupportedBrowsersToTargets ) ( browsers ) ;
3229 // Load active translations if inlining
3330 // TODO: Integrate into watch mode and only load changed translations
3431 if ( i18nOptions . shouldInline ) {
@@ -39,53 +36,11 @@ async function executeBuild(options, context, rebuildState) {
3936 const codeBundleCache = rebuildState ?. codeBundleCache ??
4037 new source_file_cache_1 . SourceFileCache ( cacheOptions . enabled ? cacheOptions . path : undefined ) ;
4138 if ( bundlerContexts === undefined ) {
42- bundlerContexts = [ ] ;
43- // Browser application code
44- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , ( 0 , application_code_bundle_1 . createBrowserCodeBundleOptions ) ( options , target , codeBundleCache ) ) ) ;
45- // Browser polyfills code
46- const browserPolyfillBundleOptions = ( 0 , application_code_bundle_1 . createBrowserPolyfillBundleOptions ) ( options , target , codeBundleCache ) ;
47- if ( browserPolyfillBundleOptions ) {
48- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , browserPolyfillBundleOptions ) ) ;
49- }
50- // Global Stylesheets
51- if ( options . globalStyles . length > 0 ) {
52- for ( const initial of [ true , false ] ) {
53- const bundleOptions = ( 0 , global_styles_1 . createGlobalStylesBundleOptions ) ( options , target , initial ) ;
54- if ( bundleOptions ) {
55- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , bundleOptions , ( ) => initial ) ) ;
56- }
57- }
58- }
59- // Global Scripts
60- if ( options . globalScripts . length > 0 ) {
61- for ( const initial of [ true , false ] ) {
62- const bundleOptions = ( 0 , global_scripts_1 . createGlobalScriptsBundleOptions ) ( options , target , initial ) ;
63- if ( bundleOptions ) {
64- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , bundleOptions , ( ) => initial ) ) ;
65- }
66- }
67- }
68- // Skip server build when none of the features are enabled.
69- if ( serverEntryPoint && ( prerenderOptions || appShellOptions || ssrOptions ) ) {
70- const nodeTargets = [ ...target , ...( 0 , utils_1 . getSupportedNodeTargets ) ( ) ] ;
71- // Server application code
72- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , ( 0 , application_code_bundle_1 . createServerCodeBundleOptions ) ( {
73- ...options ,
74- // Disable external deps for server bundles.
75- // This is because it breaks Vite 'optimizeDeps' for SSR.
76- externalPackages : false ,
77- } , nodeTargets , codeBundleCache ) , ( ) => false ) ) ;
78- // Server polyfills code
79- const serverPolyfillBundleOptions = ( 0 , application_code_bundle_1 . createServerPolyfillBundleOptions ) ( options , nodeTargets , codeBundleCache ) ;
80- if ( serverPolyfillBundleOptions ) {
81- bundlerContexts . push ( new bundler_context_1 . BundlerContext ( workspaceRoot , ! ! options . watch , serverPolyfillBundleOptions , ( ) => false ) ) ;
82- }
83- }
39+ bundlerContexts = ( 0 , setup_bundling_1 . setupBundlerContexts ) ( options , browsers , codeBundleCache ) ;
8440 }
8541 const bundlingResult = await bundler_context_1 . BundlerContext . bundleAll ( bundlerContexts , rebuildState ?. fileChanges . all ) ;
86- // Log all warnings and errors generated during bundling
87- await ( 0 , utils_1 . logMessages ) ( context , bundlingResult ) ;
8842 const executionResult = new bundler_execution_result_1 . ExecutionResult ( bundlerContexts , codeBundleCache ) ;
43+ executionResult . addWarnings ( bundlingResult . warnings ) ;
8944 // Return if the bundling has errors
9045 if ( bundlingResult . errors ) {
9146 executionResult . addErrors ( bundlingResult . errors ) ;
@@ -169,8 +124,7 @@ async function executeBuild(options, context, rebuildState) {
169124 }
170125 context . logger . info ( color_1 . colors . magenta ( prerenderMsg ) + '\n' ) ;
171126 }
172- ( 0 , utils_1 . logBuildStats ) ( context , metafile , initialFiles , budgetFailures , changedFiles , estimatedTransferSizes ) ;
173- await ( 0 , utils_1 . logMessages ) ( context , executionResult ) ;
127+ ( 0 , utils_1 . logBuildStats ) ( context . logger , metafile , initialFiles , budgetFailures , changedFiles , estimatedTransferSizes ) ;
174128 // Write metafile if stats option is enabled
175129 if ( options . stats ) {
176130 executionResult . addOutputFile ( 'stats.json' , JSON . stringify ( metafile , null , 2 ) , bundler_context_1 . BuildOutputFileType . Root ) ;
0 commit comments