@angular/build 19.1.0-next.1 → 19.1.0-next.2

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": "19.1.0-next.1",
3
+ "version": "19.1.0-next.2",
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.1901.0-next.1",
26
+ "@angular-devkit/architect": "0.1901.0-next.2",
27
27
  "@babel/core": "7.26.0",
28
28
  "@babel/helper-annotate-as-pure": "7.25.9",
29
29
  "@babel/helper-split-export-declaration": "7.24.7",
@@ -43,7 +43,7 @@
43
43
  "picomatch": "4.0.2",
44
44
  "piscina": "4.8.0",
45
45
  "rollup": "4.28.1",
46
- "sass": "1.82.0",
46
+ "sass": "1.83.0",
47
47
  "semver": "7.6.3",
48
48
  "vite": "6.0.3",
49
49
  "watchpack": "2.4.2"
@@ -57,7 +57,7 @@
57
57
  "@angular/localize": "^19.0.0 || ^19.1.0-next.0",
58
58
  "@angular/platform-server": "^19.0.0 || ^19.1.0-next.0",
59
59
  "@angular/service-worker": "^19.0.0 || ^19.1.0-next.0",
60
- "@angular/ssr": "^19.1.0-next.1",
60
+ "@angular/ssr": "^19.1.0-next.2",
61
61
  "less": "^4.2.0",
62
62
  "postcss": "^8.4.0",
63
63
  "tailwindcss": "^2.0.0 || ^3.0.0",
@@ -86,7 +86,6 @@
86
86
  "optional": true
87
87
  }
88
88
  },
89
- "packageManager": "yarn@4.5.0",
90
89
  "repository": {
91
90
  "type": "git",
92
91
  "url": "https://github.com/angular/angular-cli.git"
@@ -109,5 +108,8 @@
109
108
  "puppeteer": {
110
109
  "built": true
111
110
  }
111
+ },
112
+ "pnpm": {
113
+ "onlyBuiltDependencies": []
112
114
  }
113
115
  }
@@ -6,6 +6,39 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
9
42
  Object.defineProperty(exports, "__esModule", { value: true });
10
43
  exports.executeBuild = executeBuild;
11
44
  const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
@@ -21,7 +54,6 @@ const environment_options_1 = require("../../utils/environment-options");
21
54
  const resolve_assets_1 = require("../../utils/resolve-assets");
22
55
  const manifest_1 = require("../../utils/server-rendering/manifest");
23
56
  const supported_browsers_1 = require("../../utils/supported-browsers");
24
- const chunk_optimizer_1 = require("./chunk-optimizer");
25
57
  const execute_post_bundle_1 = require("./execute-post-bundle");
26
58
  const i18n_1 = require("./i18n");
27
59
  const setup_bundling_1 = require("./setup-bundling");
@@ -85,7 +117,8 @@ async function executeBuild(options, context, rebuildState) {
85
117
  bundlingResult = bundler_context_1.BundlerContext.mergeResults([bundlingResult, ...componentResults]);
86
118
  }
87
119
  if (options.optimizationOptions.scripts && environment_options_1.shouldOptimizeChunks) {
88
- bundlingResult = await (0, profiling_1.profileAsync)('OPTIMIZE_CHUNKS', () => (0, chunk_optimizer_1.optimizeChunks)(bundlingResult, options.sourcemapOptions.scripts ? !options.sourcemapOptions.hidden || 'hidden' : false));
120
+ const { optimizeChunks } = await Promise.resolve().then(() => __importStar(require('./chunk-optimizer')));
121
+ bundlingResult = await (0, profiling_1.profileAsync)('OPTIMIZE_CHUNKS', () => optimizeChunks(bundlingResult, options.sourcemapOptions.scripts ? !options.sourcemapOptions.hidden || 'hidden' : false));
89
122
  }
90
123
  const executionResult = new bundler_execution_result_1.ExecutionResult(bundlerContexts, componentStyleBundler, codeBundleCache, templateUpdates);
91
124
  executionResult.addWarnings(bundlingResult.warnings);
@@ -103,14 +103,13 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
103
103
  // https://nodejs.org/api/process.html#processsetsourcemapsenabledval
104
104
  process.setSourceMapsEnabled(true);
105
105
  }
106
- // Enable to support component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
106
+ // Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
107
107
  browserOptions.externalRuntimeStyles =
108
108
  serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentStyleHmr;
109
- // Enable to support component template hot replacement (`NG_HMR_TEMPLATE=1` can be used to enable)
110
- browserOptions.templateUpdates = !!serverOptions.liveReload && environment_options_1.useComponentTemplateHmr;
111
- if (browserOptions.templateUpdates) {
112
- context.logger.warn('Experimental support for component template hot replacement has been enabled via the "NG_HMR_TEMPLATE" environment variable.');
113
- }
109
+ // Enable to support component template hot replacement (`NG_HMR_TEMPLATE=0` can be used to disable selectively)
110
+ // This will also replace file-based/inline styles as code if external runtime styles are not enabled.
111
+ browserOptions.templateUpdates =
112
+ serverOptions.liveReload && serverOptions.hmr && environment_options_1.useComponentTemplateHmr;
114
113
  // Setup the prebundling transformer that will be shared across Vite prebundling requests
115
114
  const prebundleTransformer = new internal_1.JavaScriptTransformer(
116
115
  // Always enable JIT linking to support applications built with and without AOT.
@@ -185,6 +184,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
185
184
  assetFiles.set('/' + normalizePath(outputPath), normalizePath(file.inputPath));
186
185
  }
187
186
  }
187
+ // Invalidate SSR module graph to ensure that only new rebuild is used and not stale component updates
188
+ if (server && browserOptions.ssr && templateUpdates.size > 0) {
189
+ server.moduleGraph.invalidateAll();
190
+ }
188
191
  // Clear stale template updates on code rebuilds
189
192
  templateUpdates.clear();
190
193
  // Analyze result files for changes
@@ -197,6 +200,13 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
197
200
  case results_1.ResultKind.ComponentUpdate:
198
201
  (0, node_assert_1.default)(serverOptions.hmr, 'Component updates are only supported with HMR enabled.');
199
202
  (0, node_assert_1.default)(server, 'Builder must provide an initial full build before component update results.');
203
+ // Invalidate SSR module graph to ensure that new component updates are used
204
+ // TODO: Use fine-grained invalidation of only the component update modules
205
+ if (browserOptions.ssr) {
206
+ server.moduleGraph.invalidateAll();
207
+ const { ɵresetCompiledComponents } = (await server.ssrLoadModule('/main.server.mjs'));
208
+ ɵresetCompiledComponents();
209
+ }
200
210
  for (const componentUpdate of result.updates) {
201
211
  if (componentUpdate.type === 'template') {
202
212
  templateUpdates.set(componentUpdate.id, componentUpdate.content);
@@ -504,7 +514,14 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
504
514
  headers: serverOptions.headers,
505
515
  // Disable the websocket if live reload is disabled (false/undefined are the only valid values)
506
516
  ws: serverOptions.liveReload === false && serverOptions.hmr === false ? false : undefined,
507
- proxy,
517
+ // When server-side rendering (SSR) is enabled togather with SSL and Express is being used,
518
+ // we must configure Vite to use HTTP/1.1.
519
+ // This is necessary because Express does not support HTTP/2.
520
+ // We achieve this by defining an empty proxy.
521
+ // See: https://github.com/vitejs/vite/blob/c4b532cc900bf988073583511f57bd581755d5e3/packages/vite/src/node/http.ts#L106
522
+ proxy: serverOptions.ssl && ssrMode === plugins_1.ServerSsrMode.ExternalSsrMiddleware
523
+ ? (proxy ?? {})
524
+ : proxy,
508
525
  cors: {
509
526
  // Allow preflight requests to be proxied.
510
527
  preflightContinue: true,
@@ -250,6 +250,8 @@ function createServerMainCodeBundleOptions(options, target, sourceFileCache, sty
250
250
  ɵextractRoutesAndCreateRouteTree,
251
251
  ɵgetOrCreateAngularServerApp,
252
252
  } from '@angular/ssr';`,
253
+ // Need for HMR
254
+ `export { ɵresetCompiledComponents } from '@angular/core';`,
253
255
  // Re-export all symbols including default export from 'main.server.ts'
254
256
  `export { default } from '${mainServerEntryPointJsImport}';`,
255
257
  `export * from '${mainServerEntryPointJsImport}';`,
@@ -40,6 +40,17 @@ async function createAngularMemoryPlugin(options) {
40
40
  const [importerFile] = importer.split('?', 1);
41
41
  source = '/' + (0, node_path_1.join)((0, node_path_1.dirname)((0, node_path_1.relative)(virtualProjectRoot, importerFile)), source);
42
42
  }
43
+ else if (!ssr &&
44
+ source[0] === '/' &&
45
+ importer.endsWith('index.html') &&
46
+ normalizePath(importer).startsWith(virtualProjectRoot)) {
47
+ // This is only needed when using SSR and `angularSsrMiddleware` (old style) to correctly resolve
48
+ // .js files when using lazy-loading.
49
+ // Remove query if present
50
+ const [importerFile] = importer.split('?', 1);
51
+ source =
52
+ '/' + (0, node_path_1.join)((0, node_path_1.dirname)((0, node_path_1.relative)(virtualProjectRoot, importerFile)), (0, node_path_1.basename)(source));
53
+ }
43
54
  }
44
55
  const [file] = source.split('?', 1);
45
56
  if (outputFiles.has(file)) {
@@ -52,7 +63,7 @@ async function createAngularMemoryPlugin(options) {
52
63
  // Extract component identifier (first character is rollup virtual module null)
53
64
  const requestUrl = new URL(id.slice(1), 'http://localhost');
54
65
  const componentId = requestUrl.searchParams.get('c');
55
- return (componentId && options.templateUpdates?.get(componentId)) ?? '';
66
+ return (componentId && options.templateUpdates?.get(encodeURIComponent(componentId))) ?? '';
56
67
  }
57
68
  const [file] = id.split('?', 1);
58
69
  const relativeFile = '/' + normalizePath((0, node_path_1.relative)(virtualProjectRoot, file));
@@ -85,6 +85,6 @@ exports.shouldOptimizeChunks = isPresent(optimizeChunksVariable) && isEnabled(op
85
85
  const hmrComponentStylesVariable = process.env['NG_HMR_CSTYLES'];
86
86
  exports.useComponentStyleHmr = !isPresent(hmrComponentStylesVariable) || !isDisabled(hmrComponentStylesVariable);
87
87
  const hmrComponentTemplateVariable = process.env['NG_HMR_TEMPLATES'];
88
- exports.useComponentTemplateHmr = isPresent(hmrComponentTemplateVariable) && isEnabled(hmrComponentTemplateVariable);
88
+ exports.useComponentTemplateHmr = !isPresent(hmrComponentTemplateVariable) || !isDisabled(hmrComponentTemplateVariable);
89
89
  const partialSsrBuildVariable = process.env['NG_BUILD_PARTIAL_SSR'];
90
90
  exports.usePartialSsrBuild = isPresent(partialSsrBuildVariable) && isEnabled(partialSsrBuildVariable);
@@ -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 = '19.1.0-next.1';
13
+ const VERSION = '19.1.0-next.2';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["node"]
5
+ }
6
+ }