@nx/angular-rspack 20.8.1 → 20.9.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 (96) 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 +68 -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 +111 -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 +255 -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/helpers.d.ts +13 -0
  13. package/dist/lib/config/config-utils/helpers.d.ts.map +1 -0
  14. package/dist/lib/config/{helpers.js → config-utils/helpers.js} +33 -0
  15. package/dist/lib/config/config-utils/optimization-config.d.ts +5 -0
  16. package/dist/lib/config/config-utils/optimization-config.d.ts.map +1 -0
  17. package/dist/lib/config/config-utils/optimization-config.js +67 -0
  18. package/dist/lib/config/config-utils/server-config.d.ts +4 -0
  19. package/dist/lib/config/config-utils/server-config.d.ts.map +1 -0
  20. package/dist/lib/config/config-utils/server-config.js +87 -0
  21. package/dist/lib/config/config-utils/sourcemap-utils.d.ts +7 -0
  22. package/dist/lib/config/config-utils/sourcemap-utils.d.ts.map +1 -0
  23. package/dist/lib/config/config-utils/sourcemap-utils.js +48 -0
  24. package/dist/lib/config/config-utils/style-config-utils.d.ts +7 -0
  25. package/dist/lib/config/config-utils/style-config-utils.d.ts.map +1 -0
  26. package/dist/lib/config/config-utils/style-config-utils.js +353 -0
  27. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts +78 -0
  28. package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts.map +1 -0
  29. package/dist/lib/config/config-utils/user-defined-config-helpers.js +23 -0
  30. package/dist/lib/config/create-config.d.ts +2 -75
  31. package/dist/lib/config/create-config.d.ts.map +1 -1
  32. package/dist/lib/config/create-config.js +17 -473
  33. package/dist/lib/index.d.ts +4 -0
  34. package/dist/lib/index.d.ts.map +1 -1
  35. package/dist/lib/index.js +9 -0
  36. package/dist/lib/models/angular-rspack-plugin-options.d.ts +41 -4
  37. package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
  38. package/dist/lib/models/normalize-options.d.ts.map +1 -1
  39. package/dist/lib/models/normalize-options.js +53 -54
  40. package/dist/lib/models/unsupported-options.d.ts +0 -7
  41. package/dist/lib/models/unsupported-options.d.ts.map +1 -1
  42. package/dist/lib/models/unsupported-options.js +0 -4
  43. package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
  44. package/dist/lib/plugins/angular-rspack-plugin.js +0 -7
  45. package/dist/lib/plugins/angular-ssr-dev-server.d.ts +2 -2
  46. package/dist/lib/plugins/angular-ssr-dev-server.d.ts.map +1 -1
  47. package/dist/lib/plugins/angular-ssr-dev-server.js +19 -9
  48. package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -1
  49. package/dist/lib/plugins/index-html-plugin.js +2 -7
  50. package/dist/lib/plugins/loaders/angular-transform.loader.js +1 -1
  51. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts +5 -0
  52. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts.map +1 -0
  53. package/dist/lib/plugins/loaders/platform-server-exports.loader.js +18 -0
  54. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  55. package/dist/lib/plugins/ng-rspack.js +3 -3
  56. package/dist/lib/plugins/prerender-plugin.d.ts +8 -0
  57. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -0
  58. package/dist/lib/plugins/prerender-plugin.js +154 -0
  59. package/dist/lib/plugins/tools/render-worker.d.ts +31 -0
  60. package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -0
  61. package/dist/lib/plugins/tools/render-worker.js +103 -0
  62. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +21 -0
  63. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -0
  64. package/dist/lib/plugins/tools/routes-extractor-worker.js +46 -0
  65. package/dist/lib/plugins/tools/worker-pool.d.ts +13 -0
  66. package/dist/lib/plugins/tools/worker-pool.d.ts.map +1 -0
  67. package/dist/lib/plugins/tools/worker-pool.js +26 -0
  68. package/dist/lib/utils/index-file/add-body-script.d.ts +2 -0
  69. package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -0
  70. package/dist/lib/utils/index-file/add-body-script.js +15 -0
  71. package/dist/lib/utils/index-file/get-index-output-file.d.ts +3 -0
  72. package/dist/lib/utils/index-file/get-index-output-file.d.ts.map +1 -0
  73. package/dist/lib/utils/index-file/get-index-output-file.js +10 -0
  74. package/dist/lib/utils/max-workers.d.ts +2 -0
  75. package/dist/lib/utils/max-workers.d.ts.map +1 -0
  76. package/dist/lib/utils/max-workers.js +21 -0
  77. package/dist/lib/utils/postcss-cli-resources.d.ts +22 -0
  78. package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -0
  79. package/dist/lib/utils/postcss-cli-resources.js +158 -0
  80. package/dist/lib/utils/postcss-configuration.d.ts +18 -0
  81. package/dist/lib/utils/postcss-configuration.d.ts.map +1 -0
  82. package/dist/lib/utils/postcss-configuration.js +89 -0
  83. package/package.json +19 -5
  84. package/dist/lib/config/dev-server-config-utils.d.ts +0 -4
  85. package/dist/lib/config/dev-server-config-utils.d.ts.map +0 -1
  86. package/dist/lib/config/dev-server-config-utils.js +0 -107
  87. package/dist/lib/config/entry-points.d.ts.map +0 -1
  88. package/dist/lib/config/helpers.d.ts +0 -14
  89. package/dist/lib/config/helpers.d.ts.map +0 -1
  90. package/dist/lib/config/style-config-utils.d.ts +0 -22
  91. package/dist/lib/config/style-config-utils.d.ts.map +0 -1
  92. package/dist/lib/config/style-config-utils.js +0 -202
  93. package/dist/lib/utils/tailwind.d.ts +0 -2
  94. package/dist/lib/utils/tailwind.d.ts.map +0 -1
  95. package/dist/lib/utils/tailwind.js +0 -31
  96. /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;AAMtB,wBAAsB,gBAAgB,CACpC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,aAAa,CAAC,CAmExB"}
@@ -0,0 +1,68 @@
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
+ async function getBrowserConfig(normalizedOptions, i18n, hashFormat, defaultConfig) {
10
+ const isProduction = process.env['NODE_ENV'] === 'production';
11
+ return {
12
+ ...defaultConfig,
13
+ name: 'browser',
14
+ target: 'web',
15
+ entry: {
16
+ main: {
17
+ import: [
18
+ ...(i18n.shouldInline ? ['@angular/localize/init'] : []),
19
+ normalizedOptions.browser,
20
+ ],
21
+ },
22
+ ...(0, entry_points_1.getPolyfillsEntry)(normalizedOptions.polyfills, normalizedOptions.aot),
23
+ ...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalStyles, normalizedOptions.root, 'ngGlobalStyles'),
24
+ ...(0, entry_points_1.toRspackEntries)(normalizedOptions.globalScripts, normalizedOptions.root),
25
+ },
26
+ devServer: await (0, dev_server_config_utils_1.getDevServerConfig)(normalizedOptions, 'browser'),
27
+ output: {
28
+ ...defaultConfig.output,
29
+ hashFunction: isProduction ? 'xxhash64' : undefined,
30
+ path: normalizedOptions.outputPath.browser,
31
+ cssFilename: `[name]${hashFormat.file}.css`,
32
+ filename: `[name]${hashFormat.chunk}.js`,
33
+ chunkFilename: `[name]${hashFormat.chunk}.js`,
34
+ scriptType: 'module',
35
+ module: true,
36
+ },
37
+ optimization: (0, optimization_config_1.getOptimization)(normalizedOptions, 'browser'),
38
+ module: {
39
+ ...defaultConfig.module,
40
+ rules: [
41
+ {
42
+ test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
43
+ use: [
44
+ {
45
+ loader: 'builtin:swc-loader',
46
+ options: {
47
+ jsc: {
48
+ parser: {
49
+ syntax: 'typescript',
50
+ },
51
+ target: 'es2022',
52
+ },
53
+ },
54
+ },
55
+ ],
56
+ },
57
+ ...(defaultConfig.module?.rules ?? []),
58
+ ],
59
+ },
60
+ plugins: [
61
+ ...(defaultConfig.plugins ?? []),
62
+ new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
63
+ i18nOptions: i18n,
64
+ platform: 'browser',
65
+ }),
66
+ ],
67
+ };
68
+ }
@@ -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":"AAKA,OAAO,EACL,UAAU,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAKtB,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,EAC/B,UAAU,EAAE,UAAU,iDAqHvB"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCommonConfig = getCommonConfig;
4
+ const core_1 = require("@rspack/core");
5
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
6
+ const style_config_utils_1 = require("./style-config-utils");
7
+ const helpers_1 = require("./helpers");
8
+ const sourcemap_utils_1 = require("./sourcemap-utils");
9
+ async function getCommonConfig(normalizedOptions, i18n, i18nHash, hashFormat) {
10
+ const isProduction = process.env['NODE_ENV'] === 'production';
11
+ const crossOriginLoading = (0, helpers_1.getCrossOriginLoading)(normalizedOptions);
12
+ const sourceMapOptions = (0, sourcemap_utils_1.configureSourceMap)(normalizedOptions.sourceMap);
13
+ const stylesConfig = await (0, style_config_utils_1.getStylesConfig)(normalizedOptions, hashFormat, normalizedOptions.hasServer ? 'server' : 'browser');
14
+ const defaultConfig = {
15
+ context: normalizedOptions.root,
16
+ mode: isProduction ? 'production' : 'development',
17
+ devtool: normalizedOptions.sourceMap.scripts ? 'source-map' : undefined,
18
+ output: {
19
+ uniqueName: normalizedOptions.projectName ?? 'rspack-angular',
20
+ publicPath: normalizedOptions.deployUrl ?? '',
21
+ clean: normalizedOptions.deleteOutputPath,
22
+ crossOriginLoading,
23
+ trustedTypes: { policyName: 'angular#bundler' },
24
+ sourceMapFilename: normalizedOptions.sourceMap.scripts
25
+ ? '[file].map'
26
+ : undefined,
27
+ scriptType: 'module',
28
+ },
29
+ resolve: {
30
+ extensions: ['.ts', '.tsx', '.mjs', '.js'],
31
+ symlinks: !normalizedOptions.preserveSymlinks,
32
+ modules: ['node_modules'],
33
+ mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
34
+ conditionNames: ['es2020', 'es2015', '...'],
35
+ tsConfig: {
36
+ configFile: normalizedOptions.tsConfig,
37
+ },
38
+ ...(i18n.shouldInline && normalizedOptions.aot
39
+ ? { alias: { '@angular/localize/init': false } }
40
+ : {}),
41
+ },
42
+ resolveLoader: {
43
+ symlinks: !normalizedOptions.preserveSymlinks,
44
+ },
45
+ watchOptions: {
46
+ followSymlinks: normalizedOptions.preserveSymlinks,
47
+ },
48
+ ignoreWarnings: [
49
+ // https://github.com/webpack-contrib/source-map-loader/blob/b2de4249c7431dd8432da607e08f0f65e9d64219/src/index.js#L83
50
+ /Failed to parse source map from/,
51
+ // https://github.com/webpack-contrib/postcss-loader/blob/bd261875fdf9c596af4ffb3a1a73fe3c549befda/src/index.js#L153-L158
52
+ /Add postcss as project dependency/,
53
+ // esbuild will issue a warning, while still hoists the @charset at the very top.
54
+ // This is caused by a bug in css-loader https://github.com/webpack-contrib/css-loader/issues/1212
55
+ /"@charset" must be the first rule in the file/,
56
+ ],
57
+ module: {
58
+ parser: {
59
+ javascript: {
60
+ requireContext: false,
61
+ url: false,
62
+ },
63
+ },
64
+ rules: [
65
+ {
66
+ test: /\.?(svg|html)$/,
67
+ // Only process HTML and SVG which are known Angular component resources.
68
+ resourceQuery: /\?ngResource/,
69
+ type: 'asset/source',
70
+ },
71
+ ...stylesConfig.loaderRules,
72
+ ...sourceMapOptions.sourceMapRules,
73
+ { test: /[/\\]rxjs[/\\]add[/\\].+\.js$/, sideEffects: true },
74
+ {
75
+ test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
76
+ use: [
77
+ {
78
+ loader: require.resolve('@nx/angular-rspack/loaders/angular-loader'),
79
+ },
80
+ ],
81
+ },
82
+ {
83
+ test: angular_rspack_compiler_1.JS_ALL_EXT_REGEX,
84
+ use: [
85
+ {
86
+ loader: require.resolve('@nx/angular-rspack/loaders/angular-partial-transform-loader'),
87
+ },
88
+ ],
89
+ },
90
+ ],
91
+ },
92
+ plugins: [
93
+ ...sourceMapOptions.sourceMapPlugins,
94
+ ...(i18n.shouldInline
95
+ ? [
96
+ {
97
+ apply(compiler) {
98
+ compiler.hooks.compilation.tap('AngularRspackPlugin', (compilation) => {
99
+ core_1.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).chunkHash.tap('AngularRspackPlugin', (_, hash) => {
100
+ hash.update(Buffer.from('$localize' + i18nHash));
101
+ });
102
+ });
103
+ },
104
+ },
105
+ ]
106
+ : []),
107
+ ...stylesConfig.plugins,
108
+ ],
109
+ };
110
+ return defaultConfig;
111
+ }
@@ -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,CAwDpB"}
@@ -0,0 +1,255 @@
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: false,
44
+ proxy: await getProxyConfig(root, options.devServer.proxyConfig),
45
+ ...getWebSocketSettings(options, servePath),
46
+ watchFiles: ['./src/**/*.*', './public/**/*.*'],
47
+ onListening: platform === 'browser'
48
+ ? (devServer) => {
49
+ if (!devServer) {
50
+ throw new Error('@rspack/dev-server is not defined');
51
+ }
52
+ const port = devServer.server?.address()?.port ??
53
+ options.devServer.port;
54
+ console.log('Listening on port:', port);
55
+ }
56
+ : undefined,
57
+ };
58
+ }
59
+ /**
60
+ * Resolve and build a URL _path_ that will be the root of the server. This resolves base href and
61
+ * deploy URL from the browser options and returns a path from the root.
62
+ */
63
+ function buildServePath(options) {
64
+ let servePath = options.devServer.servePath;
65
+ if (servePath === undefined) {
66
+ const defaultPath = findDefaultServePath(options.baseHref, options.deployUrl);
67
+ if (defaultPath == null) {
68
+ 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.`);
69
+ }
70
+ servePath = defaultPath || '';
71
+ }
72
+ if (servePath.endsWith('/')) {
73
+ servePath = servePath.slice(0, -1);
74
+ }
75
+ if (!servePath.startsWith('/')) {
76
+ servePath = `/${servePath}`;
77
+ }
78
+ return servePath;
79
+ }
80
+ /**
81
+ * Find the default server path. We don't want to expose baseHref and deployUrl as arguments, only
82
+ * the browser options where needed.
83
+ */
84
+ function findDefaultServePath(baseHref, deployUrl) {
85
+ if (!baseHref && !deployUrl) {
86
+ return '';
87
+ }
88
+ if (/^(\w+:)?\/\//.test(baseHref || '') ||
89
+ /^(\w+:)?\/\//.test(deployUrl || '')) {
90
+ // If baseHref or deployUrl is absolute, unsupported by ng serve
91
+ return null;
92
+ }
93
+ // normalize baseHref
94
+ // for ng serve the starting base is always `/` so a relative
95
+ // and root relative value are identical
96
+ const baseHrefParts = (baseHref || '')
97
+ .split('/')
98
+ .filter((part) => part !== '');
99
+ if (baseHref && !baseHref.endsWith('/')) {
100
+ baseHrefParts.pop();
101
+ }
102
+ const normalizedBaseHref = baseHrefParts.length === 0 ? '/' : `/${baseHrefParts.join('/')}/`;
103
+ if (deployUrl && deployUrl[0] === '/') {
104
+ if (baseHref && baseHref[0] === '/' && normalizedBaseHref !== deployUrl) {
105
+ // If baseHref and deployUrl are root relative and not equivalent, unsupported by ng serve
106
+ return null;
107
+ }
108
+ return deployUrl;
109
+ }
110
+ // Join together baseHref and deployUrl
111
+ return `${normalizedBaseHref}${deployUrl || ''}`;
112
+ }
113
+ function getServerConfig(options) {
114
+ const { root, devServer: { ssl, sslCert, sslKey }, } = options;
115
+ if (!ssl) {
116
+ return 'http';
117
+ }
118
+ return {
119
+ type: 'https',
120
+ options: sslCert && sslKey
121
+ ? {
122
+ key: (0, node_path_1.resolve)(root, sslKey),
123
+ cert: (0, node_path_1.resolve)(root, sslCert),
124
+ }
125
+ : undefined,
126
+ };
127
+ }
128
+ function getAllowedHostsConfig(allowedHosts, disableHostCheck) {
129
+ if (disableHostCheck || allowedHosts === true) {
130
+ return 'all';
131
+ }
132
+ if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
133
+ return allowedHosts;
134
+ }
135
+ return undefined;
136
+ }
137
+ async function getProxyConfig(root, proxyConfig) {
138
+ if (!proxyConfig) {
139
+ return undefined;
140
+ }
141
+ const proxyPath = (0, node_path_1.resolve)(root, proxyConfig);
142
+ if (!(0, node_fs_1.existsSync)(proxyPath)) {
143
+ throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
144
+ }
145
+ let proxyConfiguration;
146
+ switch ((0, node_path_1.extname)(proxyPath)) {
147
+ case '.json': {
148
+ const content = await node_fs_1.promises.readFile(proxyPath, 'utf-8');
149
+ const { parse, printParseErrorCode } = await Promise.resolve().then(() => tslib_1.__importStar(require('jsonc-parser')));
150
+ const parseErrors = [];
151
+ proxyConfiguration = parse(content, parseErrors, {
152
+ allowTrailingComma: true,
153
+ });
154
+ if (parseErrors.length > 0) {
155
+ let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
156
+ for (const parseError of parseErrors) {
157
+ const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
158
+ errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
159
+ }
160
+ throw new Error(errorMessage);
161
+ }
162
+ break;
163
+ }
164
+ case '.mjs':
165
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
166
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
167
+ // changed to a direct dynamic import.
168
+ proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
169
+ break;
170
+ case '.cjs':
171
+ proxyConfiguration = require(proxyPath);
172
+ break;
173
+ default:
174
+ // The file could be either CommonJS or ESM.
175
+ // CommonJS is tried first then ESM if loading fails.
176
+ try {
177
+ proxyConfiguration = require(proxyPath);
178
+ }
179
+ catch (e) {
180
+ assertIsError(e);
181
+ if (e.code !== 'ERR_REQUIRE_ESM') {
182
+ throw e;
183
+ }
184
+ // Load the ESM configuration file using the TypeScript dynamic import workaround.
185
+ // Once TypeScript provides support for keeping the dynamic import this workaround can be
186
+ // changed to a direct dynamic import.
187
+ proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
188
+ }
189
+ }
190
+ return normalizeProxyConfiguration(proxyConfiguration);
191
+ }
192
+ function getWebSocketSettings(options, servePath) {
193
+ const { hmr, liveReload } = options.devServer;
194
+ if (!hmr && !liveReload) {
195
+ return { client: undefined, webSocketServer: false };
196
+ }
197
+ const webSocketPath = node_path_1.posix.join(servePath, 'ng-cli-ws');
198
+ return {
199
+ webSocketServer: {
200
+ options: { path: webSocketPath },
201
+ },
202
+ client: {
203
+ logging: 'info',
204
+ webSocketURL: getPublicHostOptions(options, webSocketPath),
205
+ overlay: {
206
+ errors: true,
207
+ warnings: false,
208
+ runtimeErrors: false,
209
+ },
210
+ },
211
+ };
212
+ }
213
+ function getPublicHostOptions(options, webSocketPath) {
214
+ let publicHost = options.devServer.publicHost;
215
+ if (publicHost) {
216
+ const hostWithProtocol = !/^\w+:\/\//.test(publicHost)
217
+ ? `https://${publicHost}`
218
+ : publicHost;
219
+ publicHost = new URL(hostWithProtocol).host;
220
+ }
221
+ return `auto://${publicHost || '0.0.0.0:0'}${webSocketPath}`;
222
+ }
223
+ function getJsonErrorLineColumn(offset, content) {
224
+ if (offset === 0) {
225
+ return { line: 1, column: 1 };
226
+ }
227
+ let line = 0;
228
+ let position = 0;
229
+ while (true) {
230
+ ++line;
231
+ const nextNewline = content.indexOf('\n', position);
232
+ if (nextNewline === -1 || nextNewline > offset) {
233
+ break;
234
+ }
235
+ position = nextNewline + 1;
236
+ }
237
+ return { line, column: offset - position + 1 };
238
+ }
239
+ function normalizeProxyConfiguration(proxy) {
240
+ return Array.isArray(proxy)
241
+ ? proxy
242
+ : Object.entries(proxy).map(([context, value]) => ({
243
+ context: [context],
244
+ ...value,
245
+ }));
246
+ }
247
+ function assertIsError(value) {
248
+ const isError = value instanceof Error ||
249
+ // The following is needing to identify errors coming from RxJs.
250
+ (typeof value === 'object' &&
251
+ value &&
252
+ 'name' in value &&
253
+ 'message' in value);
254
+ (0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
255
+ }
@@ -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,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;AAEpE,eAAO,MAAM,YAAY,QAA2B,CAAC;AAErD,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,oCAAoC,EACvD,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,aAAa,CAAC,cAAc,CAAC,CA4D/B"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VENDORS_TEST = void 0;
4
+ exports.getOptimization = getOptimization;
5
+ const core_1 = require("@rspack/core");
6
+ exports.VENDORS_TEST = /[\\/]node_modules[\\/]/;
7
+ function getOptimization(normalizedOptions, platform) {
8
+ return {
9
+ chunkIds: normalizedOptions.namedChunks ? 'named' : 'deterministic',
10
+ emitOnErrors: false,
11
+ moduleIds: 'deterministic',
12
+ runtimeChunk: platform === 'browser' ? 'single' : false,
13
+ minimizer: normalizedOptions.optimization
14
+ ? [
15
+ new core_1.SwcJsMinimizerRspackPlugin({
16
+ minimizerOptions: {
17
+ minify: true,
18
+ ...(platform === 'server'
19
+ ? {
20
+ mangle: {
21
+ reserved: [
22
+ 'renderApplication',
23
+ 'renderModule',
24
+ 'ɵSERVER_CONTEXT',
25
+ 'ɵgetRoutesFromAngularRouterConfig',
26
+ ],
27
+ },
28
+ }
29
+ : {}),
30
+ format: {
31
+ comments: false,
32
+ },
33
+ },
34
+ }),
35
+ new core_1.LightningCssMinimizerRspackPlugin(),
36
+ ]
37
+ : [],
38
+ splitChunks: {
39
+ chunks: platform === 'browser' ? 'all' : 'async',
40
+ minChunks: 1,
41
+ minSize: 20000,
42
+ maxAsyncRequests: 30,
43
+ maxInitialRequests: 30,
44
+ cacheGroups: {
45
+ default: normalizedOptions.commonChunk && {
46
+ chunks: 'async',
47
+ minChunks: 2,
48
+ priority: 10,
49
+ },
50
+ common: normalizedOptions.commonChunk && {
51
+ name: 'common',
52
+ chunks: 'async',
53
+ minChunks: 2,
54
+ enforce: true,
55
+ priority: 5,
56
+ },
57
+ vendors: false,
58
+ defaultVendors: normalizedOptions.vendorChunk && {
59
+ name: 'vendor',
60
+ chunks: (chunk) => chunk.name === 'main',
61
+ enforce: true,
62
+ test: exports.VENDORS_TEST,
63
+ },
64
+ },
65
+ },
66
+ };
67
+ }
@@ -0,0 +1,4 @@
1
+ import { type Configuration } from '@rspack/core';
2
+ import type { I18nOptions, NormalizedAngularRspackPluginOptions } from '../../models';
3
+ export declare function getServerConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, defaultConfig: Configuration): Promise<Configuration>;
4
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/server-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAA4B,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAOtB,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,aAAa,CAAC,CA8ExB"}