Skip to content

feat: implement rslib with TypeScript declaration generation #3883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d374fac
feat: rslib executor
ScriptedAlchemy May 16, 2025
4ee006b
Changes from background composer bc-20d504d2-2fd1-4b53-88c1-eeb10cd15ecc
cursoragent Jul 2, 2025
80ee7ad
Changes from background composer bc-20d504d2-2fd1-4b53-88c1-eeb10cd15ecc
cursoragent Jul 2, 2025
63f5b56
Changes from background composer bc-20d504d2-2fd1-4b53-88c1-eeb10cd15ecc
cursoragent Jul 2, 2025
e9e43e8
Changes from background composer bc-20d504d2-2fd1-4b53-88c1-eeb10cd15ecc
cursoragent Jul 2, 2025
03eb124
Changes from background composer bc-20d504d2-2fd1-4b53-88c1-eeb10cd15ecc
cursoragent Jul 2, 2025
cc4180a
feat: implement rslib with TypeScript declaration generation
ScriptedAlchemy Jul 3, 2025
66136d5
chore: remove unused publish.mjs script
ScriptedAlchemy Jul 3, 2025
8b89566
feat(runtime-core): migrate from rollup to rslib build system
ScriptedAlchemy Jul 4, 2025
fc3a1ef
fix: resolve dual package hazard by separating global type declarations
ScriptedAlchemy Jul 4, 2025
f5ce542
chore: implement partial next version detection
ScriptedAlchemy Jul 4, 2025
0b7845d
fix: update runtime-core to use rslib executor and proper configuration
ScriptedAlchemy Jul 4, 2025
db38602
fix: update pnpm-lock.yaml to include @rslib/core dependency
ScriptedAlchemy Jul 22, 2025
f43e47c
chore: merge main branch and resolve conflicts
ScriptedAlchemy Jul 22, 2025
8af6998
fix: resolve TypeScript errors in runtime package
ScriptedAlchemy Jul 22, 2025
b6a51df
fix: correct runtime-core exports and add bridge-react global types
ScriptedAlchemy Jul 22, 2025
bc8ce17
fix: resolve all build issues in PR #3883
ScriptedAlchemy Jul 22, 2025
07d31f8
chore: reverse chaneg to rslib module
ScriptedAlchemy Jul 22, 2025
bbb2f26
chore: update pnpm lockfile
ScriptedAlchemy Jul 22, 2025
058e603
fix: update rslib executor to use native API instead of process spawning
ScriptedAlchemy Jul 22, 2025
184e0cf
chore: executor
ScriptedAlchemy Jul 22, 2025
cabf9b3
feat: enhance rslib executor with rollup-equivalent options
ScriptedAlchemy Jul 22, 2025
bab6691
chore: update pnpm lockfile and build rslib plugin
ScriptedAlchemy Jul 22, 2025
232c673
Potential fix for code scanning alert no. 134: Incomplete string esca…
ScriptedAlchemy Jul 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions tools/rslib-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Rslib Nx Plugin

An Nx plugin that provides executors for building and developing with [Rslib](https://lib.rsbuild.dev/), a framework-agnostic library building solution.

## Executors

### Build (`rslib:build`)

Builds your library using Rslib.

**Options:**
- `configFile` (string): Path to the rslib config file (default: `rslib.config.ts`)
- `outputPath` (string): Output directory for build artifacts
- `watch` (boolean): Enable watch mode (default: `false`)
- `mode` (string): Build mode - `development` or `production` (default: `production`)
- `verbose` (boolean): Enable verbose logging (default: `false`)

**Example usage in `project.json`:**

```json
{
"targets": {
"build": {
"executor": "rslib:build",
"options": {
"configFile": "rslib.config.ts",
"mode": "production"
}
}
}
}
```

### Dev (`rslib:dev`)

Runs Rslib in development mode with hot reloading.

**Options:**
- `configFile` (string): Path to the rslib config file (default: `rslib.config.ts`)
- `port` (number): Port to serve on (default: `3001`)
- `host` (string): Host to serve on (default: `localhost`)
- `open` (boolean): Open browser after starting (default: `false`)
- `mode` (string): Development mode - `watch` or `mf-dev` (default: `mf-dev`)
- `verbose` (boolean): Enable verbose logging (default: `false`)

**Example usage in `project.json`:**

```json
{
"targets": {
"dev": {
"executor": "rslib:dev",
"options": {
"port": 3001,
"mode": "mf-dev",
"open": true
}
}
}
}
```

### Echo (`rslib:echo`)

Simple echo executor for testing the plugin.

**Options:**
- `message` (string): Message to echo (default: `"Hello from rslib executor!"`)

## Usage

To use this plugin in your Nx workspace:

1. Install the required dependencies:
```bash
npm install @rslib/core
```

2. Register the plugin in your `nx.json`:
```json
{
"plugins": ["tools/rslib-plugin"]
}
```

3. Configure your project's `project.json` to use the rslib executors:
```json
{
"targets": {
"build": {
"executor": "rslib:build"
},
"dev": {
"executor": "rslib:dev"
}
}
}
```

4. Create an `rslib.config.ts` file in your project root:
```typescript
import { defineConfig } from '@rslib/core';

export default defineConfig({
lib: [
{
format: 'esm',
dts: true,
},
{
format: 'cjs',
}
],
});
```

## Examples

### Building a library
```bash
nx run my-lib:build
```

### Running in development mode
```bash
nx run my-lib:dev
```

### Building with custom config
```bash
nx run my-lib:build --configFile=custom.rslib.config.ts
```

### Running in watch mode
```bash
nx run my-lib:dev --mode=watch
```

## Module Federation Support

This plugin supports Rslib's Module Federation capabilities. Use the `mf-dev` mode to run your federated modules:

```json
{
"targets": {
"mf-dev": {
"executor": "rslib:dev",
"options": {
"mode": "mf-dev",
"port": 3001
}
}
}
}
```

## Requirements

- Nx >= 21.0.0
- @rslib/core >= 0.5.0
- Node.js >= 18.0.0
26 changes: 26 additions & 0 deletions tools/rslib-plugin/dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@workspace/rslib-plugin",
"version": "0.1.0",
"description": "Nx plugin for Rslib",
"main": "./src/index.js",
"generators": "./generators.json",
"executors": "./executors.json",
"type": "commonjs",
"exports": {
"./package.json": "./package.json",
"./generators.json": "./generators.json",
"./executors.json": "./executors.json",
".": "./src/index.js"
},
"dependencies": {
"@nx/devkit": "^21.0.0",
"@rslib/core": "^0.10.4"
},
"devDependencies": {
"@types/node": "^20.0.0"
},
"peerDependencies": {
"@rslib/core": ">=0.10.0"
},
"types": "./tools/rslib-plugin/src/index.d.ts"
}
23 changes: 23 additions & 0 deletions tools/rslib-plugin/dist/src/executors/build/executor.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ExecutorContext } from '@nx/devkit';
export interface RslibBuildExecutorOptions {
configFile?: string;
outputPath?: string;
watch?: boolean;
mode?: 'development' | 'production';
verbose?: boolean;
main?: string;
additionalEntryPoints?: string[];
external?: string[];
format?: ('cjs' | 'esm' | 'umd' | 'iife')[];
tsConfig?: string;
assets?: (string | {
glob: string;
input: string;
output: string;
ignore?: string[];
})[];
project?: string;
}
export default function rslibBuildExecutor(options: RslibBuildExecutorOptions, context: ExecutorContext): Promise<{
success: boolean;
}>;
Loading