@angular-devkit/build-angular 17.3.0 → 18.0.0-next.0

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 (44) hide show
  1. package/package.json +31 -31
  2. package/src/builders/app-shell/index.js +1 -1
  3. package/src/builders/application/build-action.d.ts +5 -4
  4. package/src/builders/application/build-action.js +17 -23
  5. package/src/builders/dev-server/builder.d.ts +0 -2
  6. package/src/builders/dev-server/builder.js +1 -1
  7. package/src/builders/dev-server/vite-server.js +14 -7
  8. package/src/builders/dev-server/webpack-server.js +1 -1
  9. package/src/builders/prerender/index.d.ts +2 -3
  10. package/src/builders/ssr-dev-server/utils.d.ts +1 -2
  11. package/src/tools/babel/plugins/adjust-static-class-members.js +3 -6
  12. package/src/tools/esbuild/angular/angular-host.js +4 -0
  13. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +0 -2
  14. package/src/tools/esbuild/angular/compiler-plugin.js +5 -2
  15. package/src/tools/esbuild/bundler-context.js +2 -2
  16. package/src/tools/esbuild/utils.d.ts +3 -3
  17. package/src/tools/esbuild/utils.js +2 -2
  18. package/src/tools/vite/angular-memory-plugin.js +8 -8
  19. package/src/tools/webpack/configs/dev-server.js +20 -11
  20. package/src/tools/webpack/configs/styles.js +22 -53
  21. package/src/tools/webpack/plugins/builder-watch-plugin.js +2 -2
  22. package/src/tools/webpack/plugins/styles-webpack-plugin.js +1 -1
  23. package/src/utils/environment-options.d.ts +0 -1
  24. package/src/utils/environment-options.js +1 -11
  25. package/src/utils/i18n-options.d.ts +3 -2
  26. package/src/utils/i18n-options.js +39 -33
  27. package/src/utils/index-file/inline-fonts.d.ts +0 -2
  28. package/src/utils/normalize-asset-patterns.d.ts +1 -2
  29. package/src/utils/normalize-asset-patterns.js +1 -2
  30. package/src/utils/normalize-cache.d.ts +1 -2
  31. package/src/utils/normalize-cache.js +10 -5
  32. package/src/utils/normalize-file-replacements.d.ts +1 -2
  33. package/src/utils/normalize-file-replacements.js +1 -2
  34. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +0 -2
  35. package/src/utils/server-rendering/prerender.js +11 -3
  36. package/src/utils/service-worker.d.ts +2 -2
  37. package/src/utils/supported-browsers.d.ts +3 -2
  38. package/src/utils/webpack-browser-config.d.ts +1 -2
  39. package/src/tools/sass/sass-service-legacy.d.ts +0 -51
  40. package/src/tools/sass/sass-service-legacy.js +0 -173
  41. package/src/tools/sass/worker-legacy.d.ts +0 -8
  42. package/src/tools/sass/worker-legacy.js +0 -43
  43. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.d.ts +0 -10
  44. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +0 -39
@@ -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, () => {
@@ -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}`);
@@ -6,8 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <reference types="node" />
9
- /// <reference types="@types/node/url" />
10
- /// <reference types="@types/node/ts4.8/url" />
11
9
  import { URL } from 'node:url';
12
10
  import { NormalizedCachedOptions } from '../normalize-cache';
13
11
  export interface InlineFontsOptions {
@@ -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 { 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
12
  export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], workspaceRoot: string, projectRoot: string, projectSourceRoot: string | undefined): AssetPatternClass[];
@@ -31,10 +31,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = 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 MissingAssetSourceRootException extends core_1.BaseException {
36
+ class MissingAssetSourceRootException extends Error {
38
37
  constructor(path) {
39
38
  super(`The ${path} asset path must start with the project source root.`);
40
39
  }
@@ -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,18 @@
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
11
  const path_1 = require("path");
13
12
  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
- : {};
13
+ function hasCacheMetadata(value) {
14
+ return (!!value &&
15
+ typeof value === 'object' &&
16
+ 'cli' in value &&
17
+ !!value['cli'] &&
18
+ typeof value['cli'] === 'object' &&
19
+ 'cache' in value['cli']);
20
+ }
21
+ function normalizeCacheOptions(projectMetadata, worspaceRoot) {
22
+ const cacheMetadata = hasCacheMetadata(projectMetadata) ? projectMetadata.cli.cache : {};
18
23
  const { enabled = true, environment = 'local', path = '.angular/cache' } = cacheMetadata;
19
24
  const isCI = process.env['CI'] === '1' || process.env['CI']?.toLowerCase() === 'true';
20
25
  let cacheEnabled = enabled;
@@ -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.
@@ -13,9 +13,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.prerenderPages = void 0;
14
14
  const promises_1 = require("node:fs/promises");
15
15
  const node_path_1 = require("node:path");
16
+ const node_url_1 = require("node:url");
16
17
  const piscina_1 = __importDefault(require("piscina"));
17
18
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
18
- const node_18_utils_1 = require("./esm-in-memory-loader/node-18-utils");
19
19
  async function prerenderPages(workspaceRoot, appShellOptions = {}, prerenderOptions = {}, outputFiles, assets, document, sourcemap = false, inlineCriticalCss = false, maxThreads = 1, verbose = false) {
20
20
  const outputFilesForWorker = {};
21
21
  const serverBundlesSourceMaps = new Map();
@@ -82,7 +82,11 @@ async function renderPages(sourcemap, allRoutes, maxThreads, workspaceRoot, outp
82
82
  const output = {};
83
83
  const warnings = [];
84
84
  const errors = [];
85
- const workerExecArgv = (0, node_18_utils_1.getESMLoaderArgs)();
85
+ const workerExecArgv = [
86
+ '--import',
87
+ // Loader cannot be an absolute path on Windows.
88
+ (0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
89
+ ];
86
90
  if (sourcemap) {
87
91
  workerExecArgv.push('--enable-source-maps');
88
92
  }
@@ -149,7 +153,11 @@ async function getAllRoutes(workspaceRoot, outputFilesForWorker, assetFilesForWo
149
153
  if (!discoverRoutes) {
150
154
  return { routes };
151
155
  }
152
- const workerExecArgv = (0, node_18_utils_1.getESMLoaderArgs)();
156
+ const workerExecArgv = [
157
+ '--import',
158
+ // Loader cannot be an absolute path on Windows.
159
+ (0, node_url_1.pathToFileURL)((0, node_path_1.join)(__dirname, 'esm-in-memory-loader/register-hooks.js')).href,
160
+ ];
153
161
  if (sourcemap) {
154
162
  workerExecArgv.push('--enable-source-maps');
155
163
  }
@@ -5,8 +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
- /// <reference types="@types/node/fs" />
9
- /// <reference types="@types/node/ts4.8/fs" />
8
+ /// <reference types="node" />
9
+ /// <reference types="node" />
10
10
  import type { Config, Filesystem } from '@angular/service-worker/config';
11
11
  import { promises as fsPromises } from 'node:fs';
12
12
  import { BuildOutputFile } from '../tools/esbuild/bundler-context';
@@ -5,5 +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 { 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[];
@@ -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 { logging } from '@angular-devkit/core';
10
9
  import { Configuration } from 'webpack';
11
10
  import { Schema as BrowserBuilderSchema } from '../builders/browser/schema';
12
11
  import { NormalizedBrowserBuilderSchema } from '../utils';
@@ -14,7 +13,7 @@ import { WebpackConfigOptions } from '../utils/build-options';
14
13
  import { I18nOptions } from './i18n-options';
15
14
  export type BrowserWebpackConfigOptions = WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
16
15
  export type WebpackPartialGenerator = (configurationOptions: BrowserWebpackConfigOptions) => (Promise<Configuration> | Configuration)[];
17
- export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, projectName: string, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: WebpackPartialGenerator, logger: logging.LoggerApi, extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<Configuration>;
16
+ export declare function generateWebpackConfig(workspaceRoot: string, projectRoot: string, sourceRoot: string | undefined, projectName: string, options: NormalizedBrowserBuilderSchema, webpackPartialGenerator: WebpackPartialGenerator, logger: BuilderContext['logger'], extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>): Promise<Configuration>;
18
17
  export declare function generateI18nBrowserWebpackConfigFromContext(options: BrowserBuilderSchema, context: BuilderContext, webpackPartialGenerator: WebpackPartialGenerator, extraBuildOptions?: Partial<NormalizedBrowserBuilderSchema>): Promise<{
19
18
  config: Configuration;
20
19
  projectRoot: string;
@@ -1,51 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { LegacyResult as CompileResult, LegacyException as Exception, LegacyOptions as Options } from 'sass';
9
- /**
10
- * The callback type for the `dart-sass` asynchronous render function.
11
- */
12
- type RenderCallback = (error?: Exception, result?: CompileResult) => void;
13
- /**
14
- * A Sass renderer implementation that provides an interface that can be used by Webpack's
15
- * `sass-loader`. The implementation uses a Worker thread to perform the Sass rendering
16
- * with the `dart-sass` package. The `dart-sass` synchronous render function is used within
17
- * the worker which can be up to two times faster than the asynchronous variant.
18
- */
19
- export declare class SassLegacyWorkerImplementation {
20
- private readonly workers;
21
- private readonly availableWorkers;
22
- private readonly requests;
23
- private readonly workerPath;
24
- private idCounter;
25
- private nextWorkerIndex;
26
- /**
27
- * Provides information about the Sass implementation.
28
- * This mimics enough of the `dart-sass` value to be used with the `sass-loader`.
29
- */
30
- get info(): string;
31
- /**
32
- * The synchronous render function is not used by the `sass-loader`.
33
- */
34
- renderSync(): never;
35
- /**
36
- * Asynchronously request a Sass stylesheet to be renderered.
37
- *
38
- * @param options The `dart-sass` options to use when rendering the stylesheet.
39
- * @param callback The function to execute when the rendering is complete.
40
- */
41
- render(options: Options<'async'>, callback: RenderCallback): void;
42
- /**
43
- * Shutdown the Sass render worker.
44
- * Executing this method will stop any pending render requests.
45
- */
46
- close(): void;
47
- private createWorker;
48
- private processImporters;
49
- private createRequest;
50
- }
51
- export {};