robuild 0.0.5 → 0.0.7
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/README.md +208 -41
- package/dist/_chunks/build-5gEwHBbl.mjs +2251 -0
- package/dist/_chunks/config-CeOzkcue.d.mts +492 -0
- package/dist/_chunks/package-DIjirV4E.mjs +83 -0
- package/dist/cli.mjs +142 -12
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -2
- package/dist/_chunks/build-eIjZ3Fk8.mjs +0 -388
- package/dist/_chunks/config-DxLkhDt6.d.mts +0 -99
package/README.md
CHANGED
|
@@ -8,48 +8,54 @@ English | <a href="./README-zh.md">简体中文</a>
|
|
|
8
8
|
|
|
9
9
|
⚡️ Zero-config ESM/TS package builder. Powered by [**oxc**](https://oxc.rs/), [**rolldown**](https://rolldown.rs/) and [**rolldown-plugin-dts**](https://github.com/sxzz/rolldown-plugin-dts).
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- 🌱 Fresh rewrite with cleanups and removal of legacy features.
|
|
13
|
-
- 🚀 Using [**oxc**](https://oxc.rs/) (for transform) and [**rolldown**](https://rolldown.rs/) (for bundle) for much faster builds!
|
|
11
|
+
## Features
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
⚡ **Fast**: Built on top of [rolldown](https://rolldown.rs/) and [oxc](https://oxc.rs/)
|
|
14
|
+
📦 **Zero config**: Works out of the box, configurable when needed
|
|
15
|
+
🎯 **TypeScript**: First-class TypeScript support with `.d.ts` generation
|
|
16
|
+
🔄 **Dual mode**: Bundle or transform your source code
|
|
17
|
+
🚀 **Stub mode**: Lightning-fast development with file linking
|
|
18
|
+
🏢 **Enterprise**: Workspace support, package filtering, migration tools
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
> Features are incomplete, and API and output behavior may change between 0.x versions.
|
|
20
|
-
>
|
|
21
|
-
> Feedback and contributions are very welcome! If you'd like to make changes with more than a few lines of code, please open an issue first to discuss.
|
|
20
|
+
## Installation
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
```sh
|
|
23
|
+
npm install robuild
|
|
24
|
+
# or
|
|
25
|
+
pnpm add robuild
|
|
26
|
+
# or
|
|
27
|
+
yarn add robuild
|
|
28
|
+
```
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
## Quick Start
|
|
26
31
|
|
|
27
32
|
```sh
|
|
28
|
-
#
|
|
33
|
+
# Bundle your library
|
|
29
34
|
npx robuild ./src/index.ts
|
|
30
35
|
|
|
31
|
-
#
|
|
36
|
+
# Transform source files
|
|
32
37
|
npx robuild ./src/runtime/:./dist/runtime
|
|
33
|
-
```
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
# Watch mode for development
|
|
40
|
+
npx robuild ./src/index.ts --watch
|
|
41
|
+
```
|
|
36
42
|
|
|
37
|
-
|
|
43
|
+
## Usage
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
```sh
|
|
46
|
+
# Bundle your library
|
|
47
|
+
npx robuild ./src/index.ts
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
# Transform source files
|
|
50
|
+
npx robuild ./src/runtime/:./dist/runtime
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
entries: ['./src/index.ts'],
|
|
47
|
-
})
|
|
52
|
+
# Watch mode for development
|
|
53
|
+
npx robuild ./src/index.ts --watch
|
|
48
54
|
```
|
|
49
55
|
|
|
50
|
-
##
|
|
56
|
+
## Configuration
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
Create `build.config.ts` in your project root:
|
|
53
59
|
|
|
54
60
|
```js
|
|
55
61
|
import { defineConfig } from 'robuild'
|
|
@@ -58,33 +64,150 @@ export default defineConfig({
|
|
|
58
64
|
entries: [
|
|
59
65
|
{
|
|
60
66
|
type: 'bundle',
|
|
61
|
-
input:
|
|
62
|
-
|
|
63
|
-
// minify: false,
|
|
64
|
-
// stub: false,
|
|
65
|
-
// rolldown: {}, // https://rolldown.rs/reference/config-options
|
|
66
|
-
// dts: {}, // https://github.com/sxzz/rolldown-plugin-dts#options
|
|
67
|
+
input: './src/index.ts',
|
|
68
|
+
format: ['esm', 'cjs'],
|
|
67
69
|
},
|
|
68
70
|
{
|
|
69
71
|
type: 'transform',
|
|
70
72
|
input: './src/runtime',
|
|
71
73
|
outDir: './dist/runtime',
|
|
72
|
-
// minify: false,
|
|
73
|
-
// stub: false,
|
|
74
|
-
// oxc: {},
|
|
75
|
-
// resolve: {}
|
|
76
74
|
},
|
|
77
75
|
],
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Bundle Entry Options
|
|
80
|
+
|
|
81
|
+
| Option | Type | Description |
|
|
82
|
+
|--------|------|-------------|
|
|
83
|
+
| `input` | `string \| string[]` | Entry point(s) |
|
|
84
|
+
| `format` | `OutputFormat \| OutputFormat[]` | Output format(s): `esm`, `cjs`, `iife`, `umd` |
|
|
85
|
+
| `platform` | `Platform` | Target platform: `browser`, `node`, `neutral` |
|
|
86
|
+
| `globalName` | `string` | Global name for IIFE/UMD formats |
|
|
87
|
+
| `clean` | `boolean \| string[]` | Clean output directory |
|
|
88
|
+
| `env` | `Record<string, any>` | Environment variables to inject |
|
|
89
|
+
| `define` | `Record<string, string>` | Constants to define |
|
|
90
|
+
| `external` | `(string \| RegExp)[] \| function` | External dependencies |
|
|
91
|
+
| `noExternal` | `(string \| RegExp)[] \| function` | Force bundle dependencies |
|
|
92
|
+
| `outDir` | `string` | Output directory (default: `dist`) |
|
|
93
|
+
| `minify` | `boolean` | Minify output |
|
|
94
|
+
| `dts` | `boolean \| DtsOptions` | Generate TypeScript declarations |
|
|
95
|
+
|
|
96
|
+
## Advanced Features
|
|
97
|
+
|
|
98
|
+
### Multi-format Output
|
|
99
|
+
|
|
100
|
+
Build your library in multiple formats simultaneously:
|
|
101
|
+
|
|
102
|
+
**Supported Formats:**
|
|
103
|
+
- **ESM** (`.mjs`) - ES Modules for modern environments
|
|
104
|
+
- **CJS** (`.cjs`) - CommonJS for Node.js compatibility
|
|
105
|
+
- **IIFE** (`.js`) - Immediately Invoked Function Expression for browsers
|
|
106
|
+
- **UMD** (`.js`) - Universal Module Definition for maximum compatibility
|
|
107
|
+
|
|
108
|
+
**Output Structure:**
|
|
109
|
+
```
|
|
110
|
+
dist/
|
|
111
|
+
├── index.mjs # ESM format
|
|
112
|
+
├── index.d.mts # TypeScript declarations (ESM only)
|
|
113
|
+
├── index.cjs # CJS format
|
|
114
|
+
└── index.js # IIFE format
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Environment Variables & Constants
|
|
118
|
+
|
|
119
|
+
Inject environment variables and define constants at build time:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
export default defineConfig({
|
|
123
|
+
entries: [
|
|
124
|
+
{
|
|
125
|
+
type: 'bundle',
|
|
126
|
+
input: './src/index.ts',
|
|
127
|
+
env: {
|
|
128
|
+
VERSION: '1.0.0',
|
|
129
|
+
NODE_ENV: 'production'
|
|
130
|
+
},
|
|
131
|
+
define: {
|
|
132
|
+
__DEV__: 'false',
|
|
133
|
+
BUILD_MODE: '"production"'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
})
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
This replaces `process.env.VERSION` with `"1.0.0"` and `__DEV__` with `false` at compile time.
|
|
141
|
+
|
|
142
|
+
### External Dependencies
|
|
143
|
+
|
|
144
|
+
Control which dependencies are bundled or kept external:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
export default defineConfig({
|
|
148
|
+
entries: [
|
|
149
|
+
{
|
|
150
|
+
type: 'bundle',
|
|
151
|
+
input: './src/index.ts',
|
|
152
|
+
external: [
|
|
153
|
+
'lodash', // Keep lodash external
|
|
154
|
+
/^@types\//, // Keep all @types/* external
|
|
155
|
+
id => id.includes('node_modules') // Custom function
|
|
156
|
+
],
|
|
157
|
+
noExternal: [
|
|
158
|
+
'some-package' // Force bundle this package
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Watch Mode
|
|
166
|
+
|
|
167
|
+
For development, robuild provides a watch mode that automatically rebuilds your project when files change.
|
|
168
|
+
|
|
169
|
+
### CLI Usage
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
# Enable watch mode for any build
|
|
173
|
+
npx robuild ./src/index.ts --watch
|
|
174
|
+
|
|
175
|
+
# Watch mode with transform
|
|
176
|
+
npx robuild ./src/runtime/:./dist/runtime --watch
|
|
177
|
+
|
|
178
|
+
# Watch mode with custom working directory
|
|
179
|
+
npx robuild ./src/index.ts --watch --dir ./my-project
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Configuration
|
|
183
|
+
|
|
184
|
+
You can configure watch behavior in your `build.config.ts`:
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
import { defineConfig } from 'robuild'
|
|
188
|
+
|
|
189
|
+
export default defineConfig({
|
|
190
|
+
entries: ['./src/index.ts'],
|
|
191
|
+
watch: {
|
|
192
|
+
enabled: true, // Enable watch mode by default
|
|
193
|
+
include: ['src/**/*'], // Files to watch
|
|
194
|
+
exclude: ['**/*.test.ts'], // Files to ignore
|
|
195
|
+
delay: 100, // Rebuild delay in ms
|
|
196
|
+
ignoreInitial: false, // Skip initial build
|
|
197
|
+
watchNewFiles: true, // Watch for new files
|
|
84
198
|
},
|
|
85
199
|
})
|
|
86
200
|
```
|
|
87
201
|
|
|
202
|
+
### Features
|
|
203
|
+
|
|
204
|
+
- **Real-time rebuilding**: Automatically rebuilds when source files change
|
|
205
|
+
- **Smart file detection**: Automatically determines what files to watch based on your entries
|
|
206
|
+
- **Debounced rebuilds**: Configurable delay to prevent excessive rebuilds
|
|
207
|
+
- **Error recovery**: Continues watching even after build errors
|
|
208
|
+
- **Clear feedback**: Shows file changes and rebuild status
|
|
209
|
+
- **Graceful shutdown**: Clean exit with Ctrl+C
|
|
210
|
+
|
|
88
211
|
## Stub Mode
|
|
89
212
|
|
|
90
213
|
When working on a package locally, it can be tedious to rebuild or run the watch command every time.
|
|
@@ -107,6 +230,50 @@ You can use `stub: true` (per entry config) or the `--stub` CLI flag. In this mo
|
|
|
107
230
|
- Using [oxc-node](https://github.com/oxc-project/oxc-node) (`node --import @oxc-node/core/register`)
|
|
108
231
|
- Using [unloader](https://github.com/sxzz/unloader) (`node --import unloader/register`)
|
|
109
232
|
|
|
233
|
+
## Status
|
|
234
|
+
|
|
235
|
+
> [!IMPORTANT]
|
|
236
|
+
>
|
|
237
|
+
> This is a proof of concept. Features are incomplete, and API and output behavior may change between 0.x versions.
|
|
238
|
+
>
|
|
239
|
+
> Feedback and contributions are very welcome! If you'd like to make changes with more than a few lines of code, please open an issue first to discuss.
|
|
240
|
+
|
|
241
|
+
## 📚 Documentation
|
|
242
|
+
|
|
243
|
+
### 🎯 Guides
|
|
244
|
+
- [Getting Started](./docs/guide/getting-started.md) - Get up and running in 5 minutes
|
|
245
|
+
- [CLI Usage](./docs/guide/cli.md) - Complete command-line interface guide
|
|
246
|
+
- [Configuration](./docs/guide/configuration.md) - Detailed configuration reference
|
|
247
|
+
- [Build Modes](./docs/guide/build-modes.md) - Bundle vs Transform modes
|
|
248
|
+
- [Watch Mode](./docs/guide/watch-mode.md) - Real-time development builds
|
|
249
|
+
- [Stub Mode](./docs/guide/stub-mode.md) - Lightning-fast development mode
|
|
250
|
+
- [TypeScript](./docs/guide/typescript.md) - TypeScript best practices
|
|
251
|
+
- [ESM](./docs/guide/esm.md) - ES modules support
|
|
252
|
+
- [Performance](./docs/guide/performance.md) - Build performance optimization
|
|
253
|
+
|
|
254
|
+
### 🔧 Feature Guides
|
|
255
|
+
- [CLI & Config Enhancements](./docs/guide/cli-config-enhancements.md) - Multi-format output, platform targets, environment variables
|
|
256
|
+
- [Build Enhancements](./docs/guide/build-enhancements.md) - File copying, hashing, banner/footer, extensions
|
|
257
|
+
- [Development Experience](./docs/guide/dev-experience.md) - Success callbacks, watch optimization, Vite integration
|
|
258
|
+
|
|
259
|
+
### 🏢 Enterprise Features
|
|
260
|
+
- [Enterprise Features](./docs/guide/enterprise.md) - Workspace, filtering, exports, migration
|
|
261
|
+
- [Plugin System](./docs/guide/plugins.md) - Plugin development and usage
|
|
262
|
+
- [Advanced Build Options](./docs/guide/advanced-build.md) - Loaders, shims, CJS handling
|
|
263
|
+
- [Hooks](./docs/guide/hooks.md) - Build lifecycle hooks
|
|
264
|
+
|
|
265
|
+
### 📖 API Reference
|
|
266
|
+
- [API Overview](./docs/api/index.md) - Programmatic API overview
|
|
267
|
+
- [Configuration API](./docs/api/config.md) - Configuration options
|
|
268
|
+
- [CLI API](./docs/api/cli.md) - Command-line interface
|
|
269
|
+
- [Type Definitions](./docs/api/types.md) - TypeScript type definitions
|
|
270
|
+
|
|
271
|
+
### 🏗️ Architecture
|
|
272
|
+
- [Core Architecture](./docs/architecture/core.md) - robuild core design
|
|
273
|
+
- [Builders](./docs/architecture/builders.md) - Bundle and Transform builders
|
|
274
|
+
- [Plugin System](./docs/architecture/plugins.md) - Plugin architecture design
|
|
275
|
+
- [Performance](./docs/architecture/performance.md) - Performance optimization strategies
|
|
276
|
+
|
|
110
277
|
## Prior Arts
|
|
111
278
|
|
|
112
279
|
- [unbuild](https://github.com/unjs/unbuild): Stable solution based on rollup and [mkdist](https://github.com/unjs/mkdist).
|