@nx/rsbuild 0.0.0-pr-29314-e664f92 → 20.3.0-beta.1

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
@@ -8,6 +8,11 @@
8
8
  "description": "Initialize the `@nx/rsbuild` plugin.",
9
9
  "aliases": ["ng-add"],
10
10
  "hidden": true
11
+ },
12
+ "configuration": {
13
+ "factory": "./src/generators/configuration/configuration",
14
+ "schema": "./src/generators/configuration/schema.json",
15
+ "description": "Add an Rsbuild configuration for the provided project."
11
16
  }
12
17
  }
13
18
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/rsbuild",
3
3
  "description": "The Nx Plugin for Rsbuild contains an Nx plugin, executors and utilities that support building applications using Rsbuild.",
4
- "version": "0.0.0-pr-29314-e664f92",
4
+ "version": "20.3.0-beta.1",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -30,8 +30,8 @@
30
30
  "executors": "./executors.json",
31
31
  "dependencies": {
32
32
  "tslib": "^2.3.0",
33
- "@nx/devkit": "0.0.0-pr-29314-e664f92",
34
- "@nx/js": "0.0.0-pr-29314-e664f92",
33
+ "@nx/devkit": "20.3.0-beta.1",
34
+ "@nx/js": "20.3.0-beta.1",
35
35
  "@rsbuild/core": "1.1.8",
36
36
  "minimatch": "9.0.3"
37
37
  },
@@ -0,0 +1,4 @@
1
+ import { GeneratorCallback, type Tree } from '@nx/devkit';
2
+ import { type Schema } from './schema';
3
+ export declare function configurationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export default configurationGenerator;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configurationGenerator = configurationGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const lib_1 = require("./lib");
6
+ const js_1 = require("@nx/js");
7
+ const init_1 = require("../init/init");
8
+ const versions_1 = require("../../utils/versions");
9
+ const path_1 = require("path");
10
+ async function configurationGenerator(tree, schema) {
11
+ const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
12
+ const projects = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
13
+ const project = projects.projects[schema.project];
14
+ if (!project) {
15
+ throw new Error(`Could not find project '${schema.project}'. Please choose a project that exists in the Nx Workspace.`);
16
+ }
17
+ const options = await (0, lib_1.normalizeOptions)(tree, schema, project);
18
+ const tasks = [];
19
+ const jsInitTask = await (0, js_1.initGenerator)(tree, {
20
+ ...schema,
21
+ skipFormat: true,
22
+ tsConfigName: options.projectRoot === '.' ? 'tsconfig.json' : 'tsconfig.base.json',
23
+ });
24
+ tasks.push(jsInitTask);
25
+ const initTask = await (0, init_1.initGenerator)(tree, { skipFormat: true });
26
+ tasks.push(initTask);
27
+ if (options.skipValidation) {
28
+ const projectJson = (0, devkit_1.readProjectConfiguration)(tree, project.name);
29
+ if (projectJson.targets['build']) {
30
+ delete projectJson.targets['build'];
31
+ }
32
+ if (projectJson.targets['serve']) {
33
+ delete projectJson.targets['serve'];
34
+ }
35
+ if (projectJson.targets['dev']) {
36
+ delete projectJson.targets['dev'];
37
+ }
38
+ }
39
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@rsbuild/core': versions_1.rsbuildVersion }));
40
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), options.projectRoot, {
41
+ ...options,
42
+ tpl: '',
43
+ });
44
+ return (0, devkit_1.runTasksInSerial)(...tasks);
45
+ }
46
+ exports.default = configurationGenerator;
@@ -0,0 +1,16 @@
1
+ import { defineConfig } from '@rsbuild/core';
2
+
3
+ export default defineConfig({
4
+ source: {
5
+ entry: {
6
+ index: '<%= entry %>'
7
+ },<% if (tsConfig) { %>
8
+ tsconfigPath: '<%= tsConfig %>',<% } %>
9
+ },
10
+ output: {
11
+ target: '<%= target %>',
12
+ distPath: {
13
+ root: 'dist',
14
+ },
15
+ }
16
+ });
@@ -0,0 +1 @@
1
+ export * from './normalize-options';
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./normalize-options"), exports);
@@ -0,0 +1,9 @@
1
+ import { type Tree, type ProjectConfiguration } from '@nx/devkit';
2
+ import { type Schema } from '../schema';
3
+ export interface NormalizedOptions extends Schema {
4
+ entry: string;
5
+ target: 'node' | 'web' | 'web-worker';
6
+ tsConfig: string;
7
+ projectRoot: string;
8
+ }
9
+ export declare function normalizeOptions(tree: Tree, schema: Schema, project: ProjectConfiguration): Promise<NormalizedOptions>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeOptions = normalizeOptions;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ async function normalizeOptions(tree, schema, project) {
7
+ // Paths should be relative to the project root because inferred task will run from project root
8
+ let options = {
9
+ ...schema,
10
+ target: schema.target ?? 'web',
11
+ entry: normalizeRelativePath(schema.entry ?? './src/index.ts', project.root),
12
+ tsConfig: normalizeRelativePath(schema.tsConfig ?? './tsconfig.json', project.root),
13
+ projectRoot: project.root,
14
+ skipFormat: schema.skipFormat ?? false,
15
+ skipValidation: schema.skipValidation ?? false,
16
+ };
17
+ if (!schema.tsConfig) {
18
+ const possibleTsConfigPaths = [
19
+ './tsconfig.app.json',
20
+ './tsconfig.lib.json',
21
+ './tsconfig.json',
22
+ ];
23
+ const tsConfigPath = possibleTsConfigPaths.find((p) => tree.exists((0, devkit_1.joinPathFragments)(project.root, p)));
24
+ options.tsConfig = tsConfigPath ?? undefined;
25
+ }
26
+ return options;
27
+ }
28
+ function normalizeRelativePath(filePath, projectRoot) {
29
+ if (filePath.startsWith('./')) {
30
+ return filePath;
31
+ }
32
+ filePath = filePath.startsWith(projectRoot)
33
+ ? (0, path_1.relative)(projectRoot, filePath)
34
+ : filePath;
35
+ return `./${filePath}`;
36
+ }
@@ -0,0 +1,8 @@
1
+ export interface Schema {
2
+ project: string;
3
+ entry?: string;
4
+ tsConfig?: string;
5
+ target?: 'node' | 'web' | 'web-worker';
6
+ skipValidation?: boolean;
7
+ skipFormat?: boolean;
8
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "Rsbuild",
4
+ "title": "Nx Rsbuild Configuration Generator",
5
+ "description": "Rsbuild configuration generator.",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "description": "The name of the project.",
11
+ "$default": {
12
+ "$source": "argv",
13
+ "index": 0
14
+ },
15
+ "x-dropdown": "project",
16
+ "x-prompt": "What is the name of the project to set up a Rsbuild for?",
17
+ "x-priority": "important"
18
+ },
19
+ "entry": {
20
+ "type": "string",
21
+ "description": "Path relative to the workspace root for the entry file. Defaults to '<projectRoot>/src/index.ts'.",
22
+ "x-priority": "important"
23
+ },
24
+ "tsConfig": {
25
+ "type": "string",
26
+ "description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.app.json'.",
27
+ "x-priority": "important"
28
+ },
29
+ "target": {
30
+ "type": "string",
31
+ "description": "Target platform for the build, same as the Rsbuild output.target config option.",
32
+ "enum": ["node", "web", "web-worker"],
33
+ "default": "web"
34
+ },
35
+ "skipFormat": {
36
+ "description": "Skip formatting files.",
37
+ "type": "boolean",
38
+ "default": false,
39
+ "x-priority": "internal"
40
+ }
41
+ }
42
+ }