@nx/angular-rspack 24.0.1 → 24.0.3

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 (39) hide show
  1. package/dist/lib/config/config-utils/browser-config.d.ts +2 -1
  2. package/dist/lib/config/config-utils/browser-config.d.ts.map +1 -1
  3. package/dist/lib/config/config-utils/browser-config.js +2 -1
  4. package/dist/lib/config/config-utils/get-stats-options.d.ts.map +1 -1
  5. package/dist/lib/config/config-utils/get-stats-options.js +0 -1
  6. package/dist/lib/config/config-utils/server-config.d.ts +2 -1
  7. package/dist/lib/config/config-utils/server-config.d.ts.map +1 -1
  8. package/dist/lib/config/config-utils/server-config.js +2 -1
  9. package/dist/lib/config/create-config.d.ts.map +1 -1
  10. package/dist/lib/config/create-config.js +9 -2
  11. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  12. package/dist/lib/plugins/angular-rspack-plugin.js +16 -1
  13. package/dist/lib/plugins/angular-ssr-dev-server.d.ts +6 -3
  14. package/dist/lib/plugins/angular-ssr-dev-server.d.ts.map +1 -1
  15. package/dist/lib/plugins/angular-ssr-dev-server.js +32 -39
  16. package/dist/lib/plugins/client/ssr-reload-client.d.ts +1 -1
  17. package/dist/lib/plugins/client/ssr-reload-client.d.ts.map +1 -1
  18. package/dist/lib/plugins/client/ssr-reload-client.js +32 -14
  19. package/dist/lib/plugins/index-html-plugin.d.ts +2 -0
  20. package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -1
  21. package/dist/lib/plugins/index-html-plugin.js +23 -3
  22. package/dist/lib/plugins/ng-rspack.d.ts +3 -0
  23. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  24. package/dist/lib/plugins/ng-rspack.js +17 -1
  25. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -1
  26. package/dist/lib/plugins/prerender-plugin.js +4 -2
  27. package/dist/lib/plugins/server/ssr-reload-server.d.ts +2 -1
  28. package/dist/lib/plugins/server/ssr-reload-server.d.ts.map +1 -1
  29. package/dist/lib/plugins/server/ssr-reload-server.js +28 -7
  30. package/dist/lib/utils/index-file/add-body-script.d.ts +1 -1
  31. package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -1
  32. package/dist/lib/utils/index-file/add-body-script.js +2 -2
  33. package/dist/lib/utils/stats.d.ts +1 -6
  34. package/dist/lib/utils/stats.d.ts.map +1 -1
  35. package/dist/lib/utils/stats.js +4 -49
  36. package/package.json +3 -3
  37. package/dist/lib/utils/async-chunks.d.ts +0 -17
  38. package/dist/lib/utils/async-chunks.d.ts.map +0 -1
  39. package/dist/lib/utils/async-chunks.js +0 -44
@@ -4,5 +4,6 @@ import type { HashFormat, I18nOptions, NormalizedAngularRspackPluginOptions } fr
4
4
  import type { AngularRspackPlugin } from '../../plugins/angular-rspack-plugin';
5
5
  import type { SharedLicenseInputs } from '../../plugins/extract-licenses-plugin';
6
6
  import type { SharedServerRenderingInputs } from '../../plugins/index-html-plugin';
7
- export declare function getBrowserConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, hashFormat: HashFormat, defaultConfig: Configuration, swcTranspilationTransform: SwcTranspilationTransform, sharedLicenseInputs?: SharedLicenseInputs, sharedAngularPlugin?: AngularRspackPlugin, serverRenderingInputs?: SharedServerRenderingInputs): Promise<Configuration>;
7
+ import type { SsrReloadServer } from '../../plugins/server/ssr-reload-server';
8
+ export declare function getBrowserConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, hashFormat: HashFormat, defaultConfig: Configuration, swcTranspilationTransform: SwcTranspilationTransform, sharedLicenseInputs?: SharedLicenseInputs, sharedAngularPlugin?: AngularRspackPlugin, serverRenderingInputs?: SharedServerRenderingInputs, ssrReloadServer?: SsrReloadServer): Promise<Configuration>;
8
9
  //# sourceMappingURL=browser-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/browser-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAQnF,wBAAsB,gBAAgB,CACpC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,yBAAyB,EACpD,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,qBAAqB,CAAC,EAAE,2BAA2B,GAClD,OAAO,CAAC,aAAa,CAAC,CAiFxB"}
1
+ {"version":3,"file":"browser-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/browser-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAQ9E,wBAAsB,gBAAgB,CACpC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,yBAAyB,EACpD,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,qBAAqB,CAAC,EAAE,2BAA2B,EACnD,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,aAAa,CAAC,CAkFxB"}
@@ -10,7 +10,7 @@ const optimization_config_1 = require("./optimization-config");
10
10
  const swc_transpilation_1 = require("./swc-transpilation");
11
11
  const path_1 = require("path");
12
12
  const hmr_accept_loader_1 = require("../../plugins/loaders/hmr-accept-loader");
13
- async function getBrowserConfig(normalizedOptions, i18n, hashFormat, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs) {
13
+ async function getBrowserConfig(normalizedOptions, i18n, hashFormat, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs, ssrReloadServer) {
14
14
  const isDevServer = (0, rspack_serve_env_1.isServeMode)();
15
15
  const isProduction = process.env['NODE_ENV'] === 'production';
16
16
  const { root } = normalizedOptions;
@@ -78,6 +78,7 @@ async function getBrowserConfig(normalizedOptions, i18n, hashFormat, defaultConf
78
78
  platform: 'browser',
79
79
  sharedLicenseInputs,
80
80
  sharedAngularPlugin,
81
+ ssrReloadServer,
81
82
  serverRenderingInputs,
82
83
  }),
83
84
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"get-stats-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/get-stats-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,eAAe,CAAC,OAAO,UAAQ,GAAG,YAAY,CAsC7D"}
1
+ {"version":3,"file":"get-stats-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/get-stats-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,eAAe,CAAC,OAAO,UAAQ,GAAG,YAAY,CAoC7D"}
@@ -13,7 +13,6 @@ function getStatsOptions(verbose = false) {
13
13
  errors: true,
14
14
  assets: true, // required by custom stat output
15
15
  cachedAssets: true, // required for bundle size calculators
16
- // Needed for markAsyncChunksNonInitial.
17
16
  ids: true,
18
17
  entrypoints: true,
19
18
  };
@@ -4,5 +4,6 @@ import type { I18nOptions, NormalizedAngularRspackPluginOptions } from '../../mo
4
4
  import type { AngularRspackPlugin } from '../../plugins/angular-rspack-plugin';
5
5
  import type { SharedLicenseInputs } from '../../plugins/extract-licenses-plugin';
6
6
  import type { SharedServerRenderingInputs } from '../../plugins/index-html-plugin';
7
- export declare function getServerConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, defaultConfig: Configuration, swcTranspilationTransform: SwcTranspilationTransform, sharedLicenseInputs?: SharedLicenseInputs, sharedAngularPlugin?: AngularRspackPlugin, serverRenderingInputs?: SharedServerRenderingInputs): Promise<Configuration>;
7
+ import type { SsrReloadServer } from '../../plugins/server/ssr-reload-server';
8
+ export declare function getServerConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, defaultConfig: Configuration, swcTranspilationTransform: SwcTranspilationTransform, sharedLicenseInputs?: SharedLicenseInputs, sharedAngularPlugin?: AngularRspackPlugin, serverRenderingInputs?: SharedServerRenderingInputs, ssrReloadServer?: SsrReloadServer): Promise<Configuration>;
8
9
  //# sourceMappingURL=server-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/server-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EAErC,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAQjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAYnF,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,yBAAyB,EACpD,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,qBAAqB,CAAC,EAAE,2BAA2B,GAClD,OAAO,CAAC,aAAa,CAAC,CAsKxB"}
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/server-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EAErC,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAQjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAY9E,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,aAAa,EAC5B,yBAAyB,EAAE,yBAAyB,EACpD,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,mBAAmB,CAAC,EAAE,mBAAmB,EACzC,qBAAqB,CAAC,EAAE,2BAA2B,EACnD,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,aAAa,CAAC,CAuKxB"}
@@ -13,7 +13,7 @@ const dev_server_config_utils_1 = require("./dev-server-config-utils");
13
13
  const optimization_config_1 = require("./optimization-config");
14
14
  const swc_transpilation_1 = require("./swc-transpilation");
15
15
  const rspack_serve_env_1 = require("../../utils/rspack-serve-env");
16
- async function getServerConfig(normalizedOptions, i18n, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs) {
16
+ async function getServerConfig(normalizedOptions, i18n, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs, ssrReloadServer) {
17
17
  const isDevServer = (0, rspack_serve_env_1.isServeMode)();
18
18
  const { root } = normalizedOptions;
19
19
  const angularSSRInstalled = (0, misc_helpers_1.isPackageInstalled)(root, '@angular/ssr');
@@ -151,6 +151,7 @@ async function getServerConfig(normalizedOptions, i18n, defaultConfig, swcTransp
151
151
  platform: 'server',
152
152
  sharedLicenseInputs,
153
153
  sharedAngularPlugin,
154
+ ssrReloadServer,
154
155
  }),
155
156
  ...(normalizedOptions.prerender ||
156
157
  (normalizedOptions.appShell && !isDevServer)
@@ -1 +1 @@
1
- {"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAoB5D,wBAAsB,YAAY,CAChC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,GAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACG,EACN,YAAY,SAAgB,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAY1B;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,0BAA0B,EACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC7C,OAAO,CAAC,aAAa,EAAE,CAAC,CA4E1B"}
1
+ {"version":3,"file":"create-config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/create-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAqB5D,wBAAsB,YAAY,CAChC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,GAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACG,EACN,YAAY,SAAgB,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,CAY1B;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,0BAA0B,EACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC7C,OAAO,CAAC,aAAa,EAAE,CAAC,CAsF1B"}
@@ -12,6 +12,7 @@ const user_defined_config_helpers_1 = require("./config-utils/user-defined-confi
12
12
  const assert_supported_rspack_version_1 = require("../utils/assert-supported-rspack-version");
13
13
  const rspack_serve_env_1 = require("../utils/rspack-serve-env");
14
14
  const angular_rspack_plugin_1 = require("../plugins/angular-rspack-plugin");
15
+ const ssr_reload_server_1 = require("../plugins/server/ssr-reload-server");
15
16
  async function createConfig(defaultOptions, configurations = {}, configEnvVar = 'NGRS_CONFIG') {
16
17
  const configurationMode = process.env[configEnvVar] ?? ((0, rspack_serve_env_1.isServeMode)() ? 'development' : 'production');
17
18
  const configurationModes = (0, user_defined_config_helpers_1.parseConfigurationMode)(configurationMode);
@@ -45,13 +46,19 @@ async function _createConfig(options, rspackConfigOverrides) {
45
46
  // The browser compiler generates the documents and critical CSS plans the
46
47
  // server compiler renders with.
47
48
  const serverRenderingInputs = normalizedOptions.hasServer ? {} : undefined;
49
+ const ssrReloadServer = (0, rspack_serve_env_1.isServeMode)() &&
50
+ normalizedOptions.hasServer &&
51
+ typeof normalizedOptions.ssr === 'object' &&
52
+ normalizedOptions.ssr.entry !== undefined
53
+ ? new ssr_reload_server_1.SsrReloadServer()
54
+ : undefined;
48
55
  const configs = [];
49
56
  if (normalizedOptions.hasServer) {
50
- const serverConfig = await (0, server_config_1.getServerConfig)(normalizedOptions, i18n, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs);
57
+ const serverConfig = await (0, server_config_1.getServerConfig)(normalizedOptions, i18n, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs, ssrReloadServer);
51
58
  const mergedConfig = (0, webpack_merge_1.merge)(serverConfig, rspackConfigOverrides ?? {});
52
59
  configs.push(mergedConfig);
53
60
  }
54
- const browserConfig = await (0, browser_config_1.getBrowserConfig)(normalizedOptions, i18n, hashFormat, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs);
61
+ const browserConfig = await (0, browser_config_1.getBrowserConfig)(normalizedOptions, i18n, hashFormat, defaultConfig, swcTranspilationTransform, sharedLicenseInputs, sharedAngularPlugin, serverRenderingInputs, ssrReloadServer);
55
62
  const mergedConfig = (0, webpack_merge_1.merge)(browserConfig, rspackConfigOverrides ?? {});
56
63
  configs.unshift(mergedConfig);
57
64
  return configs;
@@ -1 +1 @@
1
- {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AA+CnB,qBAAa,mBAAoB,YAAW,oBAAoB;;IAwB9D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EA0B1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QA4XvB;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,QAgC1C;YA8Ea,gBAAgB;YAyFhB,eAAe;CAyC9B"}
1
+ {"version":3,"file":"angular-rspack-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-rspack-plugin.ts"],"names":[],"mappings":"AAoBA,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,oCAAoC,EAC1C,MAAM,WAAW,CAAC;AA+CnB,qBAAa,mBAAoB,YAAW,oBAAoB;;IAwB9D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EA0B1B;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAmYvB;IAED;;;;;;;OAOG;IACH,wBAAwB,CAAC,QAAQ,EAAE,QAAQ,QAgC1C;YA8Ea,gBAAgB;YAyFhB,eAAe;CAyC9B"}
@@ -99,11 +99,16 @@ class AngularRspackPlugin {
99
99
  });
100
100
  let currentWatchingModifiedFiles = new Set();
101
101
  let watchRunInitialized = false;
102
- // Register compilation hook once - adds modified files to dependencies
103
102
  compiler.hooks.compilation.tap(PLUGIN_NAME + '_fileDeps', (compilation) => {
104
103
  currentWatchingModifiedFiles.forEach((file) => {
105
104
  compilation.fileDependencies.add(file);
106
105
  });
106
+ if (tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin__options, "f").hasServer) {
107
+ // Server-only sources must invalidate the browser-owned Angular compilation.
108
+ for (const file of tslib_1.__classPrivateFieldGet(this, _AngularRspackPlugin_sourceFileCache, "f").referencedFiles ?? []) {
109
+ compilation.fileDependencies.add((0, node_path_1.normalize)(file));
110
+ }
111
+ }
107
112
  });
108
113
  compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
109
114
  if (!watchRunInitialized) {
@@ -232,6 +237,7 @@ class AngularRspackPlugin {
232
237
  name: PLUGIN_NAME,
233
238
  message: error.text || '',
234
239
  file: error.location?.file,
240
+ ...toRspackLocation(error.location),
235
241
  stack: error.text,
236
242
  });
237
243
  }
@@ -240,6 +246,7 @@ class AngularRspackPlugin {
240
246
  name: PLUGIN_NAME,
241
247
  message: warning.text || '',
242
248
  file: warning.location?.file,
249
+ ...toRspackLocation(warning.location),
243
250
  stack: warning.text,
244
251
  });
245
252
  }
@@ -552,6 +559,14 @@ _AngularRspackPlugin__options = new WeakMap(), _AngularRspackPlugin_i18n = new W
552
559
  }
553
560
  tslib_1.__classPrivateFieldSet(this, _AngularRspackPlugin_stylesheetMetafileInputs, flattened, "f");
554
561
  };
562
+ function toRspackLocation(location) {
563
+ if (location?.line === undefined) {
564
+ return {};
565
+ }
566
+ // Angular's columns are 0-based, rspack's `loc` columns are 1-based.
567
+ const column = location.column === undefined ? undefined : location.column + 1;
568
+ return { loc: { start: { line: location.line, column } } };
569
+ }
555
570
  function formatError(error) {
556
571
  return error instanceof Error
557
572
  ? (error.stack ?? error.message)
@@ -1,8 +1,11 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
2
- import { NormalizedAngularRspackPluginOptions } from '../models';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
+ import type { NormalizedAngularRspackPluginOptions } from '../models';
3
+ import type { SsrReloadServer } from './server/ssr-reload-server';
3
4
  export declare class AngularSsrDevServer implements RspackPluginInstance {
4
5
  #private;
5
- constructor(options: NormalizedAngularRspackPluginOptions);
6
+ private readonly options;
7
+ private readonly reloadServer?;
8
+ constructor(options: NormalizedAngularRspackPluginOptions, reloadServer?: SsrReloadServer);
6
9
  apply(compiler: Compiler): void;
7
10
  }
8
11
  //# sourceMappingURL=angular-ssr-dev-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"angular-ssr-dev-server.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-ssr-dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,oBAAoB,EAErB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oCAAoC,EAAE,MAAM,WAAW,CAAC;AAQjE,qBAAa,mBAAoB,YAAW,oBAAoB;;IAK9D,YAAY,OAAO,EAAE,oCAAoC,EAGxD;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAsCvB;CAuBF"}
1
+ {"version":3,"file":"angular-ssr-dev-server.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/angular-ssr-dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAInE,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAIlE,qBAAa,mBAAoB,YAAW,oBAAoB;;IAG5D,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAFhC,YACmB,OAAO,EAAE,oCAAoC,EAC7C,YAAY,CAAC,EAAE,eAAe,EAC7C;IAEJ,KAAK,CAAC,QAAQ,EAAE,QAAQ,QA0BvB;CAiBF"}
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
- var _AngularSsrDevServer_instances, _AngularSsrDevServer_devServerProcess, _AngularSsrDevServer_wsServer, _AngularSsrDevServer_options, _AngularSsrDevServer_attachSSRReloadClient;
2
+ var _AngularSsrDevServer_instances, _AngularSsrDevServer_devServerProcess, _AngularSsrDevServer_stopServer;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AngularSsrDevServer = void 0;
5
5
  const tslib_1 = require("tslib");
6
- const core_1 = require("@rspack/core");
7
- const child_process_1 = require("child_process");
8
- const ssr_reload_server_1 = require("./server/ssr-reload-server");
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_events_1 = require("node:events");
9
8
  const node_path_1 = require("node:path");
10
- const node_fs_1 = require("node:fs");
11
- const get_index_output_file_1 = require("../utils/index-file/get-index-output-file");
12
- const add_body_script_1 = require("../utils/index-file/add-body-script");
13
9
  const PLUGIN_NAME = 'AngularSsrDevServer';
14
10
  class AngularSsrDevServer {
15
- constructor(options) {
11
+ constructor(options, reloadServer) {
16
12
  _AngularSsrDevServer_instances.add(this);
13
+ this.options = options;
14
+ this.reloadServer = reloadServer;
17
15
  _AngularSsrDevServer_devServerProcess.set(this, void 0);
18
- _AngularSsrDevServer_wsServer.set(this, void 0);
19
- _AngularSsrDevServer_options.set(this, void 0);
20
- tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_wsServer, new ssr_reload_server_1.SsrReloadServer(), "f");
21
- tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_options, options, "f");
22
16
  }
23
17
  apply(compiler) {
24
18
  compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
@@ -28,35 +22,34 @@ class AngularSsrDevServer {
28
22
  entryValue.import = [...entryValue.import];
29
23
  }
30
24
  });
31
- compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
32
- compiler.hooks.afterEmit.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
33
- await tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_instances, "m", _AngularSsrDevServer_attachSSRReloadClient).call(this, compilation);
34
- const serverPath = (0, node_path_1.join)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.server, 'server.js');
35
- if (tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f")) {
36
- tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f").kill();
37
- tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, undefined, "f");
38
- await new Promise((res) => setTimeout(res, 50));
39
- }
40
- if (!(0, node_fs_1.existsSync)(serverPath)) {
41
- await new Promise((res) => setTimeout(res, 50));
42
- }
43
- tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, (0, child_process_1.fork)(serverPath), "f");
44
- tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f").on('spawn', () => {
45
- tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_wsServer, "f").sendReload();
46
- });
47
- callback();
48
- });
49
- callback();
25
+ compiler.hooks.afterEmit.tapPromise(
26
+ // Prerender must finish writing routes before the server can serve them.
27
+ { name: PLUGIN_NAME, stage: 1 }, async (compilation) => {
28
+ if (!compiler.watchMode || compilation.errors.length) {
29
+ return;
30
+ }
31
+ await tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_instances, "m", _AngularSsrDevServer_stopServer).call(this);
32
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, (0, node_child_process_1.fork)((0, node_path_1.join)(this.options.outputPath.server, 'server.js')), "f");
33
+ await (0, node_events_1.once)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f"), 'spawn');
34
+ this.reloadServer?.sendReload();
50
35
  });
36
+ compiler.hooks.shutdown.tapPromise(PLUGIN_NAME, () => tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_instances, "m", _AngularSsrDevServer_stopServer).call(this));
51
37
  }
52
38
  }
53
39
  exports.AngularSsrDevServer = AngularSsrDevServer;
54
- _AngularSsrDevServer_devServerProcess = new WeakMap(), _AngularSsrDevServer_wsServer = new WeakMap(), _AngularSsrDevServer_options = new WeakMap(), _AngularSsrDevServer_instances = new WeakSet(), _AngularSsrDevServer_attachSSRReloadClient = async function _AngularSsrDevServer_attachSSRReloadClient(compilation) {
55
- const clientPath = require.resolve(`${__dirname}/client/ssr-reload-client.js`);
56
- const pathToIndex = (0, node_path_1.join)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.browser, (0, get_index_output_file_1.getIndexOutputFile)(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").index));
57
- const html = (0, node_fs_1.readFileSync)(pathToIndex, 'utf-8');
58
- const updatedHtml = await (0, add_body_script_1.addBodyScript)(html, (0, node_fs_1.readFileSync)(clientPath, 'utf-8'));
59
- const source = new core_1.sources.RawSource(updatedHtml);
60
- const relativePathToIndex = pathToIndex.replace(tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_options, "f").outputPath.browser, '');
61
- compilation.emitAsset(relativePathToIndex, source);
40
+ _AngularSsrDevServer_devServerProcess = new WeakMap(), _AngularSsrDevServer_instances = new WeakSet(), _AngularSsrDevServer_stopServer = async function _AngularSsrDevServer_stopServer() {
41
+ const server = tslib_1.__classPrivateFieldGet(this, _AngularSsrDevServer_devServerProcess, "f");
42
+ tslib_1.__classPrivateFieldSet(this, _AngularSsrDevServer_devServerProcess, undefined, "f");
43
+ if (server && server.exitCode === null && server.signalCode === null) {
44
+ const exited = (0, node_events_1.once)(server, 'exit');
45
+ const forceStop = setTimeout(() => server.kill('SIGKILL'), 5000);
46
+ forceStop.unref();
47
+ try {
48
+ server.kill();
49
+ await exited;
50
+ }
51
+ finally {
52
+ clearTimeout(forceStop);
53
+ }
54
+ }
62
55
  };
@@ -1,2 +1,2 @@
1
- export {};
1
+ export declare function connectSsrReload(port: number): void;
2
2
  //# sourceMappingURL=ssr-reload-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-reload-client.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/client/ssr-reload-client.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"ssr-reload-client.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/client/ssr-reload-client.ts"],"names":[],"mappings":"AACA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,QAiC5C"}
@@ -1,17 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // casting is needed to force the type to be the global WebSocket and avoid type errors
4
- const socket = new WebSocket(`ws://localhost:60000`);
5
- socket.addEventListener('message', (event) => {
6
- if (event.data === 'ssr-reload') {
7
- console.log('[AngularSSRDevServer] Reloading the page...');
8
- // @ts-expect-error: This is a client-side file
9
- window.location.reload();
3
+ exports.connectSsrReload = connectSsrReload;
4
+ // This function is serialized into HTML and cannot reference module-scoped values.
5
+ function connectSsrReload(port) {
6
+ const socket = new WebSocket(`ws://${globalThis.location.hostname}:${port}`);
7
+ let reloading = false;
8
+ async function reloadWhenReady() {
9
+ try {
10
+ await fetch(globalThis.location.href, {
11
+ cache: 'no-store',
12
+ mode: 'no-cors',
13
+ });
14
+ }
15
+ catch {
16
+ setTimeout(reloadWhenReady, 100);
17
+ return;
18
+ }
19
+ reloading = false;
20
+ globalThis.location.reload();
10
21
  }
11
- });
12
- socket.addEventListener('open', () => {
13
- console.log('[AngularSSRDevServer] WebSocket connection established.');
14
- });
15
- socket.addEventListener('close', () => {
16
- console.warn('[AngularSSRDevServer] WebSocket connection closed.');
17
- });
22
+ socket.addEventListener('message', (event) => {
23
+ if (event.data === 'ssr-reload' && !reloading) {
24
+ reloading = true;
25
+ console.log('[AngularSSRDevServer] Reloading the page...');
26
+ void reloadWhenReady();
27
+ }
28
+ });
29
+ socket.addEventListener('open', () => {
30
+ console.log('[AngularSSRDevServer] WebSocket connection established.');
31
+ });
32
+ socket.addEventListener('close', () => {
33
+ console.warn('[AngularSSRDevServer] WebSocket connection closed.');
34
+ });
35
+ }
@@ -19,6 +19,7 @@ export interface ServerRenderingInputs {
19
19
  * `@angular/build` >= 22.2 does.
20
20
  */
21
21
  criticalCssPlans: CriticalCssPlan[] | undefined;
22
+ emitsOriginalIndex?: boolean;
22
23
  }
23
24
  /**
24
25
  * Holds the server rendering inputs of the browser compiler's last
@@ -34,6 +35,7 @@ export interface IndexHtmlPluginOptions extends IndexHtmlGeneratorOptions {
34
35
  isSsr: boolean;
35
36
  outputPath: string;
36
37
  serverRenderingInputs?: SharedServerRenderingInputs;
38
+ serverPostTransform?: IndexHtmlGeneratorOptions['postTransform'];
37
39
  }
38
40
  /**
39
41
  * Whether a server build emits its server index as `index.original.html`,
@@ -1 +1 @@
1
- {"version":3,"file":"index-html-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/index-html-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAElB,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIhF,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAc3B,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC;;;OAGG;IACH,gBAAgB,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;CACjD;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAED,MAAM,WAAW,sBAAuB,SAAQ,yBAAyB;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AS,CAwBpD;CACF"}
@@ -66,6 +66,9 @@ class IndexHtmlPlugin extends private_1.IndexHtmlGenerator {
66
66
  apply(compiler) {
67
67
  const { serverRenderingInputs } = this.options;
68
68
  const emitServerIndexAsOriginal = emitsServerIndexAsOriginal(this.options.index);
69
+ const emitOriginalIndex = emitServerIndexAsOriginal ||
70
+ (!!this.options.serverPostTransform &&
71
+ (0, get_index_output_file_1.getIndexOutputFile)(this.options.index) !== 'index.original.html');
69
72
  const compileCriticalCssPlans = (0, angular_rspack_compiler_1.isAngularBuildVersionAtLeast)('22.2.0') &&
70
73
  !!this.options.optimization?.styles.inlineCritical;
71
74
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
@@ -145,10 +148,16 @@ class IndexHtmlPlugin extends private_1.IndexHtmlGenerator {
145
148
  (0, node_assert_1.default)(tslib_1.__classPrivateFieldGet(this, _IndexHtmlPlugin_sharedIndexContent, "f") !== undefined, 'The index html generator did not run its shared steps.');
146
149
  // Unlike the browser index, these match the documents the
147
150
  // `@angular/build` application builder generates for a server.
148
- const [server, csr] = await Promise.all([
151
+ let [server, csr] = await Promise.all([
149
152
  (0, add_event_dispatch_contract_1.addEventDispatchContract)(tslib_1.__classPrivateFieldGet(this, _IndexHtmlPlugin_sharedIndexContent, "f")).then(nonce_1.addNonce),
150
153
  (0, ngcm_attribute_1.addNgcmAttribute)(csrContent),
151
154
  ]);
155
+ if (this.options.serverPostTransform) {
156
+ [server, csr] = await Promise.all([
157
+ this.options.serverPostTransform(server).then(nonce_1.addNonce),
158
+ this.options.serverPostTransform(csr).then(nonce_1.addNonce),
159
+ ]);
160
+ }
152
161
  const assetsDir = `${SERVER_INDEX_ASSETS_DIR}/${serverIndexAssets.length}`;
153
162
  const serverIndexAsset = {
154
163
  locale,
@@ -191,12 +200,23 @@ class IndexHtmlPlugin extends private_1.IndexHtmlGenerator {
191
200
  csr: csrContent,
192
201
  nonce: (await (0, nonce_1.findNonce)(serverContent)) ?? undefined,
193
202
  });
194
- if (emitServerIndexAsOriginal) {
195
- compilation.emitAsset((0, node_path_1.join)(outputPath, 'index.original.html'), new compiler.rspack.sources.RawSource(serverContent));
203
+ if (emitOriginalIndex) {
204
+ let originalContent = serverContent;
205
+ if (!emitServerIndexAsOriginal &&
206
+ this.options.serverPostTransform) {
207
+ const browserContent = compilation.assets[(0, node_path_1.join)(outputPath, (0, get_index_output_file_1.getIndexOutputFile)(this.options.index))]
208
+ .source()
209
+ .toString();
210
+ originalContent = await this.options
211
+ .serverPostTransform(browserContent)
212
+ .then(nonce_1.addNonce);
213
+ }
214
+ compilation.emitAsset((0, node_path_1.join)(outputPath, 'index.original.html'), new compiler.rspack.sources.RawSource(originalContent));
196
215
  }
197
216
  }
198
217
  tslib_1.__classPrivateFieldSet(this, _IndexHtmlPlugin_pendingServerRenderingInputs, {
199
218
  indexHtml,
219
+ emitsOriginalIndex: emitOriginalIndex,
200
220
  criticalCssPlans: compileCriticalCssPlans
201
221
  ? await tslib_1.__classPrivateFieldGet(this, _IndexHtmlPlugin_instances, "m", _IndexHtmlPlugin_compileCriticalCssPlans).call(this, compilation)
202
222
  : undefined,
@@ -2,6 +2,7 @@ import { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import type { I18nOptions, NormalizedAngularRspackPluginOptions } from '../models';
3
3
  import { READY_SIGNAL_PLUGIN } from '../utils/dev-server-ready-signal';
4
4
  import { AngularRspackPlugin } from './angular-rspack-plugin';
5
+ import type { SsrReloadServer } from './server/ssr-reload-server';
5
6
  import { type SharedLicenseInputs } from './extract-licenses-plugin';
6
7
  import { type SharedServerRenderingInputs } from './index-html-plugin';
7
8
  export declare class NgRspackPlugin implements RspackPluginInstance {
@@ -11,6 +12,7 @@ export declare class NgRspackPlugin implements RspackPluginInstance {
11
12
  private readonly sharedLicenseInputs;
12
13
  private readonly sharedAngularPlugin;
13
14
  private readonly serverRenderingInputs;
15
+ private readonly ssrReloadServer;
14
16
  readonly [READY_SIGNAL_PLUGIN] = true;
15
17
  constructor(pluginOptions: NormalizedAngularRspackPluginOptions, extraOptions: {
16
18
  platform: 'browser' | 'server';
@@ -34,6 +36,7 @@ export declare class NgRspackPlugin implements RspackPluginInstance {
34
36
  * compiler.
35
37
  */
36
38
  serverRenderingInputs?: SharedServerRenderingInputs;
39
+ ssrReloadServer?: SsrReloadServer;
37
40
  });
38
41
  apply(compiler: Compiler): void;
39
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ng-rspack.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/ng-rspack.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAGR,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,WAAW,CAAC;AACnB,OAAO,EAGL,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAI7B,qBAAa,cAAe,YAAW,oBAAoB;IACzD,QAAQ,CAAC,aAAa,EAAE,oCAAoC,CAAC;IAC7D,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAExB;IACd,QAAQ,CAAC,CAAC,mBAAmB,CAAC,QAAQ;IAEtC,YACE,aAAa,EAAE,oCAAoC,EACnD,YAAY,EAAE;QACZ,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;QAC/B,WAAW,EAAE,WAAW,CAAC;QACzB;;;;WAIG;QACH,mBAAmB,CAAC,EAAE,mBAA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G;QACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;QAC1C;;;;;;WAMG;QACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;QAC1C;;;WAGG;QACH,qBAAqB,CAAC,EAAE,2BAA2B,CAAC;QACpD,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,EASF;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QA6OvB;CACF"}
@@ -9,8 +9,10 @@ const entry_points_1 = require("../config/config-utils/entry-points");
9
9
  const dev_server_ready_signal_1 = require("../utils/dev-server-ready-signal");
10
10
  const misc_helpers_1 = require("../utils/misc-helpers");
11
11
  const rspack_serve_env_1 = require("../utils/rspack-serve-env");
12
+ const add_body_script_1 = require("../utils/index-file/add-body-script");
12
13
  const angular_rspack_plugin_1 = require("./angular-rspack-plugin");
13
14
  const angular_ssr_dev_server_1 = require("./angular-ssr-dev-server");
15
+ const ssr_reload_client_1 = require("./client/ssr-reload-client");
14
16
  const extract_licenses_plugin_1 = require("./extract-licenses-plugin");
15
17
  const i18n_inline_plugin_1 = require("./i18n-inline-plugin");
16
18
  const index_html_plugin_1 = require("./index-html-plugin");
@@ -25,10 +27,12 @@ class NgRspackPlugin {
25
27
  this.sharedLicenseInputs = extraOptions.sharedLicenseInputs;
26
28
  this.sharedAngularPlugin = extraOptions.sharedAngularPlugin;
27
29
  this.serverRenderingInputs = extraOptions.serverRenderingInputs;
30
+ this.ssrReloadServer = extraOptions.ssrReloadServer;
28
31
  }
29
32
  apply(compiler) {
30
33
  const root = this.pluginOptions.root;
31
34
  const isDevServer = (0, rspack_serve_env_1.isServeMode)();
35
+ const ssrReloadServer = this.ssrReloadServer;
32
36
  if (!isDevServer ||
33
37
  !this.pluginOptions.hasServer ||
34
38
  !(0, dev_server_ready_signal_1.ssrServerEmitsReadySignal)(root, this.pluginOptions.ssr, this.pluginOptions.fileReplacements)) {
@@ -38,7 +42,7 @@ class NgRspackPlugin {
38
42
  if (this.pluginOptions.ssr &&
39
43
  typeof this.pluginOptions.ssr === 'object' &&
40
44
  this.pluginOptions.ssr.entry !== undefined) {
41
- new angular_ssr_dev_server_1.AngularSsrDevServer(this.pluginOptions).apply(compiler);
45
+ new angular_ssr_dev_server_1.AngularSsrDevServer(this.pluginOptions, ssrReloadServer).apply(compiler);
42
46
  }
43
47
  }
44
48
  if (this.isPlatformServer) {
@@ -134,6 +138,9 @@ class NgRspackPlugin {
134
138
  else {
135
139
  new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions, this.i18n).apply(compiler);
136
140
  }
141
+ if (!this.isPlatformServer && ssrReloadServer) {
142
+ compiler.hooks.shutdown.tapPromise('NgRspackPlugin', () => ssrReloadServer.close());
143
+ }
137
144
  if (!this.isPlatformServer && this.pluginOptions.index) {
138
145
  new index_html_plugin_1.IndexHtmlPlugin({
139
146
  indexPath: this.pluginOptions.index.input,
@@ -144,6 +151,15 @@ class NgRspackPlugin {
144
151
  i18n: this.i18n,
145
152
  optimization: this.pluginOptions.optimization,
146
153
  postTransform: this.pluginOptions.index.transformer,
154
+ serverPostTransform: ssrReloadServer
155
+ ? async (html) => {
156
+ if (!compiler.watchMode) {
157
+ return html;
158
+ }
159
+ const port = await ssrReloadServer.getPort();
160
+ return (0, add_body_script_1.addBodyScript)(html, `(${ssr_reload_client_1.connectSsrReload.toString()})(${port});`, 'nx-angular-ssr-reload');
161
+ }
162
+ : undefined,
147
163
  isSsr: !!(this.pluginOptions.ssr ||
148
164
  this.pluginOptions.prerender ||
149
165
  this.pluginOptions.appShell),
@@ -1 +1 @@
1
- {"version":3,"file":"prerender-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/prerender-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOhF,OAAO,EACL,KAAK,WAAW,EAEhB,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAYnB,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAQ7B,qBAAa,eAAgB,YAAW,oBAAoB;;IAK1D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EACzB,qBAAqB,CAAC,EAAE,2BAA2B,EAKpD;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAoCvB;CAmTF"}
1
+ {"version":3,"file":"prerender-plugin.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/prerender-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAOhF,OAAO,EACL,KAAK,WAAW,EAEhB,oCAAoC,EACrC,MAAM,WAAW,CAAC;AAYnB,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAC;AAQ7B,qBAAa,eAAgB,YAAW,oBAAoB;;IAK1D,YACE,OAAO,EAAE,oCAAoC,EAC7C,WAAW,CAAC,EAAE,WAAW,EACzB,qBAAqB,CAAC,EAAE,2BAA2B,EAKpD;IAED,KAAK,CAAC,QAAQ,EAAE,QAAQ,QAoCvB;CAuTF"}
@@ -95,7 +95,8 @@ async function _PrerenderPlugin_writePrerenderedRoutesManifest(compilation, prer
95
95
  const options = {
96
96
  ...tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_getDocumentRenderOptions).call(this, inputs, locale),
97
97
  indexFile,
98
- emitsOriginalIndex: (0, index_html_plugin_1.emitsServerIndexAsOriginal)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index),
98
+ emitsOriginalIndex: inputs.emitsOriginalIndex ??
99
+ (0, index_html_plugin_1.emitsServerIndexAsOriginal)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index),
99
100
  deployUrl: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").deployUrl || '',
100
101
  inlineCriticalCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.inlineCritical,
101
102
  minifyCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.minify,
@@ -152,7 +153,8 @@ async function _PrerenderPlugin_writePrerenderedRoutesManifest(compilation, prer
152
153
  routes ??= await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_getRoutes).call(this, indexFile, normalizedOutputPath, serverBundlePath, devkit_1.workspaceRoot);
153
154
  try {
154
155
  const documentRenderOptions = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_getDocumentRenderOptions).call(this, inputs, locale);
155
- const emitsOriginalIndex = (0, index_html_plugin_1.emitsServerIndexAsOriginal)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index);
156
+ const emitsOriginalIndex = inputs.emitsOriginalIndex ??
157
+ (0, index_html_plugin_1.emitsServerIndexAsOriginal)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index);
156
158
  const results = (await Promise.all(routes.map((route) => {
157
159
  const options = {
158
160
  ...documentRenderOptions,
@@ -1,6 +1,7 @@
1
1
  export declare class SsrReloadServer {
2
2
  #private;
3
- constructor();
3
+ getPort(): Promise<number>;
4
4
  sendReload(): void;
5
+ close(): Promise<void>;
5
6
  }
6
7
  //# sourceMappingURL=ssr-reload-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ssr-reload-server.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/server/ssr-reload-server.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;;IAG1B,cAIC;IAED,UAAU,SAIT;CACF"}
1
+ {"version":3,"file":"ssr-reload-server.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/server/ssr-reload-server.ts"],"names":[],"mappings":"AAIA,qBAAa,eAAe;;IAIpB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAO/B;IAED,UAAU,SAMT;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3B;CACF"}
@@ -1,21 +1,42 @@
1
1
  "use strict";
2
- var _SsrReloadServer_server;
2
+ var _SsrReloadServer_server, _SsrReloadServer_listening;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.SsrReloadServer = void 0;
5
5
  const tslib_1 = require("tslib");
6
+ const node_events_1 = require("node:events");
6
7
  const ws_1 = require("ws");
7
8
  class SsrReloadServer {
8
9
  constructor() {
9
10
  _SsrReloadServer_server.set(this, void 0);
10
- tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_server, new ws_1.WebSocket.Server({ port: 60_000 }), "f");
11
- process.on('SIGTERM', () => tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").close());
12
- process.on('exit', () => tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").close());
11
+ _SsrReloadServer_listening.set(this, void 0);
12
+ }
13
+ async getPort() {
14
+ if (!tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f")) {
15
+ tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_server, new ws_1.WebSocketServer({ port: 0 }), "f");
16
+ tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_listening, (0, node_events_1.once)(tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f"), 'listening'), "f");
17
+ }
18
+ await tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_listening, "f");
19
+ return tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").address().port;
13
20
  }
14
21
  sendReload() {
15
- tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").clients.forEach((client) => {
16
- client.send('ssr-reload');
22
+ tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f")?.clients.forEach((client) => {
23
+ if (client.readyState === ws_1.WebSocket.OPEN) {
24
+ client.send('ssr-reload');
25
+ }
26
+ });
27
+ }
28
+ async close() {
29
+ const server = tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f");
30
+ if (!server) {
31
+ return;
32
+ }
33
+ tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_server, undefined, "f");
34
+ tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_listening, undefined, "f");
35
+ server.clients.forEach((client) => client.terminate());
36
+ await new Promise((resolve, reject) => {
37
+ server.close((error) => (error ? reject(error) : resolve()));
17
38
  });
18
39
  }
19
40
  }
20
41
  exports.SsrReloadServer = SsrReloadServer;
21
- _SsrReloadServer_server = new WeakMap();
42
+ _SsrReloadServer_server = new WeakMap(), _SsrReloadServer_listening = new WeakMap();
@@ -1,2 +1,2 @@
1
- export declare function addBodyScript(html: string, bodyScriptContents: string): Promise<string>;
1
+ export declare function addBodyScript(html: string, bodyScriptContents: string, id: string): Promise<string>;
2
2
  //# sourceMappingURL=add-body-script.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-body-script.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/index-file/add-body-script.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
1
+ {"version":3,"file":"add-body-script.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/index-file/add-body-script.ts"],"names":[],"mappings":"AAEA,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,kBAAkB,EAAE,MAAM,EAC1B,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,CAcjB"}
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addBodyScript = addBodyScript;
4
4
  const html_rewriting_stream_1 = require("./html-rewriting-stream");
5
- async function addBodyScript(html, bodyScriptContents) {
5
+ async function addBodyScript(html, bodyScriptContents, id) {
6
6
  const { rewriter, transformedContent } = await (0, html_rewriting_stream_1.htmlRewritingStream)(html);
7
- const bodyScript = `<script type="text/javascript">${bodyScriptContents}</script>`;
7
+ const bodyScript = `<script id="${id}" type="text/javascript">${bodyScriptContents}</script>`;
8
8
  rewriter.on('startTag', (tag) => {
9
9
  rewriter.emitStartTag(tag);
10
10
  if (tag.tagName === 'body') {
@@ -7,17 +7,12 @@
7
7
  */
8
8
  import { BudgetCalculatorResult } from '@angular/build/private';
9
9
  import { Configuration, StatsCompilation, Stats, StatsOptions } from '@rspack/core';
10
- import { NormalizedAngularRspackPluginOptions, NormalizedEntryPoint, ScriptOrStyleEntry } from '../models/angular-rspack-plugin-options';
11
- export interface RspackLoggingCallback {
12
- (stats: Stats, config: Configuration): void;
13
- }
10
+ import { NormalizedAngularRspackPluginOptions } from '../models/angular-rspack-plugin-options';
14
11
  export type RspackStatsOptions = Exclude<Configuration['stats'], string | boolean | undefined>;
15
- export declare function normalizeExtraEntryPoints(extraEntryPoints: ScriptOrStyleEntry[], defaultBundleName: string): NormalizedEntryPoint[];
16
12
  export declare function statsWarningsToString(json: StatsCompilation, statsConfig: RspackStatsOptions): string;
17
13
  export declare function statsErrorsToString(json: StatsCompilation, statsConfig: RspackStatsOptions): string;
18
14
  export declare function statsHasErrors(json: StatsCompilation): boolean;
19
15
  export declare function statsHasWarnings(json: StatsCompilation): boolean;
20
- export declare function createRspackLoggingCallback(options: NormalizedAngularRspackPluginOptions): (stats: any, config: any) => void;
21
16
  export interface BuildEventStats {
22
17
  aot: boolean;
23
18
  optimization: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAMjD,MAAM,WAAW,qBAAqB;IACpC,CA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,EAAE,KAAK,EACZ,WAAW,EAAE,YAAY,EACzB,cAAc,CAAC,EAAE,sBAAsB,EAAE,GACxC,IAAI,CAgBN"}
@@ -7,12 +7,10 @@
7
7
  * found in the LICENSE file at https://angular.dev/license
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.normalizeExtraEntryPoints = normalizeExtraEntryPoints;
11
10
  exports.statsWarningsToString = statsWarningsToString;
12
11
  exports.statsErrorsToString = statsErrorsToString;
13
12
  exports.statsHasErrors = statsHasErrors;
14
13
  exports.statsHasWarnings = statsHasWarnings;
15
- exports.createRspackLoggingCallback = createRspackLoggingCallback;
16
14
  exports.generateBuildEventStats = generateBuildEventStats;
17
15
  exports.rspackStatsLogger = rspackStatsLogger;
18
16
  const tslib_1 = require("tslib");
@@ -21,28 +19,6 @@ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
21
19
  const path = tslib_1.__importStar(require("node:path"));
22
20
  const normalize_options_1 = require("../models/normalize-options");
23
21
  const color_1 = require("./color");
24
- const async_chunks_1 = require("./async-chunks");
25
- const get_stats_options_1 = require("../config/config-utils/get-stats-options");
26
- function normalizeExtraEntryPoints(extraEntryPoints, defaultBundleName) {
27
- return extraEntryPoints.map((entry) => {
28
- if (typeof entry === 'string') {
29
- return { input: entry, inject: true, bundleName: defaultBundleName };
30
- }
31
- const { inject = true, ...newEntry } = entry;
32
- let bundleName;
33
- if (entry.bundleName) {
34
- bundleName = entry.bundleName;
35
- }
36
- else if (!inject) {
37
- // Lazy entry points use the file name as bundle name.
38
- bundleName = path.parse(entry.input).name;
39
- }
40
- else {
41
- bundleName = defaultBundleName;
42
- }
43
- return { ...newEntry, inject, bundleName };
44
- });
45
- }
46
22
  function getBuildDuration(rspackStats) {
47
23
  (0, node_assert_1.default)(rspackStats.builtAt, 'buildAt cannot be undefined');
48
24
  (0, node_assert_1.default)(rspackStats.time, 'time cannot be undefined');
@@ -201,14 +177,12 @@ function statsWarningsToString(json, statsConfig) {
201
177
  }
202
178
  output += ' - ';
203
179
  }
204
- if (!/^error/i.test(warning.message)) {
205
- const errorIndex = warning.message.indexOf('Error: ');
206
- warning.message = warning.message.substring(errorIndex + 7);
207
- }
208
- if (!/^warning/i.test(warning.message)) {
180
+ // rspack 1.3 prefixes an Error warning with its name, e.g. " ⚠ Error: ".
181
+ const message = warning.message.replace(/^\s*⚠\s*Error: /, '');
182
+ if (!/^warning/i.test(message)) {
209
183
  output += y('Warning: ');
210
184
  }
211
- output += `${warning.message}\n\n`;
185
+ output += `${message}\n\n`;
212
186
  }
213
187
  }
214
188
  return output ? '\n' + output : output;
@@ -274,25 +248,6 @@ function statsHasErrors(json) {
274
248
  function statsHasWarnings(json) {
275
249
  return !!(json.warnings?.length || json.children?.some((c) => c.warnings?.length));
276
250
  }
277
- function createRspackLoggingCallback(options) {
278
- const { verbose = false, scripts = [], styles = [] } = options;
279
- const extraEntryPoints = [
280
- ...normalizeExtraEntryPoints(styles, 'styles'),
281
- ...normalizeExtraEntryPoints(scripts, 'scripts'),
282
- ];
283
- return (stats, config) => {
284
- if (verbose && config.stats !== false) {
285
- const statsOptions = config.stats === true ? undefined : config.stats;
286
- console.info(stats.toString(statsOptions));
287
- }
288
- const rawStats = stats.toJson((0, get_stats_options_1.getStatsOptions)(false));
289
- const rspackStats = {
290
- ...rawStats,
291
- chunks: (0, async_chunks_1.markAsyncChunksNonInitial)(rawStats, extraEntryPoints),
292
- };
293
- rspackStatsLogger(rspackStats, config);
294
- };
295
- }
296
251
  function generateBuildEventStats(rspackStats, options) {
297
252
  const { chunks = [], assets = [] } = rspackStats;
298
253
  let jsSizeInBytes = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular-rspack",
3
- "version": "24.0.1",
3
+ "version": "24.0.3",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -56,8 +56,8 @@
56
56
  "@ampproject/remapping": "2.3.0",
57
57
  "@babel/core": "^7.29.6",
58
58
  "@discoveryjs/json-ext": "0.6.3",
59
- "@nx/angular-rspack-compiler": "24.0.1",
60
- "@nx/devkit": "24.0.1",
59
+ "@nx/angular-rspack-compiler": "24.0.3",
60
+ "@nx/devkit": "24.0.3",
61
61
  "ansi-colors": "4.1.3",
62
62
  "autoprefixer": "^10.4.9",
63
63
  "deepmerge": "^4.3.1",
@@ -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
- import { StatsChunk, StatsCompilation } from '@rspack/core';
9
- import { NormalizedEntryPoint } from '../models/angular-rspack-plugin-options';
10
- /**
11
- * Webpack stats may incorrectly mark extra entry points `initial` chunks, when
12
- * they are actually loaded asynchronously and thus not in the main bundle. This
13
- * function finds extra entry points in Webpack stats and corrects this value
14
- * whereever necessary. Does not modify {@param webpackStats}.
15
- */
16
- export declare function markAsyncChunksNonInitial(webpackStats: StatsCompilation, extraEntryPoints: NormalizedEntryPoint[]): StatsChunk[];
17
- //# sourceMappingURL=async-chunks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"async-chunks.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/async-chunks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,gBAAgB,EAC9B,gBAAgB,EAAE,oBAAoB,EAAE,GACvC,UAAU,EAAE,CAqCd"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.dev/license
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.markAsyncChunksNonInitial = markAsyncChunksNonInitial;
11
- /**
12
- * Webpack stats may incorrectly mark extra entry points `initial` chunks, when
13
- * they are actually loaded asynchronously and thus not in the main bundle. This
14
- * function finds extra entry points in Webpack stats and corrects this value
15
- * whereever necessary. Does not modify {@param webpackStats}.
16
- */
17
- function markAsyncChunksNonInitial(webpackStats, extraEntryPoints) {
18
- const { chunks = [], entrypoints: entryPoints = {} } = webpackStats;
19
- // Find all Webpack chunk IDs not injected into the main bundle. We don't have
20
- // to worry about transitive dependencies because extra entry points cannot be
21
- // depended upon in Webpack, thus any extra entry point with `inject: false`,
22
- // **cannot** be loaded in main bundle.
23
- const asyncChunkIds = extraEntryPoints
24
- .filter((entryPoint) => !entryPoint.inject && entryPoints[entryPoint.bundleName])
25
- .flatMap((entryPoint) => entryPoints[entryPoint.bundleName].chunks?.filter((n) => n !== 'runtime'));
26
- // Find chunks for each ID.
27
- const asyncChunks = asyncChunkIds.map((chunkId) => {
28
- const chunk = chunks.find((chunk) => chunk.id === chunkId);
29
- if (!chunk) {
30
- throw new Error(`Failed to find chunk (${chunkId}) in set:\n${JSON.stringify(chunks)}`);
31
- }
32
- return chunk;
33
- });
34
- // A chunk is considered `initial` only if Webpack already belives it to be initial
35
- // and the application developer did not mark it async via an extra entry point.
36
- return chunks.map((chunk) => {
37
- return asyncChunks.find((asyncChunk) => asyncChunk === chunk)
38
- ? {
39
- ...chunk,
40
- initial: false,
41
- }
42
- : chunk;
43
- });
44
- }