@nx/angular 21.0.0-canary.20250206-8bd0bcd → 21.0.0-canary.20250416-caa26a7

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 (76) hide show
  1. package/generators.json +5 -0
  2. package/migrations.json +181 -0
  3. package/ng-package.json +1 -1
  4. package/package.json +11 -9
  5. package/src/builders/dev-server/dev-server.impl.js +2 -3
  6. package/src/builders/dev-server/lib/normalize-options.js +1 -0
  7. package/src/builders/dev-server/schema.d.ts +1 -0
  8. package/src/builders/dev-server/schema.json +8 -3
  9. package/src/builders/webpack-browser/schema.d.ts +3 -1
  10. package/src/builders/webpack-browser/schema.json +5 -0
  11. package/src/builders/webpack-browser/webpack-browser.impl.js +3 -2
  12. package/src/executors/delegate-build/delegate-build.impl.d.ts +1 -3
  13. package/src/executors/delegate-build/delegate-build.impl.js +0 -3
  14. package/src/executors/package/package.impl.js +1 -4
  15. package/src/generators/add-linting/add-linting.js +1 -16
  16. package/src/generators/add-linting/schema.d.ts +1 -0
  17. package/src/generators/application/application.js +14 -1
  18. package/src/generators/application/lib/add-e2e.js +2 -2
  19. package/src/generators/application/lib/add-linting.js +1 -0
  20. package/src/generators/application/lib/add-serve-static-target.js +1 -0
  21. package/src/generators/application/lib/add-unit-test-runner.js +2 -0
  22. package/src/generators/application/lib/create-project.js +1 -0
  23. package/src/generators/application/lib/normalize-options.d.ts +1 -1
  24. package/src/generators/application/lib/normalize-options.js +9 -2
  25. package/src/generators/application/schema.d.ts +2 -2
  26. package/src/generators/application/schema.json +1 -7
  27. package/src/generators/component-test/component-test.js +1 -1
  28. package/src/generators/convert-to-rspack/convert-to-rspack.d.ts +4 -0
  29. package/src/generators/convert-to-rspack/convert-to-rspack.js +319 -0
  30. package/src/generators/convert-to-rspack/lib/create-config.d.ts +2 -0
  31. package/src/generators/convert-to-rspack/lib/create-config.js +48 -0
  32. package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.d.ts +6 -0
  33. package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +75 -0
  34. package/src/generators/convert-to-rspack/lib/update-tsconfig.d.ts +2 -0
  35. package/src/generators/convert-to-rspack/lib/update-tsconfig.js +26 -0
  36. package/src/generators/convert-to-rspack/lib/validate-supported-executor.d.ts +2 -0
  37. package/src/generators/convert-to-rspack/lib/validate-supported-executor.js +14 -0
  38. package/src/generators/convert-to-rspack/schema.d.ts +5 -0
  39. package/src/generators/convert-to-rspack/schema.json +30 -0
  40. package/src/generators/host/host.js +1 -1
  41. package/src/generators/host/schema.d.ts +0 -1
  42. package/src/generators/host/schema.json +0 -6
  43. package/src/generators/library/lib/add-project.d.ts +1 -1
  44. package/src/generators/library/lib/add-project.js +7 -1
  45. package/src/generators/library/lib/normalize-options.js +1 -1
  46. package/src/generators/library/lib/normalized-schema.d.ts +0 -1
  47. package/src/generators/library/library.js +5 -1
  48. package/src/generators/library/schema.d.ts +0 -1
  49. package/src/generators/library/schema.json +0 -6
  50. package/src/generators/ng-add/migrators/projects/e2e.migrator.js +2 -2
  51. package/src/generators/ngrx-feature-store/schema.d.ts +1 -1
  52. package/src/generators/remote/remote.js +1 -1
  53. package/src/generators/remote/schema.d.ts +0 -1
  54. package/src/generators/remote/schema.json +0 -6
  55. package/src/generators/setup-mf/lib/setup-serve-target.js +1 -0
  56. package/src/generators/setup-ssr/files/v19+/application-builder/ngmodule-src/app/__rootModuleFileName__ +2 -2
  57. package/src/generators/setup-ssr/files/v19+/application-builder/server/__serverFileName__ +1 -1
  58. package/src/generators/setup-ssr/files/v19+/application-builder/standalone-src/app/app.config.server.ts__tpl__ +2 -2
  59. package/src/generators/setup-ssr/files/v19+/application-builder-common-engine/server/__serverFileName__ +2 -0
  60. package/src/generators/setup-ssr/lib/generate-files.js +12 -1
  61. package/src/generators/setup-ssr/lib/update-project-config.js +1 -0
  62. package/src/generators/stories/stories.js +2 -2
  63. package/src/generators/utils/add-jest.d.ts +1 -0
  64. package/src/generators/utils/add-jest.js +2 -2
  65. package/src/generators/utils/add-vitest.d.ts +1 -0
  66. package/src/generators/utils/add-vitest.js +1 -1
  67. package/src/generators/utils/ensure-angular-dependencies.js +0 -1
  68. package/src/migrations/update-19-6-0/turn-off-dts-by-default.js +2 -2
  69. package/src/migrations/update-20-5-0/update-angular-cli.d.ts +3 -0
  70. package/src/migrations/update-20-5-0/update-angular-cli.js +23 -0
  71. package/src/migrations/update-21-0-0/set-continuous-option.d.ts +3 -0
  72. package/src/migrations/update-21-0-0/set-continuous-option.js +29 -0
  73. package/src/plugins/plugin.js +2 -0
  74. package/src/utils/backward-compatible-versions.js +2 -0
  75. package/src/utils/versions.d.ts +7 -6
  76. package/src/utils/versions.js +8 -7
@@ -130,12 +130,6 @@
130
130
  "description": "Create an application with stricter type checking and build optimization options.",
131
131
  "default": true
132
132
  },
133
- "standaloneConfig": {
134
- "description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
135
- "type": "boolean",
136
- "default": true,
137
- "x-deprecated": "Nx only supports standaloneConfig"
138
- },
139
133
  "port": {
140
134
  "type": "number",
141
135
  "description": "The port at which the remote application should be served."
@@ -171,7 +165,7 @@
171
165
  "bundler": {
172
166
  "description": "Bundler to use to build the application.",
173
167
  "type": "string",
174
- "enum": ["esbuild", "webpack"],
168
+ "enum": ["esbuild", "rspack", "webpack"],
175
169
  "default": "esbuild",
176
170
  "x-prompt": "Which bundler do you want to use to build the application?",
177
171
  "x-priority": "important"
@@ -6,7 +6,7 @@ const versions_1 = require("../../utils/versions");
6
6
  const storybook_inputs_1 = require("../utils/storybook-ast/storybook-inputs");
7
7
  async function componentTestGenerator(tree, options) {
8
8
  (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
9
- const { assertMinimumCypressVersion } = require('@nx/cypress/src/utils/cypress-version');
9
+ const { assertMinimumCypressVersion } = require('@nx/cypress/src/utils/versions');
10
10
  assertMinimumCypressVersion(10);
11
11
  const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
12
12
  const componentDirPath = (0, devkit_1.joinPathFragments)(root, options.componentDir);
@@ -0,0 +1,4 @@
1
+ import { type Tree, GeneratorCallback } from '@nx/devkit';
2
+ import type { ConvertToRspackSchema } from './schema';
3
+ export declare function convertToRspack(tree: Tree, schema: ConvertToRspackSchema): Promise<GeneratorCallback>;
4
+ export default convertToRspack;
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertToRspack = convertToRspack;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ const create_config_1 = require("./lib/create-config");
7
+ const get_custom_webpack_config_1 = require("./lib/get-custom-webpack-config");
8
+ const update_tsconfig_1 = require("./lib/update-tsconfig");
9
+ const validate_supported_executor_1 = require("./lib/validate-supported-executor");
10
+ const posix_1 = require("path/posix");
11
+ const path_1 = require("path");
12
+ const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
13
+ const enquirer_1 = require("enquirer");
14
+ const SUPPORTED_EXECUTORS = [
15
+ '@angular-devkit/build-angular:browser',
16
+ '@angular-devkit/build-angular:dev-server',
17
+ '@nx/angular:webpack-browser',
18
+ '@nx/angular:dev-server',
19
+ '@nx/angular:module-federation-dev-server',
20
+ ];
21
+ const RENAMED_OPTIONS = {
22
+ main: 'browser',
23
+ ngswConfigPath: 'serviceWorker',
24
+ };
25
+ const REMOVED_OPTIONS = [
26
+ 'publicHost',
27
+ 'disableHostCheck',
28
+ 'resourcesOutputPath',
29
+ 'routesFile',
30
+ 'routes',
31
+ 'discoverRoutes',
32
+ 'appModuleBundle',
33
+ 'inputIndexPath',
34
+ 'outputIndexPath',
35
+ 'buildOptimizer',
36
+ 'deployUrl',
37
+ 'buildTarget',
38
+ 'browserTarget',
39
+ ];
40
+ function normalizeFromProjectRoot(tree, path, projectRoot) {
41
+ if (projectRoot === '.') {
42
+ if (!path.startsWith('./')) {
43
+ return `./${path}`;
44
+ }
45
+ else {
46
+ return path;
47
+ }
48
+ }
49
+ else if (path.startsWith(projectRoot)) {
50
+ return path.replace(projectRoot, '.');
51
+ }
52
+ else if (!path.startsWith('./')) {
53
+ if (tree.exists(path)) {
54
+ const pathWithWorkspaceRoot = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, path);
55
+ const projectRootWithWorkspaceRoot = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, projectRoot);
56
+ return (0, path_1.relative)(projectRootWithWorkspaceRoot, pathWithWorkspaceRoot);
57
+ }
58
+ return `./${path}`;
59
+ }
60
+ return path;
61
+ }
62
+ const defaultNormalizer = (tree, path, root) => normalizeFromProjectRoot(tree, path, root);
63
+ const PATH_NORMALIZER = {
64
+ index: (tree, path, root) => {
65
+ if (typeof path === 'string') {
66
+ return normalizeFromProjectRoot(tree, path, root);
67
+ }
68
+ return {
69
+ input: normalizeFromProjectRoot(tree, path.input, root),
70
+ output: path.output ?? 'index.html',
71
+ };
72
+ },
73
+ indexHtmlTransformer: defaultNormalizer,
74
+ main: defaultNormalizer,
75
+ server: defaultNormalizer,
76
+ tsConfig: defaultNormalizer,
77
+ outputPath: (tree, path, root) => {
78
+ const relativePathFromWorkspaceRoot = (0, path_1.relative)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, root), devkit_1.workspaceRoot);
79
+ return (0, devkit_1.joinPathFragments)(relativePathFromWorkspaceRoot, path);
80
+ },
81
+ proxyConfig: defaultNormalizer,
82
+ polyfills: (tree, paths, root) => {
83
+ const normalizedPaths = [];
84
+ const normalizeFn = (path) => {
85
+ try {
86
+ const resolvedPath = require.resolve(path, {
87
+ paths: [(0, posix_1.join)(devkit_1.workspaceRoot, 'node_modules')],
88
+ });
89
+ normalizedPaths.push(path);
90
+ }
91
+ catch {
92
+ normalizedPaths.push(normalizeFromProjectRoot(tree, path, root));
93
+ }
94
+ };
95
+ if (typeof paths === 'string') {
96
+ normalizeFn(paths);
97
+ }
98
+ else {
99
+ for (const path of paths) {
100
+ normalizeFn(path);
101
+ }
102
+ }
103
+ return normalizedPaths;
104
+ },
105
+ styles: (tree, paths, root) => {
106
+ const normalizedPaths = [];
107
+ for (const path of paths) {
108
+ if (typeof path === 'string') {
109
+ normalizedPaths.push(normalizeFromProjectRoot(tree, path, root));
110
+ }
111
+ else {
112
+ normalizedPaths.push({
113
+ input: normalizeFromProjectRoot(tree, path.input, root),
114
+ bundleName: path.bundleName,
115
+ inject: path.inject ?? true,
116
+ });
117
+ }
118
+ }
119
+ return normalizedPaths;
120
+ },
121
+ scripts: (tree, paths, root) => {
122
+ const normalizedPaths = [];
123
+ for (const path of paths) {
124
+ if (typeof path === 'string') {
125
+ normalizedPaths.push(normalizeFromProjectRoot(tree, path, root));
126
+ }
127
+ else {
128
+ normalizedPaths.push({
129
+ input: normalizeFromProjectRoot(tree, path.input, root),
130
+ bundleName: path.bundleName,
131
+ inject: path.inject ?? true,
132
+ });
133
+ }
134
+ }
135
+ return normalizedPaths;
136
+ },
137
+ assets: (tree, paths, root) => {
138
+ const normalizedPaths = [];
139
+ for (const path of paths) {
140
+ if (typeof path === 'string') {
141
+ normalizedPaths.push(normalizeFromProjectRoot(tree, path, root));
142
+ }
143
+ else {
144
+ normalizedPaths.push({
145
+ ...path,
146
+ input: normalizeFromProjectRoot(tree, path.input, root),
147
+ });
148
+ }
149
+ }
150
+ return normalizedPaths;
151
+ },
152
+ fileReplacements: (tree, paths, root) => {
153
+ const normalizedPaths = [];
154
+ for (const path of paths) {
155
+ normalizedPaths.push({
156
+ replace: normalizeFromProjectRoot(tree, 'src' in path ? path.src : path.replace, root),
157
+ with: normalizeFromProjectRoot(tree, 'replaceWith' in path ? path.replaceWith : path.with, root),
158
+ });
159
+ }
160
+ return normalizedPaths;
161
+ },
162
+ };
163
+ function handleBuildTargetOptions(tree, options, newConfigurationOptions, root) {
164
+ let customWebpackConfigPath;
165
+ if (!options || Object.keys(options).length === 0) {
166
+ return customWebpackConfigPath;
167
+ }
168
+ if (options.customWebpackConfig) {
169
+ customWebpackConfigPath = options.customWebpackConfig.path;
170
+ delete options.customWebpackConfig;
171
+ }
172
+ if (options.outputs) {
173
+ // handled by the Rspack inference plugin
174
+ delete options.outputs;
175
+ }
176
+ for (const [key, value] of Object.entries(options)) {
177
+ let optionName = key;
178
+ let optionValue = key in PATH_NORMALIZER ? PATH_NORMALIZER[key](tree, value, root) : value;
179
+ if (REMOVED_OPTIONS.includes(key)) {
180
+ continue;
181
+ }
182
+ if (key in RENAMED_OPTIONS) {
183
+ optionName = RENAMED_OPTIONS[key];
184
+ }
185
+ newConfigurationOptions[optionName] = optionValue;
186
+ }
187
+ if (typeof newConfigurationOptions.polyfills === 'string') {
188
+ newConfigurationOptions.polyfills = [newConfigurationOptions.polyfills];
189
+ }
190
+ let outputPath = newConfigurationOptions.outputPath;
191
+ if (typeof outputPath === 'string') {
192
+ if (!/\/browser\/?$/.test(outputPath)) {
193
+ console.warn(`The output location of the browser build has been updated from "${outputPath}" to ` +
194
+ `"${(0, posix_1.join)(outputPath, 'browser')}". ` +
195
+ 'You might need to adjust your deployment pipeline or, as an alternative, ' +
196
+ 'set outputPath.browser to "" in order to maintain the previous functionality.');
197
+ }
198
+ else {
199
+ outputPath = outputPath.replace(/\/browser\/?$/, '');
200
+ }
201
+ newConfigurationOptions['outputPath'] = {
202
+ base: outputPath,
203
+ };
204
+ if (typeof newConfigurationOptions.resourcesOutputPath === 'string') {
205
+ const media = newConfigurationOptions.resourcesOutputPath.replaceAll('/', '');
206
+ if (media && media !== 'media') {
207
+ newConfigurationOptions['outputPath'] = {
208
+ base: outputPath,
209
+ media,
210
+ };
211
+ }
212
+ }
213
+ }
214
+ return customWebpackConfigPath;
215
+ }
216
+ function handleDevServerTargetOptions(tree, options, newConfigurationOptions, root) {
217
+ for (const [key, value] of Object.entries(options)) {
218
+ let optionName = key;
219
+ let optionValue = key in PATH_NORMALIZER ? PATH_NORMALIZER[key](tree, value, root) : value;
220
+ if (REMOVED_OPTIONS.includes(key)) {
221
+ continue;
222
+ }
223
+ if (key in RENAMED_OPTIONS) {
224
+ optionName = RENAMED_OPTIONS[key];
225
+ }
226
+ newConfigurationOptions[optionName] = optionValue;
227
+ }
228
+ }
229
+ async function getProjectToConvert(tree) {
230
+ const projects = new Set();
231
+ for (const executor of SUPPORTED_EXECUTORS) {
232
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, executor, (_, project) => {
233
+ projects.add(project);
234
+ });
235
+ }
236
+ const { project } = await (0, enquirer_1.prompt)({
237
+ type: 'select',
238
+ name: 'project',
239
+ message: 'Which project would you like to convert to rspack?',
240
+ choices: Array.from(projects),
241
+ });
242
+ return project;
243
+ }
244
+ async function convertToRspack(tree, schema) {
245
+ let { project: projectName } = schema;
246
+ if (!projectName) {
247
+ projectName = await getProjectToConvert(tree);
248
+ }
249
+ const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
250
+ const tasks = [];
251
+ const createConfigOptions = {
252
+ root: project.root,
253
+ };
254
+ const configurationOptions = {};
255
+ const buildTargetNames = [];
256
+ const serveTargetNames = [];
257
+ let customWebpackConfigPath;
258
+ (0, validate_supported_executor_1.validateSupportedBuildExecutor)(Object.values(project.targets));
259
+ for (const [targetName, target] of Object.entries(project.targets)) {
260
+ if (target.executor === '@angular-devkit/build-angular:browser' ||
261
+ target.executor === '@nx/angular:webpack-browser') {
262
+ customWebpackConfigPath = handleBuildTargetOptions(tree, target.options, createConfigOptions, project.root);
263
+ if (target.configurations) {
264
+ for (const [configurationName, configuration] of Object.entries(target.configurations)) {
265
+ configurationOptions[configurationName] = {};
266
+ handleBuildTargetOptions(tree, configuration, configurationOptions[configurationName], project.root);
267
+ }
268
+ }
269
+ buildTargetNames.push(targetName);
270
+ }
271
+ else if (target.executor === '@angular-devkit/build-angular:dev-server' ||
272
+ target.executor === '@nx/angular:dev-server' ||
273
+ target.executor === '@nx/angular:module-federation-dev-server') {
274
+ createConfigOptions.devServer = {};
275
+ if (target.options) {
276
+ handleDevServerTargetOptions(tree, target.options, createConfigOptions.devServer, project.root);
277
+ }
278
+ if (target.configurations) {
279
+ for (const [configurationName, configuration] of Object.entries(target.configurations)) {
280
+ configurationOptions[configurationName] ??= {};
281
+ configurationOptions[configurationName].devServer ??= {};
282
+ handleDevServerTargetOptions(tree, configuration, configurationOptions[configurationName].devServer, project.root);
283
+ }
284
+ }
285
+ serveTargetNames.push(targetName);
286
+ }
287
+ }
288
+ const customWebpackConfigInfo = customWebpackConfigPath
289
+ ? await (0, get_custom_webpack_config_1.getCustomWebpackConfig)(tree, project.root, customWebpackConfigPath)
290
+ : undefined;
291
+ (0, create_config_1.createConfig)(tree, createConfigOptions, configurationOptions, customWebpackConfigInfo?.normalizedPathToCustomWebpackConfig, customWebpackConfigInfo?.isWebpackConfigFunction);
292
+ (0, update_tsconfig_1.updateTsconfig)(tree, project.root);
293
+ for (const targetName of [...buildTargetNames, ...serveTargetNames]) {
294
+ delete project.targets[targetName];
295
+ }
296
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
297
+ const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
298
+ await rspackInitGenerator(tree, {
299
+ addPlugin: true,
300
+ });
301
+ // This is needed to prevent a circular execution of the build target
302
+ const rootPkgJson = (0, devkit_1.readJson)(tree, 'package.json');
303
+ if (rootPkgJson.scripts?.build === 'nx build') {
304
+ delete rootPkgJson.scripts.build;
305
+ (0, devkit_1.writeJson)(tree, 'package.json', rootPkgJson);
306
+ }
307
+ if (!schema.skipInstall) {
308
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
309
+ '@nx/angular-rspack': versions_1.angularRspackVersion,
310
+ 'ts-node': versions_1.tsNodeVersion,
311
+ });
312
+ tasks.push(installTask);
313
+ }
314
+ if (!schema.skipFormat) {
315
+ await (0, devkit_1.formatFiles)(tree);
316
+ }
317
+ return (0, devkit_1.runTasksInSerial)(...tasks);
318
+ }
319
+ exports.default = convertToRspack;
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function createConfig(tree: Tree, opts: Record<string, any>, configurationOptions?: Record<string, Record<string, any>>, existingWebpackConfigPath?: string, isExistingWebpackConfigFunction?: boolean): void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createConfig = createConfig;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function createConfig(tree, opts, configurationOptions = {}, existingWebpackConfigPath, isExistingWebpackConfigFunction) {
6
+ const { root, ...createConfigOptions } = opts;
7
+ const hasConfigurations = Object.keys(configurationOptions).length > 0;
8
+ const expandedConfigurationOptions = hasConfigurations
9
+ ? Object.entries(configurationOptions)
10
+ .map(([configurationName, configurationOptions]) => {
11
+ return `
12
+ ${configurationName}: {
13
+ options: {
14
+ ${JSON.stringify(configurationOptions, undefined, 2).slice(1, -1)}
15
+ }
16
+ }`;
17
+ })
18
+ .join(',\n')
19
+ : '';
20
+ const configContents = `
21
+ import { createConfig }from '@nx/angular-rspack';
22
+ ${existingWebpackConfigPath
23
+ ? `import baseWebpackConfig from '${existingWebpackConfigPath}';
24
+ ${isExistingWebpackConfigFunction
25
+ ? ''
26
+ : `import webpackMerge from 'webpack-merge';`}`
27
+ : ''}
28
+
29
+ ${existingWebpackConfigPath ? 'const baseConfig = ' : 'export default '}createConfig({
30
+ options: {
31
+ root: __dirname,
32
+ ${JSON.stringify(createConfigOptions, undefined, 2).slice(1, -1)}
33
+ }
34
+ }${hasConfigurations ? `, {${expandedConfigurationOptions}}` : ''});
35
+ ${existingWebpackConfigPath
36
+ ? `
37
+ export default ${isExistingWebpackConfigFunction
38
+ ? `async function (env, argv) {
39
+ const oldConfig = await baseWebpackConfig;
40
+ const browserConfig = baseConfig[0];
41
+ return oldConfig(browserConfig);
42
+ }`
43
+ : 'webpackMerge(baseConfig[0], baseWebpackConfig);'}
44
+ `
45
+ : ''}
46
+ `;
47
+ tree.write((0, devkit_1.joinPathFragments)(root, 'rspack.config.ts'), configContents);
48
+ }
@@ -0,0 +1,6 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function getCustomWebpackConfig(tree: Tree, projectRoot: string, pathToCustomWebpackConfig: string): Promise<{
3
+ isWebpackConfigFunction: boolean;
4
+ normalizedPathToCustomWebpackConfig: string;
5
+ }>;
6
+ export declare function convertWebpackConfigToUseNxModuleFederationPlugin(webpackConfigContents: string): string;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomWebpackConfig = getCustomWebpackConfig;
4
+ exports.convertWebpackConfigToUseNxModuleFederationPlugin = convertWebpackConfigToUseNxModuleFederationPlugin;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
7
+ const path_1 = require("path");
8
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
9
+ const FILE_EXTENSION_REGEX = /\.[^.]+$/;
10
+ async function getCustomWebpackConfig(tree, projectRoot, pathToCustomWebpackConfig) {
11
+ const webpackConfigContents = tree.read(pathToCustomWebpackConfig, 'utf-8');
12
+ if (webpackConfigContents.includes('@nx/module-federation/angular') &&
13
+ webpackConfigContents.includes('withModuleFederation')) {
14
+ tree.write(pathToCustomWebpackConfig, convertWebpackConfigToUseNxModuleFederationPlugin(webpackConfigContents));
15
+ return {
16
+ isWebpackConfigFunction: false,
17
+ normalizedPathToCustomWebpackConfig: `./${(0, path_1.relative)(projectRoot, pathToCustomWebpackConfig).replace(FILE_EXTENSION_REGEX, '')}`,
18
+ };
19
+ }
20
+ const configFile = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(tree.root, pathToCustomWebpackConfig));
21
+ const webpackConfig = 'default' in configFile ? configFile.default : configFile;
22
+ return {
23
+ isWebpackConfigFunction: typeof webpackConfig === 'function',
24
+ normalizedPathToCustomWebpackConfig: `./${(0, path_1.relative)(projectRoot, pathToCustomWebpackConfig).replace(FILE_EXTENSION_REGEX, '')}`,
25
+ };
26
+ }
27
+ function convertWebpackConfigToUseNxModuleFederationPlugin(webpackConfigContents) {
28
+ let newWebpackConfigContents = webpackConfigContents;
29
+ let ast = tsquery_1.tsquery.ast(webpackConfigContents);
30
+ const withModuleFederationImportNodes = (0, tsquery_1.tsquery)(ast, 'ImportDeclaration:has(StringLiteral[value=@nx/module-federation/angular])');
31
+ if (withModuleFederationImportNodes.length > 0) {
32
+ const withModuleFederationImportNode = withModuleFederationImportNodes[0];
33
+ newWebpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationImportNode.getStart())}import { NxModuleFederationPlugin } from '@nx/module-federation/rspack';${webpackConfigContents.slice(withModuleFederationImportNode.getEnd())}`;
34
+ ast = tsquery_1.tsquery.ast(newWebpackConfigContents);
35
+ const exportedWithModuleFederationNodes = (0, tsquery_1.tsquery)(ast, 'ExportAssignment:has(CallExpression > Identifier[name=withModuleFederation])');
36
+ if (exportedWithModuleFederationNodes.length > 0) {
37
+ const exportedWithModuleFederationNode = exportedWithModuleFederationNodes[0];
38
+ newWebpackConfigContents = `${newWebpackConfigContents.slice(0, exportedWithModuleFederationNode.getStart())}${newWebpackConfigContents.slice(exportedWithModuleFederationNode.getEnd())}
39
+ export default {
40
+ plugins: [
41
+ new NxModuleFederationPlugin(config, {
42
+ dts: false,
43
+ }),
44
+ ]
45
+ }
46
+ `;
47
+ }
48
+ else {
49
+ devkit_1.logger.warn("Could not find 'export default withModuleFederation' in the webpack config file. Skipping conversion.");
50
+ }
51
+ }
52
+ const withModuleFederationRequireNodes = (0, tsquery_1.tsquery)(ast, 'VariableStatement:has(CallExpression > Identifier[name=withModuleFederation], StringLiteral[value=@nx/module-federation/angular])');
53
+ if (withModuleFederationRequireNodes.length > 0) {
54
+ const withModuleFederationRequireNode = withModuleFederationRequireNodes[0];
55
+ newWebpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationRequireNode.getStart())}const { NxModuleFederationPlugin } = require('@nx/module-federation/rspack');${webpackConfigContents.slice(withModuleFederationRequireNode.getEnd())}`;
56
+ ast = tsquery_1.tsquery.ast(newWebpackConfigContents);
57
+ const exportedWithModuleFederationNodes = (0, tsquery_1.tsquery)(ast, 'ExpressionStatement:has(BinaryExpression > PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports]), CallExpression:has(Identifier[name=withModuleFederation]))');
58
+ if (exportedWithModuleFederationNodes.length > 0) {
59
+ const exportedWithModuleFederationNode = exportedWithModuleFederationNodes[0];
60
+ newWebpackConfigContents = `${newWebpackConfigContents.slice(0, exportedWithModuleFederationNode.getStart())}${newWebpackConfigContents.slice(exportedWithModuleFederationNode.getEnd())}
61
+ module.exports = {
62
+ plugins: [
63
+ new NxModuleFederationPlugin({ config }, {
64
+ dts: false,
65
+ }),
66
+ ]
67
+ }
68
+ `;
69
+ }
70
+ else {
71
+ devkit_1.logger.warn("Could not find 'module.exports = withModuleFederation' in the webpack config file. Skipping conversion.");
72
+ }
73
+ }
74
+ return newWebpackConfigContents;
75
+ }
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function updateTsconfig(tree: Tree, projectRoot: string): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTsconfig = updateTsconfig;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const js_1 = require("@nx/js");
6
+ function updateTsconfig(tree, projectRoot) {
7
+ const tsconfigPath = (0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.json');
8
+ const tsconfig = (0, devkit_1.readJson)(tree, tsconfigPath);
9
+ tsconfig['ts-node'] ??= {};
10
+ tsconfig['ts-node'].compilerOptions ??= {};
11
+ tsconfig['ts-node'].compilerOptions.module = 'CommonJS';
12
+ tsconfig['ts-node'].compilerOptions.moduleResolution = 'Node10';
13
+ if (tsconfig.compilerOptions?.customConditions) {
14
+ tsconfig['ts-node'].compilerOptions.customConditions = null;
15
+ }
16
+ else {
17
+ const rootTsconfigFile = (0, js_1.getRootTsConfigFileName)(tree);
18
+ if (rootTsconfigFile) {
19
+ const rootTsconfigJson = (0, devkit_1.readJson)(tree, rootTsconfigFile);
20
+ if (rootTsconfigJson.compilerOptions?.customConditions) {
21
+ tsconfig['ts-node'].compilerOptions.customConditions = null;
22
+ }
23
+ }
24
+ }
25
+ (0, devkit_1.writeJson)(tree, tsconfigPath, tsconfig);
26
+ }
@@ -0,0 +1,2 @@
1
+ import { TargetConfiguration } from '@nx/devkit';
2
+ export declare function validateSupportedBuildExecutor(targets: TargetConfiguration[]): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSupportedBuildExecutor = validateSupportedBuildExecutor;
4
+ const SUPPORTED_BUILD_EXECUTORS = [
5
+ '@angular-devkit/build-angular:browser',
6
+ '@nx/angular:webpack-browser',
7
+ ];
8
+ function validateSupportedBuildExecutor(targets) {
9
+ const executorsUsedByProject = targets.map((target) => target.executor);
10
+ if (!executorsUsedByProject.some((executor) => SUPPORTED_BUILD_EXECUTORS.includes(executor))) {
11
+ throw new Error('The project does not use a supported build executor. Please use one of the following executors: ' +
12
+ SUPPORTED_BUILD_EXECUTORS.join(', '));
13
+ }
14
+ }
@@ -0,0 +1,5 @@
1
+ export interface ConvertToRspackSchema {
2
+ project: string;
3
+ skipFormat?: boolean;
4
+ skipInstall?: boolean;
5
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "GeneratorNxApp",
4
+ "title": "Creates an Angular application.",
5
+ "description": "Creates an Angular application.",
6
+ "type": "object",
7
+ "cli": "nx",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "aliases": ["name", "projectName"],
12
+ "description": "Project for which to convert to rspack.",
13
+ "$default": {
14
+ "$source": "argv",
15
+ "index": 0
16
+ },
17
+ "x-priority": "important"
18
+ },
19
+ "skipFormat": {
20
+ "description": "Skip formatting files.",
21
+ "type": "boolean",
22
+ "default": false
23
+ },
24
+ "skipInstall": {
25
+ "description": "Skip installing dependencies.",
26
+ "type": "boolean",
27
+ "default": false
28
+ }
29
+ }
30
+ }
@@ -39,7 +39,7 @@ async function host(tree, schema) {
39
39
  }
40
40
  });
41
41
  }
42
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'application');
42
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
43
43
  const { projectName: hostProjectName, projectRoot: appRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
44
44
  name: options.name,
45
45
  projectType: 'application',
@@ -20,7 +20,6 @@ export interface Schema {
20
20
  e2eTestRunner?: E2eTestRunner;
21
21
  backendProject?: string;
22
22
  strict?: boolean;
23
- standaloneConfig?: boolean;
24
23
  inlineStyle?: boolean;
25
24
  inlineTemplate?: boolean;
26
25
  viewEncapsulation?: 'Emulated' | 'Native' | 'None';
@@ -144,12 +144,6 @@
144
144
  "description": "Create an application with stricter type checking and build optimization options.",
145
145
  "default": true
146
146
  },
147
- "standaloneConfig": {
148
- "description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
149
- "type": "boolean",
150
- "default": true,
151
- "x-deprecated": "Nx only supports standaloneConfig"
152
- },
153
147
  "setParserOptionsProject": {
154
148
  "type": "boolean",
155
149
  "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
@@ -1,4 +1,4 @@
1
1
  import type { Tree } from '@nx/devkit';
2
2
  import type { AngularProjectConfiguration } from '../../../utils/types';
3
3
  import type { NormalizedSchema } from './normalized-schema';
4
- export declare function addProject(tree: Tree, libraryOptions: NormalizedSchema['libraryOptions']): AngularProjectConfiguration;
4
+ export declare function addProject(tree: Tree, libraryOptions: NormalizedSchema['libraryOptions']): Promise<AngularProjectConfiguration>;
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = addProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
6
- function addProject(tree, libraryOptions) {
6
+ const add_release_config_1 = require("@nx/js/src/generators/library/utils/add-release-config");
7
+ const use_legacy_versioning_1 = require("nx/src/command-line/release/config/use-legacy-versioning");
8
+ async function addProject(tree, libraryOptions) {
7
9
  const project = {
8
10
  name: libraryOptions.name,
9
11
  root: libraryOptions.projectRoot,
@@ -34,6 +36,10 @@ function addProject(tree, libraryOptions) {
34
36
  },
35
37
  defaultConfiguration: 'production',
36
38
  };
39
+ if (libraryOptions.publishable) {
40
+ const nxJson = (0, devkit_1.readJson)(tree, 'nx.json');
41
+ await (0, add_release_config_1.addReleaseConfigForNonTsSolution)((0, use_legacy_versioning_1.shouldUseLegacyVersioning)(nxJson.release), tree, libraryOptions.name, project);
42
+ }
37
43
  }
38
44
  (0, devkit_1.addProjectConfiguration)(tree, libraryOptions.name, project);
39
45
  return project;
@@ -22,7 +22,7 @@ async function normalizeOptions(host, schema) {
22
22
  skipModule: schema.skipModule || schema.standalone,
23
23
  ...schema,
24
24
  };
25
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
25
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
26
26
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
27
27
  name: options.name,
28
28
  projectType: 'library',