@angular-devkit/build-angular 18.2.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",
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",
11
- "@angular-devkit/build-webpack": "0.1802.0",
12
- "@angular-devkit/core": "18.2.0",
13
- "@angular/build": "18.2.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",
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",
@@ -62,7 +62,7 @@
62
62
  "tree-kill": "1.2.2",
63
63
  "tslib": "2.6.3",
64
64
  "vite": "5.4.0",
65
- "watchpack": "2.4.1",
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",
77
- "@angular/localize": "^18.0.0",
78
- "@angular/platform-server": "^18.0.0",
79
- "@angular/service-worker": "^18.0.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",
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
  },
@@ -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';
13
+ const VERSION = '19.0.0-next.0';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&