@angular/build 18.1.0-next.0 → 18.1.0-next.1

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.
Files changed (104) hide show
  1. package/package.json +9 -9
  2. package/src/builders/application/build-action.js +1 -2
  3. package/src/builders/application/execute-build.js +1 -2
  4. package/src/builders/application/execute-post-bundle.js +1 -2
  5. package/src/builders/application/i18n.js +2 -3
  6. package/src/builders/application/index.js +2 -3
  7. package/src/builders/application/options.d.ts +2 -2
  8. package/src/builders/application/options.js +1 -2
  9. package/src/builders/application/setup-bundling.js +2 -8
  10. package/src/builders/dev-server/builder.d.ts +0 -1
  11. package/src/builders/dev-server/builder.js +1 -2
  12. package/src/builders/dev-server/options.d.ts +4 -0
  13. package/src/builders/dev-server/options.js +26 -2
  14. package/src/builders/dev-server/schema.d.ts +10 -0
  15. package/src/builders/dev-server/schema.json +11 -0
  16. package/src/builders/dev-server/vite-server.js +42 -34
  17. package/src/builders/extract-i18n/application-extraction.js +1 -2
  18. package/src/builders/extract-i18n/builder.js +1 -2
  19. package/src/builders/extract-i18n/options.js +1 -2
  20. package/src/tools/babel/plugins/adjust-static-class-members.d.ts +0 -1
  21. package/src/tools/babel/plugins/adjust-static-class-members.js +2 -3
  22. package/src/tools/babel/plugins/adjust-typescript-enums.d.ts +0 -1
  23. package/src/tools/babel/plugins/adjust-typescript-enums.js +2 -3
  24. package/src/tools/babel/plugins/elide-angular-metadata.d.ts +0 -1
  25. package/src/tools/babel/plugins/elide-angular-metadata.js +2 -3
  26. package/src/tools/babel/plugins/pure-toplevel-functions.d.ts +0 -1
  27. package/src/tools/babel/plugins/pure-toplevel-functions.js +1 -1
  28. package/src/tools/esbuild/angular/angular-host.js +2 -3
  29. package/src/tools/esbuild/angular/compilation/aot-compilation.js +42 -7
  30. package/src/tools/esbuild/angular/compilation/factory.js +1 -2
  31. package/src/tools/esbuild/angular/compilation/jit-bootstrap-transformer.js +2 -3
  32. package/src/tools/esbuild/angular/compilation/parallel-worker.d.ts +2 -1
  33. package/src/tools/esbuild/angular/compilation/parallel-worker.js +10 -7
  34. package/src/tools/esbuild/angular/compilation-state.js +2 -2
  35. package/src/tools/esbuild/angular/compiler-plugin.js +18 -9
  36. package/src/tools/esbuild/angular/diagnostics.js +1 -2
  37. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +1 -2
  38. package/src/tools/esbuild/angular/jit-resource-transformer.js +1 -2
  39. package/src/tools/esbuild/angular/uri.js +4 -4
  40. package/src/tools/esbuild/angular/web-worker-transformer.js +1 -2
  41. package/src/tools/esbuild/application-code-bundle.js +4 -5
  42. package/src/tools/esbuild/budget-stats.js +1 -2
  43. package/src/tools/esbuild/commonjs-checker.js +1 -2
  44. package/src/tools/esbuild/compiler-plugin-options.js +1 -2
  45. package/src/tools/esbuild/external-packages-plugin.js +1 -2
  46. package/src/tools/esbuild/global-scripts.js +1 -2
  47. package/src/tools/esbuild/global-styles.js +1 -2
  48. package/src/tools/esbuild/i18n-inliner-worker.d.ts +1 -1
  49. package/src/tools/esbuild/i18n-inliner-worker.js +1 -1
  50. package/src/tools/esbuild/i18n-locale-plugin.js +2 -2
  51. package/src/tools/esbuild/index-html-generator.js +1 -2
  52. package/src/tools/esbuild/javascript-transformer-worker.js +1 -1
  53. package/src/tools/esbuild/javascript-transformer.d.ts +1 -1
  54. package/src/tools/esbuild/license-extractor.js +1 -2
  55. package/src/tools/esbuild/load-result-cache.js +2 -2
  56. package/src/tools/esbuild/profiling.js +4 -5
  57. package/src/tools/esbuild/rxjs-esm-resolution-plugin.js +1 -2
  58. package/src/tools/esbuild/sourcemap-ignorelist-plugin.js +1 -2
  59. package/src/tools/esbuild/stylesheets/bundle-options.js +1 -2
  60. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +1 -2
  61. package/src/tools/esbuild/stylesheets/css-resource-plugin.js +1 -2
  62. package/src/tools/esbuild/stylesheets/sass-language.js +29 -3
  63. package/src/tools/esbuild/utils.js +15 -16
  64. package/src/tools/esbuild/virtual-module-plugin.js +1 -2
  65. package/src/tools/esbuild/watcher.js +2 -2
  66. package/src/tools/sass/lexer.js +1 -2
  67. package/src/tools/sass/rebasing-importer.js +2 -2
  68. package/src/tools/sass/sass-service.js +3 -1
  69. package/src/tools/sass/worker.d.ts +2 -4
  70. package/src/tools/sass/worker.js +1 -1
  71. package/src/tools/vite/angular-memory-plugin.js +1 -2
  72. package/src/tools/vite/i18n-locale-plugin.js +2 -2
  73. package/src/utils/bundle-calculator.js +4 -4
  74. package/src/utils/check-port.js +1 -2
  75. package/src/utils/delete-output-dir.js +1 -2
  76. package/src/utils/error.js +1 -2
  77. package/src/utils/format-bytes.js +1 -2
  78. package/src/utils/i18n-options.js +2 -3
  79. package/src/utils/index-file/add-event-dispatch-contract.js +1 -2
  80. package/src/utils/index-file/augment-index-html.js +1 -2
  81. package/src/utils/index-file/html-rewriting-stream.js +1 -2
  82. package/src/utils/index-file/nonce.js +1 -2
  83. package/src/utils/load-esm.js +1 -2
  84. package/src/utils/load-proxy-config.js +1 -2
  85. package/src/utils/load-translations.js +1 -2
  86. package/src/utils/normalize-asset-patterns.js +2 -2
  87. package/src/utils/normalize-cache.js +2 -3
  88. package/src/utils/normalize-optimization.js +1 -2
  89. package/src/utils/normalize-source-maps.js +1 -2
  90. package/src/utils/postcss-configuration.js +3 -4
  91. package/src/utils/purge-cache.js +1 -2
  92. package/src/utils/resolve-assets.js +1 -2
  93. package/src/utils/server-rendering/esm-in-memory-loader/loader-hooks.js +3 -4
  94. package/src/utils/server-rendering/fetch-patch.js +1 -2
  95. package/src/utils/server-rendering/load-esm-from-memory.js +1 -2
  96. package/src/utils/server-rendering/prerender.js +1 -2
  97. package/src/utils/server-rendering/render-page.js +1 -2
  98. package/src/utils/service-worker.d.ts +0 -2
  99. package/src/utils/service-worker.js +3 -4
  100. package/src/utils/stats-table.js +2 -3
  101. package/src/utils/supported-browsers.js +1 -2
  102. package/src/utils/tty.js +1 -2
  103. package/src/utils/url.js +1 -2
  104. package/src/utils/version.js +1 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "18.1.0-next.0",
3
+ "version": "18.1.0-next.1",
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.1801.0-next.0",
27
- "@babel/core": "7.24.6",
28
- "@babel/helper-annotate-as-pure": "7.24.6",
29
- "@babel/helper-split-export-declaration": "7.24.6",
26
+ "@angular-devkit/architect": "0.1801.0-next.1",
27
+ "@babel/core": "7.24.7",
28
+ "@babel/helper-annotate-as-pure": "7.24.7",
29
+ "@babel/helper-split-export-declaration": "7.24.7",
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.21.4",
35
35
  "fast-glob": "3.3.2",
36
36
  "https-proxy-agent": "7.0.4",
37
- "inquirer": "9.2.22",
37
+ "inquirer": "9.2.23",
38
38
  "lmdb": "3.0.11",
39
39
  "magic-string": "0.30.10",
40
40
  "mrmime": "2.0.0",
@@ -42,9 +42,9 @@
42
42
  "picomatch": "4.0.2",
43
43
  "piscina": "4.5.1",
44
44
  "parse5-html-rewriting-stream": "7.0.0",
45
- "sass": "1.77.2",
45
+ "sass": "1.77.4",
46
46
  "semver": "7.6.2",
47
- "undici": "6.18.1",
47
+ "undici": "6.18.2",
48
48
  "vite": "5.2.12",
49
49
  "watchpack": "2.4.1"
50
50
  },
@@ -56,7 +56,7 @@
56
56
  "less": "^4.2.0",
57
57
  "postcss": "^8.4.0",
58
58
  "tailwindcss": "^2.0.0 || ^3.0.0",
59
- "typescript": ">=5.4 <5.5"
59
+ "typescript": ">=5.4 <5.6"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@angular/localize": {
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.runEsBuildBuildAction = void 0;
36
+ exports.runEsBuildBuildAction = runEsBuildBuildAction;
37
37
  const node_fs_1 = require("node:fs");
38
38
  const node_path_1 = __importDefault(require("node:path"));
39
39
  const sass_language_1 = require("../../tools/esbuild/stylesheets/sass-language");
@@ -167,7 +167,6 @@ async function* runEsBuildBuildAction(action, options) {
167
167
  (0, sass_language_1.shutdownSassWorkerPool)();
168
168
  }
169
169
  }
170
- exports.runEsBuildBuildAction = runEsBuildBuildAction;
171
170
  async function writeAndEmitOutput(writeToFileSystem, { outputFiles, output, outputWithFiles, assetFiles }, outputOptions, writeToFileSystemFilter) {
172
171
  if (writeToFileSystem) {
173
172
  // Write output files
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.executeBuild = void 0;
10
+ exports.executeBuild = executeBuild;
11
11
  const source_file_cache_1 = require("../../tools/esbuild/angular/source-file-cache");
12
12
  const budget_stats_1 = require("../../tools/esbuild/budget-stats");
13
13
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
@@ -126,4 +126,3 @@ async function executeBuild(options, context, rebuildState) {
126
126
  }
127
127
  return executionResult;
128
128
  }
129
- exports.executeBuild = executeBuild;
@@ -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.executePostBundleSteps = void 0;
13
+ exports.executePostBundleSteps = executePostBundleSteps;
14
14
  const node_assert_1 = __importDefault(require("node:assert"));
15
15
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
16
16
  const index_html_generator_1 = require("../../tools/esbuild/index-html-generator");
@@ -90,4 +90,3 @@ async function executePostBundleSteps(options, outputFiles, assetFiles, initialF
90
90
  additionalOutputFiles,
91
91
  };
92
92
  }
93
- exports.executePostBundleSteps = executePostBundleSteps;
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.loadActiveTranslations = exports.inlineI18n = void 0;
10
+ exports.inlineI18n = inlineI18n;
11
+ exports.loadActiveTranslations = loadActiveTranslations;
11
12
  const node_path_1 = require("node:path");
12
13
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
13
14
  const i18n_inliner_1 = require("../../tools/esbuild/i18n-inliner");
@@ -89,7 +90,6 @@ async function inlineI18n(options, executionResult, initialFiles) {
89
90
  }
90
91
  return inlineResult;
91
92
  }
92
- exports.inlineI18n = inlineI18n;
93
93
  function getLocaleBaseHref(baseHref, i18n, locale) {
94
94
  if (i18n.flatOutput) {
95
95
  return undefined;
@@ -125,4 +125,3 @@ async function loadActiveTranslations(context, i18n) {
125
125
  }, undefined, i18n.duplicateTranslationBehavior);
126
126
  }
127
127
  }
128
- exports.loadActiveTranslations = loadActiveTranslations;
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.buildApplication = exports.buildApplicationInternal = void 0;
10
+ exports.buildApplicationInternal = buildApplicationInternal;
11
+ exports.buildApplication = buildApplication;
11
12
  const architect_1 = require("@angular-devkit/architect");
12
13
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
13
14
  const utils_1 = require("../../tools/esbuild/utils");
@@ -104,7 +105,6 @@ context, infrastructureSettings, extensions) {
104
105
  signal,
105
106
  });
106
107
  }
107
- exports.buildApplicationInternal = buildApplicationInternal;
108
108
  function buildApplication(options, context, pluginsOrExtensions) {
109
109
  let extensions;
110
110
  if (pluginsOrExtensions && Array.isArray(pluginsOrExtensions)) {
@@ -117,5 +117,4 @@ function buildApplication(options, context, pluginsOrExtensions) {
117
117
  }
118
118
  return buildApplicationInternal(options, context, undefined, extensions);
119
119
  }
120
- exports.buildApplication = buildApplication;
121
120
  exports.default = (0, architect_1.createBuilder)(buildApplication);
@@ -131,8 +131,8 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
131
131
  } | undefined;
132
132
  postcssConfiguration: import("../../utils/postcss-configuration").PostcssConfiguration | undefined;
133
133
  i18nOptions: I18nOptions & {
134
- duplicateTranslationBehavior?: I18NTranslation | undefined;
135
- missingTranslationBehavior?: I18NTranslation | undefined;
134
+ duplicateTranslationBehavior?: I18NTranslation;
135
+ missingTranslationBehavior?: I18NTranslation;
136
136
  };
137
137
  namedChunks: boolean | undefined;
138
138
  budgets: import("./schema").Budget[] | undefined;
@@ -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.normalizeOptions = void 0;
13
+ exports.normalizeOptions = normalizeOptions;
14
14
  const node_fs_1 = require("node:fs");
15
15
  const promises_1 = require("node:fs/promises");
16
16
  const node_module_1 = require("node:module");
@@ -247,7 +247,6 @@ async function normalizeOptions(context, projectName, options, extensions) {
247
247
  define,
248
248
  };
249
249
  }
250
- exports.normalizeOptions = normalizeOptions;
251
250
  async function getTailwindConfig(searchDirectories, workspaceRoot, context) {
252
251
  const tailwindConfigurationPath = (0, postcss_configuration_1.findTailwindConfiguration)(searchDirectories);
253
252
  if (!tailwindConfigurationPath) {
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.setupBundlerContexts = void 0;
10
+ exports.setupBundlerContexts = setupBundlerContexts;
11
11
  const application_code_bundle_1 = require("../../tools/esbuild/application-code-bundle");
12
12
  const bundler_context_1 = require("../../tools/esbuild/bundler-context");
13
13
  const global_scripts_1 = require("../../tools/esbuild/global-scripts");
@@ -54,12 +54,7 @@ function setupBundlerContexts(options, browsers, codeBundleCache) {
54
54
  if (serverEntryPoint && (prerenderOptions || appShellOptions || ssrOptions)) {
55
55
  const nodeTargets = [...target, ...(0, utils_1.getSupportedNodeTargets)()];
56
56
  // Server application code
57
- bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createServerCodeBundleOptions)({
58
- ...options,
59
- // Disable external deps for server bundles.
60
- // This is because it breaks Vite 'optimizeDeps' for SSR.
61
- externalPackages: false,
62
- }, nodeTargets, codeBundleCache)));
57
+ bundlerContexts.push(new bundler_context_1.BundlerContext(workspaceRoot, !!options.watch, (0, application_code_bundle_1.createServerCodeBundleOptions)(options, nodeTargets, codeBundleCache)));
63
58
  // Server polyfills code
64
59
  const serverPolyfillBundleOptions = (0, application_code_bundle_1.createServerPolyfillBundleOptions)(options, nodeTargets, codeBundleCache);
65
60
  if (serverPolyfillBundleOptions) {
@@ -68,4 +63,3 @@ function setupBundlerContexts(options, browsers, codeBundleCache) {
68
63
  }
69
64
  return bundlerContexts;
70
65
  }
71
- exports.setupBundlerContexts = setupBundlerContexts;
@@ -5,7 +5,6 @@
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.io/license
7
7
  */
8
- /// <reference types="node" />
9
8
  import type { BuilderContext } from '@angular-devkit/architect';
10
9
  import type { Plugin } from 'esbuild';
11
10
  import type http from 'node:http';
@@ -7,7 +7,7 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.execute = void 0;
10
+ exports.execute = execute;
11
11
  const check_port_1 = require("../../utils/check-port");
12
12
  const internal_1 = require("./internal");
13
13
  const options_1 = require("./options");
@@ -39,7 +39,6 @@ async function* execute(options, context, extensions) {
39
39
  }
40
40
  yield* (0, vite_server_1.serveWithVite)(normalizedOptions, builderName, (options, context, plugins) => (0, internal_1.buildApplicationInternal)(options, context, { write: false }, { codePlugins: plugins }), context, { indexHtml: extensions?.indexHtmlTransformer }, extensions);
41
41
  }
42
- exports.execute = execute;
43
42
  async function initialize(initialOptions, projectName, context) {
44
43
  // Purge old build disk cache.
45
44
  await (0, internal_1.purgeStaleBuildCache)(context);
@@ -40,4 +40,8 @@ export declare function normalizeOptions(context: BuilderContext, projectName: s
40
40
  sslCert: string | undefined;
41
41
  sslKey: string | undefined;
42
42
  prebundle: import("./schema").PrebundleUnion | undefined;
43
+ inspect: boolean | {
44
+ host?: string;
45
+ port?: number;
46
+ };
43
47
  }>;
@@ -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.normalizeOptions = void 0;
13
+ exports.normalizeOptions = normalizeOptions;
14
14
  const architect_1 = require("@angular-devkit/architect");
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
16
  const utils_1 = require("../../utils");
@@ -48,6 +48,30 @@ async function normalizeOptions(context, projectName, options) {
48
48
  logger.warn('Prebundling has been configured but will not be used because scripts optimization is enabled.');
49
49
  }
50
50
  }
51
+ let inspect = false;
52
+ const inspectRaw = options.inspect;
53
+ if (inspectRaw === true || inspectRaw === '' || inspectRaw === 'true') {
54
+ inspect = {
55
+ host: undefined,
56
+ port: undefined,
57
+ };
58
+ }
59
+ else if (typeof inspectRaw === 'string' && inspectRaw !== 'false') {
60
+ const port = +inspectRaw;
61
+ if (isFinite(port)) {
62
+ inspect = {
63
+ host: undefined,
64
+ port,
65
+ };
66
+ }
67
+ else {
68
+ const [host, port] = inspectRaw.split(':');
69
+ inspect = {
70
+ host,
71
+ port: isNaN(+port) ? undefined : +port,
72
+ };
73
+ }
74
+ }
51
75
  // Initial options to keep
52
76
  const { host, port, poll, open, verbose, watch, liveReload, hmr, headers, proxyConfig, servePath, ssl, sslCert, sslKey, prebundle, } = options;
53
77
  // Return all the normalized options
@@ -72,6 +96,6 @@ async function normalizeOptions(context, projectName, options) {
72
96
  sslKey,
73
97
  // Prebundling defaults to true but requires caching to function
74
98
  prebundle: cacheOptions.enabled && !optimization.scripts && prebundle,
99
+ inspect,
75
100
  };
76
101
  }
77
- exports.normalizeOptions = normalizeOptions;
@@ -22,6 +22,11 @@ export interface Schema {
22
22
  * Host to listen on.
23
23
  */
24
24
  host?: string;
25
+ /**
26
+ * Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are
27
+ * enabled.
28
+ */
29
+ inspect?: Inspect;
25
30
  /**
26
31
  * Whether to reload the page on change, using live-reload.
27
32
  */
@@ -73,6 +78,11 @@ export interface Schema {
73
78
  */
74
79
  watch?: boolean;
75
80
  }
81
+ /**
82
+ * Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are
83
+ * enabled.
84
+ */
85
+ export type Inspect = boolean | string;
76
86
  /**
77
87
  * Enable and control the Vite-based development server's prebundling capabilities. To
78
88
  * enable prebundling, the Angular CLI cache must also be enabled.
@@ -79,6 +79,17 @@
79
79
  "type": "number",
80
80
  "description": "Enable and define the file watching poll time period in milliseconds."
81
81
  },
82
+ "inspect": {
83
+ "default": false,
84
+ "description": "Activate debugging inspector. This option only has an effect when 'SSR' or 'SSG' are enabled.",
85
+ "oneOf": [
86
+ {
87
+ "type": "string",
88
+ "description": "Activate the inspector on host and port in the format of `[[host:]port]`. See the security warning in https://nodejs.org/docs/latest-v22.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure regarding the host parameter usage."
89
+ },
90
+ { "type": "boolean" }
91
+ ]
92
+ },
82
93
  "prebundle": {
83
94
  "description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
84
95
  "default": true,
@@ -33,9 +33,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.setupServer = exports.serveWithVite = void 0;
36
+ exports.serveWithVite = serveWithVite;
37
+ exports.setupServer = setupServer;
37
38
  const node_assert_1 = __importDefault(require("node:assert"));
38
39
  const promises_1 = require("node:fs/promises");
40
+ const node_inspector_1 = __importDefault(require("node:inspector"));
41
+ const node_module_1 = require("node:module");
39
42
  const node_path_1 = require("node:path");
40
43
  const angular_memory_plugin_1 = require("../../tools/vite/angular-memory-plugin");
41
44
  const i18n_locale_plugin_1 = require("../../tools/vite/i18n-locale-plugin");
@@ -161,16 +164,24 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
161
164
  }
162
165
  }
163
166
  // To avoid disconnecting the array objects from the option, these arrays need to be mutated instead of replaced.
167
+ let requiresServerRestart = false;
164
168
  if (result.externalMetadata) {
165
169
  const { implicitBrowser, implicitServer, explicit } = result.externalMetadata;
170
+ const implicitServerFiltered = implicitServer.filter((m) => removeNodeJsBuiltinModules(m) && removeAbsoluteUrls(m));
171
+ const implicitBrowserFiltered = implicitBrowser.filter(removeAbsoluteUrls);
172
+ if (browserOptions.ssr && serverOptions.prebundle !== false) {
173
+ const previousImplicitServer = new Set(externalMetadata.implicitServer);
174
+ // Restart the server to force SSR dep re-optimization when a dependency has been added.
175
+ // This is a workaround for: https://github.com/vitejs/vite/issues/14896
176
+ requiresServerRestart = implicitServerFiltered.some((dep) => !previousImplicitServer.has(dep));
177
+ }
166
178
  // Empty Arrays to avoid growing unlimited with every re-build.
167
179
  externalMetadata.explicit.length = 0;
168
180
  externalMetadata.implicitServer.length = 0;
169
181
  externalMetadata.implicitBrowser.length = 0;
170
182
  externalMetadata.explicit.push(...explicit);
171
- // Remove any absolute URLs (http://, https://, //) to avoid Vite's prebundling from processing them as files
172
- externalMetadata.implicitServer.push(...implicitServer.filter((value) => !/^(?:https?:)?\/\//.test(value)));
173
- externalMetadata.implicitBrowser.push(...implicitBrowser.filter((value) => !/^(?:https?:)?\/\//.test(value)));
183
+ externalMetadata.implicitServer.push(...implicitServerFiltered);
184
+ externalMetadata.implicitBrowser.push(...implicitBrowserFiltered);
174
185
  // The below needs to be sorted as Vite uses these options are part of the hashing invalidation algorithm.
175
186
  // See: https://github.com/vitejs/vite/blob/0873bae0cfe0f0718ad2f5743dd34a17e4ab563d/packages/vite/src/node/optimizer/index.ts#L1203-L1239
176
187
  externalMetadata.explicit.sort();
@@ -182,7 +193,12 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
182
193
  server.config.server.fs.allow = [
183
194
  ...new Set([...server.config.server.fs.allow, ...assetFiles.values()]),
184
195
  ];
185
- handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger);
196
+ await handleUpdate(normalizePath, generatedFiles, server, serverOptions, context.logger);
197
+ if (requiresServerRestart) {
198
+ // Restart the server to force SSR dep re-optimization when a dependency has been added.
199
+ // This is a workaround for: https://github.com/vitejs/vite/issues/14896
200
+ await server.restart();
201
+ }
186
202
  }
187
203
  else {
188
204
  const projectName = context.target?.project;
@@ -190,6 +206,11 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
190
206
  throw new Error('The builder requires a target.');
191
207
  }
192
208
  context.logger.info('NOTE: Raw file sizes do not reflect development server per-request transformations.');
209
+ if (browserOptions.ssr && serverOptions.inspect) {
210
+ const { host, port } = serverOptions.inspect;
211
+ node_inspector_1.default.open(port, host, true);
212
+ context.addTeardown(() => node_inspector_1.default.close());
213
+ }
193
214
  const { root = '' } = await context.getProjectMetadata(projectName);
194
215
  const projectRoot = (0, node_path_1.join)(context.workspaceRoot, root);
195
216
  const browsers = (0, internal_1.getSupportedBrowsers)(projectRoot, context.logger);
@@ -202,16 +223,10 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
202
223
  const serverConfiguration = await setupServer(serverOptions, generatedFiles, assetFiles, browserOptions.preserveSymlinks, externalMetadata, !!browserOptions.ssr, prebundleTransformer, target, (0, internal_1.isZonelessApp)(polyfills), browserOptions.loader, extensions?.middleware, transformers?.indexHtml, thirdPartySourcemaps);
203
224
  server = await createServer(serverConfiguration);
204
225
  await server.listen();
205
- if (serverConfiguration.ssr?.optimizeDeps?.disabled === false) {
206
- /**
207
- * Vite will only start dependency optimization of SSR modules when the first request comes in.
208
- * In some cases, this causes a long waiting time. To mitigate this, we call `ssrLoadModule` to
209
- * initiate this process before the first request.
210
- *
211
- * NOTE: This will intentionally fail from the unknown module, but currently there is no other way
212
- * to initiate the SSR dep optimizer.
213
- */
214
- void server.ssrLoadModule('<deps-caller>').catch(() => { });
226
+ if (browserOptions.ssr && serverOptions.prebundle !== false) {
227
+ // Warm up the SSR request and begin optimizing dependencies.
228
+ // Without this, Vite will only start optimizing SSR modules when the first request is made.
229
+ void server.warmupRequest('./main.server.mjs', { ssr: true });
215
230
  }
216
231
  const urls = server.resolvedUrls;
217
232
  if (urls && (urls.local.length || urls.network.length)) {
@@ -244,7 +259,6 @@ async function* serveWithVite(serverOptions, builderName, builderAction, context
244
259
  }
245
260
  await new Promise((resolve) => (deferred = resolve));
246
261
  }
247
- exports.serveWithVite = serveWithVite;
248
262
  function handleUpdate(normalizePath, generatedFiles, server, serverOptions, logger) {
249
263
  const updatedFiles = [];
250
264
  // Invalidate any updated files
@@ -338,10 +352,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
338
352
  const { normalizePath } = await (0, load_esm_1.loadEsmModule)('vite');
339
353
  // Path will not exist on disk and only used to provide separate path for Vite requests
340
354
  const virtualProjectRoot = normalizePath((0, node_path_1.join)(serverOptions.workspaceRoot, `.angular/vite-root`, serverOptions.buildTarget.project));
341
- const serverExplicitExternal = [
342
- ...(await Promise.resolve().then(() => __importStar(require('node:module')))).builtinModules,
343
- ...externalMetadata.explicit,
344
- ];
345
355
  const cacheDir = (0, node_path_1.join)(serverOptions.cacheOptions.path, 'vite');
346
356
  const configuration = {
347
357
  configFile: false,
@@ -402,22 +412,12 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
402
412
  // Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
403
413
  noExternal: /.*/,
404
414
  // Exclude any Node.js built in module and provided dependencies (currently build defined externals)
405
- external: serverExplicitExternal,
415
+ external: externalMetadata.explicit,
406
416
  optimizeDeps: getDepOptimizationConfig({
407
- /**
408
- * *********************************************
409
- * NOTE: Temporary disable 'optimizeDeps' for SSR.
410
- * *********************************************
411
- *
412
- * Currently this causes a number of issues.
413
- * - Deps are re-optimized everytime the server is started.
414
- * - Added deps after a rebuild are not optimized.
415
- * - Breaks RxJs (Unless it is added as external). See: https://github.com/angular/angular-cli/issues/26235
416
- */
417
417
  // Only enable with caching since it causes prebundle dependencies to be cached
418
- disabled: true, // serverOptions.prebundle === false,
418
+ disabled: serverOptions.prebundle === false,
419
419
  // Exclude any explicitly defined dependencies (currently build defined externals and node.js built-ins)
420
- exclude: serverExplicitExternal,
420
+ exclude: externalMetadata.explicit,
421
421
  // Include all implict dependencies from the external packages internal option
422
422
  include: externalMetadata.implicitServer,
423
423
  ssr: true,
@@ -477,7 +477,6 @@ async function setupServer(serverOptions, outputFiles, assets, preserveSymlinks,
477
477
  }
478
478
  return configuration;
479
479
  }
480
- exports.setupServer = setupServer;
481
480
  function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless, prebundleTransformer, ssr, loader, thirdPartySourcemaps, }) {
482
481
  const plugins = [
483
482
  {
@@ -512,3 +511,12 @@ function getDepOptimizationConfig({ disabled, exclude, include, target, zoneless
512
511
  },
513
512
  };
514
513
  }
514
+ const nodeJsBuiltinModules = new Set(node_module_1.builtinModules);
515
+ /** Remove any Node.js builtin modules to avoid Vite's prebundling from processing them as files. */
516
+ function removeNodeJsBuiltinModules(value) {
517
+ return !nodeJsBuiltinModules.has(value);
518
+ }
519
+ /** Remove any absolute URLs (http://, https://, //) to avoid Vite's prebundling from processing them as files. */
520
+ function removeAbsoluteUrls(value) {
521
+ return !/^(?:https?:)?\/\//.test(value);
522
+ }
@@ -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.extractMessages = void 0;
13
+ exports.extractMessages = extractMessages;
14
14
  const node_assert_1 = __importDefault(require("node:assert"));
15
15
  const node_path_1 = __importDefault(require("node:path"));
16
16
  const application_1 = require("../application");
@@ -74,7 +74,6 @@ async function extractMessages(options, builderName, context, extractorConstruct
74
74
  useLegacyIds: false,
75
75
  };
76
76
  }
77
- exports.extractMessages = extractMessages;
78
77
  function setupLocalizeExtractor(extractorConstructor, files, context) {
79
78
  // Setup a virtual file system instance for the extractor
80
79
  // * MessageExtractor itself uses readFile, relative and resolve
@@ -33,7 +33,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
34
34
  };
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.execute = void 0;
36
+ exports.execute = execute;
37
37
  const node_fs_1 = __importDefault(require("node:fs"));
38
38
  const node_path_1 = __importDefault(require("node:path"));
39
39
  const load_esm_1 = require("../../utils/load-esm");
@@ -108,7 +108,6 @@ async function execute(options, context, extensions) {
108
108
  }
109
109
  return { success: true, outputPath: normalizedOptions.outFile };
110
110
  }
111
- exports.execute = execute;
112
111
  async function createSerializer(localizeToolsModule, format, sourceLocale, basePath, useLegacyIds, diagnostics) {
113
112
  const { XmbTranslationSerializer, LegacyMessageIdMigrationSerializer, ArbTranslationSerializer, Xliff1TranslationSerializer, Xliff2TranslationSerializer, SimpleJsonTranslationSerializer, } = localizeToolsModule;
114
113
  switch (format) {
@@ -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.normalizeOptions = void 0;
13
+ exports.normalizeOptions = normalizeOptions;
14
14
  const architect_1 = require("@angular-devkit/architect");
15
15
  const node_assert_1 = require("node:assert");
16
16
  const node_path_1 = __importDefault(require("node:path"));
@@ -64,7 +64,6 @@ async function normalizeOptions(context, projectName, options) {
64
64
  progress: options.progress ?? true,
65
65
  };
66
66
  }
67
- exports.normalizeOptions = normalizeOptions;
68
67
  function getDefaultOutFile(format) {
69
68
  switch (format) {
70
69
  case schema_1.Format.Xmb:
@@ -5,7 +5,6 @@
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.io/license
7
7
  */
8
- /// <reference types="@angular/compiler-cli/private/babel" />
9
8
  import { PluginObj } from '@babel/core';
10
9
  /**
11
10
  * Provides one or more keywords that if found within the content of a source file indicate
@@ -10,7 +10,8 @@ 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.getKeywords = void 0;
13
+ exports.getKeywords = getKeywords;
14
+ exports.default = default_1;
14
15
  const core_1 = require("@babel/core");
15
16
  const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
16
17
  const helper_split_export_declaration_1 = __importDefault(require("@babel/helper-split-export-declaration"));
@@ -57,7 +58,6 @@ const angularStaticsToElide = {
57
58
  function getKeywords() {
58
59
  return ['class'];
59
60
  }
60
- exports.getKeywords = getKeywords;
61
61
  /**
62
62
  * Determines whether a property and its initializer value can be safely wrapped in a pure
63
63
  * annotated IIFE. Values that may cause side effects are not considered safe to wrap.
@@ -281,7 +281,6 @@ function default_1() {
281
281
  },
282
282
  };
283
283
  }
284
- exports.default = default_1;
285
284
  /**
286
285
  * Static class properties may be downleveled at later stages in the build pipeline
287
286
  * which results in additional function calls outside the class body. These calls
@@ -5,7 +5,6 @@
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.io/license
7
7
  */
8
- /// <reference types="@angular/compiler-cli/private/babel" />
9
8
  import { PluginObj } from '@babel/core';
10
9
  /**
11
10
  * Provides one or more keywords that if found within the content of a source file indicate
@@ -10,7 +10,8 @@ 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.getKeywords = void 0;
13
+ exports.getKeywords = getKeywords;
14
+ exports.default = default_1;
14
15
  const core_1 = require("@babel/core");
15
16
  const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotate-as-pure"));
16
17
  /**
@@ -22,7 +23,6 @@ const helper_annotate_as_pure_1 = __importDefault(require("@babel/helper-annotat
22
23
  function getKeywords() {
23
24
  return ['var'];
24
25
  }
25
- exports.getKeywords = getKeywords;
26
26
  /**
27
27
  * A babel plugin factory function for adjusting TypeScript emitted enums.
28
28
  *
@@ -110,4 +110,3 @@ function default_1() {
110
110
  },
111
111
  };
112
112
  }
113
- exports.default = default_1;
@@ -5,7 +5,6 @@
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.io/license
7
7
  */
8
- /// <reference types="@angular/compiler-cli/private/babel" />
9
8
  import type { PluginObj } from '@babel/core';
10
9
  /**
11
10
  * Provides one or more keywords that if found within the content of a source file indicate
@@ -7,7 +7,8 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getKeywords = void 0;
10
+ exports.getKeywords = getKeywords;
11
+ exports.default = default_1;
11
12
  /**
12
13
  * The name of the Angular class metadata function created by the Angular compiler.
13
14
  */
@@ -29,7 +30,6 @@ const SET_CLASS_DEBUG_INFO_NAME = 'ɵsetClassDebugInfo';
29
30
  function getKeywords() {
30
31
  return Object.keys(angularMetadataFunctions);
31
32
  }
32
- exports.getKeywords = getKeywords;
33
33
  /**
34
34
  * An object map of function names and related value checks for discovery of Angular generated
35
35
  * metadata calls.
@@ -77,7 +77,6 @@ function default_1() {
77
77
  },
78
78
  };
79
79
  }
80
- exports.default = default_1;
81
80
  /** Determines if a function call is a call to `setClassMetadata`. */
82
81
  function isSetClassMetadataCall(callArguments) {
83
82
  // `setClassMetadata` calls have to meet the following criteria: