@angular-devkit/build-angular 18.2.0-rc.0 → 19.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.
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "18.2.0-rc.0",
3
+ "version": "19.0.0-next.0",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "main": "src/index.js",
6
6
  "typings": "src/index.d.ts",
7
7
  "builders": "builders.json",
8
8
  "dependencies": {
9
9
  "@ampproject/remapping": "2.3.0",
10
- "@angular-devkit/architect": "0.1802.0-rc.0",
11
- "@angular-devkit/build-webpack": "0.1802.0-rc.0",
12
- "@angular-devkit/core": "18.2.0-rc.0",
13
- "@angular/build": "18.2.0-rc.0",
10
+ "@angular-devkit/architect": "0.1900.0-next.0",
11
+ "@angular-devkit/build-webpack": "0.1900.0-next.0",
12
+ "@angular-devkit/core": "19.0.0-next.0",
13
+ "@angular/build": "19.0.0-next.0",
14
14
  "@babel/core": "7.25.2",
15
15
  "@babel/generator": "7.25.0",
16
16
  "@babel/helper-annotate-as-pure": "7.24.7",
@@ -21,7 +21,7 @@
21
21
  "@babel/preset-env": "7.25.3",
22
22
  "@babel/runtime": "7.25.0",
23
23
  "@discoveryjs/json-ext": "0.6.1",
24
- "@ngtools/webpack": "18.2.0-rc.0",
24
+ "@ngtools/webpack": "19.0.0-next.0",
25
25
  "@vitejs/plugin-basic-ssl": "1.1.0",
26
26
  "ansi-colors": "4.1.3",
27
27
  "autoprefixer": "10.4.20",
@@ -58,11 +58,11 @@
58
58
  "semver": "7.6.3",
59
59
  "source-map-loader": "5.0.0",
60
60
  "source-map-support": "0.5.21",
61
- "terser": "5.31.4",
61
+ "terser": "5.31.6",
62
62
  "tree-kill": "1.2.2",
63
63
  "tslib": "2.6.3",
64
- "vite": "5.3.5",
65
- "watchpack": "2.4.1",
64
+ "vite": "5.4.0",
65
+ "watchpack": "2.4.2",
66
66
  "webpack": "5.93.0",
67
67
  "webpack-dev-middleware": "7.3.0",
68
68
  "webpack-dev-server": "5.0.4",
@@ -73,16 +73,17 @@
73
73
  "esbuild": "0.23.0"
74
74
  },
75
75
  "peerDependencies": {
76
- "@angular/compiler-cli": "^18.0.0 || ^18.2.0-next.0",
77
- "@angular/localize": "^18.0.0 || ^18.2.0-next.0",
78
- "@angular/platform-server": "^18.0.0 || ^18.2.0-next.0",
79
- "@angular/service-worker": "^18.0.0 || ^18.2.0-next.0",
76
+ "@angular/compiler-cli": "^19.0.0-next.0",
77
+ "@angular/localize": "^19.0.0-next.0",
78
+ "@angular/platform-server": "^19.0.0-next.0",
79
+ "@angular/service-worker": "^19.0.0-next.0",
80
+ "@angular/ssr": "^19.0.0-next.0",
80
81
  "@web/test-runner": "^0.18.0",
81
82
  "browser-sync": "^3.0.2",
82
83
  "jest": "^29.5.0",
83
84
  "jest-environment-jsdom": "^29.5.0",
84
85
  "karma": "^6.3.0",
85
- "ng-packagr": "^18.0.0 || ^18.2.0-next.0",
86
+ "ng-packagr": "^19.0.0-next.0",
86
87
  "protractor": "^7.0.0",
87
88
  "tailwindcss": "^2.0.0 || ^3.0.0",
88
89
  "typescript": ">=5.4 <5.6"
@@ -97,6 +98,9 @@
97
98
  "@angular/service-worker": {
98
99
  "optional": true
99
100
  },
101
+ "@angular/ssr": {
102
+ "optional": true
103
+ },
100
104
  "@web/test-runner": {
101
105
  "optional": true
102
106
  },
@@ -5,10 +5,12 @@
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.dev/license
7
7
  */
8
- import { Result } from '@angular/build/private';
9
- import { BuilderContext } from '@angular-devkit/architect';
8
+ import { type ApplicationBuilderOptions } from '@angular/build';
9
+ import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
10
10
  import type { Plugin } from 'esbuild';
11
11
  import type { Schema as BrowserBuilderOptions } from './schema';
12
+ export type { BrowserBuilderOptions };
13
+ type OutputPathClass = Exclude<ApplicationBuilderOptions['outputPath'], string | undefined>;
12
14
  /**
13
15
  * Main execution function for the esbuild-based application builder.
14
16
  * The options are compatible with the Webpack-based builder.
@@ -18,9 +20,9 @@ import type { Schema as BrowserBuilderOptions } from './schema';
18
20
  */
19
21
  export declare function buildEsbuildBrowser(userOptions: BrowserBuilderOptions, context: BuilderContext, infrastructureSettings?: {
20
22
  write?: boolean;
21
- }, plugins?: Plugin[]): AsyncIterable<Result>;
22
- export declare function buildEsbuildBrowserArchitect(options: BrowserBuilderOptions, context: BuilderContext): AsyncGenerator<{
23
- success: boolean;
24
- }, void, unknown>;
23
+ }, plugins?: Plugin[]): AsyncIterable<BuilderOutput>;
24
+ export declare function convertBrowserOptions(options: BrowserBuilderOptions): Omit<ApplicationBuilderOptions, 'outputPath'> & {
25
+ outputPath: OutputPathClass;
26
+ };
25
27
  declare const _default: import("../../../../architect/src/internal").Builder<BrowserBuilderOptions & import("../../../../core/src").JsonObject>;
26
28
  export default _default;
@@ -6,16 +6,11 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  exports.buildEsbuildBrowser = buildEsbuildBrowser;
14
- exports.buildEsbuildBrowserArchitect = buildEsbuildBrowserArchitect;
15
- const private_1 = require("@angular/build/private");
11
+ exports.convertBrowserOptions = convertBrowserOptions;
12
+ const build_1 = require("@angular/build");
16
13
  const architect_1 = require("@angular-devkit/architect");
17
- const promises_1 = __importDefault(require("node:fs/promises"));
18
- const node_path_1 = __importDefault(require("node:path"));
19
14
  const builder_status_warnings_1 = require("./builder-status-warnings");
20
15
  /**
21
16
  * Main execution function for the esbuild-based application builder.
@@ -27,41 +22,11 @@ const builder_status_warnings_1 = require("./builder-status-warnings");
27
22
  async function* buildEsbuildBrowser(userOptions, context, infrastructureSettings, plugins) {
28
23
  // Inform user of status of builder and options
29
24
  (0, builder_status_warnings_1.logBuilderStatusWarnings)(userOptions, context);
30
- const normalizedOptions = normalizeOptions(userOptions);
31
- const { deleteOutputPath, outputPath } = normalizedOptions;
32
- const fullOutputPath = node_path_1.default.join(context.workspaceRoot, outputPath.base);
33
- if (deleteOutputPath && infrastructureSettings?.write !== false) {
34
- await (0, private_1.deleteOutputDir)(context.workspaceRoot, outputPath.base);
35
- }
36
- for await (const result of (0, private_1.buildApplicationInternal)(normalizedOptions, context, plugins && { codePlugins: plugins })) {
37
- // Write the file directly from this builder to maintain webpack output compatibility
38
- // and not output browser files into '/browser'.
39
- if (infrastructureSettings?.write !== false &&
40
- (result.kind === private_1.ResultKind.Full || result.kind === private_1.ResultKind.Incremental)) {
41
- const directoryExists = new Set();
42
- // Writes the output file to disk and ensures the containing directories are present
43
- await (0, private_1.emitFilesToDisk)(Object.entries(result.files), async ([filePath, file]) => {
44
- // Ensure output subdirectories exist
45
- const basePath = node_path_1.default.dirname(filePath);
46
- if (basePath && !directoryExists.has(basePath)) {
47
- await promises_1.default.mkdir(node_path_1.default.join(fullOutputPath, basePath), { recursive: true });
48
- directoryExists.add(basePath);
49
- }
50
- if (file.origin === 'memory') {
51
- // Write file contents
52
- await promises_1.default.writeFile(node_path_1.default.join(fullOutputPath, filePath), file.contents);
53
- }
54
- else {
55
- // Copy file contents
56
- await promises_1.default.copyFile(file.inputPath, node_path_1.default.join(fullOutputPath, filePath), promises_1.default.constants.COPYFILE_FICLONE);
57
- }
58
- });
59
- }
60
- yield result;
61
- }
25
+ const normalizedOptions = convertBrowserOptions(userOptions);
26
+ yield* (0, build_1.buildApplication)(normalizedOptions, context, { codePlugins: plugins });
62
27
  }
63
- function normalizeOptions(options) {
64
- const { main: browser, outputPath, ngswConfigPath, serviceWorker, polyfills, ...otherOptions } = options;
28
+ function convertBrowserOptions(options) {
29
+ const { main: browser, outputPath, ngswConfigPath, serviceWorker, polyfills, resourcesOutputPath, ...otherOptions } = options;
65
30
  return {
66
31
  browser,
67
32
  serviceWorker: serviceWorker ? ngswConfigPath : false,
@@ -69,13 +34,10 @@ function normalizeOptions(options) {
69
34
  outputPath: {
70
35
  base: outputPath,
71
36
  browser: '',
37
+ server: '',
38
+ media: resourcesOutputPath ?? 'media',
72
39
  },
73
40
  ...otherOptions,
74
41
  };
75
42
  }
76
- async function* buildEsbuildBrowserArchitect(options, context) {
77
- for await (const result of buildEsbuildBrowser(options, context)) {
78
- yield { success: result.kind !== private_1.ResultKind.Failure };
79
- }
80
- }
81
- exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowserArchitect);
43
+ exports.default = (0, architect_1.createBuilder)(buildEsbuildBrowser);
@@ -72,10 +72,12 @@ function execute(options, context, transforms = {}, extensions) {
72
72
  if (options.disableHostCheck) {
73
73
  context.logger.warn(`The "disableHostCheck" option will not be used because it is not supported by the "${builderName}" builder.`);
74
74
  }
75
- return (0, rxjs_1.defer)(() => Promise.all([Promise.resolve().then(() => __importStar(require('@angular/build/private'))), Promise.resolve().then(() => __importStar(require('../browser-esbuild')))])).pipe((0, rxjs_1.switchMap)(([{ serveWithVite, buildApplicationInternal }, { buildEsbuildBrowser }]) => serveWithVite(normalizedOptions, builderName, (options, context, codePlugins) => {
75
+ return (0, rxjs_1.defer)(() => Promise.all([Promise.resolve().then(() => __importStar(require('@angular/build/private'))), Promise.resolve().then(() => __importStar(require('../browser-esbuild')))])).pipe((0, rxjs_1.switchMap)(([{ serveWithVite, buildApplicationInternal }, { convertBrowserOptions }]) => serveWithVite(normalizedOptions, builderName, (options, context, codePlugins) => {
76
76
  return builderName === '@angular-devkit/build-angular:browser-esbuild'
77
77
  ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- buildEsbuildBrowser(options, context, { write: false }, codePlugins)
78
+ buildApplicationInternal(convertBrowserOptions(options), context, {
79
+ codePlugins,
80
+ })
79
81
  : buildApplicationInternal(options, context, { codePlugins });
80
82
  }, context, transforms, extensions)));
81
83
  }
@@ -17,25 +17,23 @@ const browser_esbuild_1 = require("../browser-esbuild");
17
17
  async function extractMessages(options, builderName, context, extractorConstructor) {
18
18
  const messages = [];
19
19
  // Setup the build options for the application based on the buildTarget option
20
- const buildOptions = (await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName));
20
+ let buildOptions;
21
+ if (builderName === '@angular-devkit/build-angular:application') {
22
+ buildOptions = (await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName));
23
+ }
24
+ else {
25
+ buildOptions = (0, browser_esbuild_1.convertBrowserOptions)((await context.validateOptions(await context.getTargetOptions(options.buildTarget), builderName)));
26
+ }
21
27
  buildOptions.optimization = false;
22
28
  buildOptions.sourceMap = { scripts: true, vendor: true, styles: false };
23
29
  buildOptions.localize = false;
24
30
  buildOptions.budgets = undefined;
25
31
  buildOptions.index = false;
26
32
  buildOptions.serviceWorker = false;
27
- let build;
28
- if (builderName === '@angular-devkit/build-angular:application') {
29
- build = private_1.buildApplicationInternal;
30
- buildOptions.ssr = false;
31
- buildOptions.appShell = false;
32
- buildOptions.prerender = false;
33
- }
34
- else {
35
- build = browser_esbuild_1.buildEsbuildBrowser;
36
- }
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- const builderResult = await first(build(buildOptions, context, { write: false }));
33
+ buildOptions.ssr = false;
34
+ buildOptions.appShell = false;
35
+ buildOptions.prerender = false;
36
+ const builderResult = await first((0, private_1.buildApplicationInternal)(buildOptions, context));
39
37
  let success = false;
40
38
  if (!builderResult || builderResult.kind === private_1.ResultKind.Failure) {
41
39
  context.logger.error('Application build failed.');
@@ -39,14 +39,15 @@ const path = __importStar(require("node:path"));
39
39
  const node_worker_threads_1 = require("node:worker_threads");
40
40
  const { zonePackage, serverBundlePath, outputPath, indexFile } = node_worker_threads_1.workerData;
41
41
  async function extract() {
42
- const { AppServerModule, extractRoutes, default: bootstrapAppFn, } = (await Promise.resolve(`${serverBundlePath}`).then(s => __importStar(require(s))));
42
+ const { AppServerModule, ɵgetRoutesFromAngularRouterConfig: getRoutesFromAngularRouterConfig, default: bootstrapAppFn, } = (await Promise.resolve(`${serverBundlePath}`).then(s => __importStar(require(s))));
43
43
  const browserIndexInputPath = path.join(outputPath, indexFile);
44
44
  const document = await fs.promises.readFile(browserIndexInputPath, 'utf8');
45
45
  const bootstrapAppFnOrModule = bootstrapAppFn || AppServerModule;
46
46
  (0, node_assert_1.default)(bootstrapAppFnOrModule, `The file "${serverBundlePath}" does not have a default export for an AppServerModule or a bootstrapping function.`);
47
47
  const routes = [];
48
- for await (const { route, success } of extractRoutes(bootstrapAppFnOrModule, document)) {
49
- if (success) {
48
+ const { routes: extractRoutes } = await getRoutesFromAngularRouterConfig(bootstrapAppFnOrModule, document, new URL('http://localhost'));
49
+ for (const { route, redirectTo } of extractRoutes) {
50
+ if (redirectTo === undefined && !/[:*]/.test(route)) {
50
51
  routes.push(route);
51
52
  }
52
53
  }
@@ -183,13 +183,16 @@ function getPlatformServerExportsConfig(wco) {
183
183
  // Only add `@angular/platform-server` exports when it is installed.
184
184
  // In some cases this builder is used when `@angular/platform-server` is not installed.
185
185
  // Example: when using `@nguniversal/common/clover` which does not need `@angular/platform-server`.
186
- return (0, helpers_1.isPlatformServerInstalled)(wco.root)
186
+ return (0, helpers_1.isPackageInstalled)(wco.root, '@angular/platform-server')
187
187
  ? {
188
188
  module: {
189
189
  rules: [
190
190
  {
191
191
  loader: require.resolve('./platform-server-exports-loader'),
192
192
  include: [path.resolve(wco.root, wco.buildOptions.main)],
193
+ options: {
194
+ angularSSRInstalled: (0, helpers_1.isPackageInstalled)(wco.root, '@angular/ssr'),
195
+ },
193
196
  },
194
197
  ],
195
198
  },
@@ -10,4 +10,6 @@
10
10
  * allow exports from multiple files in the same entry.
11
11
  * @see https://github.com/webpack/webpack/issues/15936.
12
12
  */
13
- export default function (this: import('webpack').LoaderContext<{}>, content: string, map: Parameters<import('webpack').LoaderDefinitionFunction>[1]): void;
13
+ export default function (this: import('webpack').LoaderContext<{
14
+ angularSSRInstalled: boolean;
15
+ }>, content: string, map: Parameters<import('webpack').LoaderDefinitionFunction>[1]): void;
@@ -8,23 +8,23 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.default = default_1;
11
- const node_fs_1 = require("node:fs");
12
- const node_path_1 = require("node:path");
13
11
  /**
14
12
  * This loader is needed to add additional exports and is a workaround for a Webpack bug that doesn't
15
13
  * allow exports from multiple files in the same entry.
16
14
  * @see https://github.com/webpack/webpack/issues/15936.
17
15
  */
18
16
  function default_1(content, map) {
19
- const extractorPath = (0, node_path_1.join)((0, node_path_1.dirname)(require.resolve('@angular/build/package.json')), 'src/utils/routes-extractor/extractor.js');
20
- const source = `${content}
17
+ const { angularSSRInstalled } = this.getOptions();
18
+ let source = `${content}
21
19
 
22
20
  // EXPORTS added by @angular-devkit/build-angular
23
21
  export { renderApplication, renderModule, ɵSERVER_CONTEXT } from '@angular/platform-server';
24
- ` +
25
- // We do not import it directly so that node.js modules are resolved using the correct context.
26
- // Remove source map URL comments from the code if a sourcemap is present as this will not match the file.
27
- (0, node_fs_1.readFileSync)(extractorPath, 'utf-8').replace(/^\/\/# sourceMappingURL=[^\r\n]*/gm, '');
22
+ `;
23
+ if (angularSSRInstalled) {
24
+ source += `
25
+ export { ɵgetRoutesFromAngularRouterConfig } from '@angular/ssr';
26
+ `;
27
+ }
28
28
  this.callback(null, source, map);
29
29
  return;
30
30
  }
@@ -85,7 +85,8 @@ async function getCommonConfig(wco) {
85
85
  if (isPlatformServer) {
86
86
  // Fixes Critical dependency: the request of a dependency is an expression
87
87
  extraPlugins.push(new webpack_2.ContextReplacementPlugin(/@?hapi|express[\\/]/));
88
- if ((0, helpers_1.isPlatformServerInstalled)(wco.root) && Array.isArray(entryPoints['main'])) {
88
+ if ((0, helpers_1.isPackageInstalled)(wco.root, '@angular/platform-server') &&
89
+ Array.isArray(entryPoints['main'])) {
89
90
  // This import must come before any imports (direct or transitive) that rely on DOM built-ins being
90
91
  // available, such as `@angular/elements`.
91
92
  entryPoints['main'].unshift('@angular/platform-server/init');
@@ -34,7 +34,10 @@ export declare function globalScriptsByBundleName(scripts: ScriptElement[]): {
34
34
  export declare function assetPatterns(root: string, assets: AssetPatternClass[]): ObjectPattern[];
35
35
  export declare function getStatsOptions(verbose?: boolean): WebpackStatsOptions;
36
36
  /**
37
- * @param root the workspace root
38
- * @returns `true` when `@angular/platform-server` is installed.
37
+ * Checks if a specified package is installed in the given workspace.
38
+ *
39
+ * @param root - The root directory of the workspace.
40
+ * @param name - The name of the package to check for.
41
+ * @returns `true` if the package is installed, `false` otherwise.
39
42
  */
40
- export declare function isPlatformServerInstalled(root: string): boolean;
43
+ export declare function isPackageInstalled(root: string, name: string): boolean;
@@ -42,7 +42,7 @@ exports.getCacheSettings = getCacheSettings;
42
42
  exports.globalScriptsByBundleName = globalScriptsByBundleName;
43
43
  exports.assetPatterns = assetPatterns;
44
44
  exports.getStatsOptions = getStatsOptions;
45
- exports.isPlatformServerInstalled = isPlatformServerInstalled;
45
+ exports.isPackageInstalled = isPackageInstalled;
46
46
  const crypto_1 = require("crypto");
47
47
  const fast_glob_1 = __importDefault(require("fast-glob"));
48
48
  const path = __importStar(require("path"));
@@ -276,12 +276,15 @@ function getStatsOptions(verbose = false) {
276
276
  : webpackOutputOptions;
277
277
  }
278
278
  /**
279
- * @param root the workspace root
280
- * @returns `true` when `@angular/platform-server` is installed.
279
+ * Checks if a specified package is installed in the given workspace.
280
+ *
281
+ * @param root - The root directory of the workspace.
282
+ * @param name - The name of the package to check for.
283
+ * @returns `true` if the package is installed, `false` otherwise.
281
284
  */
282
- function isPlatformServerInstalled(root) {
285
+ function isPackageInstalled(root, name) {
283
286
  try {
284
- require.resolve('@angular/platform-server', { paths: [root] });
287
+ require.resolve(name, { paths: [root] });
285
288
  return true;
286
289
  }
287
290
  catch {
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = normalizeCacheOptions;
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.2.0-rc.0';
13
+ const VERSION = '19.0.0-next.0';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -1,17 +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.dev/license
7
- */
8
-
9
- /* eslint-disable import/no-extraneous-dependencies */
10
- // Workaround for https://github.com/bazelbuild/rules_nodejs/issues/1033
11
- // Alternative approach instead of https://github.com/angular/angular/pull/33226
12
- declare module '@babel/core' {
13
- export * from '@types/babel__core';
14
- }
15
- declare module '@babel/generator' {
16
- export { default } from '@types/babel__generator';
17
- }