Skip to content

Commit f5cf028

Browse files
author
Angular Builds
committed
a957ede build: update angular
1 parent 6239d8b commit f5cf028

33 files changed

+289
-125
lines changed

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "17.2.0-next.0+sha-7c522aa",
3+
"version": "17.2.0-next.1+sha-a957ede",
44
"description": "Angular Webpack Build Facade",
55
"main": "src/index.js",
66
"typings": "src/index.d.ts",
77
"builders": "builders.json",
88
"dependencies": {
99
"@ampproject/remapping": "2.2.1",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#7c522aa",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#7c522aa",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#7c522aa",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#a957ede",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#a957ede",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#a957ede",
1313
"@babel/core": "7.23.9",
1414
"@babel/generator": "7.23.6",
1515
"@babel/helper-annotate-as-pure": "7.22.5",
@@ -20,7 +20,7 @@
2020
"@babel/preset-env": "7.23.9",
2121
"@babel/runtime": "7.23.9",
2222
"@discoveryjs/json-ext": "0.5.7",
23-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#7c522aa",
23+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#a957ede",
2424
"@vitejs/plugin-basic-ssl": "1.1.0",
2525
"ansi-colors": "4.1.3",
2626
"autoprefixer": "10.4.17",
@@ -29,42 +29,42 @@
2929
"browserslist": "^4.21.5",
3030
"copy-webpack-plugin": "12.0.2",
3131
"critters": "0.0.20",
32-
"css-loader": "6.9.1",
32+
"css-loader": "6.10.0",
3333
"esbuild-wasm": "0.20.0",
3434
"fast-glob": "3.3.2",
3535
"https-proxy-agent": "7.0.2",
3636
"http-proxy-middleware": "2.0.6",
37-
"inquirer": "9.2.13",
37+
"inquirer": "9.2.14",
3838
"jsonc-parser": "3.2.1",
3939
"karma-source-map-support": "1.4.0",
4040
"less": "4.2.0",
4141
"less-loader": "11.1.0",
4242
"license-webpack-plugin": "4.0.2",
4343
"loader-utils": "3.2.1",
44-
"magic-string": "0.30.5",
45-
"mini-css-extract-plugin": "2.7.7",
44+
"magic-string": "0.30.7",
45+
"mini-css-extract-plugin": "2.8.0",
4646
"mrmime": "2.0.0",
4747
"open": "8.4.2",
4848
"ora": "5.4.1",
4949
"parse5-html-rewriting-stream": "7.0.0",
50-
"picomatch": "3.0.1",
50+
"picomatch": "4.0.1",
5151
"piscina": "4.3.1",
52-
"postcss": "8.4.33",
52+
"postcss": "8.4.35",
5353
"postcss-loader": "8.1.0",
5454
"resolve-url-loader": "5.0.0",
5555
"rxjs": "7.8.1",
5656
"sass": "1.70.0",
5757
"sass-loader": "14.1.0",
58-
"semver": "7.5.4",
58+
"semver": "7.6.0",
5959
"source-map-loader": "5.0.0",
6060
"source-map-support": "0.5.21",
6161
"terser": "5.27.0",
6262
"tree-kill": "1.2.2",
6363
"tslib": "2.6.2",
64-
"undici": "6.5.0",
64+
"undici": "6.6.2",
6565
"vite": "5.0.12",
6666
"watchpack": "2.4.0",
67-
"webpack": "5.90.0",
67+
"webpack": "5.90.1",
6868
"webpack-dev-middleware": "6.1.1",
6969
"webpack-dev-server": "4.15.1",
7070
"webpack-merge": "5.10.0",

src/builders/application/build-action.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildSta
2626
poll?: number;
2727
signal?: AbortSignal;
2828
preserveSymlinks?: boolean;
29+
clearScreen?: boolean;
2930
}): AsyncIterable<(ExecutionResult['outputWithFiles'] | ExecutionResult['output']) & BuilderOutput>;

src/builders/application/build-action.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,21 @@ const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language")
4040
const utils_1 = require("../../tools/esbuild/utils");
4141
const delete_output_dir_1 = require("../../utils/delete-output-dir");
4242
const environment_options_1 = require("../../utils/environment-options");
43+
// Watch workspace for package manager changes
44+
const packageWatchFiles = [
45+
// manifest can affect module resolution
46+
'package.json',
47+
// npm lock file
48+
'package-lock.json',
49+
// pnpm lock file
50+
'pnpm-lock.yaml',
51+
// yarn lock file including Yarn PnP manifest files (https://yarnpkg.com/advanced/pnp-spec/)
52+
'yarn.lock',
53+
'.pnp.cjs',
54+
'.pnp.data.json',
55+
];
4356
async function* runEsBuildBuildAction(action, options) {
44-
const { writeToFileSystemFilter, writeToFileSystem, watch, poll, logger, deleteOutputPath, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, } = options;
57+
const { writeToFileSystemFilter, writeToFileSystem, watch, poll, clearScreen, logger, deleteOutputPath, cacheOptions, outputOptions, verbose, projectRoot, workspaceRoot, progress, preserveSymlinks, } = options;
4558
if (deleteOutputPath && writeToFileSystem) {
4659
await (0, delete_output_dir_1.deleteOutputDir)(workspaceRoot, outputOptions.base, [
4760
outputOptions.browser,
@@ -54,8 +67,6 @@ async function* runEsBuildBuildAction(action, options) {
5467
try {
5568
// Perform the build action
5669
result = await withProgress('Building...', () => action());
57-
// Log all diagnostic (error/warning) messages from the build
58-
await (0, utils_1.logMessages)(logger, result);
5970
}
6071
finally {
6172
// Ensure Sass workers are shutdown if not watching
@@ -95,19 +106,6 @@ async function* runEsBuildBuildAction(action, options) {
95106
if (environment_options_1.shouldWatchRoot) {
96107
watcher.add(projectRoot);
97108
}
98-
// Watch workspace for package manager changes
99-
const packageWatchFiles = [
100-
// manifest can affect module resolution
101-
'package.json',
102-
// npm lock file
103-
'package-lock.json',
104-
// pnpm lock file
105-
'pnpm-lock.yaml',
106-
// yarn lock file including Yarn PnP manifest files (https://yarnpkg.com/advanced/pnp-spec/)
107-
'yarn.lock',
108-
'.pnp.cjs',
109-
'.pnp.data.json',
110-
];
111109
watcher.add(packageWatchFiles
112110
.map((file) => node_path_1.default.join(workspaceRoot, file))
113111
.filter((file) => (0, node_fs_1.existsSync)(file)));
@@ -138,12 +136,14 @@ async function* runEsBuildBuildAction(action, options) {
138136
if (options.signal?.aborted) {
139137
break;
140138
}
139+
if (clearScreen) {
140+
// eslint-disable-next-line no-console
141+
console.clear();
142+
}
141143
if (verbose) {
142144
logger.info(changes.toDebugString());
143145
}
144146
result = await withProgress('Changes detected. Rebuilding...', () => action(result.createRebuildState(changes)));
145-
// Log all diagnostic (error/warning) messages from the rebuild
146-
await (0, utils_1.logMessages)(logger, result);
147147
// Update watched locations provided by the new build result.
148148
// Keep watching all previous files if there are any errors; otherwise consider all
149149
// files stale until confirmed present in the new result's watch files.

src/builders/application/execute-build.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ const commonjs_checker_1 = require("../../tools/esbuild/commonjs-checker");
1616
const license_extractor_1 = require("../../tools/esbuild/license-extractor");
1717
const utils_1 = require("../../tools/esbuild/utils");
1818
const bundle_calculator_1 = require("../../utils/bundle-calculator");
19-
const color_1 = require("../../utils/color");
2019
const copy_assets_1 = require("../../utils/copy-assets");
2120
const supported_browsers_1 = require("../../utils/supported-browsers");
2221
const execute_post_bundle_1 = require("./execute-post-bundle");
2322
const i18n_1 = require("./i18n");
2423
const setup_bundling_1 = require("./setup-bundling");
2524
async function executeBuild(options, context, rebuildState) {
26-
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, prerenderOptions, ssrOptions, verbose, } = options;
25+
const { projectRoot, workspaceRoot, i18nOptions, optimizationOptions, assets, cacheOptions, prerenderOptions, ssrOptions, verbose, colors, jsonLogs, } = options;
2726
// TODO: Consider integrating into watch mode. Would require full rebuild on target changes.
2827
const browsers = (0, supported_browsers_1.getSupportedBrowsers)(projectRoot, context.logger);
2928
// Load active translations if inlining
@@ -96,39 +95,33 @@ async function executeBuild(options, context, rebuildState) {
9695
executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
9796
}
9897
// Perform i18n translation inlining if enabled
99-
let prerenderedRoutes;
10098
if (i18nOptions.shouldInline) {
10199
const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
102100
executionResult.addErrors(result.errors);
103101
executionResult.addWarnings(result.warnings);
104-
prerenderedRoutes = result.prerenderedRoutes;
102+
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
105103
}
106104
else {
107105
const result = await (0, execute_post_bundle_1.executePostBundleSteps)(options, executionResult.outputFiles, executionResult.assetFiles, initialFiles,
108106
// Set lang attribute to the defined source locale if present
109107
i18nOptions.hasDefinedSourceLocale ? i18nOptions.sourceLocale : undefined);
110108
executionResult.addErrors(result.errors);
111109
executionResult.addWarnings(result.warnings);
112-
prerenderedRoutes = result.prerenderedRoutes;
110+
executionResult.addPrerenderedRoutes(result.prerenderedRoutes);
113111
executionResult.outputFiles.push(...result.additionalOutputFiles);
114112
executionResult.assetFiles.push(...result.additionalAssets);
115113
}
116114
if (prerenderOptions) {
117-
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes.sort((a, b) => a.localeCompare(b)) }, null, 2), bundler_context_1.BuildOutputFileType.Root);
118-
let prerenderMsg = `Prerendered ${prerenderedRoutes.length} static route`;
119-
if (prerenderedRoutes.length > 1) {
120-
prerenderMsg += 's.';
121-
}
122-
else {
123-
prerenderMsg += '.';
124-
}
125-
context.logger.info(color_1.colors.magenta(prerenderMsg) + '\n');
115+
const prerenderedRoutes = executionResult.prerenderedRoutes;
116+
executionResult.addOutputFile('prerendered-routes.json', JSON.stringify({ routes: prerenderedRoutes }, null, 2), bundler_context_1.BuildOutputFileType.Root);
126117
}
127-
(0, utils_1.logBuildStats)(context.logger, metafile, initialFiles, budgetFailures, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose);
128118
// Write metafile if stats option is enabled
129119
if (options.stats) {
130120
executionResult.addOutputFile('stats.json', JSON.stringify(metafile, null, 2), bundler_context_1.BuildOutputFileType.Root);
131121
}
122+
if (!jsonLogs) {
123+
context.logger.info((0, utils_1.logBuildStats)(metafile, initialFiles, budgetFailures, colors, changedFiles, estimatedTransferSizes, !!ssrOptions, verbose));
124+
}
132125
return executionResult;
133126
}
134127
exports.executeBuild = executeBuild;

src/builders/application/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
1010
exports.buildApplication = exports.buildApplicationInternal = void 0;
1111
const architect_1 = require("@angular-devkit/architect");
1212
const bundler_context_1 = require("../../tools/esbuild/bundler-context");
13+
const utils_1 = require("../../tools/esbuild/utils");
14+
const color_1 = require("../../utils/color");
1315
const purge_cache_1 = require("../../utils/purge-cache");
1416
const version_1 = require("../../utils/version");
1517
const build_action_1 = require("./build-action");
@@ -57,11 +59,25 @@ context, infrastructureSettings, extensions) {
5759
context.addTeardown(() => controller.abort('builder-teardown'));
5860
}
5961
yield* (0, build_action_1.runEsBuildBuildAction)(async (rebuildState) => {
62+
const { prerenderOptions, outputOptions, jsonLogs } = normalizedOptions;
6063
const startTime = process.hrtime.bigint();
6164
const result = await (0, execute_build_1.executeBuild)(normalizedOptions, context, rebuildState);
62-
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
63-
const status = result.errors.length > 0 ? 'failed' : 'complete';
64-
logger.info(`Application bundle generation ${status}. [${buildTime.toFixed(3)} seconds]`);
65+
if (!jsonLogs) {
66+
if (prerenderOptions) {
67+
const prerenderedRoutesLength = result.prerenderedRoutes.length;
68+
let prerenderMsg = `Prerendered ${prerenderedRoutesLength} static route`;
69+
prerenderMsg += prerenderedRoutesLength !== 1 ? 's.' : '.';
70+
logger.info(color_1.colors.magenta(prerenderMsg));
71+
}
72+
const buildTime = Number(process.hrtime.bigint() - startTime) / 10 ** 9;
73+
const hasError = result.errors.length > 0;
74+
if (writeToFileSystem && !hasError) {
75+
logger.info(`Output location: ${outputOptions.base}\n`);
76+
}
77+
logger.info(`Application bundle generation ${hasError ? 'failed' : 'complete'}. [${buildTime.toFixed(3)} seconds]`);
78+
}
79+
// Log all diagnostic (error/warning) messages
80+
await (0, utils_1.logMessages)(logger, result, normalizedOptions);
6581
return result;
6682
}, {
6783
watch: normalizedOptions.watch,
@@ -74,6 +90,7 @@ context, infrastructureSettings, extensions) {
7490
projectRoot: normalizedOptions.projectRoot,
7591
workspaceRoot: normalizedOptions.workspaceRoot,
7692
progress: normalizedOptions.progress,
93+
clearScreen: normalizedOptions.clearScreen,
7794
writeToFileSystem,
7895
// For app-shell and SSG server files are not required by users.
7996
// Omit these when SSR is not enabled.

src/builders/application/options.d.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ interface InternalOptions {
3131
* Indicates whether all node packages should be marked as external.
3232
* Currently used by the dev-server to support prebundling.
3333
*/
34-
externalPackages?: boolean;
34+
externalPackages?: boolean | {
35+
exclude: string[];
36+
};
3537
/**
3638
* Forces the output from the localize post-processing to not create nested directories per locale output.
3739
* This is only used by the development server which currently only supports a single locale per build.
@@ -72,7 +74,9 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
7274
polyfills: string[] | undefined;
7375
poll: number | undefined;
7476
progress: boolean;
75-
externalPackages: boolean | undefined;
77+
externalPackages: boolean | {
78+
exclude: string[];
79+
} | undefined;
7680
preserveSymlinks: boolean;
7781
stylePreprocessorOptions: import("./schema").StylePreprocessorOptions | undefined;
7882
subresourceIntegrity: boolean | undefined;
@@ -137,5 +141,11 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
137141
publicPath: string | undefined;
138142
plugins: Plugin[] | undefined;
139143
loaderExtensions: Record<string, "binary" | "file" | "text"> | undefined;
144+
jsonLogs: boolean;
145+
colors: boolean;
146+
clearScreen: boolean | undefined;
147+
define: {
148+
[key: string]: string;
149+
} | undefined;
140150
}>;
141151
export {};

src/builders/application/options.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const node_module_1 = require("node:module");
1717
const node_path_1 = __importDefault(require("node:path"));
1818
const helpers_1 = require("../../tools/webpack/utils/helpers");
1919
const utils_1 = require("../../utils");
20+
const color_1 = require("../../utils/color");
21+
const environment_options_1 = require("../../utils/environment-options");
2022
const i18n_options_1 = require("../../utils/i18n-options");
2123
const normalize_cache_1 = require("../../utils/normalize-cache");
2224
const package_chunk_sort_1 = require("../../utils/package-chunk-sort");
@@ -176,7 +178,7 @@ async function normalizeOptions(context, projectName, options, extensions) {
176178
};
177179
}
178180
// Initial options to keep
179-
const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, deleteOutputPath, namedChunks, budgets, deployUrl, } = options;
181+
const { allowedCommonJsDependencies, aot, baseHref, crossOrigin, externalDependencies, extractLicenses, inlineStyleLanguage = 'css', outExtension, serviceWorker, poll, polyfills, statsJson, stylePreprocessorOptions, subresourceIntegrity, verbose, watch, progress = true, externalPackages, deleteOutputPath, namedChunks, budgets, deployUrl, clearScreen, define, } = options;
180182
// Return all the normalized options
181183
return {
182184
advancedOptimizations: !!aot && optimizationOptions.scripts,
@@ -226,6 +228,10 @@ async function normalizeOptions(context, projectName, options, extensions) {
226228
publicPath: deployUrl ? deployUrl : undefined,
227229
plugins: extensions?.codePlugins?.length ? extensions?.codePlugins : undefined,
228230
loaderExtensions,
231+
jsonLogs: environment_options_1.useJSONBuildLogs,
232+
colors: color_1.colors.enabled,
233+
clearScreen,
234+
define,
229235
};
230236
}
231237
exports.normalizeOptions = normalizeOptions;

src/builders/application/schema.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,23 @@ export interface Schema {
3333
* set.
3434
*/
3535
budgets?: Budget[];
36+
/**
37+
* Automatically clear the terminal screen during rebuilds.
38+
*/
39+
clearScreen?: boolean;
3640
/**
3741
* Define the crossorigin attribute setting of elements that provide CORS support.
3842
*/
3943
crossOrigin?: CrossOrigin;
44+
/**
45+
* Defines global identifiers that will be replaced with a specified constant value when
46+
* found in any JavaScript or TypeScript code including libraries. The value will be used
47+
* directly. String values must be put in quotes. Identifiers within Angular metadata such
48+
* as Component Decorators will not be replaced.
49+
*/
50+
define?: {
51+
[key: string]: string;
52+
};
4053
/**
4154
* Delete the output path before building.
4255
*/

src/builders/application/schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@
133133
},
134134
"default": []
135135
},
136+
"clearScreen": {
137+
"type": "boolean",
138+
"default": false,
139+
"description": "Automatically clear the terminal screen during rebuilds."
140+
},
136141
"optimization": {
137142
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, inlining of critical CSS and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
138143
"default": true,
@@ -211,6 +216,13 @@
211216
"^\\.\\S+$": { "enum": ["text", "binary", "file", "empty"] }
212217
}
213218
},
219+
"define": {
220+
"description": "Defines global identifiers that will be replaced with a specified constant value when found in any JavaScript or TypeScript code including libraries. The value will be used directly. String values must be put in quotes. Identifiers within Angular metadata such as Component Decorators will not be replaced.",
221+
"type": "object",
222+
"additionalProperties": {
223+
"type": "string"
224+
}
225+
},
214226
"fileReplacements": {
215227
"description": "Replace compilation source files with other compilation source files in the build.",
216228
"type": "array",

src/builders/browser/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
120120
webpackFactory: require('webpack'),
121121
logging: transforms.logging ||
122122
((stats, config) => {
123-
if (options.verbose) {
124-
context.logger.info(stats.toString(config.stats));
123+
if (options.verbose && config.stats !== false) {
124+
const statsOptions = config.stats === true ? undefined : config.stats;
125+
context.logger.info(stats.toString(statsOptions));
125126
}
126127
}),
127128
}).pipe((0, rxjs_1.concatMap)(

0 commit comments

Comments
 (0)