feat(bundler): Introduce rspack bundler support and update multi-bundler workflow

This commit is contained in:
Juergen Kunz
2025-06-19 20:37:21 +00:00
parent 2bc219e3bc
commit a4b6956072
12 changed files with 539 additions and 24 deletions

View File

@ -6,10 +6,11 @@
- The main class `TsBundle` spawns child processes using `smartspawn.ThreadSimple`
## Bundler Implementations
- **esbuild** (default): Fully implemented, production ready
- **rolldown**: Implemented and working (beta), produces smaller bundles than esbuild
- **rollup**: Empty module directory exists but not implemented
- **parcel**: Empty module directory exists but not implemented
- **esbuild** (default): Fully implemented, production ready, 2.2K minified
- **rolldown**: Implemented and working (beta), produces smallest bundles (1.5K minified)
- **rspack**: Implemented and working, webpack-compatible API, 6.1K minified
- **rollup**: Removed (was never implemented)
- **parcel**: Removed (was never implemented)
## Adding New Bundlers
To add a new bundler, you need:
@ -24,12 +25,22 @@ To add a new bundler, you need:
- Rolldown is in beta (v1.0.0-beta.18) but working well
- API: Use `rolldown()` function directly, not `rolldown.rolldown()`
- Output options go in the `write()` method, not the initial config
- Uses `dir` and `entryFileNames` instead of `file` for output (handles dynamic imports)
- Includes `inlineDynamicImports: true` to avoid chunk splitting issues
- Produces smaller minified bundles than esbuild (1.5K vs 2.2K in tests)
- Supports TypeScript via `resolve.tsconfigFilename`
## Rspack Specific Notes
- Rspack v1.3.15 - stable and production ready
- Uses webpack-compatible API (callback-based)
- Built-in SWC loader for TypeScript transpilation
- Produces larger bundles than esbuild/rolldown due to webpack runtime overhead
- Best choice if you need webpack compatibility or advanced features
- Supports ES modules output via `experiments.outputModule: true`
## CLI Usage
- Default bundler: `tsbundle`
- Specify bundler: `tsbundle --bundler=rolldown`
- Default bundler: `tsbundle` (uses esbuild)
- Specify bundler: `tsbundle --bundler=rolldown` or `tsbundle --bundler=rspack`
- Production mode: `tsbundle --production`
- Combined: `tsbundle --bundler=rolldown --production`