@nx/angular-rspack 20.8.2 → 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 (95) 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/platform-server-exports.loader.d.ts +5 -0
  51. package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts.map +1 -0
  52. package/dist/lib/plugins/loaders/platform-server-exports.loader.js +18 -0
  53. package/dist/lib/plugins/ng-rspack.d.ts.map +1 -1
  54. package/dist/lib/plugins/ng-rspack.js +3 -3
  55. package/dist/lib/plugins/prerender-plugin.d.ts +8 -0
  56. package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -0
  57. package/dist/lib/plugins/prerender-plugin.js +154 -0
  58. package/dist/lib/plugins/tools/render-worker.d.ts +31 -0
  59. package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -0
  60. package/dist/lib/plugins/tools/render-worker.js +103 -0
  61. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +21 -0
  62. package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -0
  63. package/dist/lib/plugins/tools/routes-extractor-worker.js +46 -0
  64. package/dist/lib/plugins/tools/worker-pool.d.ts +13 -0
  65. package/dist/lib/plugins/tools/worker-pool.d.ts.map +1 -0
  66. package/dist/lib/plugins/tools/worker-pool.js +26 -0
  67. package/dist/lib/utils/index-file/add-body-script.d.ts +2 -0
  68. package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -0
  69. package/dist/lib/utils/index-file/add-body-script.js +15 -0
  70. package/dist/lib/utils/index-file/get-index-output-file.d.ts +3 -0
  71. package/dist/lib/utils/index-file/get-index-output-file.d.ts.map +1 -0
  72. package/dist/lib/utils/index-file/get-index-output-file.js +10 -0
  73. package/dist/lib/utils/max-workers.d.ts +2 -0
  74. package/dist/lib/utils/max-workers.d.ts.map +1 -0
  75. package/dist/lib/utils/max-workers.js +21 -0
  76. package/dist/lib/utils/postcss-cli-resources.d.ts +22 -0
  77. package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -0
  78. package/dist/lib/utils/postcss-cli-resources.js +158 -0
  79. package/dist/lib/utils/postcss-configuration.d.ts +18 -0
  80. package/dist/lib/utils/postcss-configuration.d.ts.map +1 -0
  81. package/dist/lib/utils/postcss-configuration.js +89 -0
  82. package/package.json +19 -5
  83. package/dist/lib/config/dev-server-config-utils.d.ts +0 -4
  84. package/dist/lib/config/dev-server-config-utils.d.ts.map +0 -1
  85. package/dist/lib/config/dev-server-config-utils.js +0 -107
  86. package/dist/lib/config/entry-points.d.ts.map +0 -1
  87. package/dist/lib/config/helpers.d.ts +0 -14
  88. package/dist/lib/config/helpers.d.ts.map +0 -1
  89. package/dist/lib/config/style-config-utils.d.ts +0 -22
  90. package/dist/lib/config/style-config-utils.d.ts.map +0 -1
  91. package/dist/lib/config/style-config-utils.js +0 -202
  92. package/dist/lib/utils/tailwind.d.ts +0 -2
  93. package/dist/lib/utils/tailwind.d.ts.map +0 -1
  94. package/dist/lib/utils/tailwind.js +0 -31
  95. /package/dist/lib/config/{entry-points.js → config-utils/entry-points.js} +0 -0
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getServerConfig = getServerConfig;
4
+ const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
5
+ const core_1 = require("@rspack/core");
6
+ const path_1 = require("path");
7
+ const ng_rspack_1 = require("../../plugins/ng-rspack");
8
+ const prerender_plugin_1 = require("../../plugins/prerender-plugin");
9
+ const misc_helpers_1 = require("../../utils/misc-helpers");
10
+ const dev_server_config_utils_1 = require("./dev-server-config-utils");
11
+ const optimization_config_1 = require("./optimization-config");
12
+ async function getServerConfig(normalizedOptions, i18n, defaultConfig) {
13
+ const isDevServer = !!process.env['WEBPACK_SERVE'];
14
+ const { root } = normalizedOptions;
15
+ return {
16
+ ...defaultConfig,
17
+ dependencies: ['browser'],
18
+ name: 'server',
19
+ target: 'node',
20
+ entry: {
21
+ server: {
22
+ import: [
23
+ ...((0, misc_helpers_1.isPackageInstalled)(root, '@angular/platform-server')
24
+ ? // This import must come before any imports (direct or transitive) that rely on DOM built-ins being
25
+ // available, such as `@angular/elements`.
26
+ ['@angular/platform-server/init']
27
+ : []),
28
+ ...(i18n.shouldInline ? ['@angular/localize/init'] : []),
29
+ normalizedOptions.ssr.entry,
30
+ ],
31
+ },
32
+ },
33
+ output: {
34
+ ...defaultConfig.output,
35
+ path: normalizedOptions.outputPath.server,
36
+ filename: '[name].js',
37
+ chunkFilename: '[name].js',
38
+ library: { type: 'commonjs' },
39
+ },
40
+ devServer: await (0, dev_server_config_utils_1.getDevServerConfig)(normalizedOptions, 'server'),
41
+ externals: normalizedOptions.externalDependencies,
42
+ optimization: (0, optimization_config_1.getOptimization)(normalizedOptions, 'server'),
43
+ module: {
44
+ ...defaultConfig.module,
45
+ rules: [
46
+ {
47
+ test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
48
+ use: [
49
+ {
50
+ loader: 'builtin:swc-loader',
51
+ options: {
52
+ jsc: {
53
+ parser: {
54
+ syntax: 'typescript',
55
+ },
56
+ target: 'es2022',
57
+ },
58
+ },
59
+ },
60
+ ],
61
+ },
62
+ {
63
+ loader: require.resolve('@nx/angular-rspack/loaders/platform-server-exports-loader'),
64
+ include: [
65
+ (0, path_1.resolve)(root, normalizedOptions.ssr.entry),
66
+ ],
67
+ options: {
68
+ angularSSRInstalled: (0, misc_helpers_1.isPackageInstalled)(root, '@angular/ssr'),
69
+ },
70
+ },
71
+ ...(defaultConfig.module?.rules ?? []),
72
+ ],
73
+ },
74
+ plugins: [
75
+ ...(defaultConfig.plugins ?? []),
76
+ // Fixes Critical dependency: the request of a dependency is an expression
77
+ new core_1.ContextReplacementPlugin(/@?hapi|express[\\/]/),
78
+ new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
79
+ i18nOptions: i18n,
80
+ platform: 'server',
81
+ }),
82
+ ...(normalizedOptions.prerender && !isDevServer
83
+ ? [new prerender_plugin_1.PrerenderPlugin(normalizedOptions, i18n)]
84
+ : []),
85
+ ],
86
+ };
87
+ }
@@ -0,0 +1,7 @@
1
+ import { RspackPluginInstance, RuleSetRule } from '@rspack/core';
2
+ import type { SourceMap } from '../../models';
3
+ export declare function configureSourceMap(sourceMap: SourceMap): {
4
+ sourceMapRules: RuleSetRule[];
5
+ sourceMapPlugins: RspackPluginInstance[];
6
+ };
7
+ //# sourceMappingURL=sourcemap-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourcemap-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/sourcemap-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS;;;EAoDtD"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureSourceMap = configureSourceMap;
4
+ const core_1 = require("@rspack/core");
5
+ const dev_tools_ignore_plugin_1 = require("../../plugins/tools/dev-tools-ignore-plugin");
6
+ function configureSourceMap(sourceMap) {
7
+ const { scripts, styles, hidden, vendor } = sourceMap;
8
+ const sourceMapRules = [];
9
+ const sourceMapPlugins = [];
10
+ if (scripts || styles) {
11
+ const include = [];
12
+ if (scripts) {
13
+ include.push(/js$/);
14
+ }
15
+ if (styles) {
16
+ include.push(/css$/);
17
+ }
18
+ sourceMapPlugins.push(new dev_tools_ignore_plugin_1.DevToolsIgnorePlugin());
19
+ sourceMapPlugins.push(new core_1.SourceMapDevToolPlugin({
20
+ filename: '[file].map',
21
+ include,
22
+ // We want to set sourceRoot to `webpack:///` for non
23
+ // inline sourcemaps as otherwise paths to sourcemaps will be broken in browser
24
+ // `webpack:///` is needed for Visual Studio breakpoints to work properly as currently
25
+ // there is no way to set the 'webRoot'
26
+ sourceRoot: 'webpack:///',
27
+ moduleFilenameTemplate: '[resource-path]',
28
+ append: hidden ? false : undefined,
29
+ }));
30
+ sourceMapRules.push({
31
+ test: /\.[cm]?jsx?$/,
32
+ enforce: 'pre',
33
+ loader: require.resolve('source-map-loader'),
34
+ options: {
35
+ filterSourceMappingUrl: (_mapUri, resourcePath) => {
36
+ if (vendor) {
37
+ // Consume all sourcemaps when vendor option is enabled.
38
+ return true;
39
+ }
40
+ // Don't consume sourcemaps in node_modules when vendor is disabled.
41
+ // But, do consume local libraries sourcemaps.
42
+ return !resourcePath.includes('node_modules');
43
+ },
44
+ },
45
+ });
46
+ }
47
+ return { sourceMapRules, sourceMapPlugins };
48
+ }
@@ -0,0 +1,7 @@
1
+ import { type Plugins, type RuleSetRules } from '@rspack/core';
2
+ import type { HashFormat, NormalizedAngularRspackPluginOptions } from '../../models';
3
+ export declare function getStylesConfig(buildOptions: NormalizedAngularRspackPluginOptions, hashFormat: HashFormat, platform: 'browser' | 'server'): Promise<{
4
+ loaderRules: RuleSetRules;
5
+ plugins: Plugins;
6
+ }>;
7
+ //# sourceMappingURL=style-config-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style-config-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/style-config-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,YAAY,EAElB,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACV,UAAU,EACV,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAStB,wBAAsB,eAAe,CACnC,YAAY,EAAE,oCAAoC,EAClD,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,OAAO,CAAC;IACT,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CA4PD"}
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStylesConfig = getStylesConfig;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const core_1 = require("@rspack/core");
7
+ const node_module_1 = require("node:module");
8
+ const node_path_1 = require("node:path");
9
+ const node_url_1 = require("node:url");
10
+ const postcss_cli_resources_1 = tslib_1.__importDefault(require("../../utils/postcss-cli-resources"));
11
+ const postcss_configuration_1 = require("../../utils/postcss-configuration");
12
+ async function getStylesConfig(buildOptions, hashFormat, platform) {
13
+ const extraPlugins = [];
14
+ const cssSourceMap = buildOptions.sourceMap.styles;
15
+ // use includePaths from appConfig
16
+ const includePaths = buildOptions.stylePreprocessorOptions?.includePaths?.map((p) => (0, node_path_1.resolve)(buildOptions.root, p)) ?? [];
17
+ const assetNameTemplate = assetNameTemplateFactory(hashFormat);
18
+ const extraPostcssPlugins = [];
19
+ // A configuration file can exist in the project or workspace root
20
+ const searchDirectories = await (0, postcss_configuration_1.generateSearchDirectories)([
21
+ buildOptions.root,
22
+ devkit_1.workspaceRoot,
23
+ ]);
24
+ const postcssConfiguration = await (0, postcss_configuration_1.loadPostcssConfiguration)(searchDirectories);
25
+ if (postcssConfiguration) {
26
+ for (const [pluginName, pluginOptions] of postcssConfiguration.plugins) {
27
+ const { default: plugin } = await Promise.resolve(`${pluginName}`).then(s => tslib_1.__importStar(require(s)));
28
+ if (typeof plugin !== 'function' || plugin.postcss !== true) {
29
+ throw new Error(`Attempted to load invalid Postcss plugin: "${pluginName}"`);
30
+ }
31
+ extraPostcssPlugins.push(plugin(pluginOptions));
32
+ }
33
+ }
34
+ else {
35
+ const tailwindConfig = await getTailwindConfig(searchDirectories, devkit_1.workspaceRoot);
36
+ if (tailwindConfig) {
37
+ const tailwind = await Promise.resolve(`${tailwindConfig.package}`).then(s => tslib_1.__importStar(require(s)));
38
+ extraPostcssPlugins.push(tailwind.default({ config: tailwindConfig.file }));
39
+ }
40
+ }
41
+ const autoprefixer = require('autoprefixer');
42
+ const postcssOptionsCreator = (inlineSourcemaps, extracted) => {
43
+ const optionGenerator = (loader) => ({
44
+ map: inlineSourcemaps
45
+ ? {
46
+ inline: true,
47
+ annotation: false,
48
+ }
49
+ : undefined,
50
+ plugins: [
51
+ (0, postcss_cli_resources_1.default)({
52
+ baseHref: buildOptions.baseHref,
53
+ deployUrl: buildOptions.deployUrl,
54
+ resourcesOutputPath: buildOptions.outputPath.media,
55
+ loader,
56
+ filename: assetNameTemplate,
57
+ emitFile: platform !== 'server',
58
+ extracted,
59
+ }),
60
+ ...extraPostcssPlugins,
61
+ autoprefixer({
62
+ ignoreUnknownVersions: true,
63
+ overrideBrowserslist: buildOptions.supportedBrowsers,
64
+ }),
65
+ ],
66
+ });
67
+ // postcss-loader fails when trying to determine configuration files for data URIs
68
+ optionGenerator.config = false;
69
+ return optionGenerator;
70
+ };
71
+ let componentsSourceMap = !!cssSourceMap;
72
+ if (cssSourceMap) {
73
+ // TODO: use below once we support optimization granular options
74
+ // if (buildOptions.optimization.styles.minify) {
75
+ if (buildOptions.optimization) {
76
+ // Never use component css sourcemap when style optimizations are on.
77
+ // It will just increase bundle size without offering good debug experience.
78
+ console.warn('Components styles sourcemaps are not generated when styles optimization is enabled.');
79
+ componentsSourceMap = false;
80
+ }
81
+ else if (buildOptions.sourceMap.hidden) {
82
+ // Inline all sourcemap types except hidden ones, which are the same as no sourcemaps
83
+ // for component css.
84
+ console.warn('Components styles sourcemaps are not generated when sourcemaps are hidden.');
85
+ componentsSourceMap = false;
86
+ }
87
+ }
88
+ // extract global css from js files into own css file.
89
+ extraPlugins.push(new core_1.CssExtractRspackPlugin({ filename: `[name]${hashFormat.extract}.css` }));
90
+ // TODO: add this once we support hmr
91
+ // if (!buildOptions.hmr) {
92
+ // // don't remove `.js` files for `.css` when we are using HMR these contain HMR accept codes.
93
+ // // suppress empty .js files in css only entry points.
94
+ // extraPlugins.push(new SuppressExtractedTextChunksWebpackPlugin());
95
+ // }
96
+ const postCss = require('postcss');
97
+ const postCssLoaderPath = require.resolve('postcss-loader');
98
+ const componentStyleLoaders = [
99
+ {
100
+ loader: require.resolve('css-loader'),
101
+ options: {
102
+ url: false,
103
+ sourceMap: componentsSourceMap,
104
+ importLoaders: 1,
105
+ exportType: 'string',
106
+ esModule: false,
107
+ },
108
+ },
109
+ {
110
+ loader: postCssLoaderPath,
111
+ options: {
112
+ implementation: postCss,
113
+ postcssOptions: postcssOptionsCreator(componentsSourceMap, false),
114
+ },
115
+ },
116
+ ];
117
+ const globalStyleLoaders = [
118
+ {
119
+ loader: core_1.CssExtractRspackPlugin.loader,
120
+ },
121
+ {
122
+ loader: require.resolve('css-loader'),
123
+ options: {
124
+ url: false,
125
+ sourceMap: !!cssSourceMap,
126
+ importLoaders: 1,
127
+ },
128
+ },
129
+ {
130
+ loader: postCssLoaderPath,
131
+ options: {
132
+ implementation: postCss,
133
+ postcssOptions: postcssOptionsCreator(false, true),
134
+ sourceMap: !!cssSourceMap,
135
+ },
136
+ },
137
+ ];
138
+ const styleLanguages = [
139
+ {
140
+ extensions: ['css'],
141
+ use: [],
142
+ },
143
+ {
144
+ extensions: ['scss'],
145
+ use: [
146
+ {
147
+ loader: require.resolve('resolve-url-loader'),
148
+ options: {
149
+ sourceMap: cssSourceMap,
150
+ },
151
+ },
152
+ {
153
+ loader: require.resolve('sass-loader'),
154
+ options: getSassLoaderOptions(devkit_1.workspaceRoot, includePaths, false, !!buildOptions.verbose, !!buildOptions.preserveSymlinks),
155
+ },
156
+ ],
157
+ },
158
+ {
159
+ extensions: ['sass'],
160
+ use: [
161
+ {
162
+ loader: require.resolve('resolve-url-loader'),
163
+ options: {
164
+ sourceMap: cssSourceMap,
165
+ },
166
+ },
167
+ {
168
+ loader: require.resolve('sass-loader'),
169
+ options: getSassLoaderOptions(devkit_1.workspaceRoot, includePaths, true, !!buildOptions.verbose, !!buildOptions.preserveSymlinks),
170
+ },
171
+ ],
172
+ },
173
+ {
174
+ extensions: ['less'],
175
+ use: [
176
+ {
177
+ loader: require.resolve('less-loader'),
178
+ options: {
179
+ sourceMap: cssSourceMap,
180
+ lessOptions: {
181
+ javascriptEnabled: true,
182
+ paths: includePaths,
183
+ },
184
+ },
185
+ },
186
+ ],
187
+ },
188
+ ];
189
+ return {
190
+ loaderRules: styleLanguages.map(({ extensions, use }) => ({
191
+ test: new RegExp(`\\.(?:${extensions.join('|')})$`, 'i'),
192
+ rules: [
193
+ // Setup processing rules for global and component styles
194
+ {
195
+ oneOf: [
196
+ // Global styles are only defined global styles
197
+ {
198
+ use: globalStyleLoaders,
199
+ resourceQuery: /\?ngGlobalStyle/,
200
+ },
201
+ // Component styles are all styles except defined global styles
202
+ {
203
+ use: componentStyleLoaders,
204
+ resourceQuery: /\?ngResource/,
205
+ },
206
+ ],
207
+ },
208
+ { use },
209
+ ],
210
+ })),
211
+ plugins: extraPlugins,
212
+ };
213
+ }
214
+ function assetNameTemplateFactory(hashFormat) {
215
+ const visitedFiles = new Map();
216
+ return (resourcePath) => {
217
+ if (hashFormat.file) {
218
+ // File names are hashed therefore we don't need to handle files with the same file name.
219
+ return `[name]${hashFormat.file}.[ext]`;
220
+ }
221
+ const filename = (0, node_path_1.basename)(resourcePath);
222
+ // Check if the file with the same name has already been processed.
223
+ const visited = visitedFiles.get(filename);
224
+ if (!visited) {
225
+ // Not visited.
226
+ visitedFiles.set(filename, resourcePath);
227
+ return filename;
228
+ }
229
+ else if (visited === resourcePath) {
230
+ // Same file.
231
+ return filename;
232
+ }
233
+ // File has the same name but it's in a different location.
234
+ return '[path][name].[ext]';
235
+ };
236
+ }
237
+ function getSassLoaderOptions(root, includePaths, indentedSyntax, verbose, preserveSymlinks) {
238
+ return {
239
+ api: 'modern-compiler',
240
+ sourceMap: true,
241
+ implementation: require.resolve('sass-embedded'),
242
+ // Webpack importer is only implemented in the legacy API and we have our own custom Webpack importer.
243
+ // See: https://github.com/webpack-contrib/sass-loader/blob/997f3eb41d86dd00d5fa49c395a1aeb41573108c/src/utils.js#L642-L651
244
+ webpackImporter: false,
245
+ sassOptions: (loaderContext) => ({
246
+ importers: [
247
+ getSassResolutionImporter(loaderContext, root, preserveSymlinks),
248
+ ],
249
+ loadPaths: includePaths,
250
+ // Use expanded as otherwise sass will remove comments that are needed for autoprefixer
251
+ // Ex: /* autoprefixer grid: autoplace */
252
+ // See: https://github.com/webpack-contrib/sass-loader/blob/45ad0be17264ceada5f0b4fb87e9357abe85c4ff/src/getSassOptions.js#L68-L70
253
+ style: 'expanded',
254
+ // Silences compiler warnings from 3rd party stylesheets
255
+ quietDeps: !verbose,
256
+ verbose,
257
+ syntax: indentedSyntax ? 'indented' : 'scss',
258
+ sourceMapIncludeSources: true,
259
+ }),
260
+ };
261
+ }
262
+ function getSassResolutionImporter(loaderContext, root, preserveSymlinks) {
263
+ const commonResolverOptions = {
264
+ conditionNames: ['sass', 'style'],
265
+ mainFields: ['sass', 'style', 'main', '...'],
266
+ extensions: ['.scss', '.sass', '.css'],
267
+ restrictions: [/\.((sa|sc|c)ss)$/i],
268
+ preferRelative: true,
269
+ symlinks: !preserveSymlinks,
270
+ };
271
+ // Sass also supports import-only files. If you name a file <name>.import.scss, it will only be loaded for imports, not for @uses.
272
+ // See: https://sass-lang.com/documentation/at-rules/import#import-only-files
273
+ const resolveImport = loaderContext.getResolve({
274
+ byDependency: {
275
+ 'sass-import': {
276
+ ...commonResolverOptions,
277
+ mainFiles: ['_index.import', '_index', 'index.import', 'index', '...'],
278
+ },
279
+ },
280
+ });
281
+ const resolveModule = loaderContext.getResolve({
282
+ byDependency: {
283
+ 'sass-module': {
284
+ ...commonResolverOptions,
285
+ mainFiles: ['_index', 'index', '...'],
286
+ },
287
+ },
288
+ });
289
+ return {
290
+ findFileUrl: async (url, { fromImport, containingUrl }) => {
291
+ if (url.charAt(0) === '.') {
292
+ // Let Sass handle relative imports.
293
+ return null;
294
+ }
295
+ let resolveDir = root;
296
+ if (containingUrl) {
297
+ resolveDir = (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(containingUrl));
298
+ }
299
+ const resolve = fromImport ? resolveImport : resolveModule;
300
+ // Try to resolve from root of workspace
301
+ const result = await tryResolve(resolve, resolveDir, url);
302
+ return result ? (0, node_url_1.pathToFileURL)(result) : null;
303
+ },
304
+ };
305
+ }
306
+ async function tryResolve(resolve, root, url) {
307
+ const promisifiedResolve = (root, url) => new Promise((res, rej) => {
308
+ resolve(root, url, (err, result) => {
309
+ if (err) {
310
+ rej();
311
+ }
312
+ else {
313
+ res(result);
314
+ }
315
+ });
316
+ });
317
+ try {
318
+ return await promisifiedResolve(root, url);
319
+ }
320
+ catch {
321
+ // Try to resolve a partial file
322
+ // @use '@material/button/button' as mdc-button;
323
+ // `@material/button/button` -> `@material/button/_button`
324
+ const lastSlashIndex = url.lastIndexOf('/');
325
+ const underscoreIndex = lastSlashIndex + 1;
326
+ if (underscoreIndex > 0 && url.charAt(underscoreIndex) !== '_') {
327
+ const partialFileUrl = `${url.slice(0, underscoreIndex)}_${url.slice(underscoreIndex)}`;
328
+ return promisifiedResolve(root, partialFileUrl).catch(() => undefined);
329
+ }
330
+ }
331
+ return undefined;
332
+ }
333
+ async function getTailwindConfig(searchDirectories, workspaceRoot) {
334
+ const tailwindConfigurationPath = (0, postcss_configuration_1.findTailwindConfiguration)(searchDirectories);
335
+ if (!tailwindConfigurationPath) {
336
+ return undefined;
337
+ }
338
+ // Create a node resolver from the configuration file
339
+ const resolver = (0, node_module_1.createRequire)(tailwindConfigurationPath);
340
+ try {
341
+ return {
342
+ file: tailwindConfigurationPath,
343
+ package: resolver.resolve('tailwindcss'),
344
+ };
345
+ }
346
+ catch {
347
+ const relativeTailwindConfigPath = (0, node_path_1.relative)(workspaceRoot, tailwindConfigurationPath);
348
+ console.warn(`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
349
+ ` but the 'tailwindcss' package is not installed.` +
350
+ ` To enable Tailwind CSS, please install the 'tailwindcss' package.`);
351
+ }
352
+ return undefined;
353
+ }
@@ -0,0 +1,78 @@
1
+ import type { Configuration } from '@rspack/core';
2
+ import type { AngularRspackPluginOptions } from '../../models';
3
+ export declare function handleConfigurations(defaultOptions: {
4
+ options: AngularRspackPluginOptions;
5
+ rspackConfigOverrides?: Partial<Configuration>;
6
+ }, configurations: Record<string, {
7
+ options: Partial<AngularRspackPluginOptions>;
8
+ rspackConfigOverrides?: Partial<Configuration>;
9
+ }>, configurationModes: string[]): {
10
+ mergedConfigurationBuildOptions: {
11
+ aot?: boolean;
12
+ assets?: import("../../models").AssetElement[];
13
+ baseHref?: string;
14
+ browser?: string;
15
+ commonChunk?: boolean;
16
+ crossOrigin?: "none" | "anonymous" | "use-credentials";
17
+ define?: Record<string, string>;
18
+ deleteOutputPath?: boolean;
19
+ deployUrl?: string;
20
+ devServer?: import("../../models").DevServerOptions;
21
+ externalDependencies?: string[];
22
+ extractLicenses?: boolean;
23
+ fileReplacements?: import("@nx/angular-rspack-compiler").FileReplacement[];
24
+ index?: import("../../models").IndexElement;
25
+ inlineStyleLanguage?: import("@nx/angular-rspack-compiler").InlineStyleLanguage;
26
+ i18nMetadata?: import("../../models").I18nProjectMetadata;
27
+ i18nMissingTranslation?: "warning" | "error" | "ignore";
28
+ i18nDuplicateTranslation?: "warning" | "error" | "ignore";
29
+ localize?: boolean | string[];
30
+ namedChunks?: boolean;
31
+ ngswConfigPath?: string;
32
+ optimization?: boolean | import("../../models").OptimizationOptions;
33
+ outputHashing?: import("../../models").OutputHashing;
34
+ outputPath?: string | (Required<Pick<import("../../models").OutputPath, "base">> & Partial<import("../../models").OutputPath>);
35
+ polyfills?: string[];
36
+ prerender?: boolean | {
37
+ routes?: string[];
38
+ routesFile?: string;
39
+ discoverRoutes?: boolean;
40
+ };
41
+ preserveSymlinks?: boolean;
42
+ root?: string;
43
+ scripts?: import("../../models").ScriptOrStyleEntry[];
44
+ server?: string;
45
+ serviceWorker?: boolean;
46
+ skipTypeChecking?: boolean;
47
+ sourceMap?: boolean | Partial<import("../../models").SourceMap>;
48
+ ssr?: boolean | {
49
+ entry: string;
50
+ experimentalPlatform?: "node" | "neutral";
51
+ };
52
+ stylePreprocessorOptions?: import("@nx/angular-rspack-compiler").StylePreprocessorOptions;
53
+ styles?: import("../../models").ScriptOrStyleEntry[];
54
+ subresourceIntegrity?: boolean;
55
+ tsConfig?: string;
56
+ useTsProjectReferences?: boolean;
57
+ vendorChunk?: boolean;
58
+ webWorkerTsConfig?: string;
59
+ security?: {
60
+ autoCsp?: boolean | {
61
+ unsafeEval?: boolean;
62
+ };
63
+ };
64
+ clearScreen?: boolean;
65
+ verbose?: boolean;
66
+ progress?: boolean;
67
+ watch?: boolean;
68
+ poll?: number;
69
+ statsJson?: boolean;
70
+ budgets?: import("../../models/unsupported-options").BudgetEntry[];
71
+ allowedCommonJsDependencies?: string[];
72
+ appShell?: boolean;
73
+ outputMode?: "static" | "server";
74
+ };
75
+ mergedRspackConfigOverrides: Partial<import("@rspack/core").RspackOptions>;
76
+ };
77
+ export declare function parseConfigurationMode(configurationMode: string): string[];
78
+ //# sourceMappingURL=user-defined-config-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-defined-config-helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/user-defined-config-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE/D,wBAAgB,oBAAoB,CAClC,cAAc,EAAE;IACd,OAAO,EAAE,0BAA0B,CAAC;IACpC,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,EACD,cAAc,EAAE,MAAM,CACpB,MAAM,EACN;IACE,OAAO,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAChD,CACF,EACD,kBAAkB,EAAE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAwBujH,CAAC;sBAA2O,CAAC;0BAA8L,CAAC;;;;;;;;;;;gCAA4gB,CAAC;;;;;;;;;;mBAtBx+I,CAAC;0BACvB,CAAC;;;;;;;;;;;;;;;EAgBhB;AAED,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,YAE/D"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleConfigurations = handleConfigurations;
4
+ exports.parseConfigurationMode = parseConfigurationMode;
5
+ const tslib_1 = require("tslib");
6
+ const webpack_merge_1 = require("webpack-merge");
7
+ const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
8
+ function handleConfigurations(defaultOptions, configurations, configurationModes) {
9
+ let mergedConfigurationBuildOptions = { ...defaultOptions.options };
10
+ let mergedRspackConfigOverrides = defaultOptions.rspackConfigOverrides ?? {};
11
+ for (const configurationName of configurationModes) {
12
+ if (configurationName in configurations) {
13
+ mergedConfigurationBuildOptions = (0, deepmerge_1.default)(mergedConfigurationBuildOptions, configurations[configurationName].options ?? {});
14
+ if (configurations[configurationName].rspackConfigOverrides) {
15
+ mergedRspackConfigOverrides = (0, webpack_merge_1.merge)(mergedRspackConfigOverrides, configurations[configurationName].rspackConfigOverrides);
16
+ }
17
+ }
18
+ }
19
+ return { mergedConfigurationBuildOptions, mergedRspackConfigOverrides };
20
+ }
21
+ function parseConfigurationMode(configurationMode) {
22
+ return configurationMode.split(',').map((m) => m.trim());
23
+ }