@angular-devkit/build-angular 17.3.2 → 18.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +33 -33
  2. package/src/builders/app-shell/index.js +1 -1
  3. package/src/builders/application/build-action.d.ts +2 -3
  4. package/src/builders/application/options.d.ts +3 -1
  5. package/src/builders/application/schema.d.ts +1 -1
  6. package/src/builders/application/schema.json +2 -1
  7. package/src/builders/browser/schema.d.ts +1 -1
  8. package/src/builders/browser/schema.json +2 -1
  9. package/src/builders/browser-esbuild/schema.d.ts +1 -1
  10. package/src/builders/browser-esbuild/schema.json +2 -1
  11. package/src/builders/dev-server/builder.d.ts +0 -2
  12. package/src/builders/dev-server/vite-server.js +14 -7
  13. package/src/builders/dev-server/webpack-server.js +1 -1
  14. package/src/builders/karma/schema.d.ts +1 -1
  15. package/src/builders/karma/schema.json +2 -1
  16. package/src/builders/prerender/index.d.ts +2 -3
  17. package/src/builders/server/schema.d.ts +1 -1
  18. package/src/builders/server/schema.json +2 -1
  19. package/src/builders/ssr-dev-server/utils.d.ts +1 -2
  20. package/src/builders/web-test-runner/schema.d.ts +1 -1
  21. package/src/builders/web-test-runner/schema.json +2 -1
  22. package/src/tools/babel/plugins/adjust-static-class-members.js +3 -6
  23. package/src/tools/babel/plugins/index.d.ts +11 -0
  24. package/src/tools/babel/plugins/index.js +21 -0
  25. package/src/tools/babel/presets/application.js +4 -3
  26. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -2
  27. package/src/tools/esbuild/javascript-transformer-worker.js +82 -26
  28. package/src/tools/esbuild/utils.d.ts +2 -2
  29. package/src/tools/esbuild/utils.js +1 -1
  30. package/src/tools/vite/angular-memory-plugin.js +5 -7
  31. package/src/tools/webpack/configs/dev-server.js +20 -11
  32. package/src/tools/webpack/configs/styles.js +22 -53
  33. package/src/tools/webpack/plugins/builder-watch-plugin.js +2 -2
  34. package/src/tools/webpack/plugins/styles-webpack-plugin.js +1 -1
  35. package/src/tools/webpack/utils/helpers.js +1 -1
  36. package/src/utils/environment-options.d.ts +0 -1
  37. package/src/utils/environment-options.js +1 -11
  38. package/src/utils/i18n-options.d.ts +3 -2
  39. package/src/utils/i18n-options.js +39 -33
  40. package/src/utils/index-file/inline-fonts.d.ts +0 -4
  41. package/src/utils/index-file/inline-fonts.js +3 -5
  42. package/src/utils/normalize-asset-patterns.d.ts +4 -3
  43. package/src/utils/normalize-asset-patterns.js +7 -3
  44. package/src/utils/normalize-cache.d.ts +1 -2
  45. package/src/utils/normalize-cache.js +15 -9
  46. package/src/utils/normalize-file-replacements.d.ts +1 -2
  47. package/src/utils/normalize-file-replacements.js +1 -2
  48. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -2
  49. package/src/utils/server-rendering/prerender.js +11 -3
  50. package/src/utils/service-worker.d.ts +2 -2
  51. package/src/utils/supported-browsers.d.ts +3 -2
  52. package/src/utils/webpack-browser-config.d.ts +1 -2
  53. package/src/tools/sass/sass-service-legacy.d.ts +0 -51
  54. package/src/tools/sass/sass-service-legacy.js +0 -173
  55. package/src/tools/sass/worker-legacy.d.ts +0 -8
  56. package/src/tools/sass/worker-legacy.js +0 -43
  57. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.d.ts +0 -10
  58. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +0 -39
@@ -5,7 +5,7 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { logging } from '@angular-devkit/core';
8
+ import { BuilderContext } from '@angular-devkit/architect';
9
9
  import { BuildOptions, Metafile, OutputFile } from 'esbuild';
10
10
  import { NormalizedApplicationBuildOptions, NormalizedOutputOptions } from '../../builders/application/options';
11
11
  import { BudgetCalculatorResult } from '../../utils/bundle-calculator';
@@ -38,4 +38,4 @@ export declare function transformSupportedBrowsersToTargets(supportedBrowsers: s
38
38
  */
39
39
  export declare function getSupportedNodeTargets(): string[];
40
40
  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>;
@@ -331,7 +331,7 @@ function transformSupportedBrowsersToTargets(supportedBrowsers) {
331
331
  return transformed;
332
332
  }
333
333
  exports.transformSupportedBrowsersToTargets = transformSupportedBrowsersToTargets;
334
- const SUPPORTED_NODE_VERSIONS = '^18.13.0 || >=20.9.0';
334
+ const SUPPORTED_NODE_VERSIONS = '^18.19.1 || >=20.11.1';
335
335
  /**
336
336
  * Transform supported Node.js versions to esbuild target.
337
337
  * @see https://esbuild.github.io/api/#target
@@ -232,13 +232,11 @@ exports.createAngularMemoryPlugin = createAngularMemoryPlugin;
232
232
  */
233
233
  async function loadViteClientCode(file) {
234
234
  const originalContents = await (0, promises_1.readFile)(file, 'utf-8');
235
- const firstUpdate = originalContents.replace('You can also disable this overlay by setting', '');
236
- (0, node_assert_1.default)(originalContents !== firstUpdate, 'Failed to update Vite client error overlay text. (1)');
237
- const secondUpdate = firstUpdate.replace(
238
- // eslint-disable-next-line max-len
239
- '<code part="config-option-name">server.hmr.overlay</code> to <code part="config-option-value">false</code> in <code part="config-file-name">${hmrConfigName}.</code>', '');
240
- (0, node_assert_1.default)(firstUpdate !== secondUpdate, 'Failed to update Vite client error overlay text. (2)');
241
- return secondUpdate;
235
+ const updatedContents = originalContents.replace(`h('br'), 'You can also disable this overlay by setting ', ` +
236
+ `h('code', { part: 'config-option-name' }, 'server.hmr.overlay'), '` +
237
+ ` to ', h('code', { part: 'config-option-value' }, 'false'), ' in ', h('code', { part: 'config-file-name' }, hmrConfigName), '.'`, '');
238
+ (0, node_assert_1.default)(originalContents !== updatedContents, 'Failed to update Vite client error overlay text.');
239
+ return updatedContents;
242
240
  }
243
241
  function pathnameWithoutBasePath(url, basePath) {
244
242
  const parsedUrl = new URL(url, 'http://localhost');
@@ -162,12 +162,13 @@ async function addProxyConfig(root, proxyConfig) {
162
162
  if (!(0, fs_1.existsSync)(proxyPath)) {
163
163
  throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
164
164
  }
165
+ let proxyConfiguration;
165
166
  switch ((0, path_1.extname)(proxyPath)) {
166
167
  case '.json': {
167
168
  const content = await fs_1.promises.readFile(proxyPath, 'utf-8');
168
169
  const { parse, printParseErrorCode } = await Promise.resolve().then(() => __importStar(require('jsonc-parser')));
169
170
  const parseErrors = [];
170
- const proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });
171
+ proxyConfiguration = parse(content, parseErrors, { allowTrailingComma: true });
171
172
  if (parseErrors.length > 0) {
172
173
  let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
173
174
  for (const parseError of parseErrors) {
@@ -176,32 +177,35 @@ async function addProxyConfig(root, proxyConfig) {
176
177
  }
177
178
  throw new Error(errorMessage);
178
179
  }
179
- return proxyConfiguration;
180
+ break;
180
181
  }
181
182
  case '.mjs':
182
183
  // Load the ESM configuration file using the TypeScript dynamic import workaround.
183
184
  // Once TypeScript provides support for keeping the dynamic import this workaround can be
184
185
  // changed to a direct dynamic import.
185
- return (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
186
+ proxyConfiguration = (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
187
+ break;
186
188
  case '.cjs':
187
- return require(proxyPath);
189
+ proxyConfiguration = require(proxyPath);
190
+ break;
188
191
  default:
189
192
  // The file could be either CommonJS or ESM.
190
193
  // CommonJS is tried first then ESM if loading fails.
191
194
  try {
192
- return require(proxyPath);
195
+ proxyConfiguration = require(proxyPath);
193
196
  }
194
197
  catch (e) {
195
198
  (0, error_1.assertIsError)(e);
196
- if (e.code === 'ERR_REQUIRE_ESM') {
197
- // Load the ESM configuration file using the TypeScript dynamic import workaround.
198
- // Once TypeScript provides support for keeping the dynamic import this workaround can be
199
- // changed to a direct dynamic import.
200
- return (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
199
+ if (e.code !== 'ERR_REQUIRE_ESM') {
200
+ throw e;
201
201
  }
202
- throw e;
202
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
203
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
204
+ // changed to a direct dynamic import.
205
+ proxyConfiguration = (await (0, load_esm_1.loadEsmModule)((0, url_1.pathToFileURL)(proxyPath))).default;
203
206
  }
204
207
  }
208
+ return normalizeProxyConfiguration(proxyConfiguration);
205
209
  }
206
210
  /**
207
211
  * Calculates the line and column for an error offset in the content of a JSON file.
@@ -301,3 +305,8 @@ function getPublicHostOptions(options, webSocketPath) {
301
305
  }
302
306
  return `auto://${publicHost || '0.0.0.0:0'}${webSocketPath}`;
303
307
  }
308
+ function normalizeProxyConfiguration(proxy) {
309
+ return Array.isArray(proxy)
310
+ ? proxy
311
+ : Object.entries(proxy).map(([context, value]) => ({ context: [context], ...value }));
312
+ }
@@ -37,10 +37,8 @@ exports.getStylesConfig = void 0;
37
37
  const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
38
38
  const path = __importStar(require("node:path"));
39
39
  const node_url_1 = require("node:url");
40
- const environment_options_1 = require("../../../utils/environment-options");
41
40
  const tailwind_1 = require("../../../utils/tailwind");
42
41
  const sass_service_1 = require("../../sass/sass-service");
43
- const sass_service_legacy_1 = require("../../sass/sass-service-legacy");
44
42
  const plugins_1 = require("../plugins");
45
43
  const css_optimizer_plugin_1 = require("../plugins/css-optimizer-plugin");
46
44
  const styles_webpack_plugin_1 = require("../plugins/styles-webpack-plugin");
@@ -68,9 +66,7 @@ async function getStylesConfig(wco) {
68
66
  extraPlugins.push(new plugins_1.RemoveHashPlugin({ chunkNames: noInjectNames, hashFormat }));
69
67
  }
70
68
  }
71
- const sassImplementation = environment_options_1.useLegacySass
72
- ? new sass_service_legacy_1.SassLegacyWorkerImplementation()
73
- : new sass_service_1.SassWorkerImplementation();
69
+ const sassImplementation = new sass_service_1.SassWorkerImplementation();
74
70
  extraPlugins.push({
75
71
  apply(compiler) {
76
72
  compiler.hooks.shutdown.tap('sass-worker', () => {
@@ -284,54 +280,27 @@ async function getStylesConfig(wco) {
284
280
  }
285
281
  exports.getStylesConfig = getStylesConfig;
286
282
  function getSassLoaderOptions(root, implementation, includePaths, indentedSyntax, verbose, preserveSymlinks) {
287
- return implementation instanceof sass_service_1.SassWorkerImplementation
288
- ? {
289
- sourceMap: true,
290
- api: 'modern',
291
- implementation,
292
- // Webpack importer is only implemented in the legacy API and we have our own custom Webpack importer.
293
- // See: https://github.com/webpack-contrib/sass-loader/blob/997f3eb41d86dd00d5fa49c395a1aeb41573108c/src/utils.js#L642-L651
294
- webpackImporter: false,
295
- sassOptions: (loaderContext) => ({
296
- importers: [getSassResolutionImporter(loaderContext, root, preserveSymlinks)],
297
- loadPaths: includePaths,
298
- // Use expanded as otherwise sass will remove comments that are needed for autoprefixer
299
- // Ex: /* autoprefixer grid: autoplace */
300
- // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
301
- style: 'expanded',
302
- // Silences compiler warnings from 3rd party stylesheets
303
- quietDeps: !verbose,
304
- verbose,
305
- syntax: indentedSyntax ? 'indented' : 'scss',
306
- sourceMapIncludeSources: true,
307
- }),
308
- }
309
- : {
310
- sourceMap: true,
311
- api: 'legacy',
312
- implementation,
313
- sassOptions: {
314
- importer: (url, from) => {
315
- if (url.charAt(0) === '~') {
316
- throw new Error(`'${from}' imports '${url}' with a tilde. Usage of '~' in imports is no longer supported.`);
317
- }
318
- return null;
319
- },
320
- // Prevent use of `fibers` package as it no longer works in newer Node.js versions
321
- fiber: false,
322
- indentedSyntax,
323
- // bootstrap-sass requires a minimum precision of 8
324
- precision: 8,
325
- includePaths,
326
- // Use expanded as otherwise sass will remove comments that are needed for autoprefixer
327
- // Ex: /* autoprefixer grid: autoplace */
328
- // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
329
- outputStyle: 'expanded',
330
- // Silences compiler warnings from 3rd party stylesheets
331
- quietDeps: !verbose,
332
- verbose,
333
- },
334
- };
283
+ return {
284
+ sourceMap: true,
285
+ api: 'modern',
286
+ implementation,
287
+ // Webpack importer is only implemented in the legacy API and we have our own custom Webpack importer.
288
+ // See: https://github.com/webpack-contrib/sass-loader/blob/997f3eb41d86dd00d5fa49c395a1aeb41573108c/src/utils.js#L642-L651
289
+ webpackImporter: false,
290
+ sassOptions: (loaderContext) => ({
291
+ importers: [getSassResolutionImporter(loaderContext, root, preserveSymlinks)],
292
+ loadPaths: includePaths,
293
+ // Use expanded as otherwise sass will remove comments that are needed for autoprefixer
294
+ // Ex: /* autoprefixer grid: autoplace */
295
+ // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
296
+ style: 'expanded',
297
+ // Silences compiler warnings from 3rd party stylesheets
298
+ quietDeps: !verbose,
299
+ verbose,
300
+ syntax: indentedSyntax ? 'indented' : 'scss',
301
+ sourceMapIncludeSources: true,
302
+ }),
303
+ };
335
304
  }
336
305
  function getSassResolutionImporter(loaderContext, root, preserveSymlinks) {
337
306
  const commonResolverOptions = {
@@ -51,7 +51,7 @@ class BuilderWatchFileSystem {
51
51
  const directoryChanges = new Set();
52
52
  const missingChanges = new Set();
53
53
  for (const event of events) {
54
- this.inputFileSystem.purge?.(event.path);
54
+ this.inputFileSystem?.purge?.(event.path);
55
55
  if (event.type === 'deleted') {
56
56
  timeInfo.delete(event.path);
57
57
  removals.add(event.path);
@@ -70,7 +70,7 @@ class BuilderWatchFileSystem {
70
70
  }
71
71
  }
72
72
  const timeInfoMap = new Map(timeInfo);
73
- callback(undefined, timeInfoMap, timeInfoMap, new Set([...fileChanges, ...directoryChanges, ...missingChanges]), removals);
73
+ callback(null, timeInfoMap, timeInfoMap, new Set([...fileChanges, ...directoryChanges, ...missingChanges]), removals);
74
74
  });
75
75
  });
76
76
  return {
@@ -34,7 +34,7 @@ class StylesWebpackPlugin {
34
34
  preferRelative: true,
35
35
  useSyncFileSystemCalls: true,
36
36
  symlinks: !preserveSymlinks,
37
- fileSystem: compiler.inputFileSystem,
37
+ fileSystem: compiler.inputFileSystem ?? undefined,
38
38
  });
39
39
  const webpackOptions = compiler.options;
40
40
  compiler.hooks.environment.tap(PLUGIN_NAME, () => {
@@ -206,7 +206,7 @@ function assetPatterns(root, assets) {
206
206
  return assets.map((asset, index) => {
207
207
  // Resolve input paths relative to workspace root and add slash at the end.
208
208
  // eslint-disable-next-line prefer-const
209
- let { input, output, ignore = [], glob } = asset;
209
+ let { input, output = '', ignore = [], glob } = asset;
210
210
  input = path.resolve(root, input).replace(/\\/g, '/');
211
211
  input = input.endsWith('/') ? input : input + '/';
212
212
  output = output.endsWith('/') ? output : output + '/';
@@ -10,7 +10,6 @@ export declare const shouldBeautify: boolean;
10
10
  export declare const allowMinify: boolean;
11
11
  export declare const maxWorkers: number;
12
12
  export declare const useParallelTs: boolean;
13
- export declare const useLegacySass: boolean;
14
13
  export declare const debugPerformance: boolean;
15
14
  export declare const shouldWatchRoot: boolean;
16
15
  export declare const useTypeChecking: boolean;
@@ -7,8 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.useJSONBuildLogs = exports.useTypeChecking = exports.shouldWatchRoot = exports.debugPerformance = exports.useLegacySass = exports.useParallelTs = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
11
- const color_1 = require("./color");
10
+ exports.useJSONBuildLogs = exports.useTypeChecking = exports.shouldWatchRoot = exports.debugPerformance = exports.useParallelTs = exports.maxWorkers = exports.allowMinify = exports.shouldBeautify = exports.allowMangle = void 0;
12
11
  function isDisabled(variable) {
13
12
  return variable === '0' || variable.toLowerCase() === 'false';
14
13
  }
@@ -70,15 +69,6 @@ const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
70
69
  exports.maxWorkers = isPresent(maxWorkersVariable) ? +maxWorkersVariable : 4;
71
70
  const parallelTsVariable = process.env['NG_BUILD_PARALLEL_TS'];
72
71
  exports.useParallelTs = !isPresent(parallelTsVariable) || !isDisabled(parallelTsVariable);
73
- const legacySassVariable = process.env['NG_BUILD_LEGACY_SASS'];
74
- exports.useLegacySass = (() => {
75
- if (!isPresent(legacySassVariable)) {
76
- return false;
77
- }
78
- // eslint-disable-next-line no-console
79
- console.warn(color_1.colors.yellow(`Warning: 'NG_BUILD_LEGACY_SASS' environment variable support will be removed in version 16.`));
80
- return isEnabled(legacySassVariable);
81
- })();
82
72
  const debugPerfVariable = process.env['NG_BUILD_DEBUG_PERF'];
83
73
  exports.debugPerformance = isPresent(debugPerfVariable) && isEnabled(debugPerfVariable);
84
74
  const watchRootVariable = process.env['NG_BUILD_WATCH_ROOT'];
@@ -6,7 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import { BuilderContext } from '@angular-devkit/architect';
9
- import { json } from '@angular-devkit/core';
10
9
  import { Schema as BrowserBuilderSchema, I18NTranslation } from '../builders/browser/schema';
11
10
  import { Schema as ServerBuilderSchema } from '../builders/server/schema';
12
11
  import { TranslationLoader } from './load-translations';
@@ -28,7 +27,9 @@ export interface I18nOptions {
28
27
  readonly shouldInline: boolean;
29
28
  hasDefinedSourceLocale?: boolean;
30
29
  }
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;
32
33
  export declare function configureI18nBuild<T extends BrowserBuilderSchema | ServerBuilderSchema>(context: BuilderContext, options: T): Promise<{
33
34
  buildOptions: T;
34
35
  i18n: I18nOptions;
@@ -11,11 +11,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  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"));
19
18
  const schema_1 = require("../builders/browser/schema");
20
19
  const read_tsconfig_1 = require("../utils/read-tsconfig");
21
20
  const load_translations_1 = require("./load-translations");
@@ -39,11 +38,19 @@ function normalizeTranslationFileOption(option, locale, expectObjectInError) {
39
38
  }
40
39
  throw new Error(errorMessage);
41
40
  }
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.`);
45
44
  }
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');
47
54
  const i18n = {
48
55
  inlineLocales: new Set(),
49
56
  // en-US is the default locale added to Angular applications (https://angular.io/guide/i18n#i18n-pipes)
@@ -55,21 +62,21 @@ function createI18nOptions(metadata, inline) {
55
62
  };
56
63
  let rawSourceLocale;
57
64
  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') {
67
66
  rawSourceLocale = metadata.sourceLocale;
68
67
  }
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;
72
77
  }
78
+ }
79
+ if (rawSourceLocale !== undefined) {
73
80
  i18n.sourceLocale = rawSourceLocale;
74
81
  i18n.hasDefinedSourceLocale = true;
75
82
  }
@@ -77,16 +84,15 @@ function createI18nOptions(metadata, inline) {
77
84
  files: [],
78
85
  baseHref: rawSourceLocaleBaseHref,
79
86
  };
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');
84
89
  for (const [locale, options] of Object.entries(metadata.locales)) {
85
90
  let translationFiles;
86
91
  let baseHref;
87
- if (core_1.json.isJsonObject(options)) {
92
+ if (options && typeof options === 'object' && 'translation' in options) {
88
93
  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`);
90
96
  baseHref = options.baseHref;
91
97
  }
92
98
  }
@@ -129,10 +135,10 @@ async function configureI18nBuild(context, options) {
129
135
  if (!i18n.shouldInline && !i18n.hasDefinedSourceLocale) {
130
136
  return { buildOptions, i18n };
131
137
  }
132
- const projectRoot = path_1.default.join(context.workspaceRoot, metadata.root || '');
138
+ const projectRoot = node_path_1.default.join(context.workspaceRoot, metadata.root || '');
133
139
  // 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));
136
142
  // Load locale data and translations (if present)
137
143
  let loader;
138
144
  const usedFormats = new Set();
@@ -177,11 +183,11 @@ async function configureI18nBuild(context, options) {
177
183
  if (i18n.shouldInline) {
178
184
  // TODO: we should likely save these in the .angular directory in the next major version.
179
185
  // 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-'));
181
187
  buildOptions.outputPath = tempPath;
182
188
  process.on('exit', () => {
183
189
  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 });
185
191
  }
186
192
  catch { }
187
193
  });
@@ -203,7 +209,7 @@ function findLocaleDataPath(locale, resolver) {
203
209
  function loadTranslations(locale, desc, workspaceRoot, loader, logger, usedFormats, duplicateTranslation) {
204
210
  let translations = undefined;
205
211
  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));
207
213
  for (const diagnostics of loadResult.diagnostics.messages) {
208
214
  if (diagnostics.type === 'error') {
209
215
  logger.error(`Error parsing translation file '${file.path}': ${diagnostics.message}`);
@@ -5,10 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- /// <reference types="node" />
9
- /// <reference types="@types/node/url" />
10
- /// <reference types="@types/node/ts4.8/url" />
11
- import { URL } from 'node:url';
12
8
  import { NormalizedCachedOptions } from '../normalize-cache';
13
9
  export interface InlineFontsOptions {
14
10
  minify?: boolean;
@@ -36,8 +36,6 @@ const node_crypto_1 = require("node:crypto");
36
36
  const promises_1 = require("node:fs/promises");
37
37
  const https = __importStar(require("node:https"));
38
38
  const node_path_1 = require("node:path");
39
- const node_url_1 = require("node:url");
40
- const package_version_1 = require("../package-version");
41
39
  const html_rewriting_stream_1 = require("./html-rewriting-stream");
42
40
  const SUPPORTED_PROVIDERS = {
43
41
  'fonts.googleapis.com': {
@@ -161,7 +159,7 @@ class InlineFontsProcessor {
161
159
  async getResponse(url) {
162
160
  let cacheFile;
163
161
  if (this.cachePath) {
164
- const key = (0, node_crypto_1.createHash)(CONTENT_HASH_ALGORITHM).update(`${package_version_1.VERSION}|${url}`).digest('hex');
162
+ const key = (0, node_crypto_1.createHash)(CONTENT_HASH_ALGORITHM).update(`${url}`).digest('hex');
165
163
  cacheFile = (0, node_path_1.join)(this.cachePath, key);
166
164
  }
167
165
  if (cacheFile) {
@@ -226,7 +224,7 @@ class InlineFontsProcessor {
226
224
  return data;
227
225
  }
228
226
  async processURL(url) {
229
- const normalizedURL = url instanceof node_url_1.URL ? url : this.createNormalizedUrl(url);
227
+ const normalizedURL = url instanceof URL ? url : this.createNormalizedUrl(url);
230
228
  if (!normalizedURL) {
231
229
  return;
232
230
  }
@@ -255,7 +253,7 @@ class InlineFontsProcessor {
255
253
  }
256
254
  createNormalizedUrl(value) {
257
255
  // Need to convert '//' to 'https://' because the URL parser will fail with '//'.
258
- const url = new node_url_1.URL(value.startsWith('//') ? `https:${value}` : value, 'resolve://');
256
+ const url = new URL(value.startsWith('//') ? `https:${value}` : value, 'resolve://');
259
257
  switch (url.protocol) {
260
258
  case 'http:':
261
259
  case 'https:':
@@ -5,9 +5,10 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { BaseException } from '@angular-devkit/core';
9
8
  import { AssetPattern, AssetPatternClass } from '../builders/browser/schema';
10
- export declare class MissingAssetSourceRootException extends BaseException {
9
+ export declare class MissingAssetSourceRootException extends Error {
11
10
  constructor(path: string);
12
11
  }
13
- export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): AssetPatternClass[];
12
+ export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): (AssetPatternClass & {
13
+ output: string;
14
+ })[];
@@ -29,12 +29,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
29
29
  __setModuleDefault(result, mod);
30
30
  return result;
31
31
  };
32
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
32
35
  Object.defineProperty(exports, "__esModule", { value: true });
33
36
  exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
34
- const core_1 = require("@angular-devkit/core");
35
37
  const fs_1 = require("fs");
38
+ const node_assert_1 = __importDefault(require("node:assert"));
36
39
  const path = __importStar(require("path"));
37
- class MissingAssetSourceRootException extends core_1.BaseException {
40
+ class MissingAssetSourceRootException extends Error {
38
41
  constructor(path) {
39
42
  super(`The ${path} asset path must start with the project source root.`);
40
43
  }
@@ -81,8 +84,9 @@ function normalizeAssetPatterns(assetPatterns, workspaceRoot, projectRoot, proje
81
84
  assetPattern = { glob, input, output };
82
85
  }
83
86
  else {
84
- assetPattern.output = path.join('.', assetPattern.output);
87
+ assetPattern.output = path.join('.', assetPattern.output ?? '');
85
88
  }
89
+ (0, node_assert_1.default)(assetPattern.output !== undefined);
86
90
  if (assetPattern.output.startsWith('..')) {
87
91
  throw new Error('An asset cannot be written to a location outside of the output path.');
88
92
  }
@@ -5,7 +5,6 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { json } from '@angular-devkit/core';
9
8
  export interface NormalizedCachedOptions {
10
9
  /** Whether disk cache is enabled. */
11
10
  enabled: boolean;
@@ -14,4 +13,4 @@ export interface NormalizedCachedOptions {
14
13
  /** Disk cache base path. Example: `/.angular/cache`. */
15
14
  basePath: string;
16
15
  }
17
- export declare function normalizeCacheOptions(metadata: json.JsonObject, worspaceRoot: string): NormalizedCachedOptions;
16
+ export declare function normalizeCacheOptions(projectMetadata: unknown, worspaceRoot: string): NormalizedCachedOptions;
@@ -8,13 +8,19 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = void 0;
11
- const core_1 = require("@angular-devkit/core");
12
- const path_1 = require("path");
13
- const package_version_1 = require("./package-version");
14
- function normalizeCacheOptions(metadata, worspaceRoot) {
15
- const cacheMetadata = core_1.json.isJsonObject(metadata.cli) && core_1.json.isJsonObject(metadata.cli.cache)
16
- ? metadata.cli.cache
17
- : {};
11
+ const node_path_1 = require("node:path");
12
+ /** Version placeholder is replaced during the build process with actual package version */
13
+ const VERSION = '18.0.0-next.1';
14
+ function hasCacheMetadata(value) {
15
+ return (!!value &&
16
+ typeof value === 'object' &&
17
+ 'cli' in value &&
18
+ !!value['cli'] &&
19
+ typeof value['cli'] === 'object' &&
20
+ 'cache' in value['cli']);
21
+ }
22
+ function normalizeCacheOptions(projectMetadata, worspaceRoot) {
23
+ const cacheMetadata = hasCacheMetadata(projectMetadata) ? projectMetadata.cli.cache : {};
18
24
  const { enabled = true, environment = 'local', path = '.angular/cache' } = cacheMetadata;
19
25
  const isCI = process.env['CI'] === '1' || process.env['CI']?.toLowerCase() === 'true';
20
26
  let cacheEnabled = enabled;
@@ -28,11 +34,11 @@ function normalizeCacheOptions(metadata, worspaceRoot) {
28
34
  break;
29
35
  }
30
36
  }
31
- const cacheBasePath = (0, path_1.resolve)(worspaceRoot, path);
37
+ const cacheBasePath = (0, node_path_1.resolve)(worspaceRoot, path);
32
38
  return {
33
39
  enabled: cacheEnabled,
34
40
  basePath: cacheBasePath,
35
- path: (0, path_1.join)(cacheBasePath, package_version_1.VERSION),
41
+ path: (0, node_path_1.join)(cacheBasePath, VERSION),
36
42
  };
37
43
  }
38
44
  exports.normalizeCacheOptions = normalizeCacheOptions;
@@ -5,9 +5,8 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import { BaseException } from '@angular-devkit/core';
9
8
  import { FileReplacement } from '../builders/browser/schema';
10
- export declare class MissingFileReplacementException extends BaseException {
9
+ export declare class MissingFileReplacementException extends Error {
11
10
  constructor(path: string);
12
11
  }
13
12
  export interface NormalizedFileReplacement {
@@ -31,10 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.normalizeFileReplacements = exports.MissingFileReplacementException = void 0;
34
- const core_1 = require("@angular-devkit/core");
35
34
  const fs_1 = require("fs");
36
35
  const path = __importStar(require("path"));
37
- class MissingFileReplacementException extends core_1.BaseException {
36
+ class MissingFileReplacementException extends Error {
38
37
  constructor(path) {
39
38
  super(`The ${path} path in file replacements does not exist.`);
40
39
  }
@@ -17,7 +17,6 @@ const node_path_1 = require("node:path");
17
17
  const node_url_1 = require("node:url");
18
18
  const url_1 = require("url");
19
19
  const javascript_transformer_1 = require("../../../tools/esbuild/javascript-transformer");
20
- const node_18_utils_1 = require("./node-18-utils");
21
20
  /**
22
21
  * Node.js ESM loader to redirect imports to in memory files.
23
22
  * @see: https://nodejs.org/api/esm.html#loaders for more information about loaders.
@@ -30,7 +29,6 @@ const javascriptTransformer = new javascript_transformer_1.JavaScriptTransformer
30
29
  // In a development environment the additional scope information does not
31
30
  // have a negative effect unlike production where final output size is relevant.
32
31
  { sourcemap: true, jit: true }, 1);
33
- (0, node_18_utils_1.callInitializeIfNeeded)(initialize);
34
32
  function initialize(data) {
35
33
  // This path does not actually exist but is used to overlay the in memory files with the
36
34
  // actual filesystem for resolution purposes.