@nx/angular 0.0.0-pr-29771-01aa6b4 → 0.0.0-pr-29860-43e1fcb

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-29771-01aa6b4",
3
+ "version": "0.0.0-pr-29860-43e1fcb",
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-29771-01aa6b4",
75
- "@nx/js": "0.0.0-pr-29771-01aa6b4",
76
- "@nx/eslint": "0.0.0-pr-29771-01aa6b4",
77
- "@nx/webpack": "0.0.0-pr-29771-01aa6b4",
78
- "@nx/module-federation": "0.0.0-pr-29771-01aa6b4",
79
- "@nx/web": "0.0.0-pr-29771-01aa6b4",
80
- "@nx/workspace": "0.0.0-pr-29771-01aa6b4",
74
+ "@nx/devkit": "0.0.0-pr-29860-43e1fcb",
75
+ "@nx/js": "0.0.0-pr-29860-43e1fcb",
76
+ "@nx/eslint": "0.0.0-pr-29860-43e1fcb",
77
+ "@nx/webpack": "0.0.0-pr-29860-43e1fcb",
78
+ "@nx/rspack": "0.0.0-pr-29860-43e1fcb",
79
+ "@nx/module-federation": "0.0.0-pr-29860-43e1fcb",
80
+ "@nx/web": "0.0.0-pr-29860-43e1fcb",
81
+ "@nx/workspace": "0.0.0-pr-29860-43e1fcb",
81
82
  "piscina": "^4.4.0"
82
83
  },
83
84
  "peerDependencies": {
@@ -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,62 @@
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
+ async function convertToRspack(tree, schema) {
8
+ const { project: projectName } = schema;
9
+ const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
10
+ const tasks = [];
11
+ const createConfigOptions = {
12
+ root: project.root,
13
+ };
14
+ const buildAndServeTargetNames = [];
15
+ for (const [targetName, target] of Object.entries(project.targets)) {
16
+ if (target.executor === '@angular-devkit/build-angular:browser' ||
17
+ target.executor === '@nx/angular:webpack-browser') {
18
+ createConfigOptions.browser = target.options.main;
19
+ createConfigOptions.index = target.options.index;
20
+ createConfigOptions.assets = target.options.assets.map((asset) => {
21
+ if (typeof asset === 'string') {
22
+ return asset;
23
+ }
24
+ return asset.input;
25
+ });
26
+ createConfigOptions.styles = target.options.styles;
27
+ createConfigOptions.scripts = target.options.scripts;
28
+ createConfigOptions.polyfills = target.options.polyfills;
29
+ createConfigOptions.tsconfigPath = target.options.tsConfig;
30
+ createConfigOptions.jit =
31
+ target.options.aot === undefined ? false : !target.options.aot;
32
+ createConfigOptions.inlineStylesExtension =
33
+ target.options.inlineStyleLanguage === undefined
34
+ ? 'css'
35
+ : target.options.inlineStyleLanguage;
36
+ // TODO: Add more options that can be correctly mapped
37
+ buildAndServeTargetNames.push(targetName);
38
+ }
39
+ else if (target.executor === '@angular-devkit/build-angular:dev-server' ||
40
+ target.executor === '@nx/angular:dev-server') {
41
+ buildAndServeTargetNames.push(targetName);
42
+ }
43
+ }
44
+ (0, create_config_1.createConfig)(tree, createConfigOptions);
45
+ for (const targetName of buildAndServeTargetNames) {
46
+ delete project.targets[targetName];
47
+ }
48
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
49
+ const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
50
+ await rspackInitGenerator(tree, {
51
+ addPlugin: true,
52
+ });
53
+ // TODO: Add skipInstall flag
54
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
55
+ '@ng-rspack/build': versions_1.ngRspackVersion,
56
+ });
57
+ tasks.push(installTask);
58
+ // TODO: Add skipFormatting flag
59
+ await (0, devkit_1.formatFiles)(tree);
60
+ return (0, devkit_1.runTasksInSerial)(...tasks);
61
+ }
62
+ 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>): void;
@@ -0,0 +1,50 @@
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) {
6
+ const configContents = `const { createConfig } = require('@ng-rspack/build');
7
+
8
+ module.exports = createConfig({
9
+ root: __dirname,
10
+ index: '${normalizeFromProjectRoot(opts.index, opts.root)}',
11
+ browser: '${normalizeFromProjectRoot(opts.browser, opts.root)}',
12
+ ${opts.server
13
+ ? `server: '${normalizeFromProjectRoot(opts.server, opts.root)}',`
14
+ : ''}
15
+ ${opts.ssrEntry
16
+ ? `ssrEntry: '${normalizeFromProjectRoot(opts.ssrEntry, opts.root)}',`
17
+ : ''}
18
+ tsconfigPath: '${normalizeFromProjectRoot(opts.tsconfigPath, opts.root)}',
19
+ polyfills: ${JSON.stringify(opts.polyfills)},
20
+ assets: ${JSON.stringify(opts.assets.map((a) => normalizeFromProjectRoot(a, opts.root)))},
21
+ styles: ${JSON.stringify(opts.styles.map((s) => normalizeFromProjectRoot(s, opts.root)))},
22
+ scripts: ${JSON.stringify(opts.scripts.map((s) => normalizeFromProjectRoot(s, opts.root)))},
23
+ jit: ${opts.jit},
24
+ ${opts.inlineStylesExtension
25
+ ? `inlineStylesExtension: '${opts.inlineStylesExtension}'`
26
+ : ''},
27
+ fileReplacements: ${JSON.stringify(opts.fileReplacements ?? [])},
28
+ hasServer: ${opts.server || opts.ssrEntry ? true : false},
29
+ skipTypeChecking: false,
30
+ });
31
+ `;
32
+ tree.write((0, devkit_1.joinPathFragments)(opts.root, 'rspack.config.ts'), configContents);
33
+ }
34
+ function normalizeFromProjectRoot(path, projectRoot) {
35
+ if (projectRoot === '.') {
36
+ if (!path.startsWith('./')) {
37
+ return `./${path}`;
38
+ }
39
+ else {
40
+ return path;
41
+ }
42
+ }
43
+ else if (path.startsWith(projectRoot)) {
44
+ return path.replace(projectRoot, '.');
45
+ }
46
+ else if (!path.startsWith('./')) {
47
+ return `./${path}`;
48
+ }
49
+ return path;
50
+ }
@@ -0,0 +1,3 @@
1
+ export interface ConvertToRspackSchema {
2
+ project: string;
3
+ }
@@ -0,0 +1,22 @@
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
+ }
22
+ }
@@ -144,7 +144,7 @@ function getComponentInfoFromDir(tree, entryPoint, dir, componentName, moduleFol
144
144
  let componentFileName = null;
145
145
  const componentImportPathChildren = [];
146
146
  (0, devkit_1.visitNotIgnoredFiles)(tree, dir, (filePath) => {
147
- componentImportPathChildren.push(filePath);
147
+ componentImportPathChildren.push((0, devkit_1.normalizePath)(filePath));
148
148
  });
149
149
  for (const candidateFile of componentImportPathChildren) {
150
150
  if (candidateFile.endsWith('.ts')) {
@@ -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';