docs(rspack): add docs for rspack

This commit is contained in:
Colum Ferry 2024-09-10 17:59:30 +01:00
parent a38eca2930
commit 6c032ab800
42 changed files with 1298 additions and 1021 deletions

View File

@ -9753,6 +9753,130 @@
"isExternal": false,
"disableCollapsible": false
},
{
"id": "rspack",
"path": "/nx-api/rspack",
"name": "rspack",
"children": [
{
"id": "documents",
"path": "/nx-api/rspack/documents",
"name": "documents",
"children": [
{
"name": "Overview",
"path": "/nx-api/rspack/documents/overview",
"id": "overview",
"isExternal": false,
"children": [],
"disableCollapsible": false
}
],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "executors",
"path": "/nx-api/rspack/executors",
"name": "executors",
"children": [
{
"id": "rspack",
"path": "/nx-api/rspack/executors/rspack",
"name": "rspack",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "dev-server",
"path": "/nx-api/rspack/executors/dev-server",
"name": "dev-server",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "ssr-dev-server",
"path": "/nx-api/rspack/executors/ssr-dev-server",
"name": "ssr-dev-server",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "module-federation-dev-server",
"path": "/nx-api/rspack/executors/module-federation-dev-server",
"name": "module-federation-dev-server",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "module-federation-ssr-dev-server",
"path": "/nx-api/rspack/executors/module-federation-ssr-dev-server",
"name": "module-federation-ssr-dev-server",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "module-federation-static-server",
"path": "/nx-api/rspack/executors/module-federation-static-server",
"name": "module-federation-static-server",
"children": [],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "generators",
"path": "/nx-api/rspack/generators",
"name": "generators",
"children": [
{
"id": "configuration",
"path": "/nx-api/rspack/generators/configuration",
"name": "configuration",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "init",
"path": "/nx-api/rspack/generators/init",
"name": "init",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "preset",
"path": "/nx-api/rspack/generators/preset",
"name": "preset",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "application",
"path": "/nx-api/rspack/generators/application",
"name": "application",
"children": [],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "storybook",
"path": "/nx-api/storybook",

View File

@ -2886,6 +2886,122 @@
},
"path": "/nx-api/rollup"
},
"rspack": {
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "rspack",
"packageName": "@nx/rspack",
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
"documents": {
"/nx-api/rspack/documents/overview": {
"id": "overview",
"name": "Overview",
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
"file": "generated/packages/rspack/documents/overview",
"itemList": [],
"isExternal": false,
"path": "/nx-api/rspack/documents/overview",
"tags": [],
"originalFilePath": "shared/packages/rspack/rspack-plugin"
}
},
"root": "/packages/rspack",
"source": "/packages/rspack/src",
"executors": {
"/nx-api/rspack/executors/rspack": {
"description": "Run Rspack via an executor for a project.",
"file": "generated/packages/rspack/executors/rspack.json",
"hidden": false,
"name": "rspack",
"originalFilePath": "/packages/rspack/src/executors/rspack/schema.json",
"path": "/nx-api/rspack/executors/rspack",
"type": "executor"
},
"/nx-api/rspack/executors/dev-server": {
"description": "Run @rspack/dev-server to serve a project.",
"file": "generated/packages/rspack/executors/dev-server.json",
"hidden": false,
"name": "dev-server",
"originalFilePath": "/packages/rspack/src/executors/dev-server/schema.json",
"path": "/nx-api/rspack/executors/dev-server",
"type": "executor"
},
"/nx-api/rspack/executors/ssr-dev-server": {
"description": "Serve a SSR application.",
"file": "generated/packages/rspack/executors/ssr-dev-server.json",
"hidden": false,
"name": "ssr-dev-server",
"originalFilePath": "/packages/rspack/src/executors/ssr-dev-server/schema.json",
"path": "/nx-api/rspack/executors/ssr-dev-server",
"type": "executor"
},
"/nx-api/rspack/executors/module-federation-dev-server": {
"description": "Serve a host or remote application.",
"file": "generated/packages/rspack/executors/module-federation-dev-server.json",
"hidden": false,
"name": "module-federation-dev-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-dev-server/schema.json",
"path": "/nx-api/rspack/executors/module-federation-dev-server",
"type": "executor"
},
"/nx-api/rspack/executors/module-federation-ssr-dev-server": {
"description": "Serve a host application along with it's known remotes.",
"file": "generated/packages/rspack/executors/module-federation-ssr-dev-server.json",
"hidden": false,
"name": "module-federation-ssr-dev-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-ssr-dev-server/schema.json",
"path": "/nx-api/rspack/executors/module-federation-ssr-dev-server",
"type": "executor"
},
"/nx-api/rspack/executors/module-federation-static-server": {
"description": "Serve a host and its remotes statically.",
"file": "generated/packages/rspack/executors/module-federation-static-server.json",
"hidden": false,
"name": "module-federation-static-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-static-server/schema.json",
"path": "/nx-api/rspack/executors/module-federation-static-server",
"type": "executor"
}
},
"generators": {
"/nx-api/rspack/generators/configuration": {
"description": "Rspack configuration generator.",
"file": "generated/packages/rspack/generators/configuration.json",
"hidden": false,
"name": "configuration",
"originalFilePath": "/packages/rspack/src/generators/configuration/schema.json",
"path": "/nx-api/rspack/generators/configuration",
"type": "generator"
},
"/nx-api/rspack/generators/init": {
"description": "Rspack init generator.",
"file": "generated/packages/rspack/generators/init.json",
"hidden": true,
"name": "init",
"originalFilePath": "/packages/rspack/src/generators/init/schema.json",
"path": "/nx-api/rspack/generators/init",
"type": "generator"
},
"/nx-api/rspack/generators/preset": {
"description": "React preset generator.",
"file": "generated/packages/rspack/generators/preset.json",
"hidden": true,
"name": "preset",
"originalFilePath": "/packages/rspack/src/generators/preset/schema.json",
"path": "/nx-api/rspack/generators/preset",
"type": "generator"
},
"/nx-api/rspack/generators/application": {
"description": "React application generator.",
"file": "generated/packages/rspack/generators/application.json",
"hidden": false,
"name": "application",
"originalFilePath": "/packages/rspack/src/generators/application/schema.json",
"path": "/nx-api/rspack/generators/application",
"type": "generator"
}
},
"path": "/nx-api/rspack"
},
"storybook": {
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "storybook",

View File

@ -2861,6 +2861,121 @@
"root": "/packages/rollup",
"source": "/packages/rollup/src"
},
{
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
"documents": [
{
"id": "overview",
"name": "Overview",
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
"file": "generated/packages/rspack/documents/overview",
"itemList": [],
"isExternal": false,
"path": "rspack/documents/overview",
"tags": [],
"originalFilePath": "shared/packages/rspack/rspack-plugin"
}
],
"executors": [
{
"description": "Run Rspack via an executor for a project.",
"file": "generated/packages/rspack/executors/rspack.json",
"hidden": false,
"name": "rspack",
"originalFilePath": "/packages/rspack/src/executors/rspack/schema.json",
"path": "rspack/executors/rspack",
"type": "executor"
},
{
"description": "Run @rspack/dev-server to serve a project.",
"file": "generated/packages/rspack/executors/dev-server.json",
"hidden": false,
"name": "dev-server",
"originalFilePath": "/packages/rspack/src/executors/dev-server/schema.json",
"path": "rspack/executors/dev-server",
"type": "executor"
},
{
"description": "Serve a SSR application.",
"file": "generated/packages/rspack/executors/ssr-dev-server.json",
"hidden": false,
"name": "ssr-dev-server",
"originalFilePath": "/packages/rspack/src/executors/ssr-dev-server/schema.json",
"path": "rspack/executors/ssr-dev-server",
"type": "executor"
},
{
"description": "Serve a host or remote application.",
"file": "generated/packages/rspack/executors/module-federation-dev-server.json",
"hidden": false,
"name": "module-federation-dev-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-dev-server/schema.json",
"path": "rspack/executors/module-federation-dev-server",
"type": "executor"
},
{
"description": "Serve a host application along with it's known remotes.",
"file": "generated/packages/rspack/executors/module-federation-ssr-dev-server.json",
"hidden": false,
"name": "module-federation-ssr-dev-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-ssr-dev-server/schema.json",
"path": "rspack/executors/module-federation-ssr-dev-server",
"type": "executor"
},
{
"description": "Serve a host and its remotes statically.",
"file": "generated/packages/rspack/executors/module-federation-static-server.json",
"hidden": false,
"name": "module-federation-static-server",
"originalFilePath": "/packages/rspack/src/executors/module-federation-static-server/schema.json",
"path": "rspack/executors/module-federation-static-server",
"type": "executor"
}
],
"generators": [
{
"description": "Rspack configuration generator.",
"file": "generated/packages/rspack/generators/configuration.json",
"hidden": false,
"name": "configuration",
"originalFilePath": "/packages/rspack/src/generators/configuration/schema.json",
"path": "rspack/generators/configuration",
"type": "generator"
},
{
"description": "Rspack init generator.",
"file": "generated/packages/rspack/generators/init.json",
"hidden": true,
"name": "init",
"originalFilePath": "/packages/rspack/src/generators/init/schema.json",
"path": "rspack/generators/init",
"type": "generator"
},
{
"description": "React preset generator.",
"file": "generated/packages/rspack/generators/preset.json",
"hidden": true,
"name": "preset",
"originalFilePath": "/packages/rspack/src/generators/preset/schema.json",
"path": "rspack/generators/preset",
"type": "generator"
},
{
"description": "React application generator.",
"file": "generated/packages/rspack/generators/application.json",
"hidden": false,
"name": "application",
"originalFilePath": "/packages/rspack/src/generators/application/schema.json",
"path": "rspack/generators/application",
"type": "generator"
}
],
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "rspack",
"packageName": "@nx/rspack",
"root": "/packages/rspack",
"source": "/packages/rspack/src"
},
{
"description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
"documents": [

View File

@ -0,0 +1,98 @@
---
title: Overview of the Nx Rspack Plugin
description: The Nx Plugin for Rspack contains executors, generators, and utilities for managing Rspack projects in an Nx Workspace.
---
The Nx Plugin for Rspack contains executors, generators, and utilities for managing Rspack projects in an Nx Workspace.
## Setting Up @nx/rspack
### Installation
{% callout type="note" title="Keep Nx Package Versions In Sync" %}
Make sure to install the `@nx/rspack` version that matches the version of `nx` in your repository. If the version numbers get out of sync, you can encounter some difficult to debug errors. You can [fix Nx version mismatches with this recipe](/recipes/tips-n-tricks/keep-nx-versions-in-sync).
{% /callout %}
In any Nx workspace, you can install `@nx/rspack` by running the following command:
{% tabs %}
{% tab label="Nx 18+" %}
```shell {% skipRescope=true %}
nx add @nx/rspack
```
This will install the correct version of `@nx/rspack`.
### How @nx/rspack Infers Tasks
The `@nx/rspack` plugin will create a task for any project that has a Rspack configuration file present. Any of the following files will be recognized as a Rspack configuration file:
- `rspack.config.js`
- `rspack.config.ts`
- `rspack.config.mjs`
- `rspack.config.mts`
- `rspack.config.cjs`
- `rspack.config.cts`
### View Inferred Tasks
To view inferred tasks for a project, open the [project details view](/concepts/inferred-tasks) in Nx Console or run `nx show project my-project --web` in the command line.
### @nx/rspack Configuration
The `@nx/rspack/plugin` is configured in the `plugins` array in `nx.json`.
```json {% fileName="nx.json" %}
{
"plugins": [
{
"plugin": "@nx/rspack/plugin",
"options": {
"buildTargetName": "build",
"previewTargetName": "preview",
"serveTargetName": "serve",
"serveStaticTargetName": "serve-static"
}
}
]
}
```
The `buildTargetName`, `previewTargetName`, `serveTargetName` and `serveStaticTargetName` options control the names of the inferred Rspack tasks. The default names are `build`, `preview`, `serve` and `serve-static`.
{% /tab %}
{% tab label="Nx < 18" %}
Install the `@nx/rspack` package with your package manager.
```shell
npm add -D @nx/rspack
```
{% /tab %}
{% /tabs %}
## Using @nx/rspack
### Generate a new project using Rspack
You can generate a [React](/nx-api/react) application or library that uses Rspack. The [`@nx/react:app`](/nx-api/react/generators/application) and [`@nx/react:lib`](/nx-api/react/generators/library) generators accept the `bundler` option, where you can pass `rspack`. This will generate a new application configured to use Rspack, and it will also install all the necessary dependencies, including the `@nx/rspack` plugin.
To generate a React application using Rspack, run the following:
```bash
nx g @nx/react:app my-app --bundler=rspack
```
To generate a React library using Rspack, run the following:
```bash
nx g @nx/react:lib my-lib --bundler=rspack
```
### Modify an existing React project to use Rspack
You can use the `@nx/rspack:configuration` generator to change your React to use Rspack. This generator will modify your project's configuration to use Rspack, and it will also install all the necessary dependencies, including the `@nx/rspack` plugin.
You can read more about this generator on the [`@nx/rspack:configuration`](/nx-api/rspack/generators/configuration) generator page.

View File

@ -0,0 +1,55 @@
{
"name": "dev-server",
"implementation": "/packages/rspack/src/executors/dev-server/dev-server.impl.ts",
"schema": {
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Rspack dev-server executor",
"description": "Run @rspack/dev-server to serve a project.",
"type": "object",
"properties": {
"buildTarget": {
"type": "string",
"description": "The build target for rspack."
},
"port": {
"type": "number",
"description": "The port to for the dev-server to listen on."
},
"mode": {
"type": "string",
"description": "Mode to run the server in.",
"enum": ["development", "production", "none"]
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"ssl": {
"type": "boolean",
"description": "Serve using `HTTPS`.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving `HTTPS`."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving `HTTPS`."
},
"publicHost": {
"type": "string",
"description": "Public URL where the application will be served."
}
},
"required": ["buildTarget"],
"presets": []
},
"description": "Run @rspack/dev-server to serve a project.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/dev-server/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,100 @@
{
"name": "module-federation-dev-server",
"implementation": "/packages/rspack/src/executors/module-federation-dev-server/module-federation-dev-server.impl.ts",
"schema": {
"version": 2,
"outputCapture": "direct-nodejs",
"title": "Rspack Module Federation Dev Server",
"description": "Serve a module federation application.",
"cli": "nx",
"type": "object",
"properties": {
"devRemotes": {
"type": "array",
"items": {
"oneOf": [
{ "type": "string" },
{
"type": "object",
"properties": {
"remoteName": { "type": "string" },
"configuration": { "type": "string" }
},
"required": ["remoteName"],
"additionalProperties": false
}
]
},
"description": "List of remote applications to run in development mode (i.e. using serve target).",
"x-priority": "important"
},
"skipRemotes": {
"type": "array",
"items": { "type": "string" },
"description": "List of remote applications to not automatically serve, either statically or in development mode. This will not remove the remotes from the `module-federation.config` file, and therefore the application may still try to fetch these remotes.\nThis option is useful if you have other means for serving the `remote` application(s).\n**NOTE:** Remotes that are not in the workspace will be skipped automatically.",
"x-priority": "important"
},
"buildTarget": {
"type": "string",
"description": "Target which builds the application.",
"x-priority": "important"
},
"port": {
"type": "number",
"description": "Port to listen on.",
"default": 4200,
"x-priority": "important"
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"ssl": {
"type": "boolean",
"description": "Serve using `HTTPS`.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving `HTTPS`."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving `HTTPS`."
},
"publicHost": {
"type": "string",
"description": "Public URL where the application will be served."
},
"static": {
"type": "boolean",
"description": "Whether to use a static file server instead of the rspack-dev-server. This should be used for remote applications that are also host applications."
},
"isInitialHost": {
"type": "boolean",
"description": "Whether the host that is running this executor is the first in the project tree to do so.",
"default": true,
"x-priority": "internal"
},
"parallel": {
"type": "number",
"description": "Max number of parallel processes for building static remotes"
},
"staticRemotesPort": {
"type": "number",
"description": "The port at which to serve the file-server for the static remotes."
},
"pathToManifestFile": {
"type": "string",
"description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic remote applications relative to the workspace root."
}
},
"presets": []
},
"description": "Serve a host or remote application.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/module-federation-dev-server/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,85 @@
{
"name": "module-federation-ssr-dev-server",
"implementation": "/packages/rspack/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.ts",
"schema": {
"version": 2,
"outputCapture": "direct-nodejs",
"title": "Module Federation SSR Dev Server",
"description": "Serve a SSR host application along with its known remotes.",
"cli": "nx",
"type": "object",
"properties": {
"browserTarget": {
"type": "string",
"description": "Target which builds the browser application.",
"x-priority": "important"
},
"serverTarget": {
"type": "string",
"description": "Target which builds the server application.",
"x-priority": "important"
},
"port": {
"type": "number",
"description": "The port to be set on `process.env.PORT` for use in the server.",
"default": 4200,
"x-priority": "important"
},
"devRemotes": {
"type": "array",
"items": { "type": "string" },
"description": "List of remote applications to run in development mode (i.e. using serve target).",
"x-priority": "important"
},
"skipRemotes": {
"type": "array",
"items": { "type": "string" },
"description": "List of remote applications to not automatically serve, either statically or in development mode.",
"x-priority": "important"
},
"host": {
"type": "string",
"description": "Host to listen on.",
"default": "localhost"
},
"staticRemotesPort": {
"type": "number",
"description": "The port at which to serve the file-server for the static remotes."
},
"pathToManifestFile": {
"type": "string",
"description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic remote applications relative to the workspace root."
},
"ssl": {
"type": "boolean",
"description": "Serve using HTTPS.",
"default": false
},
"sslKey": {
"type": "string",
"description": "SSL key to use for serving HTTPS."
},
"sslCert": {
"type": "string",
"description": "SSL certificate to use for serving HTTPS."
},
"publicHost": {
"type": "string",
"description": "Public URL where the application will be served."
},
"isInitialHost": {
"type": "boolean",
"description": "Whether the host that is running this executor is the first in the project tree to do so.",
"default": true,
"x-priority": "internal"
}
},
"required": ["browserTarget", "serverTarget"],
"presets": []
},
"description": "Serve a host application along with it's known remotes.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/module-federation-ssr-dev-server/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,20 @@
{
"name": "module-federation-static-server",
"implementation": "/packages/rspack/src/executors/module-federation-static-server/module-federation-static-server.impl.ts",
"schema": {
"version": 2,
"outputCapture": "direct-nodejs",
"title": "Module Federation Static Dev Server",
"description": "Serve a host application statically along with it's remotes.",
"cli": "nx",
"type": "object",
"properties": { "serveTarget": { "type": "string" } },
"required": ["serveTarget"],
"presets": []
},
"description": "Serve a host and its remotes statically.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/module-federation-static-server/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,202 @@
{
"name": "rspack",
"implementation": "/packages/rspack/src/executors/rspack/rspack.impl.ts",
"schema": {
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Rspack build executor",
"description": "Run Rspack via an executor for a project.",
"type": "object",
"properties": {
"target": {
"type": "string",
"description": "The platform to target (e.g. web, node).",
"enum": ["web", "node"]
},
"main": { "type": "string", "description": "The main entry file." },
"outputPath": {
"type": "string",
"description": "The output path for the bundle."
},
"outputFileName": {
"type": "string",
"description": "The main output entry file"
},
"tsConfig": {
"type": "string",
"description": "The tsconfig file to build the project."
},
"typeCheck": {
"type": "boolean",
"description": "Skip the type checking."
},
"indexHtml": {
"type": "string",
"description": "The path to the index.html file."
},
"index": {
"type": "string",
"description": "HTML File which will be contain the application.",
"x-completion-type": "file",
"x-completion-glob": "**/*@(.html|.htm)"
},
"baseHref": {
"type": "string",
"description": "Base url for the application being built."
},
"deployUrl": {
"type": "string",
"description": "URL where the application will be deployed."
},
"rspackConfig": {
"type": "string",
"description": "The path to the rspack config file."
},
"optimization": {
"description": "Enables optimization of the build output.",
"oneOf": [
{
"type": "object",
"properties": {
"scripts": {
"type": "boolean",
"description": "Enables optimization of the scripts output.",
"default": true
},
"styles": {
"type": "boolean",
"description": "Enables optimization of the styles output.",
"default": true
}
},
"additionalProperties": false
},
{ "type": "boolean" }
]
},
"sourceMap": {
"description": "Output sourcemaps. Use 'hidden' for use with error reporting tools without generating sourcemap comment.",
"default": true,
"oneOf": [{ "type": "boolean" }, { "type": "string" }]
},
"assets": {
"type": "array",
"description": "List of static application assets.",
"default": [],
"items": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": false
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
}
},
"extractLicenses": {
"type": "boolean",
"description": "Extract all licenses in a separate file.",
"default": true
},
"fileReplacements": {
"description": "Replace files with other files in the build.",
"type": "array",
"items": {
"type": "object",
"properties": {
"replace": {
"type": "string",
"description": "The file to be replaced.",
"x-completion-type": "file"
},
"with": {
"type": "string",
"description": "The file to replace with.",
"x-completion-type": "file"
}
},
"additionalProperties": false,
"required": ["replace", "with"]
},
"default": []
},
"mode": {
"type": "string",
"description": "Mode to run the build in.",
"enum": ["development", "production", "none"]
},
"generatePackageJson": {
"type": "boolean",
"description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated."
}
},
"required": ["target", "main", "outputPath", "tsConfig", "rspackConfig"],
"definitions": {
"assetPattern": {
"oneOf": [
{
"type": "object",
"properties": {
"glob": {
"type": "string",
"description": "The pattern to match."
},
"input": {
"type": "string",
"description": "The input directory path in which to apply 'glob'. Defaults to the project root."
},
"ignore": {
"description": "An array of globs to ignore.",
"type": "array",
"items": { "type": "string" }
},
"output": {
"type": "string",
"description": "Absolute path within the output."
},
"watch": {
"type": "boolean",
"description": "Enable re-building when files change.",
"default": false
}
},
"additionalProperties": false,
"required": ["glob", "input", "output"]
},
{ "type": "string" }
]
}
},
"presets": []
},
"description": "Run Rspack via an executor for a project.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/rspack/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,46 @@
{
"name": "ssr-dev-server",
"implementation": "/packages/rspack/src/executors/ssr-dev-server/ssr-dev-server.impl.ts",
"schema": {
"outputCapture": "direct-nodejs",
"title": "Rspack SSR Dev Server",
"description": "Serve a SSR application using rspack.",
"cli": "nx",
"type": "object",
"properties": {
"browserTarget": {
"type": "string",
"description": "Target which builds the browser application.",
"x-priority": "important"
},
"serverTarget": {
"type": "string",
"description": "Target which builds the server application.",
"x-priority": "important"
},
"port": {
"type": "number",
"description": "The port to be set on `process.env.PORT` for use in the server.",
"default": 4200,
"x-priority": "important"
},
"browserTargetOptions": {
"type": "object",
"description": "Additional options to pass into the browser build target.",
"default": {}
},
"serverTargetOptions": {
"type": "object",
"description": "Additional options to pass into the server build target.",
"default": {}
}
},
"required": ["browserTarget", "serverTarget"],
"presets": []
},
"description": "Serve a SSR application.",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/executors/ssr-dev-server/schema.json",
"type": "executor"
}

View File

@ -0,0 +1,98 @@
{
"name": "application",
"factory": "./src/generators/application/application",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "Application",
"title": "Application generator for React + rspack",
"type": "object",
"description": "React + Rspack application generator.",
"examples": [
{
"command": "nx g app myapp --directory=myorg",
"description": "Generate `apps/myorg/myapp` and `apps/myorg/myapp-e2e`"
}
],
"properties": {
"name": {
"description": "The name of the application.",
"type": "string",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "What name would you like to use for the application?",
"pattern": "^[a-zA-Z].*$",
"x-priority": "important"
},
"framework": {
"type": "string",
"description": "The framework to use for the application.",
"x-prompt": "What framework do you want to use when generating this application?",
"enum": ["none", "react", "web", "nest"],
"alias": ["uiFramework"],
"x-priority": "important",
"default": "react"
},
"style": {
"description": "The file extension to be used for style files.",
"type": "string",
"default": "css",
"alias": "s",
"x-prompt": {
"message": "Which stylesheet format would you like to use?",
"type": "list",
"items": [
{ "value": "css", "label": "CSS" },
{
"value": "scss",
"label": "SASS(.scss) [ http://sass-lang.com ]"
},
{
"value": "styl",
"label": "Stylus(.styl) [ http://stylus-lang.com ]"
},
{
"value": "less",
"label": "LESS [ http://lesscss.org ]"
},
{ "value": "none", "label": "None" }
]
}
},
"unitTestRunner": {
"type": "string",
"description": "The unit test runner to use.",
"enum": ["none", "jest"],
"default": "jest"
},
"e2eTestRunner": {
"type": "string",
"description": "The e2e test runner to use.",
"enum": ["none", "cypress"],
"default": "cypress"
},
"directory": {
"type": "string",
"description": "The directory to nest the app under."
},
"tags": {
"type": "string",
"description": "Add tags to the application (used for linting).",
"alias": "t"
},
"monorepo": {
"type": "boolean",
"description": "Creates an integrated monorepo.",
"aliases": ["integrated"]
},
"rootProject": { "type": "boolean", "x-priority": "internal" }
},
"required": ["name"],
"presets": []
},
"aliases": ["app"],
"x-type": "application",
"description": "React application generator.",
"implementation": "/packages/rspack/src/generators/application/application.ts",
"hidden": false,
"path": "/packages/rspack/src/generators/application/schema.json",
"type": "generator"
}

View File

@ -0,0 +1,78 @@
{
"name": "configuration",
"factory": "./src/generators/configuration/configuration",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "Rspack",
"title": "Nx Rspack Configuration Generator",
"description": "Rspack configuration generator.",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"$default": { "$source": "argv", "index": 0 },
"x-dropdown": "project",
"x-prompt": "What is the name of the project to set up a rspack for?",
"x-priority": "important"
},
"framework": {
"type": "string",
"description": "The framework used by the project.",
"x-prompt": "What framework is the project you want to convert using?",
"enum": ["none", "react", "web", "nest"],
"alias": ["uiFramework"],
"x-priority": "important"
},
"main": {
"type": "string",
"description": "Path relative to the workspace root for the main entry file. Defaults to '<projectRoot>/src/main.ts'.",
"x-priority": "important"
},
"tsConfig": {
"type": "string",
"description": "Path relative to the workspace root for the tsconfig file to build with. Defaults to '<projectRoot>/tsconfig.app.json'.",
"x-priority": "important"
},
"target": {
"type": "string",
"description": "Target platform for the build, same as the rspack config option.",
"enum": ["node", "web"],
"default": "web"
},
"devServer": {
"type": "boolean",
"description": "Add a serve target to run a local rspack dev-server",
"default": false
},
"style": {
"type": "string",
"description": "The style solution to use.",
"enum": ["none", "css", "scss", "less"]
},
"newProject": {
"type": "boolean",
"description": "Is this a new project?",
"default": false,
"hidden": true
},
"buildTarget": {
"type": "string",
"description": "The build target of the project to be transformed to use the @nx/vite:build executor."
},
"serveTarget": {
"type": "string",
"description": "The serve target of the project to be transformed to use the @nx/vite:dev-server and @nx/vite:preview-server executors."
},
"rootProject": { "type": "boolean", "x-priority": "internal" }
},
"required": ["project"],
"presets": []
},
"description": "Rspack configuration generator.",
"implementation": "/packages/rspack/src/generators/configuration/configuration.ts",
"aliases": [],
"hidden": false,
"path": "/packages/rspack/src/generators/configuration/schema.json",
"type": "generator"
}

View File

@ -0,0 +1,39 @@
{
"name": "init",
"factory": "./src/generators/init/init",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "Init",
"title": "Nx Rspack Init Generator",
"type": "object",
"description": "Rspack init generator.",
"properties": {
"framework": {
"type": "string",
"description": "The UI framework used by the project.",
"enum": ["none", "react", "web", "nest"],
"alias": ["uiFramework"]
},
"style": {
"type": "string",
"description": "The style solution to use.",
"enum": ["none", "css", "scss", "less", "styl"]
},
"rootProject": { "type": "boolean", "x-priority": "internal" },
"keepExistingVersions": {
"type": "boolean",
"x-priority": "internal",
"description": "Keep existing dependencies versions",
"default": false
}
},
"required": [],
"presets": []
},
"description": "Rspack init generator.",
"hidden": true,
"implementation": "/packages/rspack/src/generators/init/init.ts",
"aliases": [],
"path": "/packages/rspack/src/generators/init/schema.json",
"type": "generator"
}

View File

@ -0,0 +1,70 @@
{
"name": "preset",
"factory": "./src/generators/preset/preset",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "Preset",
"title": "Standalone React and rspack preset",
"description": "React + Rspack preset generator.",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "",
"$default": { "$source": "argv", "index": 0 },
"x-priority": "important"
},
"framework": {
"type": "string",
"description": "The framework to use for the application.",
"enum": ["none", "react", "web", "nest"],
"alias": ["uiFramework"],
"x-priority": "important",
"default": "react"
},
"less": { "type": "boolean", "description": "Use less for styling." },
"sass": { "type": "boolean", "description": "Use sass for styling." },
"stylus": { "type": "boolean", "description": "Use stylus for styling." },
"unitTestRunner": {
"type": "string",
"description": "The unit test runner to use.",
"enum": ["none", "jest"],
"default": "jest"
},
"e2eTestRunner": {
"type": "string",
"description": "The e2e test runner to use.",
"enum": ["none", "cypress"],
"default": "cypress"
},
"directory": {
"type": "string",
"description": "The directory to nest the app under."
},
"tags": {
"type": "string",
"description": "Add tags to the project (used for linting).",
"alias": "t"
},
"monorepo": {
"type": "boolean",
"description": "Creates an integrated monorepo.",
"default": false,
"aliases": ["integrated"]
},
"rootProject": {
"type": "boolean",
"x-priority": "internal",
"default": true
}
},
"required": ["name"],
"presets": []
},
"description": "React preset generator.",
"hidden": true,
"implementation": "/packages/rspack/src/generators/preset/preset.ts",
"aliases": [],
"path": "/packages/rspack/src/generators/preset/schema.json",
"type": "generator"
}

View File

@ -2519,6 +2519,19 @@
}
]
},
{
"name": "rspack",
"id": "rspack",
"description": "Rspack package.",
"itemList": [
{
"name": "Overview",
"id": "overview",
"path": "/nx-api/rspack",
"file": "shared/packages/rspack/rspack-plugin"
}
]
},
{
"name": "detox",
"id": "detox",

View File

@ -24,7 +24,6 @@ nx add @nx/rspack
This will install the correct version of `@nx/rspack`.
### How @nx/rspack Infers Tasks
The `@nx/rspack` plugin will create a task for any project that has a Rspack configuration file present. Any of the following files will be recognized as a Rspack configuration file:
@ -94,7 +93,6 @@ nx g @nx/react:lib my-lib --bundler=rspack
### Modify an existing React project to use Rspack
You can use the `@nx/rspack:rspack-project` generator to change your React to use Rspack. This generator will modify your project's configuration to use Rspack, and it will also install all the necessary dependencies, including the `@nx/rspack` plugin.
You can read more about this generator on the [`@nx/rspack:rspack-project`](/nx-api/rspack/generators/rspack-project) generator page.
You can use the `@nx/rspack:configuration` generator to change your React to use Rspack. This generator will modify your project's configuration to use Rspack, and it will also install all the necessary dependencies, including the `@nx/rspack` plugin.
You can read more about this generator on the [`@nx/rspack:configuration`](/nx-api/rspack/generators/configuration) generator page.

View File

@ -677,6 +677,21 @@
- [init](/nx-api/rollup/generators/init)
- [configuration](/nx-api/rollup/generators/configuration)
- [convert-to-inferred](/nx-api/rollup/generators/convert-to-inferred)
- [rspack](/nx-api/rspack)
- [documents](/nx-api/rspack/documents)
- [Overview](/nx-api/rspack/documents/overview)
- [executors](/nx-api/rspack/executors)
- [rspack](/nx-api/rspack/executors/rspack)
- [dev-server](/nx-api/rspack/executors/dev-server)
- [ssr-dev-server](/nx-api/rspack/executors/ssr-dev-server)
- [module-federation-dev-server](/nx-api/rspack/executors/module-federation-dev-server)
- [module-federation-ssr-dev-server](/nx-api/rspack/executors/module-federation-ssr-dev-server)
- [module-federation-static-server](/nx-api/rspack/executors/module-federation-static-server)
- [generators](/nx-api/rspack/generators)
- [configuration](/nx-api/rspack/generators/configuration)
- [init](/nx-api/rspack/generators/init)
- [preset](/nx-api/rspack/generators/preset)
- [application](/nx-api/rspack/generators/application)
- [storybook](/nx-api/storybook)
- [documents](/nx-api/storybook/documents)
- [Overview](/nx-api/storybook/documents/overview)

View File

@ -1,72 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { PackageSchemaSubList } from '@nx/nx-dev/feature-package-schema-viewer/src/lib/package-schema-sub-list';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function DocumentsIndex({
menu,
pkg,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: { menu: Menu; package: ProcessedPackageMetadata } = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaSubList pkg={vm.package} type={'document'} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps(): Promise<{
props: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
};
}> {
return {
props: {
menu: menusApi.getMenu('nx-api', 'nx-api'),
pkg,
},
};
}

View File

@ -1,93 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { DocViewer } from '@nx/nx-dev/feature-doc-viewer';
import { ProcessedDocument, RelatedDocument } from '@nx/nx-dev/models-document';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { content } from '../../../../lib/rspack/content/overview';
import { pkg } from '../../../../lib/rspack/pkg';
import { fetchGithubStarCount } from '../../../../lib/githubStars.api';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function Overview({
document,
menu,
relatedDocuments,
widgetData,
}: {
document: ProcessedDocument;
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
relatedDocuments: RelatedDocument[];
widgetData: { githubStarsCount: number };
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
document: ProcessedDocument;
menu: Menu;
relatedDocuments: RelatedDocument[];
} = {
document,
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
relatedDocuments,
};
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<DocViewer
document={vm.document}
relatedDocuments={vm.relatedDocuments}
widgetData={widgetData}
/>
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
const document = {
content: content,
description: '',
filePath: '',
id: 'overview',
name: 'Overview of the Nx Rspack Plugin',
relatedDocuments: {},
tags: [],
};
return {
props: {
pkg,
document,
widgetData: {
githubStarsCount: await fetchGithubStarCount(),
},
relatedDocuments: [],
menu: menusApi.getMenu('nx-api', ''),
},
};
}

View File

@ -1,94 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { DocViewer } from '@nx/nx-dev/feature-doc-viewer';
import { ProcessedDocument, RelatedDocument } from '@nx/nx-dev/models-document';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { content } from '../../../../lib/rspack/content/rspack-config-setup';
import { pkg } from '../../../../lib/rspack/pkg';
import { fetchGithubStarCount } from '../../../../lib/githubStars.api';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function RspackConfigSetup({
document,
menu,
relatedDocuments,
widgetData,
}: {
document: ProcessedDocument;
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
relatedDocuments: RelatedDocument[];
widgetData: { githubStarsCount: number };
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
document: ProcessedDocument;
menu: Menu;
relatedDocuments: RelatedDocument[];
} = {
document,
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
relatedDocuments,
};
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<DocViewer
document={vm.document}
relatedDocuments={vm.relatedDocuments}
widgetData={widgetData}
/>
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
const document = {
content: content,
description:
'A guide on how to configure Rspack on your Nx workspace, and instructions on how to customize your Rspack configuration.',
filePath: '',
id: 'rspack-plugins',
name: ' How to configure Rspack on your Nx workspace',
relatedDocuments: {},
tags: [],
};
return {
props: {
pkg,
document,
widgetData: {
githubStarsCount: await fetchGithubStarCount(),
},
relatedDocuments: [],
menu: menusApi.getMenu('nx-api', ''),
},
};
}

View File

@ -1,93 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { DocViewer } from '@nx/nx-dev/feature-doc-viewer';
import { ProcessedDocument, RelatedDocument } from '@nx/nx-dev/models-document';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { content } from '../../../../lib/rspack/content/rspack-plugin';
import { pkg } from '../../../../lib/rspack/pkg';
import { fetchGithubStarCount } from '../../../../lib/githubStars.api';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function RspackPlugins({
document,
menu,
relatedDocuments,
widgetData,
}: {
document: ProcessedDocument;
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
relatedDocuments: RelatedDocument[];
widgetData: { githubStarsCount: number };
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
document: ProcessedDocument;
menu: Menu;
relatedDocuments: RelatedDocument[];
} = {
document,
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
relatedDocuments,
};
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<DocViewer
document={vm.document}
relatedDocuments={vm.relatedDocuments}
widgetData={widgetData}
/>
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
const document = {
content: content,
description: 'Rspack plugins',
filePath: '',
id: 'rspack-plugins',
name: 'Rspack plugins',
relatedDocuments: {},
tags: [],
};
return {
props: {
pkg,
document,
widgetData: {
githubStarsCount: await fetchGithubStarCount(),
},
relatedDocuments: [],
menu: menusApi.getMenu('nx-api', ''),
},
};
}

View File

@ -1,79 +0,0 @@
import { PackageSchemaViewer } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import {
ProcessedPackageMetadata,
SchemaMetadata,
} from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { schema } from '../../../../lib/rspack/schema/executors/dev-server';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function DevServerExecutor({
menu,
pkg,
schema,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
schema: SchemaMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
menu: Menu;
package: ProcessedPackageMetadata;
schema: SchemaMetadata;
} = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
schema: schema,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaViewer pkg={vm.package} schema={vm.schema} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
pkg,
schema,
menu: menusApi.getMenu('nx-api', 'nx-api'),
},
};
}

View File

@ -1,72 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { PackageSchemaSubList } from '@nx/nx-dev/feature-package-schema-viewer/src/lib/package-schema-sub-list';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function ExecutorsIndex({
menu,
pkg,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: { menu: Menu; package: ProcessedPackageMetadata } = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaSubList pkg={vm.package} type={'executor'} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps(): Promise<{
props: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
};
}> {
return {
props: {
menu: menusApi.getMenu('nx-api', 'nx-api'),
pkg,
},
};
}

View File

@ -1,79 +0,0 @@
import { PackageSchemaViewer } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import {
ProcessedPackageMetadata,
SchemaMetadata,
} from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { schema } from '../../../../lib/rspack/schema/executors/rspack';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function RspackExecutor({
menu,
pkg,
schema,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
schema: SchemaMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
menu: Menu;
package: ProcessedPackageMetadata;
schema: SchemaMetadata;
} = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
schema: schema,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaViewer pkg={vm.package} schema={vm.schema} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
pkg,
schema,
menu: menusApi.getMenu('nx-api', 'nx-api'),
},
};
}

View File

@ -1,79 +0,0 @@
import { PackageSchemaViewer } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import {
ProcessedPackageMetadata,
SchemaMetadata,
} from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { schema } from '../../../../lib/rspack/schema/generators/application';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function ApplicationGenerator({
menu,
pkg,
schema,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
schema: SchemaMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
menu: Menu;
package: ProcessedPackageMetadata;
schema: SchemaMetadata;
} = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
schema: schema,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaViewer pkg={vm.package} schema={vm.schema} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
pkg,
schema,
menu: menusApi.getMenu('nx-api', 'nx-api'),
},
};
}

View File

@ -1,79 +0,0 @@
import { PackageSchemaViewer } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import {
ProcessedPackageMetadata,
SchemaMetadata,
} from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { schema } from '../../../../lib/rspack/schema/generators/configuration';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function ConfigurationGenerator({
menu,
pkg,
schema,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
schema: SchemaMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
menu: Menu;
package: ProcessedPackageMetadata;
schema: SchemaMetadata;
} = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
schema: schema,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaViewer pkg={vm.package} schema={vm.schema} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
pkg,
schema,
menu: menusApi.getMenu('nx-api', 'nx-api'),
},
};
}

View File

@ -1,72 +0,0 @@
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { PackageSchemaSubList } from '@nx/nx-dev/feature-package-schema-viewer/src/lib/package-schema-sub-list';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function GeneratorsIndex({
menu,
pkg,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: { menu: Menu; package: ProcessedPackageMetadata } = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaSubList pkg={vm.package} type={'generator'} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps(): Promise<{
props: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
};
}> {
return {
props: {
menu: menusApi.getMenu('nx-api', 'nx-api'),
pkg,
},
};
}

View File

@ -1,79 +0,0 @@
import { PackageSchemaViewer } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import {
ProcessedPackageMetadata,
SchemaMetadata,
} from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../../lib/menus.api';
import { useNavToggle } from '../../../../lib/navigation-toggle.effect';
import { schema } from '../../../../lib/rspack/schema/generators/init';
import { pkg } from '../../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function InitGenerator({
menu,
pkg,
schema,
}: {
menu: MenuItem[];
pkg: ProcessedPackageMetadata;
schema: SchemaMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: {
menu: Menu;
package: ProcessedPackageMetadata;
schema: SchemaMetadata;
} = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
schema: schema,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaViewer pkg={vm.package} schema={vm.schema} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
pkg,
schema,
menu: menusApi.getMenu('nx-api', 'nx-api'),
},
};
}

View File

@ -1,71 +0,0 @@
import { PackageSchemaList } from '@nx/nx-dev/feature-package-schema-viewer';
import { getPackagesSections } from '@nx/nx-dev/data-access-menu';
import { sortCorePackagesFirst } from '@nx/nx-dev/data-access-packages';
import { Menu, MenuItem, MenuSection } from '@nx/nx-dev/models-menu';
import { ProcessedPackageMetadata } from '@nx/nx-dev/models-package';
import { DocumentationHeader, SidebarContainer } from '@nx/nx-dev/ui-common';
import { menusApi } from '../../../lib/menus.api';
import { useNavToggle } from '../../../lib/navigation-toggle.effect';
import { content } from '../../../lib/rspack/content/overview';
import { pkg } from '../../../lib/rspack/pkg';
import { ScrollableContent } from '@nx/ui-scrollable-content';
export default function RspackIndex({
overview,
menu,
pkg,
}: {
menu: MenuItem[];
overview: string;
pkg: ProcessedPackageMetadata;
}): JSX.Element {
const { toggleNav, navIsOpen } = useNavToggle();
const vm: { menu: Menu; package: ProcessedPackageMetadata } = {
menu: {
sections: sortCorePackagesFirst<MenuSection>(
getPackagesSections(menu),
'id'
),
},
package: pkg,
};
/**
* Show either the docviewer or the package view depending on:
* - docviewer: it is a documentation document
* - packageviewer: it is package generated documentation
*/
return (
<div id="shell" className="flex h-full flex-col">
<div className="w-full flex-shrink-0">
<DocumentationHeader isNavOpen={navIsOpen} toggleNav={toggleNav} />
</div>
<main
id="main"
role="main"
className="flex h-full flex-1 overflow-y-hidden"
>
<SidebarContainer
menu={vm.menu}
navIsOpen={navIsOpen}
toggleNav={toggleNav}
/>
<ScrollableContent resetScrollOnNavigation={true}>
<PackageSchemaList pkg={vm.package} overview={overview} />
</ScrollableContent>
</main>
</div>
);
}
export async function getStaticProps() {
return {
props: {
menu: menusApi.getMenu('nx-api', 'nx-api'),
overview: content,
pkg,
},
};
}

View File

@ -6,7 +6,7 @@
"targets": {
"build": {
"outputs": ["{workspaceRoot}/build/packages/{projectName}/README.md"],
"command": "node ./scripts/copy-readme.js remix-legacy"
"command": "node ./scripts/copy-readme.js rspack-legacy"
},
"build-base": {
"executor": "@nrwl/js:tsc",

View File

@ -17,10 +17,6 @@ This package is a [Rspack plugin for Nx](https://nx.dev/nx-api/rspack).
{{content}}
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
<hr>

View File

@ -4,12 +4,12 @@
"rspack": {
"implementation": "./src/executors/rspack/rspack.impl",
"schema": "./src/executors/rspack/schema.json",
"description": "rspack executor"
"description": "Run Rspack via an executor for a project."
},
"dev-server": {
"implementation": "./src/executors/dev-server/dev-server.impl",
"schema": "./src/executors/dev-server/schema.json",
"description": "dev-server executor"
"description": "Run @rspack/dev-server to serve a project."
},
"ssr-dev-server": {
"implementation": "./src/executors/ssr-dev-server/ssr-dev-server.impl",

View File

@ -1,5 +1,6 @@
{
"name": "@nx/rspack",
"description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
"version": "0.0.1",
"type": "commonjs",
"repository": {

View File

@ -2,7 +2,7 @@
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Rspack dev-server executor",
"description": "",
"description": "Run @rspack/dev-server to serve a project.",
"type": "object",
"properties": {
"buildTarget": {
@ -16,11 +16,7 @@
"mode": {
"type": "string",
"description": "Mode to run the server in.",
"enum": [
"development",
"production",
"none"
]
"enum": ["development", "production", "none"]
},
"host": {
"type": "string",
@ -45,7 +41,5 @@
"description": "Public URL where the application will be served."
}
},
"required": [
"buildTarget"
]
"required": ["buildTarget"]
}

View File

@ -23,9 +23,7 @@
"type": "string"
}
},
"required": [
"remoteName"
],
"required": ["remoteName"],
"additionalProperties": false
}
]

View File

@ -75,8 +75,5 @@
"x-priority": "internal"
}
},
"required": [
"browserTarget",
"serverTarget"
]
"required": ["browserTarget", "serverTarget"]
}

View File

@ -2,16 +2,13 @@
"$schema": "http://json-schema.org/schema",
"version": 2,
"title": "Rspack build executor",
"description": "",
"description": "Run Rspack via an executor for a project.",
"type": "object",
"properties": {
"target": {
"type": "string",
"description": "The platform to target (e.g. web, node).",
"enum": [
"web",
"node"
]
"enum": ["web", "node"]
},
"main": {
"type": "string",
@ -122,34 +119,21 @@
}
},
"additionalProperties": false,
"required": [
"replace",
"with"
]
"required": ["replace", "with"]
},
"default": []
},
"mode": {
"type": "string",
"description": "Mode to run the build in.",
"enum": [
"development",
"production",
"none"
]
"enum": ["development", "production", "none"]
},
"generatePackageJson": {
"type": "boolean",
"description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated."
}
},
"required": [
"target",
"main",
"outputPath",
"tsConfig",
"rspackConfig"
],
"required": ["target", "main", "outputPath", "tsConfig", "rspackConfig"],
"definitions": {
"assetPattern": {
"oneOf": [
@ -182,11 +166,7 @@
}
},
"additionalProperties": false,
"required": [
"glob",
"input",
"output"
]
"required": ["glob", "input", "output"]
},
{
"type": "string"

View File

@ -32,8 +32,5 @@
"default": {}
}
},
"required": [
"browserTarget",
"serverTarget"
]
"required": ["browserTarget", "serverTarget"]
}

View File

@ -3,6 +3,7 @@
"$id": "Application",
"title": "Application generator for React + rspack",
"type": "object",
"description": "React + Rspack application generator.",
"examples": [
{
"command": "nx g app myapp --directory=myorg",

View File

@ -1,7 +1,8 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "Rspack",
"title": "",
"title": "Nx Rspack Configuration Generator",
"description": "Rspack configuration generator.",
"type": "object",
"properties": {
"project": {

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "Init",
"title": "",
"title": "Nx Rspack Init Generator",
"type": "object",
"description": "Rspack init generator.",
"properties": {
"framework": {
"type": "string",

View File

@ -2,6 +2,7 @@
"$schema": "http://json-schema.org/schema",
"$id": "Preset",
"title": "Standalone React and rspack preset",
"description": "React + Rspack preset generator.",
"type": "object",
"properties": {
"name": {