@nx/angular-rspack 20.8.2 → 21.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/lib/config/config-utils/browser-config.d.ts +4 -0
  2. package/dist/lib/config/config-utils/browser-config.d.ts.map +1 -0
  3. package/dist/lib/config/config-utils/browser-config.js +79 -0
  4. package/dist/lib/config/config-utils/common-config.d.ts +3 -0
  5. package/dist/lib/config/config-utils/common-config.d.ts.map +1 -0
  6. package/dist/lib/config/config-utils/common-config.js +143 -0
  7. package/dist/lib/config/config-utils/dev-server-config-utils.d.ts +4 -0
  8. package/dist/lib/config/config-utils/dev-server-config-utils.d.ts.map +1 -0
  9. package/dist/lib/config/config-utils/dev-server-config-utils.js +257 -0
  10. package/dist/lib/config/{entry-points.d.ts → config-utils/entry-points.d.ts} +1 -1
  11. package/dist/lib/config/config-utils/entry-points.d.ts.map +1 -0
  12. package/dist/lib/config/config-utils/get-stats-options.d.ts +3 -0
  13. package/dist/lib/config/config-utils/get-stats-options.d.ts.map +1 -0
  14. package/dist/lib/config/config-utils/get-stats-options.js +39 -0
  15. package/dist/lib/config/config-utils/helpers.d.ts +13 -0
  16. package/dist/lib/config/config-utils/helpers.d.ts.map +1 -0
  17. package/dist/lib/config/{helpers.js → config-utils/helpers.js} +33 -0
  18. package/dist/lib/config/config-utils/optimization-config.d.ts +5 -0
  19. package/dist/lib/config/config-utils/optimization-config.d.ts.map +1 -0
  20. package/dist/lib/config/config-utils/optimization-config.js +69 -0
  21. package/dist/lib/config/config-utils/server-config.d.ts +4 -0
  22. package/dist/lib/config/config-utils/server-config.d.ts.map +1 -0
  23. package/dist/lib/config/config-utils/server-config.js +88 -0
  24. package/dist/lib/config/config-utils/sourcemap-utils.d.ts +7 -0
  25. package/dist/lib/config/config-utils/sourcemap-utils.d.ts.map +1 -0
  26. package/dist/lib/config/config-utils/sourcemap-utils.js +48 -0
  27. package/dist/lib/config/config-utils/style-config-utils.d.ts +7 -0
  28. package/dist/lib/config/config-utils/style-config-utils.d.ts.map +1 -0
  29. package/dist/lib/config/config-utils/style-config-utils.js +352 -0
  30. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts +71 -0
  31. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts.map +1 -0
  32. package/dist/lib/config/config-utils/user-defined-config-helpers.js +23 -0
  33. package/dist/lib/config/create-config.d.ts +2 -75
  34. package/dist/lib/config/create-config.d.ts.map +1 -1
  35. package/dist/lib/config/create-config.js +17 -473
  36. package/dist/lib/index.d.ts +4 -0
  37. package/dist/lib/index.d.ts.map +1 -1
  38. package/dist/lib/index.js +9 -0
  39. package/dist/lib/models/angular-rspack-plugin-options.d.ts +141 -10
  40. package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
  41. package/dist/lib/models/augmented-compilation.d.ts +2 -2
  42. package/dist/lib/models/augmented-compilation.d.ts.map +1 -1
  43. package/dist/lib/models/normalize-options.d.ts +2 -2
  44. package/dist/lib/models/normalize-options.d.ts.map +1 -1
  45. package/dist/lib/models/normalize-options.js +114 -80
  46. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  47. package/dist/lib/plugins/angular-rspack-plugin.js +58 -19
  48. package/dist/lib/plugins/angular-ssr-dev-server.d.ts +2 -2
  49. package/dist/lib/plugins/angular-ssr-dev-server.d.ts.map +1 -1
  50. package/dist/lib/plugins/angular-ssr-dev-server.js +19 -9
  51. package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts +19 -0
  52. package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts.map +1 -0
  53. package/dist/lib/plugins/any-component-style-budget-checker-plugin.js +65 -0
  54. package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -1
  55. package/dist/lib/plugins/i18n-inline-plugin.js +5 -3
  56. package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -1
  57. package/dist/lib/plugins/index-html-plugin.js +2 -7
  58. package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -1
  59. package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +4 -1
  60. package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts +11 -0
  61. package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts.map +1 -0
  62. package/dist/lib/plugins/loaders/hmr-accept-loader.js +24 -0
  63. package/dist/lib/plugins/loaders/hmr-accept.d.ts +9 -0
  64. package/dist/lib/plugins/loaders/hmr-accept.d.ts.map +1 -0
  65. package/dist/lib/plugins/loaders/hmr-accept.js +183 -0
  66. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts +5 -0
  67. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts.map +1 -0
  68. package/dist/lib/plugins/loaders/platform-server-exports.loader.js +18 -0
  69. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  70. package/dist/lib/plugins/ng-rspack.js +38 -18
  71. package/dist/lib/plugins/prerender-plugin.d.ts +8 -0
  72. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -0
  73. package/dist/lib/plugins/prerender-plugin.js +219 -0
  74. package/dist/lib/plugins/progress-plugin.d.ts +12 -0
  75. package/dist/lib/plugins/progress-plugin.d.ts.map +1 -0
  76. package/dist/lib/plugins/progress-plugin.js +36 -0
  77. package/dist/lib/plugins/stats-json-plugin.d.ts +14 -0
  78. package/dist/lib/plugins/stats-json-plugin.d.ts.map +1 -0
  79. package/dist/lib/plugins/stats-json-plugin.js +70 -0
  80. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts +5 -0
  81. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts.map +1 -0
  82. package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.js +34 -0
  83. package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts.map +1 -1
  84. package/dist/lib/plugins/tools/dev-tools-ignore-plugin.js +1 -1
  85. package/dist/lib/plugins/tools/render-worker.d.ts +31 -0
  86. package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -0
  87. package/dist/lib/plugins/tools/render-worker.js +103 -0
  88. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +21 -0
  89. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -0
  90. package/dist/lib/plugins/tools/routes-extractor-worker.js +46 -0
  91. package/dist/lib/plugins/tools/worker-pool.d.ts +13 -0
  92. package/dist/lib/plugins/tools/worker-pool.d.ts.map +1 -0
  93. package/dist/lib/plugins/tools/worker-pool.js +26 -0
  94. package/dist/lib/plugins/transfer-size-plugin.d.ts +12 -0
  95. package/dist/lib/plugins/transfer-size-plugin.d.ts.map +1 -0
  96. package/dist/lib/plugins/transfer-size-plugin.js +49 -0
  97. package/dist/lib/plugins/watch-file-logs-plugin.d.ts +12 -0
  98. package/dist/lib/plugins/watch-file-logs-plugin.d.ts.map +1 -0
  99. package/dist/lib/plugins/watch-file-logs-plugin.js +27 -0
  100. package/dist/lib/utils/async-chunks.d.ts +17 -0
  101. package/dist/lib/utils/async-chunks.d.ts.map +1 -0
  102. package/dist/lib/utils/async-chunks.js +44 -0
  103. package/dist/lib/utils/color.d.ts +11 -0
  104. package/dist/lib/utils/color.d.ts.map +1 -0
  105. package/dist/lib/utils/color.js +41 -0
  106. package/dist/lib/utils/index-file/add-body-script.d.ts +2 -0
  107. package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -0
  108. package/dist/lib/utils/index-file/add-body-script.js +15 -0
  109. package/dist/lib/utils/index-file/get-index-input-file.d.ts +3 -0
  110. package/dist/lib/utils/index-file/get-index-input-file.d.ts.map +1 -0
  111. package/dist/lib/utils/index-file/get-index-input-file.js +9 -0
  112. package/dist/lib/utils/index-file/get-index-output-file.d.ts +3 -0
  113. package/dist/lib/utils/index-file/get-index-output-file.d.ts.map +1 -0
  114. package/dist/lib/utils/index-file/get-index-output-file.js +10 -0
  115. package/dist/lib/utils/max-workers.d.ts +2 -0
  116. package/dist/lib/utils/max-workers.d.ts.map +1 -0
  117. package/dist/lib/utils/max-workers.js +21 -0
  118. package/dist/lib/utils/misc-helpers.d.ts +1 -0
  119. package/dist/lib/utils/misc-helpers.d.ts.map +1 -1
  120. package/dist/lib/utils/misc-helpers.js +4 -0
  121. package/dist/lib/utils/postcss-cli-resources.d.ts +22 -0
  122. package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -0
  123. package/dist/lib/utils/postcss-cli-resources.js +158 -0
  124. package/dist/lib/utils/postcss-configuration.d.ts +18 -0
  125. package/dist/lib/utils/postcss-configuration.d.ts.map +1 -0
  126. package/dist/lib/utils/postcss-configuration.js +89 -0
  127. package/dist/lib/utils/rspack-diagnostics.d.ts +3 -3
  128. package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -1
  129. package/dist/lib/utils/rspack-diagnostics.js +16 -4
  130. package/dist/lib/utils/spinner.d.ts +21 -0
  131. package/dist/lib/utils/spinner.d.ts.map +1 -0
  132. package/dist/lib/utils/spinner.js +53 -0
  133. package/dist/lib/utils/stats.d.ts +35 -0
  134. package/dist/lib/utils/stats.d.ts.map +1 -0
  135. package/dist/lib/utils/stats.js +312 -0
  136. package/dist/lib/utils/tty.d.ts +9 -0
  137. package/dist/lib/utils/tty.d.ts.map +1 -0
  138. package/dist/lib/utils/tty.js +22 -0
  139. package/package.json +23 -5
  140. package/dist/lib/config/dev-server-config-utils.d.ts +0 -4
  141. package/dist/lib/config/dev-server-config-utils.d.ts.map +0 -1
  142. package/dist/lib/config/dev-server-config-utils.js +0 -107
  143. package/dist/lib/config/entry-points.d.ts.map +0 -1
  144. package/dist/lib/config/helpers.d.ts +0 -14
  145. package/dist/lib/config/helpers.d.ts.map +0 -1
  146. package/dist/lib/config/style-config-utils.d.ts +0 -22
  147. package/dist/lib/config/style-config-utils.d.ts.map +0 -1
  148. package/dist/lib/config/style-config-utils.js +0 -202
  149. package/dist/lib/models/unsupported-options.d.ts +0 -46
  150. package/dist/lib/models/unsupported-options.d.ts.map +0 -1
  151. package/dist/lib/models/unsupported-options.js +0 -26
  152. package/dist/lib/utils/tailwind.d.ts +0 -2
  153. package/dist/lib/utils/tailwind.d.ts.map +0 -1
  154. package/dist/lib/utils/tailwind.js +0 -31
  155. /package/dist/lib/config/{entry-points.js → config-utils/entry-points.js} +0 -0
@@ -0,0 +1,4 @@
1
+ import type { Configuration } from '@rspack/core';
2
+ import type { HashFormat, I18nOptions, NormalizedAngularRspackPluginOptions } from '../../models';
3
+ export declare function getBrowserConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, hashFormat: HashFormat, defaultConfig: Configuration): Promise<Configuration>;
4
+ //# sourceMappingURL=browser-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/browser-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAQtB,wBAAsB,gBAAgB,CACpC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,aAAa,CAAC,CA4ExB"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBrowserConfig = getBrowserConfig;
4
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
5
+ const ng_rspack_1 = require("../../plugins/ng-rspack");
6
+ const dev_server_config_utils_1 = require("./dev-server-config-utils");
7
+ const entry_points_1 = require("./entry-points");
8
+ const optimization_config_1 = require("./optimization-config");
9
+ const path_1 = require("path");
10
+ const hmr_accept_loader_1 = require("../../plugins/loaders/hmr-accept-loader");
11
+ async function getBrowserConfig(normalizedOptions, i18n, hashFormat, defaultConfig) {
12
+ const isProduction = process.env['NODE_ENV'] === 'production';
13
+ const { root } = normalizedOptions;
14
+ return {
15
+ ...defaultConfig,
16
+ name: 'browser',
17
+ target: 'web',
18
+ entry: {
19
+ main: {
20
+ import: [
21
+ ...(i18n.shouldInline ? ['@angular/localize/init'] : []),
22
+ normalizedOptions.browser,
23
+ ],
24
+ },
25
+ ...(0, entry_points_1.getPolyfillsEntry)(normalizedOptions.polyfills, normalizedOptions.aot),
26
+ ...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalStyles, normalizedOptions.root, 'ngGlobalStyles'),
27
+ ...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalScripts, normalizedOptions.root),
28
+ },
29
+ devServer: await (0, dev_server_config_utils_1.getDevServerConfig)(normalizedOptions, 'browser'),
30
+ output: {
31
+ ...defaultConfig.output,
32
+ hashFunction: isProduction ? 'xxhash64' : undefined,
33
+ path: normalizedOptions.outputPath.browser,
34
+ cssFilename: `[name]${hashFormat.file}.css`,
35
+ filename: `[name]${hashFormat.chunk}.js`,
36
+ chunkFilename: `[name]${hashFormat.chunk}.js`,
37
+ scriptType: 'module',
38
+ module: true,
39
+ },
40
+ optimization: (0, optimization_config_1.getOptimization)(normalizedOptions, 'browser'),
41
+ module: {
42
+ ...defaultConfig.module,
43
+ rules: [
44
+ {
45
+ test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
46
+ use: [
47
+ {
48
+ loader: 'builtin:swc-loader',
49
+ options: {
50
+ jsc: {
51
+ parser: {
52
+ syntax: 'typescript',
53
+ },
54
+ target: 'es2022',
55
+ },
56
+ },
57
+ },
58
+ ],
59
+ },
60
+ ...(normalizedOptions.devServer?.hmr
61
+ ? [
62
+ {
63
+ loader: hmr_accept_loader_1.HmrLoader,
64
+ include: [(0, path_1.resolve)(root, normalizedOptions.browser)],
65
+ },
66
+ ]
67
+ : []),
68
+ ...(defaultConfig.module?.rules ?? []),
69
+ ],
70
+ },
71
+ plugins: [
72
+ ...(defaultConfig.plugins ?? []),
73
+ new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
74
+ i18nOptions: i18n,
75
+ platform: 'browser',
76
+ }),
77
+ ],
78
+ };
79
+ }
@@ -0,0 +1,3 @@
1
+ import { HashFormat, I18nOptions, NormalizedAngularRspackPluginOptions } from '../../models';
2
+ export declare function getCommonConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, i18nHash: string | (() => void), hashFormat: HashFormat): Promise<import("@rspack/core").RspackOptions>;
3
+ //# sourceMappingURL=common-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/common-config.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,UAAU,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAQtB,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,EAC/B,UAAU,EAAE,UAAU,iDA2JvB"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCommonConfig = getCommonConfig;
4
+ const core_1 = require("@rspack/core");
5
+ const node_path_1 = require("node:path");
6
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
7
+ const style_config_utils_1 = require("./style-config-utils");
8
+ const helpers_1 = require("./helpers");
9
+ const sourcemap_utils_1 = require("./sourcemap-utils");
10
+ const stats_json_plugin_1 = require("../../plugins/stats-json-plugin");
11
+ const watch_file_logs_plugin_1 = require("../../plugins/watch-file-logs-plugin");
12
+ const get_index_input_file_1 = require("../../utils/index-file/get-index-input-file");
13
+ async function getCommonConfig(normalizedOptions, i18n, i18nHash, hashFormat) {
14
+ const isProduction = process.env['NODE_ENV'] === 'production';
15
+ const crossOriginLoading = (0, helpers_1.getCrossOriginLoading)(normalizedOptions);
16
+ const sourceMapOptions = (0, sourcemap_utils_1.configureSourceMap)(normalizedOptions.sourceMap);
17
+ const stylesConfig = await (0, style_config_utils_1.getStylesConfig)(normalizedOptions, hashFormat, normalizedOptions.hasServer ? 'server' : 'browser');
18
+ const indexInputFile = (0, node_path_1.join)(normalizedOptions.root, (0, get_index_input_file_1.getIndexInputFile)(normalizedOptions.index));
19
+ const indexInputWatchPlugin = {
20
+ apply: (compiler) => {
21
+ compiler.hooks.thisCompilation.tap('build-angular', (compilation) => {
22
+ compilation.fileDependencies.add(indexInputFile);
23
+ });
24
+ },
25
+ };
26
+ const defaultConfig = {
27
+ context: normalizedOptions.root,
28
+ profile: normalizedOptions.statsJson,
29
+ mode: isProduction ? 'production' : 'development',
30
+ devtool: normalizedOptions.sourceMap.scripts ? 'source-map' : undefined,
31
+ infrastructureLogging: {
32
+ appendOnly: false,
33
+ debug: normalizedOptions.verbose,
34
+ level: normalizedOptions.verbose ? 'verbose' : 'none',
35
+ },
36
+ performance: {
37
+ hints: false,
38
+ },
39
+ stats: 'none', // This is handled in the AngularRspackPlugin by the rspackStatsLogger
40
+ output: {
41
+ uniqueName: normalizedOptions.projectName ?? 'rspack-angular',
42
+ publicPath: normalizedOptions.deployUrl ?? '',
43
+ clean: normalizedOptions.deleteOutputPath,
44
+ crossOriginLoading,
45
+ trustedTypes: { policyName: 'angular#bundler' },
46
+ sourceMapFilename: normalizedOptions.sourceMap.scripts
47
+ ? '[file].map'
48
+ : undefined,
49
+ scriptType: 'module',
50
+ },
51
+ resolve: {
52
+ extensions: ['.ts', '.tsx', '.mjs', '.js'],
53
+ symlinks: !normalizedOptions.preserveSymlinks,
54
+ modules: ['node_modules'],
55
+ mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
56
+ conditionNames: ['es2020', 'es2015', '...'],
57
+ tsConfig: {
58
+ configFile: normalizedOptions.tsConfig,
59
+ },
60
+ ...(i18n.shouldInline && normalizedOptions.aot
61
+ ? { alias: { '@angular/localize/init': false } }
62
+ : {}),
63
+ },
64
+ resolveLoader: {
65
+ symlinks: !normalizedOptions.preserveSymlinks,
66
+ },
67
+ watch: normalizedOptions.watch,
68
+ watchOptions: {
69
+ poll: normalizedOptions.poll,
70
+ followSymlinks: normalizedOptions.preserveSymlinks,
71
+ ignored: normalizedOptions.poll === undefined ? undefined : '**/node_modules/**',
72
+ },
73
+ ignoreWarnings: [
74
+ // https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
75
+ /Failed to parse source map from/,
76
+ // https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
77
+ /Add postcss as project dependency/,
78
+ // esbuild will issue a warning, while still hoists the @charset at the very top.
79
+ // This is caused by a bug in css-loader https://github.com/webpack-contrib/css-loader/issues/1212
80
+ /"@charset" must be the first rule in the file/,
81
+ ],
82
+ module: {
83
+ parser: {
84
+ javascript: {
85
+ requireContext: false,
86
+ url: false,
87
+ },
88
+ },
89
+ rules: [
90
+ {
91
+ test: /\.?(svg|html)$/,
92
+ // Only process HTML and SVG which are known Angular component resources.
93
+ resourceQuery: /\?ngResource/,
94
+ type: 'asset/source',
95
+ },
96
+ ...stylesConfig.loaderRules,
97
+ ...sourceMapOptions.sourceMapRules,
98
+ { test: /[/\\]rxjs[/\\]add[/\\].+\.js$/, sideEffects: true },
99
+ {
100
+ test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
101
+ use: [
102
+ {
103
+ loader: require.resolve('@nx/angular-rspack/loaders/angular-loader'),
104
+ },
105
+ ],
106
+ },
107
+ {
108
+ test: angular_rspack_compiler_1.JS_ALL_EXT_REGEX,
109
+ use: [
110
+ {
111
+ loader: require.resolve('@nx/angular-rspack/loaders/angular-partial-transform-loader'),
112
+ },
113
+ ],
114
+ },
115
+ ],
116
+ },
117
+ plugins: [
118
+ ...sourceMapOptions.sourceMapPlugins,
119
+ ...(normalizedOptions.verbose ? [new watch_file_logs_plugin_1.WatchFilesLogsPlugin()] : []),
120
+ ...(normalizedOptions.watch ? [indexInputWatchPlugin] : []),
121
+ ...(normalizedOptions.statsJson
122
+ ? [
123
+ new stats_json_plugin_1.StatsJsonPlugin((0, node_path_1.resolve)(normalizedOptions.root, normalizedOptions.outputPath.base, 'stats.json')),
124
+ ]
125
+ : []),
126
+ ...(i18n.shouldInline
127
+ ? [
128
+ {
129
+ apply(compiler) {
130
+ compiler.hooks.compilation.tap('AngularRspackPlugin', (compilation) => {
131
+ core_1.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap('AngularRspackPlugin', (_, hash) => {
132
+ hash.update(Buffer.from('$localize' + i18nHash));
133
+ });
134
+ });
135
+ },
136
+ },
137
+ ]
138
+ : []),
139
+ ...stylesConfig.plugins,
140
+ ],
141
+ };
142
+ return defaultConfig;
143
+ }
@@ -0,0 +1,4 @@
1
+ import type { DevServer } from '@rspack/core';
2
+ import type { NormalizedAngularRspackPluginOptions } from '../../models';
3
+ export declare function getDevServerConfig(options: NormalizedAngularRspackPluginOptions, platform: 'browser' | 'server'): Promise<DevServer>;
4
+ //# sourceMappingURL=dev-server-config-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-server-config-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/dev-server-config-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAK9C,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAIzE,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,oCAAoC,EAC7C,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,OAAO,CAAC,SAAS,CAAC,CA2DpB"}
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDevServerConfig = getDevServerConfig;
4
+ const tslib_1 = require("tslib");
5
+ const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
6
+ const node_fs_1 = require("node:fs");
7
+ const node_path_1 = require("node:path");
8
+ const node_url_1 = require("node:url");
9
+ const get_index_output_file_1 = require("../../utils/index-file/get-index-output-file");
10
+ const misc_helpers_1 = require("../../utils/misc-helpers");
11
+ async function getDevServerConfig(options, platform) {
12
+ const { root } = options;
13
+ const servePath = buildServePath(options);
14
+ return {
15
+ host: options.devServer.host,
16
+ port: options.devServer.port,
17
+ headers: {
18
+ 'Access-Control-Allow-Origin': '*',
19
+ ...options.devServer.headers,
20
+ },
21
+ historyApiFallback: {
22
+ index: node_path_1.posix.join(servePath, (0, get_index_output_file_1.getIndexOutputFile)(options.index)),
23
+ disableDotRule: true,
24
+ htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
25
+ rewrites: [
26
+ {
27
+ from: new RegExp(`^(?!${servePath})/.*`),
28
+ to: (context) => context.parsedUrl.href,
29
+ },
30
+ ],
31
+ },
32
+ compress: false,
33
+ static: false,
34
+ server: getServerConfig(options),
35
+ allowedHosts: getAllowedHostsConfig(options.devServer.allowedHosts, options.devServer.disableHostCheck),
36
+ devMiddleware: {
37
+ publicPath: servePath,
38
+ writeToDisk: platform === 'browser' && options.hasServer
39
+ ? (file) => !file.includes('.hot-update.')
40
+ : undefined,
41
+ },
42
+ liveReload: options.devServer.liveReload,
43
+ hot: options.devServer.hmr && !options.devServer.liveReload
44
+ ? 'only'
45
+ : options.devServer.hmr,
46
+ proxy: await getProxyConfig(root, options.devServer.proxyConfig),
47
+ ...getWebSocketSettings(options, servePath),
48
+ watchFiles: ['./src/**/*.*', './public/**/*.*'],
49
+ onListening: platform === 'browser'
50
+ ? (devServer) => {
51
+ if (!devServer) {
52
+ throw new Error('@rspack/dev-server is not defined');
53
+ }
54
+ const port = devServer.server?.address()?.port ??
55
+ options.devServer.port;
56
+ console.log('Listening on port:', port);
57
+ }
58
+ : undefined,
59
+ };
60
+ }
61
+ /**
62
+ * Resolve and build a URL _path_ that will be the root of the server. This resolves base href and
63
+ * deploy URL from the browser options and returns a path from the root.
64
+ */
65
+ function buildServePath(options) {
66
+ let servePath = options.devServer.servePath;
67
+ if (servePath === undefined) {
68
+ const defaultPath = findDefaultServePath(options.baseHref, options.deployUrl);
69
+ if (defaultPath == null) {
70
+ console.warn(`Warning: --deploy-url and/or --base-href contain unsupported values for ng serve. Default serve path of '/' used. Use --serve-path to override.`);
71
+ }
72
+ servePath = defaultPath || '';
73
+ }
74
+ if (servePath.endsWith('/')) {
75
+ servePath = servePath.slice(0, -1);
76
+ }
77
+ if (!servePath.startsWith('/')) {
78
+ servePath = `/${servePath}`;
79
+ }
80
+ return servePath;
81
+ }
82
+ /**
83
+ * Find the default server path. We don't want to expose baseHref and deployUrl as arguments, only
84
+ * the browser options where needed.
85
+ */
86
+ function findDefaultServePath(baseHref, deployUrl) {
87
+ if (!baseHref && !deployUrl) {
88
+ return '';
89
+ }
90
+ if (/^(\w+:)?\/\//.test(baseHref || '') ||
91
+ /^(\w+:)?\/\//.test(deployUrl || '')) {
92
+ // If baseHref or deployUrl is absolute, unsupported by ng serve
93
+ return null;
94
+ }
95
+ // normalize baseHref
96
+ // for ng serve the starting base is always `/` so a relative
97
+ // and root relative value are identical
98
+ const baseHrefParts = (baseHref || '')
99
+ .split('/')
100
+ .filter((part) => part !== '');
101
+ if (baseHref && !baseHref.endsWith('/')) {
102
+ baseHrefParts.pop();
103
+ }
104
+ const normalizedBaseHref = baseHrefParts.length === 0 ? '/' : `/${baseHrefParts.join('/')}/`;
105
+ if (deployUrl && deployUrl[0] === '/') {
106
+ if (baseHref && baseHref[0] === '/' && normalizedBaseHref !== deployUrl) {
107
+ // If baseHref and deployUrl are root relative and not equivalent, unsupported by ng serve
108
+ return null;
109
+ }
110
+ return deployUrl;
111
+ }
112
+ // Join together baseHref and deployUrl
113
+ return `${normalizedBaseHref}${deployUrl || ''}`;
114
+ }
115
+ function getServerConfig(options) {
116
+ const { root, devServer: { ssl, sslCert, sslKey }, } = options;
117
+ if (!ssl) {
118
+ return 'http';
119
+ }
120
+ return {
121
+ type: 'https',
122
+ options: sslCert && sslKey
123
+ ? {
124
+ key: (0, node_path_1.resolve)(root, sslKey),
125
+ cert: (0, node_path_1.resolve)(root, sslCert),
126
+ }
127
+ : undefined,
128
+ };
129
+ }
130
+ function getAllowedHostsConfig(allowedHosts, disableHostCheck) {
131
+ if (disableHostCheck || allowedHosts === true) {
132
+ return 'all';
133
+ }
134
+ if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
135
+ return allowedHosts;
136
+ }
137
+ return undefined;
138
+ }
139
+ async function getProxyConfig(root, proxyConfig) {
140
+ if (!proxyConfig) {
141
+ return undefined;
142
+ }
143
+ const proxyPath = (0, node_path_1.resolve)(root, proxyConfig);
144
+ if (!(0, node_fs_1.existsSync)(proxyPath)) {
145
+ throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
146
+ }
147
+ let proxyConfiguration;
148
+ switch ((0, node_path_1.extname)(proxyPath)) {
149
+ case '.json': {
150
+ const content = await node_fs_1.promises.readFile(proxyPath, 'utf-8');
151
+ const { parse, printParseErrorCode } = await Promise.resolve().then(() => tslib_1.__importStar(require('jsonc-parser')));
152
+ const parseErrors = [];
153
+ proxyConfiguration = parse(content, parseErrors, {
154
+ allowTrailingComma: true,
155
+ });
156
+ if (parseErrors.length > 0) {
157
+ let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
158
+ for (const parseError of parseErrors) {
159
+ const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
160
+ errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
161
+ }
162
+ throw new Error(errorMessage);
163
+ }
164
+ break;
165
+ }
166
+ case '.mjs':
167
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
168
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
169
+ // changed to a direct dynamic import.
170
+ proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
171
+ break;
172
+ case '.cjs':
173
+ proxyConfiguration = require(proxyPath);
174
+ break;
175
+ default:
176
+ // The file could be either CommonJS or ESM.
177
+ // CommonJS is tried first then ESM if loading fails.
178
+ try {
179
+ proxyConfiguration = require(proxyPath);
180
+ }
181
+ catch (e) {
182
+ assertIsError(e);
183
+ if (e.code !== 'ERR_REQUIRE_ESM') {
184
+ throw e;
185
+ }
186
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
187
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
188
+ // changed to a direct dynamic import.
189
+ proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
190
+ }
191
+ }
192
+ return normalizeProxyConfiguration(proxyConfiguration);
193
+ }
194
+ function getWebSocketSettings(options, servePath) {
195
+ const { hmr, liveReload } = options.devServer;
196
+ if (!hmr && !liveReload) {
197
+ return { client: undefined, webSocketServer: false };
198
+ }
199
+ const webSocketPath = node_path_1.posix.join(servePath, 'ng-cli-ws');
200
+ return {
201
+ webSocketServer: {
202
+ options: { path: webSocketPath },
203
+ },
204
+ client: {
205
+ logging: 'info',
206
+ webSocketURL: getPublicHostOptions(options, webSocketPath),
207
+ overlay: {
208
+ errors: true,
209
+ warnings: false,
210
+ runtimeErrors: false,
211
+ },
212
+ },
213
+ };
214
+ }
215
+ function getPublicHostOptions(options, webSocketPath) {
216
+ let publicHost = options.devServer.publicHost;
217
+ if (publicHost) {
218
+ const hostWithProtocol = !/^\w+:\/\//.test(publicHost)
219
+ ? `https://${publicHost}`
220
+ : publicHost;
221
+ publicHost = new URL(hostWithProtocol).host;
222
+ }
223
+ return `auto://${publicHost || '0.0.0.0:0'}${webSocketPath}`;
224
+ }
225
+ function getJsonErrorLineColumn(offset, content) {
226
+ if (offset === 0) {
227
+ return { line: 1, column: 1 };
228
+ }
229
+ let line = 0;
230
+ let position = 0;
231
+ while (true) {
232
+ ++line;
233
+ const nextNewline = content.indexOf('\n', position);
234
+ if (nextNewline === -1 || nextNewline > offset) {
235
+ break;
236
+ }
237
+ position = nextNewline + 1;
238
+ }
239
+ return { line, column: offset - position + 1 };
240
+ }
241
+ function normalizeProxyConfiguration(proxy) {
242
+ return Array.isArray(proxy)
243
+ ? proxy
244
+ : Object.entries(proxy).map(([context, value]) => ({
245
+ context: [context],
246
+ ...value,
247
+ }));
248
+ }
249
+ function assertIsError(value) {
250
+ const isError = value instanceof Error ||
251
+ // The following is needing to identify errors coming from RxJs.
252
+ (typeof value === 'object' &&
253
+ value &&
254
+ 'name' in value &&
255
+ 'message' in value);
256
+ (0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
257
+ }
@@ -1,4 +1,4 @@
1
- import type { GlobalEntry } from '../models';
1
+ import type { GlobalEntry } from '../../models';
2
2
  export declare function getEntryPoints(globalStyles: GlobalEntry[], globalScripts: GlobalEntry[], isHMREnabled?: boolean): [name: string, isModule: boolean][];
3
3
  export declare function getPolyfillsEntry(polyfills: string[], aot: boolean): {
4
4
  polyfills?: string[];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-points.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/entry-points.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,WAAW,EAAE,EAC3B,aAAa,EAAE,WAAW,EAAE,EAC5B,YAAY,CAAC,EAAE,OAAO,GACrB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAerC;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,EAAE,OAAO,GACX;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAW1B;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM;YAEmB,MAAM,EAAE;GAahD"}
@@ -0,0 +1,3 @@
1
+ import { type StatsOptions } from '@rspack/core';
2
+ export declare function getStatsOptions(verbose?: boolean): StatsOptions;
3
+ //# sourceMappingURL=get-stats-options.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStatsOptions = getStatsOptions;
4
+ function getStatsOptions(verbose = false) {
5
+ const rspackStatsOptions = {
6
+ all: false, // Fallback value for stats options when an option is not defined. It has precedence over local webpack defaults.
7
+ colors: true,
8
+ hash: true, // required by custom stat output
9
+ timings: true, // required by custom stat output
10
+ chunks: true, // required by custom stat output
11
+ builtAt: true, // required by custom stat output
12
+ warnings: true,
13
+ errors: true,
14
+ assets: true, // required by custom stat output
15
+ cachedAssets: true, // required for bundle size calculators
16
+ // Needed for markAsyncChunksNonInitial.
17
+ ids: true,
18
+ entrypoints: true,
19
+ };
20
+ const verboseStatsOutputOptions = {
21
+ // The verbose output will most likely be piped to a file, so colors just mess it up.
22
+ colors: false,
23
+ usedExports: true,
24
+ optimizationBailout: true,
25
+ reasons: true,
26
+ children: true,
27
+ assets: true,
28
+ version: true,
29
+ chunkModules: true,
30
+ errorDetails: true,
31
+ errorStack: true,
32
+ moduleTrace: true,
33
+ logging: 'verbose',
34
+ modulesSpace: Infinity,
35
+ };
36
+ return verbose
37
+ ? { ...rspackStatsOptions, ...verboseStatsOutputOptions }
38
+ : rspackStatsOptions;
39
+ }
@@ -0,0 +1,13 @@
1
+ import { AngularRspackPluginOptions, HashFormat, NormalizedAngularRspackPluginOptions, OutputHashing } from '../../models';
2
+ /**
3
+ * Delete an output directory, but error out if it's the root of the project.
4
+ */
5
+ export declare function deleteOutputDir(root: string, outputPath: string, emptyOnlyDirectories?: string[]): Promise<void>;
6
+ export declare function getOutputHashFormat(outputHashing?: OutputHashing, length?: number): HashFormat;
7
+ export declare function normalizeOptionWithI18n(options: AngularRspackPluginOptions): Promise<{
8
+ i18n: import("@angular/build/private").I18nOptions;
9
+ i18nHash: string | (() => void);
10
+ normalizedOptions: NormalizedAngularRspackPluginOptions;
11
+ }>;
12
+ export declare function getCrossOriginLoading(normalizedOptions: NormalizedAngularRspackPluginOptions): false | "anonymous" | "use-credentials";
13
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/helpers.ts"],"names":[],"mappings":"AASA,OAAO,EACL,0BAA0B,EAC1B,UAAU,EACV,oCAAoC,EAEpC,aAAa,EACd,MAAM,cAAc,CAAC;AAItB;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAgB,mBAAmB,CACjC,aAAa,GAAE,aAAsB,EACrC,MAAM,SAAI,GACT,UAAU,CAkCZ;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,0BAA0B;;;;GAmBpC;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,oCAAoC,2CAcxD"}
@@ -2,8 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteOutputDir = deleteOutputDir;
4
4
  exports.getOutputHashFormat = getOutputHashFormat;
5
+ exports.normalizeOptionWithI18n = normalizeOptionWithI18n;
6
+ exports.getCrossOriginLoading = getCrossOriginLoading;
7
+ /**
8
+ * @license
9
+ * Copyright Google LLC All Rights Reserved.
10
+ *
11
+ * Use of this source code is governed by an MIT-style license that can be
12
+ * found in the LICENSE file at https://angular.dev/license
13
+ */
5
14
  const promises_1 = require("node:fs/promises");
6
15
  const node_path_1 = require("node:path");
16
+ const models_1 = require("../../models");
17
+ const create_i18n_options_1 = require("../i18n/create-i18n-options");
7
18
  /**
8
19
  * Delete an output directory, but error out if it's the root of the project.
9
20
  */
@@ -71,3 +82,25 @@ function getOutputHashFormat(outputHashing = 'none', length = 8) {
71
82
  };
72
83
  }
73
84
  }
85
+ async function normalizeOptionWithI18n(options) {
86
+ const { options: _options, i18n } = await (0, create_i18n_options_1.configureI18n)(options.root ?? process.cwd(), options);
87
+ // Update file hashes to include translation file content
88
+ const i18nHash = i18n.shouldInline
89
+ ? Object.values(i18n.locales).reduce((data, locale) => data + locale.files.map((file) => file.integrity || '').join('|'), '')
90
+ : () => {
91
+ // no-op as i18n is not inlined
92
+ };
93
+ const normalizedOptions = await (0, models_1.normalizeOptions)(_options);
94
+ return { i18n, i18nHash, normalizedOptions };
95
+ }
96
+ function getCrossOriginLoading(normalizedOptions) {
97
+ let crossOriginLoading = false;
98
+ if (normalizedOptions.subresourceIntegrity &&
99
+ normalizedOptions.crossOrigin === 'none') {
100
+ crossOriginLoading = 'anonymous';
101
+ }
102
+ else if (normalizedOptions.crossOrigin !== 'none') {
103
+ crossOriginLoading = normalizedOptions.crossOrigin;
104
+ }
105
+ return crossOriginLoading;
106
+ }
@@ -0,0 +1,5 @@
1
+ import { Configuration } from '@rspack/core';
2
+ import { NormalizedAngularRspackPluginOptions } from '../../models';
3
+ export declare const VENDORS_TEST: RegExp;
4
+ export declare function getOptimization(normalizedOptions: NormalizedAngularRspackPluginOptions, platform: 'browser' | 'server'): Configuration['optimization'];
5
+ //# sourceMappingURL=optimization-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"optimization-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/optimization-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAGpE,eAAO,MAAM,YAAY,QAA2B,CAAC;AAErD,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,oCAAoC,EACvD,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,aAAa,CAAC,cAAc,CAAC,CA6D/B"}