Skip to content

Commit 3bc6a83

Browse files
author
Angular Builds
committed
2c62054 build: update angular
1 parent fde6dbc commit 3bc6a83

12 files changed

+60
-58
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@angular-devkit/build-angular",
3-
"version": "18.0.0-next.0+sha-f112a0a",
3+
"version": "18.0.0-next.0+sha-2c62054",
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.3.0",
10-
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#f112a0a",
11-
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#f112a0a",
12-
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#f112a0a",
10+
"@angular-devkit/architect": "github:angular/angular-devkit-architect-builds#2c62054",
11+
"@angular-devkit/build-webpack": "github:angular/angular-devkit-build-webpack-builds#2c62054",
12+
"@angular-devkit/core": "github:angular/angular-devkit-core-builds#2c62054",
1313
"@babel/core": "7.24.0",
1414
"@babel/generator": "7.23.6",
1515
"@babel/helper-annotate-as-pure": "7.22.5",
@@ -20,7 +20,7 @@
2020
"@babel/preset-env": "7.24.0",
2121
"@babel/runtime": "7.24.0",
2222
"@discoveryjs/json-ext": "0.5.7",
23-
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#f112a0a",
23+
"@ngtools/webpack": "github:angular/ngtools-webpack-builds#2c62054",
2424
"@vitejs/plugin-basic-ssl": "1.1.0",
2525
"ansi-colors": "4.1.3",
2626
"autoprefixer": "10.4.18",

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { BuilderOutput } from '@angular-devkit/architect';
9-
import type { logging } from '@angular-devkit/core';
8+
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
109
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
1110
import { ExecutionResult, RebuildState } from '../../tools/esbuild/bundler-execution-result';
1211
import { NormalizedCachedOptions } from '../../utils/normalize-cache';
@@ -15,7 +14,7 @@ export declare function runEsBuildBuildAction(action: (rebuildState?: RebuildSta
1514
workspaceRoot: string;
1615
projectRoot: string;
1716
outputOptions: NormalizedOutputOptions;
18-
logger: logging.LoggerApi;
17+
logger: BuilderContext['logger'];
1918
cacheOptions: NormalizedCachedOptions;
2019
writeToFileSystem: boolean;
2120
writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;

src/tools/esbuild/utils.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { logging } from '@angular-devkit/core';
8+
import { BuilderContext } from '@angular-devkit/architect';
99
import { BuildOptions, Metafile, OutputFile } from 'esbuild';
1010
import { NormalizedApplicationBuildOptions, NormalizedOutputOptions } from '../../builders/application/options';
1111
import { BudgetCalculatorResult } from '../../utils/bundle-calculator';
@@ -38,4 +38,4 @@ export declare function transformSupportedBrowsersToTargets(supportedBrowsers: s
3838
*/
3939
export declare function getSupportedNodeTargets(): string[];
4040
export declare function createJsonBuildManifest(result: ExecutionResult, normalizedOptions: NormalizedApplicationBuildOptions): Promise<string>;
41-
export declare function logMessages(logger: logging.LoggerApi, executionResult: ExecutionResult, color?: boolean, jsonLogs?: boolean): Promise<void>;
41+
export declare function logMessages(logger: BuilderContext['logger'], executionResult: ExecutionResult, color?: boolean, jsonLogs?: boolean): Promise<void>;

src/utils/i18n-options.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { BuilderContext } from '@angular-devkit/architect';
9-
import { json } from '@angular-devkit/core';
109
import { Schema as BrowserBuilderSchema, I18NTranslation } from '../builders/browser/schema';
1110
import { Schema as ServerBuilderSchema } from '../builders/server/schema';
1211
import { TranslationLoader } from './load-translations';
@@ -28,7 +27,9 @@ export interface I18nOptions {
2827
readonly shouldInline: boolean;
2928
hasDefinedSourceLocale?: boolean;
3029
}
31-
export declare function createI18nOptions(metadata: json.JsonObject, inline?: boolean | string[]): I18nOptions;
30+
export declare function createI18nOptions(projectMetadata: {
31+
i18n?: unknown;
32+
}, inline?: boolean | string[]): I18nOptions;
3233
export declare function configureI18nBuild<T extends BrowserBuilderSchema | ServerBuilderSchema>(context: BuilderContext, options: T): Promise<{
3334
buildOptions: T;
3435
i18n: I18nOptions;

src/utils/i18n-options.js

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1111
};
1212
Object.defineProperty(exports, "__esModule", { value: true });
1313
exports.loadTranslations = exports.configureI18nBuild = exports.createI18nOptions = void 0;
14-
const core_1 = require("@angular-devkit/core");
15-
const fs_1 = __importDefault(require("fs"));
16-
const module_1 = __importDefault(require("module"));
17-
const os_1 = __importDefault(require("os"));
18-
const path_1 = __importDefault(require("path"));
14+
const node_fs_1 = __importDefault(require("node:fs"));
15+
const node_module_1 = require("node:module");
16+
const node_os_1 = __importDefault(require("node:os"));
17+
const node_path_1 = __importDefault(require("node:path"));
1918
const schema_1 = require("../builders/browser/schema");
2019
const read_tsconfig_1 = require("../utils/read-tsconfig");
2120
const load_translations_1 = require("./load-translations");
@@ -39,11 +38,19 @@ function normalizeTranslationFileOption(option, locale, expectObjectInError) {
3938
}
4039
throw new Error(errorMessage);
4140
}
42-
function createI18nOptions(metadata, inline) {
43-
if (metadata.i18n !== undefined && !core_1.json.isJsonObject(metadata.i18n)) {
44-
throw new Error('Project i18n field is malformed. Expected an object.');
41+
function ensureObject(value, name) {
42+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
43+
throw new Error(`Project ${name} field is malformed. Expected an object.`);
4544
}
46-
metadata = metadata.i18n || {};
45+
}
46+
function ensureString(value, name) {
47+
if (typeof value !== 'string') {
48+
throw new Error(`Project ${name} field is malformed. Expected a string.`);
49+
}
50+
}
51+
function createI18nOptions(projectMetadata, inline) {
52+
const { i18n: metadata = {} } = projectMetadata;
53+
ensureObject(metadata, 'i18n');
4754
const i18n = {
4855
inlineLocales: new Set(),
4956
// en-US is the default locale added to Angular applications (https://angular.io/guide/i18n#i18n-pipes)
@@ -55,38 +62,37 @@ function createI18nOptions(metadata, inline) {
5562
};
5663
let rawSourceLocale;
5764
let rawSourceLocaleBaseHref;
58-
if (core_1.json.isJsonObject(metadata.sourceLocale)) {
59-
rawSourceLocale = metadata.sourceLocale.code;
60-
if (metadata.sourceLocale.baseHref !== undefined &&
61-
typeof metadata.sourceLocale.baseHref !== 'string') {
62-
throw new Error('Project i18n sourceLocale baseHref field is malformed. Expected a string.');
63-
}
64-
rawSourceLocaleBaseHref = metadata.sourceLocale.baseHref;
65-
}
66-
else {
65+
if (typeof metadata.sourceLocale === 'string') {
6766
rawSourceLocale = metadata.sourceLocale;
6867
}
69-
if (rawSourceLocale !== undefined) {
70-
if (typeof rawSourceLocale !== 'string') {
71-
throw new Error('Project i18n sourceLocale field is malformed. Expected a string.');
68+
else if (metadata.sourceLocale !== undefined) {
69+
ensureObject(metadata.sourceLocale, 'i18n sourceLocale');
70+
if (metadata.sourceLocale.code !== undefined) {
71+
ensureString(metadata.sourceLocale.code, 'i18n sourceLocale code');
72+
rawSourceLocale = metadata.sourceLocale.code;
73+
}
74+
if (metadata.sourceLocale.baseHref !== undefined) {
75+
ensureString(metadata.sourceLocale.baseHref, 'i18n sourceLocale baseHref');
76+
rawSourceLocaleBaseHref = metadata.sourceLocale.baseHref;
7277
}
78+
}
79+
if (rawSourceLocale !== undefined) {
7380
i18n.sourceLocale = rawSourceLocale;
7481
i18n.hasDefinedSourceLocale = true;
7582
}
7683
i18n.locales[i18n.sourceLocale] = {
7784
files: [],
7885
baseHref: rawSourceLocaleBaseHref,
7986
};
80-
if (metadata.locales !== undefined && !core_1.json.isJsonObject(metadata.locales)) {
81-
throw new Error('Project i18n locales field is malformed. Expected an object.');
82-
}
83-
else if (metadata.locales) {
87+
if (metadata.locales !== undefined) {
88+
ensureObject(metadata.locales, 'i18n locales');
8489
for (const [locale, options] of Object.entries(metadata.locales)) {
8590
let translationFiles;
8691
let baseHref;
87-
if (core_1.json.isJsonObject(options)) {
92+
if (options && typeof options === 'object' && 'translation' in options) {
8893
translationFiles = normalizeTranslationFileOption(options.translation, locale, false);
89-
if (typeof options.baseHref === 'string') {
94+
if ('baseHref' in options) {
95+
ensureString(options.baseHref, `i18n locales ${locale} baseHref`);
9096
baseHref = options.baseHref;
9197
}
9298
}
@@ -129,10 +135,10 @@ async function configureI18nBuild(context, options) {
129135
if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
130136
return { buildOptions, i18n };
131137
}
132-
const projectRoot = path_1.default.join(context.workspaceRoot, metadata.root || '');
138+
const projectRoot = node_path_1.default.join(context.workspaceRoot, metadata.root || '');
133139
// The trailing slash is required to signal that the path is a directory and not a file.
134-
const projectRequire = module_1.default.createRequire(projectRoot + '/');
135-
const localeResolver = (locale) => projectRequire.resolve(path_1.default.join(LOCALE_DATA_BASE_MODULE, locale));
140+
const projectRequire = (0, node_module_1.createRequire)(projectRoot + '/');
141+
const localeResolver = (locale) => projectRequire.resolve(node_path_1.default.join(LOCALE_DATA_BASE_MODULE, locale));
136142
// Load locale data and translations (if present)
137143
let loader;
138144
const usedFormats = new Set();
@@ -177,11 +183,11 @@ async function configureI18nBuild(context, options) {
177183
if (i18n.shouldInline) {
178184
// TODO: we should likely save these in the .angular directory in the next major version.
179185
// We'd need to do a migration to add the temp directory to gitignore.
180-
const tempPath = fs_1.default.mkdtempSync(path_1.default.join(fs_1.default.realpathSync(os_1.default.tmpdir()), 'angular-cli-i18n-'));
186+
const tempPath = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_fs_1.default.realpathSync(node_os_1.default.tmpdir()), 'angular-cli-i18n-'));
181187
buildOptions.outputPath = tempPath;
182188
process.on('exit', () => {
183189
try {
184-
fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
190+
node_fs_1.default.rmSync(tempPath, { force: true, recursive: true, maxRetries: 3 });
185191
}
186192
catch { }
187193
});
@@ -203,7 +209,7 @@ function findLocaleDataPath(locale, resolver) {
203209
function loadTranslations(locale, desc, workspaceRoot, loader, logger, usedFormats, duplicateTranslation) {
204210
let translations = undefined;
205211
for (const file of desc.files) {
206-
const loadResult = loader(path_1.default.join(workspaceRoot, file.path));
212+
const loadResult = loader(node_path_1.default.join(workspaceRoot, file.path));
207213
for (const diagnostics of loadResult.diagnostics.messages) {
208214
if (diagnostics.type === 'error') {
209215
logger.error(`Error parsing translation file '${file.path}': ${diagnostics.message}`);

src/utils/normalize-asset-patterns.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { BaseException } from '@angular-devkit/core';
98
import { AssetPattern, AssetPatternClass } from '../builders/browser/schema';
10-
export declare class MissingAssetSourceRootException extends BaseException {
9+
export declare class MissingAssetSourceRootException extends Error {
1110
constructor(path: string);
1211
}
1312
export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): AssetPatternClass[];

src/utils/normalize-asset-patterns.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
3131
};
3232
Object.defineProperty(exports, "__esModule", { value: true });
3333
exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
34-
const core_1 = require("@angular-devkit/core");
3534
const fs_1 = require("fs");
3635
const path = __importStar(require("path"));
37-
class MissingAssetSourceRootException extends core_1.BaseException {
36+
class MissingAssetSourceRootException extends Error {
3837
constructor(path) {
3938
super(`The ${path} asset path must start with the project source root.`);
4039
}

src/utils/normalize-file-replacements.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { BaseException } from '@angular-devkit/core';
98
import { FileReplacement } from '../builders/browser/schema';
10-
export declare class MissingFileReplacementException extends BaseException {
9+
export declare class MissingFileReplacementException extends Error {
1110
constructor(path: string);
1211
}
1312
export interface NormalizedFileReplacement {

src/utils/normalize-file-replacements.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
3131
};
3232
Object.defineProperty(exports, "__esModule", { value: true });
3333
exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
34-
const core_1 = require("@angular-devkit/core");
3534
const fs_1 = require("fs");
3635
const path = __importStar(require("path"));
37-
class MissingFileReplacementException extends core_1.BaseException {
36+
class MissingFileReplacementException extends Error {
3837
constructor(path) {
3938
super(`The ${path} path in file replacements does not exist.`);
4039
}

src/utils/supported-browsers.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { logging } from '@angular-devkit/core';
9-
export declare function getSupportedBrowsers(projectRoot: string, logger: logging.LoggerApi): string[];
8+
export declare function getSupportedBrowsers(projectRoot: string, logger: {
9+
warn(message: string): void;
10+
}): string[];

0 commit comments

Comments
 (0)