@angular/build 18.0.0-next.5 → 18.0.0-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "18.0.0-next.5",
3
+ "version": "18.0.0-rc.0",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,10 +23,10 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.1800.0-next.5",
27
- "@babel/core": "7.24.4",
26
+ "@angular-devkit/architect": "0.1800.0-rc.0",
27
+ "@babel/core": "7.24.5",
28
28
  "@babel/helper-annotate-as-pure": "7.22.5",
29
- "@babel/helper-split-export-declaration": "7.22.6",
29
+ "@babel/helper-split-export-declaration": "7.24.5",
30
30
  "@vitejs/plugin-basic-ssl": "1.1.0",
31
31
  "ansi-colors": "4.1.3",
32
32
  "browserslist": "^4.23.0",
@@ -34,7 +34,7 @@
34
34
  "esbuild": "0.20.2",
35
35
  "fast-glob": "3.3.2",
36
36
  "https-proxy-agent": "7.0.4",
37
- "inquirer": "9.2.19",
37
+ "inquirer": "9.2.20",
38
38
  "magic-string": "0.30.10",
39
39
  "mrmime": "2.0.0",
40
40
  "ora": "5.4.1",
@@ -44,7 +44,7 @@
44
44
  "postcss": "8.4.38",
45
45
  "sass": "1.75.0",
46
46
  "semver": "7.6.0",
47
- "undici": "6.14.1",
47
+ "undici": "6.15.0",
48
48
  "vite": "5.2.10",
49
49
  "watchpack": "2.4.1"
50
50
  },
@@ -54,6 +54,7 @@
54
54
  "@angular/platform-server": "^18.0.0 || ^18.0.0-next.0",
55
55
  "@angular/service-worker": "^18.0.0 || ^18.0.0-next.0",
56
56
  "less": "^4.2.0",
57
+ "postcss": "^8.4.0",
57
58
  "tailwindcss": "^2.0.0 || ^3.0.0",
58
59
  "typescript": ">=5.4 <5.5"
59
60
  },
@@ -70,6 +71,9 @@
70
71
  "less": {
71
72
  "optional": true
72
73
  },
74
+ "postcss": {
75
+ "optional": true
76
+ },
73
77
  "tailwindcss": {
74
78
  "optional": true
75
79
  }
@@ -92,6 +92,10 @@ async function executeBuild(options, context, rebuildState) {
92
92
  if (options.extractLicenses) {
93
93
  executionResult.addOutputFile('3rdpartylicenses.txt', await (0, license_extractor_1.extractLicenses)(metafile, workspaceRoot), bundler_context_1.BuildOutputFileType.Root);
94
94
  }
95
+ // Watch input index HTML file if configured
96
+ if (options.indexHtmlOptions) {
97
+ executionResult.extraWatchFiles.push(options.indexHtmlOptions.input);
98
+ }
95
99
  // Perform i18n translation inlining if enabled
96
100
  if (i18nOptions.shouldInline) {
97
101
  const result = await (0, i18n_1.inlineI18n)(options, executionResult, initialFiles);
@@ -39,5 +39,5 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
39
39
  ssl: boolean | undefined;
40
40
  sslCert: string | undefined;
41
41
  sslKey: string | undefined;
42
- prebundle: import("./schema").PrebundleUnion;
42
+ prebundle: import("./schema").PrebundleUnion | undefined;
43
43
  }>;
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.normalizeOptions = void 0;
14
14
  const architect_1 = require("@angular-devkit/architect");
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
+ const utils_1 = require("../../utils");
16
17
  const normalize_cache_1 = require("../../utils/normalize-cache");
17
18
  /**
18
19
  * Normalize the user provided options by creating full paths for all path based options
@@ -25,13 +26,28 @@ const normalize_cache_1 = require("../../utils/normalize-cache");
25
26
  * @returns An object containing normalized options required to perform the build.
26
27
  */
27
28
  async function normalizeOptions(context, projectName, options) {
28
- const workspaceRoot = context.workspaceRoot;
29
+ const { workspaceRoot, logger } = context;
29
30
  const projectMetadata = await context.getProjectMetadata(projectName);
30
31
  const projectRoot = node_path_1.default.join(workspaceRoot, projectMetadata.root ?? '');
31
32
  const cacheOptions = (0, normalize_cache_1.normalizeCacheOptions)(projectMetadata, workspaceRoot);
32
33
  // Target specifier defaults to the current project's build target using a development configuration
33
34
  const buildTargetSpecifier = options.buildTarget ?? `::development`;
34
35
  const buildTarget = (0, architect_1.targetFromTargetString)(buildTargetSpecifier, projectName, 'build');
36
+ // Get the application builder options.
37
+ const browserBuilderName = await context.getBuilderNameForTarget(buildTarget);
38
+ const rawBuildOptions = await context.getTargetOptions(buildTarget);
39
+ const buildOptions = (await context.validateOptions(rawBuildOptions, browserBuilderName));
40
+ const optimization = (0, utils_1.normalizeOptimization)(buildOptions.optimization);
41
+ if (options.prebundle) {
42
+ if (!cacheOptions.enabled) {
43
+ // Warn if the initial options provided by the user enable prebundling but caching is disabled
44
+ logger.warn('Prebundling has been configured but will not be used because caching has been disabled.');
45
+ }
46
+ else if (optimization.scripts) {
47
+ // Warn if the initial options provided by the user enable prebundling but script optimization is enabled.
48
+ logger.warn('Prebundling has been configured but will not be used because scripts optimization is enabled.');
49
+ }
50
+ }
35
51
  // Initial options to keep
36
52
  const { host, port, poll, open, verbose, watch, liveReload, hmr, headers, proxyConfig, servePath, ssl, sslCert, sslKey, prebundle, } = options;
37
53
  // Return all the normalized options
@@ -55,7 +71,7 @@ async function normalizeOptions(context, projectName, options) {
55
71
  sslCert,
56
72
  sslKey,
57
73
  // Prebundling defaults to true but requires caching to function
58
- prebundle: cacheOptions.enabled && (prebundle ?? true),
74
+ prebundle: cacheOptions.enabled && !optimization.scripts && prebundle,
59
75
  };
60
76
  }
61
77
  exports.normalizeOptions = normalizeOptions;
@@ -81,6 +81,7 @@
81
81
  },
82
82
  "prebundle": {
83
83
  "description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
84
+ "default": true,
84
85
  "oneOf": [
85
86
  { "type": "boolean" },
86
87
  {
@@ -7,7 +7,7 @@ export interface Schema {
7
7
  * `project:target[:configuration]`. You can also pass in more than one configuration name
8
8
  * as a comma-separated list. Example: `project:target:production,staging`.
9
9
  */
10
- buildTarget: string;
10
+ buildTarget?: string;
11
11
  /**
12
12
  * Output format for the generated file.
13
13
  */
@@ -29,6 +29,5 @@
29
29
  "description": "Name of the file to output."
30
30
  }
31
31
  },
32
- "additionalProperties": false,
33
- "required": ["buildTarget"]
32
+ "additionalProperties": false
34
33
  }
package/src/private.d.ts CHANGED
@@ -19,6 +19,9 @@ export { ExternalResultMetadata } from './tools/esbuild/bundler-execution-result
19
19
  export { emitFilesToDisk } from './tools/esbuild/utils';
20
20
  export { transformSupportedBrowsersToTargets } from './tools/esbuild/utils';
21
21
  export { SassWorkerImplementation } from './tools/sass/sass-service';
22
+ export { SourceFileCache } from './tools/esbuild/angular/source-file-cache';
23
+ export { createJitResourceTransformer } from './tools/esbuild/angular/jit-resource-transformer';
24
+ export { JavaScriptTransformer } from './tools/esbuild/javascript-transformer';
22
25
  export * from './utils/bundle-calculator';
23
26
  export { checkPort } from './utils/check-port';
24
27
  export { deleteOutputDir } from './utils/delete-output-dir';
package/src/private.js CHANGED
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.serveWithVite = exports.buildApplicationInternal = void 0;
24
+ exports.assertCompatibleAngularVersion = exports.getSupportedBrowsers = exports.generateBuildStatsTable = exports.augmentAppWithServiceWorker = exports.purgeStaleBuildCache = exports.createTranslationLoader = exports.loadProxyConfiguration = exports.InlineCriticalCssProcessor = exports.IndexHtmlGenerator = exports.loadTranslations = exports.createI18nOptions = exports.deleteOutputDir = exports.checkPort = exports.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = exports.SassWorkerImplementation = exports.transformSupportedBrowsersToTargets = exports.emitFilesToDisk = exports.serveWithVite = exports.buildApplicationInternal = void 0;
25
25
  /**
26
26
  * @fileoverview
27
27
  * Private exports intended only for use with the @angular-devkit/build-angular package.
@@ -41,6 +41,12 @@ var utils_2 = require("./tools/esbuild/utils");
41
41
  Object.defineProperty(exports, "transformSupportedBrowsersToTargets", { enumerable: true, get: function () { return utils_2.transformSupportedBrowsersToTargets; } });
42
42
  var sass_service_1 = require("./tools/sass/sass-service");
43
43
  Object.defineProperty(exports, "SassWorkerImplementation", { enumerable: true, get: function () { return sass_service_1.SassWorkerImplementation; } });
44
+ var source_file_cache_1 = require("./tools/esbuild/angular/source-file-cache");
45
+ Object.defineProperty(exports, "SourceFileCache", { enumerable: true, get: function () { return source_file_cache_1.SourceFileCache; } });
46
+ var jit_resource_transformer_1 = require("./tools/esbuild/angular/jit-resource-transformer");
47
+ Object.defineProperty(exports, "createJitResourceTransformer", { enumerable: true, get: function () { return jit_resource_transformer_1.createJitResourceTransformer; } });
48
+ var javascript_transformer_1 = require("./tools/esbuild/javascript-transformer");
49
+ Object.defineProperty(exports, "JavaScriptTransformer", { enumerable: true, get: function () { return javascript_transformer_1.JavaScriptTransformer; } });
44
50
  // Utilities
45
51
  __exportStar(require("./utils/bundle-calculator"), exports);
46
52
  var check_port_1 = require("./utils/check-port");
@@ -37,6 +37,7 @@ export declare class ExecutionResult {
37
37
  warnings: (Message | PartialMessage)[];
38
38
  logs: string[];
39
39
  externalMetadata?: ExternalResultMetadata;
40
+ extraWatchFiles: string[];
40
41
  constructor(rebuildContexts: BundlerContext[], codeBundleCache?: SourceFileCache | undefined);
41
42
  addOutputFile(path: string, content: string, type: BuildOutputFileType): void;
42
43
  addAssets(assets: BuildOutputAsset[]): void;
@@ -23,6 +23,7 @@ class ExecutionResult {
23
23
  warnings = [];
24
24
  logs = [];
25
25
  externalMetadata;
26
+ extraWatchFiles = [];
26
27
  constructor(rebuildContexts, codeBundleCache) {
27
28
  this.rebuildContexts = rebuildContexts;
28
29
  this.codeBundleCache = codeBundleCache;
@@ -103,7 +104,7 @@ class ExecutionResult {
103
104
  // Load result caches internally normalize file dependencies
104
105
  files.push(...this.codeBundleCache.loadResultCache.watchFiles);
105
106
  }
106
- return files;
107
+ return files.concat(this.extraWatchFiles);
107
108
  }
108
109
  createRebuildState(fileChanges) {
109
110
  this.codeBundleCache?.invalidate([...fileChanges.modified, ...fileChanges.removed]);
@@ -61,7 +61,7 @@ const TAILWIND_KEYWORDS = [
61
61
  /**
62
62
  * Cached postcss instances that can be re-used between various StylesheetPluginFactory instances.
63
63
  */
64
- const postcssProcessor = new Map();
64
+ const postcssProcessors = new Map();
65
65
  class StylesheetPluginFactory {
66
66
  options;
67
67
  cache;
@@ -88,7 +88,7 @@ class StylesheetPluginFactory {
88
88
  }
89
89
  if (options.postcssConfiguration) {
90
90
  const postCssInstanceKey = JSON.stringify(options.postcssConfiguration);
91
- this.postcssProcessor = postcssProcessor.get(postCssInstanceKey)?.deref();
91
+ this.postcssProcessor = postcssProcessors.get(postCssInstanceKey)?.deref();
92
92
  if (!this.postcssProcessor) {
93
93
  postcss ??= (await Promise.resolve().then(() => __importStar(require('postcss')))).default;
94
94
  this.postcssProcessor = postcss();
@@ -99,18 +99,18 @@ class StylesheetPluginFactory {
99
99
  }
100
100
  this.postcssProcessor.use(plugin(pluginOptions));
101
101
  }
102
- postcssProcessor.set(postCssInstanceKey, new WeakRef(this.postcssProcessor));
102
+ postcssProcessors.set(postCssInstanceKey, new WeakRef(this.postcssProcessor));
103
103
  }
104
104
  }
105
105
  else if (options.tailwindConfiguration) {
106
106
  const { package: tailwindPackage, file: config } = options.tailwindConfiguration;
107
107
  const postCssInstanceKey = tailwindPackage + ':' + config;
108
- this.postcssProcessor = postcssProcessor.get(postCssInstanceKey)?.deref();
108
+ this.postcssProcessor = postcssProcessors.get(postCssInstanceKey)?.deref();
109
109
  if (!this.postcssProcessor) {
110
110
  postcss ??= (await Promise.resolve().then(() => __importStar(require('postcss')))).default;
111
111
  const tailwind = await Promise.resolve(`${tailwindPackage}`).then(s => __importStar(require(s)));
112
112
  this.postcssProcessor = postcss().use(tailwind.default({ config }));
113
- postcssProcessor.set(postCssInstanceKey, new WeakRef(this.postcssProcessor));
113
+ postcssProcessors.set(postCssInstanceKey, new WeakRef(this.postcssProcessor));
114
114
  }
115
115
  }
116
116
  return this.postcssProcessor;
@@ -119,7 +119,28 @@ class StylesheetPluginFactory {
119
119
  name: 'angular-' + language.name,
120
120
  async setup(build) {
121
121
  // Setup postcss if needed
122
- const postcssProcessor = await setupPostcss();
122
+ let postcssProcessor;
123
+ build.onStart(async () => {
124
+ try {
125
+ postcssProcessor = await setupPostcss();
126
+ }
127
+ catch {
128
+ return {
129
+ errors: [
130
+ {
131
+ text: 'Unable to load the "postcss" stylesheet processor.',
132
+ location: null,
133
+ notes: [
134
+ {
135
+ text: 'Ensure that the "postcss" Node.js package is installed within the project. ' +
136
+ "If not present, installation via the project's package manager should resolve the error.",
137
+ },
138
+ ],
139
+ },
140
+ ],
141
+ };
142
+ }
143
+ });
123
144
  // Add a load callback to support inline Component styles
124
145
  build.onLoad({ filter: language.componentFilter, namespace: 'angular:styles/component' }, (0, load_result_cache_1.createCachedLoad)(cache, (args) => {
125
146
  const data = options.inlineComponentData?.[args.path];
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = void 0;
11
11
  const node_path_1 = require("node:path");
12
12
  /** Version placeholder is replaced during the build process with actual package version */
13
- const VERSION = '18.0.0-next.5';
13
+ const VERSION = '18.0.0-rc.0';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&