@angular/build 18.0.5 → 18.0.7

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.5",
3
+ "version": "18.0.7",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,7 +23,7 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.1800.5",
26
+ "@angular-devkit/architect": "0.1800.7",
27
27
  "@babel/core": "7.24.5",
28
28
  "@babel/helper-annotate-as-pure": "7.22.5",
29
29
  "@babel/helper-split-export-declaration": "7.24.5",
package/src/private.d.ts CHANGED
@@ -22,6 +22,7 @@ export { SassWorkerImplementation } from './tools/sass/sass-service';
22
22
  export { SourceFileCache } from './tools/esbuild/angular/source-file-cache';
23
23
  export { createJitResourceTransformer } from './tools/esbuild/angular/jit-resource-transformer';
24
24
  export { JavaScriptTransformer } from './tools/esbuild/javascript-transformer';
25
+ export { createCompilerPlugin } from './tools/esbuild/angular/compiler-plugin';
25
26
  export * from './utils/bundle-calculator';
26
27
  export { checkPort } from './utils/check-port';
27
28
  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.JavaScriptTransformer = exports.createJitResourceTransformer = exports.SourceFileCache = 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.createCompilerPlugin = 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.
@@ -47,6 +47,8 @@ var jit_resource_transformer_1 = require("./tools/esbuild/angular/jit-resource-t
47
47
  Object.defineProperty(exports, "createJitResourceTransformer", { enumerable: true, get: function () { return jit_resource_transformer_1.createJitResourceTransformer; } });
48
48
  var javascript_transformer_1 = require("./tools/esbuild/javascript-transformer");
49
49
  Object.defineProperty(exports, "JavaScriptTransformer", { enumerable: true, get: function () { return javascript_transformer_1.JavaScriptTransformer; } });
50
+ var compiler_plugin_1 = require("./tools/esbuild/angular/compiler-plugin");
51
+ Object.defineProperty(exports, "createCompilerPlugin", { enumerable: true, get: function () { return compiler_plugin_1.createCompilerPlugin; } });
50
52
  // Utilities
51
53
  __exportStar(require("./utils/bundle-calculator"), exports);
52
54
  var check_port_1 = require("./utils/check-port");
@@ -57,8 +57,23 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
57
57
  // Webcontainers currently do not support this persistent cache store.
58
58
  let cacheStore;
59
59
  if (pluginOptions.sourceFileCache?.persistentCachePath && !process.versions.webcontainer) {
60
- const { LmbdCacheStore } = await Promise.resolve().then(() => __importStar(require('../lmdb-cache-store')));
61
- cacheStore = new LmbdCacheStore(path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'));
60
+ try {
61
+ const { LmbdCacheStore } = await Promise.resolve().then(() => __importStar(require('../lmdb-cache-store')));
62
+ cacheStore = new LmbdCacheStore(path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'));
63
+ }
64
+ catch (e) {
65
+ setupWarnings.push({
66
+ text: 'Unable to initialize JavaScript cache storage.',
67
+ location: null,
68
+ notes: [
69
+ // Only show first line of lmdb load error which has platform support listed
70
+ { text: e?.message.split('\n')[0] ?? `${e}` },
71
+ {
72
+ text: 'This will not affect the build output content but may result in slower builds.',
73
+ },
74
+ ],
75
+ });
76
+ }
62
77
  }
63
78
  const javascriptTransformer = new javascript_transformer_1.JavaScriptTransformer({
64
79
  sourcemap: !!pluginOptions.sourcemap,
@@ -8,7 +8,7 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.generateBudgetStats = void 0;
11
- const node_path_1 = require("node:path");
11
+ const utils_1 = require("./utils");
12
12
  /**
13
13
  * Generates a bundle budget calculator compatible stats object that provides
14
14
  * the necessary information for the Webpack-based bundle budget code to
@@ -35,9 +35,7 @@ function generateBudgetStats(metafile, initialFiles) {
35
35
  let name = initialRecord?.name;
36
36
  if (name === undefined && entry.entryPoint) {
37
37
  // For non-initial lazy modules, convert the entry point file into a Webpack compatible name
38
- name = (0, node_path_1.basename)(entry.entryPoint)
39
- .replace(/\.[cm]?[jt]s$/, '')
40
- .replace(/[\\/.]/g, '-');
38
+ name = (0, utils_1.getEntryPointName)(entry.entryPoint);
41
39
  }
42
40
  stats.chunks.push({
43
41
  files: [file],
@@ -47,3 +47,4 @@ export declare function logMessages(logger: BuilderContext['logger'], executionR
47
47
  * @returns true, when the application is considered as zoneless.
48
48
  */
49
49
  export declare function isZonelessApp(polyfills: string[] | undefined): boolean;
50
+ export declare function getEntryPointName(entryPoint: string): string;
@@ -10,7 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.isZonelessApp = exports.logMessages = exports.createJsonBuildManifest = exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
13
+ exports.getEntryPointName = exports.isZonelessApp = exports.logMessages = exports.createJsonBuildManifest = exports.getSupportedNodeTargets = exports.transformSupportedBrowsersToTargets = exports.convertOutputFile = exports.createOutputFileFromData = exports.createOutputFileFromText = exports.emitFilesToDisk = exports.writeResultFiles = exports.getFeatureSupport = exports.withNoProgress = exports.withSpinner = exports.calculateEstimatedTransferSizes = exports.logBuildStats = void 0;
14
14
  const esbuild_1 = require("esbuild");
15
15
  const node_crypto_1 = require("node:crypto");
16
16
  const node_fs_1 = require("node:fs");
@@ -49,9 +49,7 @@ function logBuildStats(metafile, initial, budgetFailures, colors, changedFiles,
49
49
  }
50
50
  let name = initial.get(file)?.name;
51
51
  if (name === undefined && output.entryPoint) {
52
- name = (0, node_path_1.basename)(output.entryPoint)
53
- .replace(/\.[cm]?[jt]s$/, '')
54
- .replace(/[\\/.]/g, '-');
52
+ name = getEntryPointName(output.entryPoint);
55
53
  }
56
54
  const stat = {
57
55
  initial: initial.has(file),
@@ -390,3 +388,10 @@ function isZonelessApp(polyfills) {
390
388
  return !polyfills?.some((p) => p === 'zone.js' || /\.[mc]?[jt]s$/.test(p));
391
389
  }
392
390
  exports.isZonelessApp = isZonelessApp;
391
+ function getEntryPointName(entryPoint) {
392
+ return (0, node_path_1.basename)(entryPoint)
393
+ .replace(/(.*:)/, '') // global:bundle.css -> bundle.css
394
+ .replace(/\.[cm]?[jt]s$/, '')
395
+ .replace(/[\\/.]/g, '-');
396
+ }
397
+ exports.getEntryPointName = getEntryPointName;
@@ -89,6 +89,7 @@ function createAngularMemoryPlugin(options) {
89
89
  // The base of the URL is unused but required to parse the URL.
90
90
  const pathname = pathnameWithoutBasePath(req.url, server.config.base);
91
91
  const extension = (0, node_path_1.extname)(pathname);
92
+ const pathnameHasTrailingSlash = pathname[pathname.length - 1] === '/';
92
93
  // Rewrite all build assets to a vite raw fs URL
93
94
  const assetSourcePath = assets.get(pathname);
94
95
  if (assetSourcePath !== undefined) {
@@ -105,7 +106,7 @@ function createAngularMemoryPlugin(options) {
105
106
  // HTML fallbacking
106
107
  // This matches what happens in the vite html fallback middleware.
107
108
  // ref: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/server/middlewares/htmlFallback.ts#L9
108
- const htmlAssetSourcePath = pathname[pathname.length - 1] === '/'
109
+ const htmlAssetSourcePath = pathnameHasTrailingSlash
109
110
  ? // Trailing slash check for `index.html`.
110
111
  assets.get(pathname + 'index.html')
111
112
  : // Non-trailing slash check for fallback `.html`
@@ -133,6 +134,17 @@ function createAngularMemoryPlugin(options) {
133
134
  return;
134
135
  }
135
136
  }
137
+ // If the path has no trailing slash and it matches a servable directory redirect to the same path with slash.
138
+ // This matches the default express static behaviour.
139
+ // See: https://github.com/expressjs/serve-static/blob/89fc94567fae632718a2157206c52654680e9d01/index.js#L182
140
+ if (!pathnameHasTrailingSlash) {
141
+ for (const assetPath of assets.keys()) {
142
+ if (pathname === assetPath.substring(0, assetPath.lastIndexOf('/'))) {
143
+ redirect(res, req.url + '/');
144
+ return;
145
+ }
146
+ }
147
+ }
136
148
  next();
137
149
  });
138
150
  if (extensionMiddleware?.length) {
@@ -266,3 +278,19 @@ function lookupMimeTypeFromRequest(url) {
266
278
  }
267
279
  return extension && (0, mrmime_1.lookup)(extension);
268
280
  }
281
+ function redirect(res, location) {
282
+ res.statusCode = 301;
283
+ res.setHeader('Content-Type', 'text/html');
284
+ res.setHeader('Location', location);
285
+ res.end(`
286
+ <!DOCTYPE html>
287
+ <html lang="en">
288
+ <head>
289
+ <meta charset="utf-8">
290
+ <title>Redirecting</title>
291
+ </head>
292
+ <body>
293
+ <pre>Redirecting to <a href="${location}">${location}</a></pre>
294
+ </body>
295
+ </html>`);
296
+ }
@@ -69,7 +69,7 @@ exports.allowMinify = debugOptimize.minify;
69
69
  const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
70
70
  exports.maxWorkers = isPresent(maxWorkersVariable)
71
71
  ? +maxWorkersVariable
72
- : Math.min(4, (0, node_os_1.availableParallelism)());
72
+ : Math.min(4, Math.max((0, node_os_1.availableParallelism)() - 1, 1));
73
73
  const parallelTsVariable = process.env['NG_BUILD_PARALLEL_TS'];
74
74
  exports.useParallelTs = !isPresent(parallelTsVariable) || !isDisabled(parallelTsVariable);
75
75
  const debugPerfVariable = process.env['NG_BUILD_DEBUG_PERF'];
@@ -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.5';
13
+ const VERSION = '18.0.7';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&