@nx/angular 0.0.0-pr-3-8473941 → 0.0.0-pr-29860-74361a9

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.
package/generators.json CHANGED
@@ -38,6 +38,11 @@
38
38
  "schema": "./src/generators/convert-to-application-executor/schema.json",
39
39
  "description": "Converts projects to use the `@nx/angular:application` executor or the `@angular-devkit/build-angular:application` builder."
40
40
  },
41
+ "convert-to-rspack": {
42
+ "factory": "./src/generators/convert-to-rspack/convert-to-rspack",
43
+ "schema": "./src/generators/convert-to-rspack/schema.json",
44
+ "description": "Converts Angular Webpack projects to use Rspack."
45
+ },
41
46
  "directive": {
42
47
  "factory": "./src/generators/directive/directive",
43
48
  "schema": "./src/generators/directive/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "0.0.0-pr-3-8473941",
3
+ "version": "0.0.0-pr-29860-74361a9",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -71,13 +71,14 @@
71
71
  "semver": "^7.5.3",
72
72
  "tslib": "^2.3.0",
73
73
  "webpack-merge": "^5.8.0",
74
- "@nx/devkit": "0.0.0-pr-3-8473941",
75
- "@nx/js": "0.0.0-pr-3-8473941",
76
- "@nx/eslint": "0.0.0-pr-3-8473941",
77
- "@nx/webpack": "0.0.0-pr-3-8473941",
78
- "@nx/module-federation": "0.0.0-pr-3-8473941",
79
- "@nx/web": "0.0.0-pr-3-8473941",
80
- "@nx/workspace": "0.0.0-pr-3-8473941",
74
+ "@nx/devkit": "0.0.0-pr-29860-74361a9",
75
+ "@nx/js": "0.0.0-pr-29860-74361a9",
76
+ "@nx/eslint": "0.0.0-pr-29860-74361a9",
77
+ "@nx/webpack": "0.0.0-pr-29860-74361a9",
78
+ "@nx/rspack": "0.0.0-pr-29860-74361a9",
79
+ "@nx/module-federation": "0.0.0-pr-29860-74361a9",
80
+ "@nx/web": "0.0.0-pr-29860-74361a9",
81
+ "@nx/workspace": "0.0.0-pr-29860-74361a9",
81
82
  "piscina": "^4.4.0"
82
83
  },
83
84
  "peerDependencies": {
@@ -120,7 +120,7 @@ function executeDevServerBuilder(rawOptions, context) {
120
120
  if (workspaceDependencies.length > 0) {
121
121
  baseWebpackConfig.plugins.push(
122
122
  // @ts-expect-error - difference between angular and webpack plugin definitions bc of webpack versions
123
- new webpack_nx_build_coordination_plugin_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${parsedBuildTarget.target} --projects=${workspaceDependencies.join(',')}`));
123
+ new webpack_nx_build_coordination_plugin_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${parsedBuildTarget.target} --projects=${workspaceDependencies.join(',')}`, { skipWatchingDeps: !options.watchDependencies }));
124
124
  }
125
125
  }
126
126
  if (!pathToWebpackConfig) {
@@ -151,6 +151,7 @@ function getDelegateBuilderOptions(options) {
151
151
  }
152
152
  // delete extra option not supported by the delegate builder
153
153
  delete delegateBuilderOptions.buildLibsFromSource;
154
+ delete delegateBuilderOptions.watchDependencies;
154
155
  return delegateBuilderOptions;
155
156
  }
156
157
  async function loadIndexHtmlFileTransformer(pathToIndexFileTransformer, tsConfig, context, isUsingWebpackBuilder) {
@@ -18,5 +18,6 @@ function normalizeOptions(schema) {
18
18
  hmr: schema.hmr ?? (angularMajorVersion < 19 ? false : undefined),
19
19
  open: schema.open ?? false,
20
20
  ssl: schema.ssl ?? false,
21
+ watchDependencies: schema.watchDependencies ?? true,
21
22
  };
22
23
  }
@@ -21,6 +21,7 @@ interface BaseSchema {
21
21
  prebundle?: boolean | { exclude: string[] };
22
22
  buildLibsFromSource?: boolean;
23
23
  esbuildMiddleware?: string[];
24
+ watchDependencies?: boolean;
24
25
  }
25
26
 
26
27
  export type SchemaWithBrowserTarget = BaseSchema & {
@@ -156,6 +156,11 @@
156
156
  "type": "string",
157
157
  "description": "The path to the middleware function. Relative to the workspace root."
158
158
  }
159
+ },
160
+ "watchDependencies": {
161
+ "type": "boolean",
162
+ "description": "Watch buildable dependencies and rebuild when they change.",
163
+ "default": true
159
164
  }
160
165
  },
161
166
  "additionalProperties": false,
@@ -6,8 +6,10 @@ export type BrowserBuilderSchema = Schema & {
6
6
  };
7
7
  indexHtmlTransformer?: string;
8
8
  buildLibsFromSource?: boolean;
9
+ watchDependencies?: boolean;
10
+
9
11
  /**
10
- * @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 20.
12
+ * @deprecated Use `indexHtmlTransformer` instead. It will be removed in Nx 21.
11
13
  */
12
14
  indexFileTransformer?: string;
13
15
  };
@@ -464,6 +464,11 @@
464
464
  "type": "boolean",
465
465
  "description": "Read buildable libraries from source instead of building them separately.",
466
466
  "default": true
467
+ },
468
+ "watchDependencies": {
469
+ "type": "boolean",
470
+ "description": "Watch buildable dependencies and rebuild when they change.",
471
+ "default": true
467
472
  }
468
473
  },
469
474
  "additionalProperties": false,
@@ -25,7 +25,8 @@ function shouldSkipInitialTargetRun(projectGraph, project, target) {
25
25
  }
26
26
  function executeWebpackBrowserBuilder(options, context) {
27
27
  options.buildLibsFromSource ??= true;
28
- const { buildLibsFromSource, customWebpackConfig, indexHtmlTransformer, indexFileTransformer, ...delegateBuilderOptions } = options;
28
+ options.watchDependencies ??= true;
29
+ const { buildLibsFromSource, customWebpackConfig, indexHtmlTransformer, indexFileTransformer, watchDependencies, ...delegateBuilderOptions } = options;
29
30
  process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildLibsFromSource}`;
30
31
  process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({ ...context.target });
31
32
  const pathToWebpackConfig = customWebpackConfig?.path &&
@@ -61,7 +62,7 @@ function executeWebpackBrowserBuilder(options, context) {
61
62
  const skipInitialRun = shouldSkipInitialTargetRun(projectGraph, context.target.project, context.target.target);
62
63
  baseWebpackConfig.plugins.push(
63
64
  // @ts-expect-error - difference between angular and webpack plugin definitions bc of webpack versions
64
- new webpack_nx_build_coordination_plugin_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${context.target.target} --projects=${workspaceDependencies.join(',')}`, skipInitialRun));
65
+ new webpack_nx_build_coordination_plugin_1.WebpackNxBuildCoordinationPlugin(`nx run-many --target=${context.target.target} --projects=${workspaceDependencies.join(',')}`, { skipInitialRun, skipWatchingDeps: !watchDependencies }));
65
66
  }
66
67
  }
67
68
  if (!pathToWebpackConfig) {
@@ -61,21 +61,6 @@ async function addLintingGenerator(tree, options) {
61
61
  files: ['*.html'],
62
62
  rules: {},
63
63
  });
64
- if ((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)) {
65
- (0, eslint_file_1.addOverrideToLintConfig)(tree, '', {
66
- files: ['*.json'],
67
- parser: 'jsonc-eslint-parser',
68
- rules: {
69
- '@nx/dependency-checks': [
70
- 'error',
71
- {
72
- // With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
73
- ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
74
- },
75
- ],
76
- },
77
- });
78
- }
79
64
  }
80
65
  else {
81
66
  (0, eslint_file_1.replaceOverridesInLintConfig)(tree, options.projectRoot, [
@@ -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,72 @@
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
+ async function convertToRspack(tree, schema) {
9
+ const { project: projectName } = schema;
10
+ const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
11
+ const tasks = [];
12
+ const createConfigOptions = {
13
+ root: project.root,
14
+ };
15
+ const buildAndServeTargetNames = [];
16
+ let customWebpackConfigPath;
17
+ for (const [targetName, target] of Object.entries(project.targets)) {
18
+ if (target.executor === '@angular-devkit/build-angular:browser' ||
19
+ target.executor === '@nx/angular:webpack-browser') {
20
+ createConfigOptions.browser = target.options.main;
21
+ createConfigOptions.index = target.options.index;
22
+ createConfigOptions.assets = target.options.assets.map((asset) => {
23
+ if (typeof asset === 'string') {
24
+ return asset;
25
+ }
26
+ return asset.input;
27
+ });
28
+ createConfigOptions.styles = target.options.styles;
29
+ createConfigOptions.scripts = target.options.scripts;
30
+ createConfigOptions.polyfills = target.options.polyfills;
31
+ createConfigOptions.tsconfigPath = target.options.tsConfig;
32
+ createConfigOptions.jit =
33
+ target.options.aot === undefined ? false : !target.options.aot;
34
+ createConfigOptions.inlineStylesExtension =
35
+ target.options.inlineStyleLanguage === undefined
36
+ ? 'css'
37
+ : target.options.inlineStyleLanguage;
38
+ if (target.options.customWebpackConfig) {
39
+ customWebpackConfigPath = target.options.customWebpackConfig.path;
40
+ }
41
+ // TODO: Add more options that can be correctly mapped
42
+ buildAndServeTargetNames.push(targetName);
43
+ }
44
+ else if (target.executor === '@angular-devkit/build-angular:dev-server' ||
45
+ target.executor === '@nx/angular:dev-server') {
46
+ buildAndServeTargetNames.push(targetName);
47
+ }
48
+ }
49
+ const customWebpackConfigInfo = customWebpackConfigPath
50
+ ? await (0, get_custom_webpack_config_1.getCustomWebpackConfig)(tree, project.root, customWebpackConfigPath)
51
+ : undefined;
52
+ (0, create_config_1.createConfig)(tree, createConfigOptions, customWebpackConfigInfo?.normalizedPathToCustomWebpackConfig, customWebpackConfigInfo?.isWebpackConfigFunction);
53
+ for (const targetName of buildAndServeTargetNames) {
54
+ delete project.targets[targetName];
55
+ }
56
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
57
+ const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
58
+ await rspackInitGenerator(tree, {
59
+ addPlugin: true,
60
+ });
61
+ if (!schema.skipInstall) {
62
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
63
+ '@ng-rspack/build': versions_1.ngRspackVersion,
64
+ });
65
+ tasks.push(installTask);
66
+ }
67
+ if (!schema.skipFormat) {
68
+ await (0, devkit_1.formatFiles)(tree);
69
+ }
70
+ return (0, devkit_1.runTasksInSerial)(...tasks);
71
+ }
72
+ exports.default = convertToRspack;
@@ -0,0 +1,17 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export interface CreateConfigOptions {
3
+ root: string;
4
+ index: string;
5
+ browser: string;
6
+ server?: string;
7
+ ssrEntry?: string;
8
+ polyfills: string[];
9
+ tsconfigPath: string;
10
+ assets: string[];
11
+ styles: string[];
12
+ scripts: string[];
13
+ jit?: boolean;
14
+ inlineStylesExtension?: string;
15
+ fileReplacements?: string[];
16
+ }
17
+ export declare function createConfig(tree: Tree, opts: Partial<CreateConfigOptions>, existingWebpackConfigPath?: string, isExistingWebpackConfigFunction?: boolean): void;
@@ -0,0 +1,63 @@
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, existingWebpackConfigPath, isExistingWebpackConfigFunction) {
6
+ const configContents = `const { createConfig } = require('@ng-rspack/build');
7
+ ${existingWebpackConfigPath
8
+ ? `const baseWebpackConfig = require('${existingWebpackConfigPath}');
9
+ ${isExistingWebpackConfigFunction
10
+ ? ''
11
+ : `const webpackMerge = require('webpack-merge');`}`
12
+ : ''}
13
+
14
+ ${existingWebpackConfigPath ? 'const baseConfig' : 'module.exports'} = createConfig({
15
+ root: __dirname,
16
+ index: '${normalizeFromProjectRoot(opts.index, opts.root)}',
17
+ browser: '${normalizeFromProjectRoot(opts.browser, opts.root)}',
18
+ ${opts.server
19
+ ? `server: '${normalizeFromProjectRoot(opts.server, opts.root)}',`
20
+ : ''}
21
+ ${opts.ssrEntry
22
+ ? `ssrEntry: '${normalizeFromProjectRoot(opts.ssrEntry, opts.root)}',`
23
+ : ''}
24
+ tsconfigPath: '${normalizeFromProjectRoot(opts.tsconfigPath, opts.root)}',
25
+ polyfills: ${JSON.stringify(opts.polyfills)},
26
+ assets: ${JSON.stringify(opts.assets.map((a) => normalizeFromProjectRoot(a, opts.root)))},
27
+ styles: ${JSON.stringify(opts.styles.map((s) => normalizeFromProjectRoot(s, opts.root)))},
28
+ scripts: ${JSON.stringify(opts.scripts.map((s) => normalizeFromProjectRoot(s, opts.root)))},
29
+ jit: ${opts.jit},
30
+ ${opts.inlineStylesExtension
31
+ ? `inlineStylesExtension: '${opts.inlineStylesExtension}'`
32
+ : ''},
33
+ fileReplacements: ${JSON.stringify(opts.fileReplacements ?? [])},
34
+ hasServer: ${opts.server || opts.ssrEntry ? true : false},
35
+ skipTypeChecking: false,
36
+ });
37
+ ${existingWebpackConfigPath
38
+ ? `
39
+ module.exports = ${isExistingWebpackConfigFunction
40
+ ? 'baseWebpackConfig(baseConfig)'
41
+ : 'webpackMerge(baseConfig, baseWebpackConfig)'}
42
+ `
43
+ : ''}
44
+ `;
45
+ tree.write((0, devkit_1.joinPathFragments)(opts.root, 'rspack.config.ts'), configContents);
46
+ }
47
+ function normalizeFromProjectRoot(path, projectRoot) {
48
+ if (projectRoot === '.') {
49
+ if (!path.startsWith('./')) {
50
+ return `./${path}`;
51
+ }
52
+ else {
53
+ return path;
54
+ }
55
+ }
56
+ else if (path.startsWith(projectRoot)) {
57
+ return path.replace(projectRoot, '.');
58
+ }
59
+ else if (!path.startsWith('./')) {
60
+ return `./${path}`;
61
+ }
62
+ return path;
63
+ }
@@ -0,0 +1,5 @@
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
+ }>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomWebpackConfig = getCustomWebpackConfig;
4
+ const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
5
+ const path_1 = require("path");
6
+ const FILE_EXTENSION_REGEX = /\.[^.]+$/;
7
+ async function getCustomWebpackConfig(tree, projectRoot, pathToCustomWebpackConfig) {
8
+ const configFile = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(tree.root, pathToCustomWebpackConfig));
9
+ const webpackConfig = 'default' in configFile ? configFile.default : configFile;
10
+ return {
11
+ isWebpackConfigFunction: typeof webpackConfig === 'function',
12
+ normalizedPathToCustomWebpackConfig: `./${(0, path_1.relative)(projectRoot, pathToCustomWebpackConfig).replace(FILE_EXTENSION_REGEX, '')}`,
13
+ };
14
+ }
@@ -0,0 +1,5 @@
1
+ export interface ConvertToRspackSchema {
2
+ project: string;
3
+ skipFormat?: boolean;
4
+ skipInstall?: boolean;
5
+ }
@@ -0,0 +1,32 @@
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-prompt": "Which project do you want to convert to rspack?",
18
+ "x-dropdown": "projects",
19
+ "x-priority": "important"
20
+ },
21
+ "skipFormat": {
22
+ "description": "Skip formatting files.",
23
+ "type": "boolean",
24
+ "default": false
25
+ },
26
+ "skipInstall": {
27
+ "description": "Skip installing dependencies.",
28
+ "type": "boolean",
29
+ "default": false
30
+ }
31
+ }
32
+ }
@@ -6,6 +6,7 @@ exports.backwardCompatibleVersions = {
6
6
  angularVersion: '~17.3.0',
7
7
  angularDevkitVersion: '~17.3.0',
8
8
  ngPackagrVersion: '~17.3.0',
9
+ ngRspackVersion: '~19.0.0-alpha.26',
9
10
  ngrxVersion: '~17.0.0',
10
11
  rxjsVersion: '~7.8.0',
11
12
  zoneJsVersion: '~0.14.3',
@@ -33,6 +34,7 @@ exports.backwardCompatibleVersions = {
33
34
  angularVersion: '~18.2.0',
34
35
  angularDevkitVersion: '~18.2.0',
35
36
  ngPackagrVersion: '~18.2.0',
37
+ ngRspackVersion: '~19.0.0-alpha.26',
36
38
  ngrxVersion: '~18.0.2',
37
39
  rxjsVersion: '~7.8.0',
38
40
  zoneJsVersion: '~0.14.3',
@@ -2,6 +2,7 @@ export declare const nxVersion: any;
2
2
  export declare const angularVersion = "~19.1.0";
3
3
  export declare const angularDevkitVersion = "~19.1.0";
4
4
  export declare const ngPackagrVersion = "~19.1.0";
5
+ export declare const ngRspackVersion = "~19.0.0-alpha.26";
5
6
  export declare const ngrxVersion = "^19.0.0";
6
7
  export declare const rxjsVersion = "~7.8.0";
7
8
  export declare const zoneJsVersion = "~0.15.0";
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
3
+ exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngRspackVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.angularVersion = '~19.1.0';
6
6
  exports.angularDevkitVersion = '~19.1.0';
7
7
  exports.ngPackagrVersion = '~19.1.0';
8
+ exports.ngRspackVersion = '~19.0.0-alpha.26';
8
9
  exports.ngrxVersion = '^19.0.0';
9
10
  exports.rxjsVersion = '~7.8.0';
10
11
  exports.zoneJsVersion = '~0.15.0';