robuild 0.0.7 → 0.0.9
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
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
English | <a href="./README-zh.md">简体中文</a>
|
|
8
8
|
|
|
9
|
-
⚡️ Zero-config ESM/TS package builder. Powered by [**
|
|
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
11
|
## Features
|
|
12
12
|
|
|
@@ -76,203 +76,11 @@ export default defineConfig({
|
|
|
76
76
|
})
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
## Documentation
|
|
80
80
|
|
|
81
|
-
|
|
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 |
|
|
81
|
+
📖 **[Complete Documentation](https://sunny-117.github.io/robuild/)**
|
|
95
82
|
|
|
96
|
-
|
|
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
|
|
198
|
-
},
|
|
199
|
-
})
|
|
200
|
-
```
|
|
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
|
-
|
|
211
|
-
## Stub Mode
|
|
212
|
-
|
|
213
|
-
When working on a package locally, it can be tedious to rebuild or run the watch command every time.
|
|
214
|
-
|
|
215
|
-
You can use `stub: true` (per entry config) or the `--stub` CLI flag. In this mode, robuild skips the actual build and instead links the expected dist paths to the source files.
|
|
216
|
-
|
|
217
|
-
- For bundle entries, `.mjs` and `.d.mts` files re-export the source file.
|
|
218
|
-
- For transpile entries, src dir is symlinked to dist.
|
|
219
|
-
|
|
220
|
-
**Caveats:**
|
|
221
|
-
|
|
222
|
-
- You need a runtime that natively supports TypeScript. Deno, Bun, Vite, and Node.js (1)
|
|
223
|
-
- For transpile mode, you need to configure your bundler to resolve either `.ts` or `.mjs` extensions.
|
|
224
|
-
- For bundle mode, if you add a new entry or add/remove a `default` export, you need to run the stub build again.
|
|
225
|
-
|
|
226
|
-
(1) For Node.js, you have several options:
|
|
227
|
-
|
|
228
|
-
- Using `node --experimental-strip-types` (Available in [22.6](https://nodejs.org/en/blog/release/v22.6.0))
|
|
229
|
-
- Using [jiti](https://github.com/unjs/jiti) (`node --import jiti/register`)
|
|
230
|
-
- Using [oxc-node](https://github.com/oxc-project/oxc-node) (`node --import @oxc-node/core/register`)
|
|
231
|
-
- Using [unloader](https://github.com/sxzz/unloader) (`node --import unloader/register`)
|
|
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
|
|
83
|
+
Visit our documentation site for detailed guides, API reference, and examples.
|
|
276
84
|
|
|
277
85
|
## Prior Arts
|
|
278
86
|
|
|
@@ -215,7 +215,7 @@ function createGlobImportPlugin(options = {}) {
|
|
|
215
215
|
return {
|
|
216
216
|
name: "glob-import",
|
|
217
217
|
transform: async (code, id) => {
|
|
218
|
-
const globImportRegex = /import\.meta\.glob\s*\(\s*(['"`])(.*?)\1\s*(?:,\s*({[^}]
|
|
218
|
+
const globImportRegex = /import\.meta\.glob\s*\(\s*(['"`])(.*?)\1\s*(?:,\s*(\{[^}]*\})\s*)?\)/g;
|
|
219
219
|
let match;
|
|
220
220
|
let hasGlobImports = false;
|
|
221
221
|
let transformedCode = code;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region package.json
|
|
2
2
|
var name = "robuild";
|
|
3
3
|
var type = "module";
|
|
4
|
-
var version = "0.0.
|
|
4
|
+
var version = "0.0.9";
|
|
5
5
|
var packageManager = "pnpm@10.11.1";
|
|
6
6
|
var description = "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc";
|
|
7
7
|
var license = "MIT";
|
|
@@ -31,7 +31,8 @@ var scripts = {
|
|
|
31
31
|
};
|
|
32
32
|
var dependencies = {
|
|
33
33
|
"c12": "^3.0.4",
|
|
34
|
-
"
|
|
34
|
+
"cac": "^6.7.14",
|
|
35
|
+
"chokidar": "^3.0.3",
|
|
35
36
|
"consola": "^3.4.2",
|
|
36
37
|
"defu": "^6.1.4",
|
|
37
38
|
"exsolve": "^1.0.5",
|
package/dist/cli.mjs
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robuild",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"packageManager": "pnpm@10.11.1",
|
|
6
6
|
"description": "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"c12": "^3.0.4",
|
|
36
|
-
"
|
|
36
|
+
"cac": "^6.7.14",
|
|
37
|
+
"chokidar": "^3.0.3",
|
|
37
38
|
"consola": "^3.4.2",
|
|
38
39
|
"defu": "^6.1.4",
|
|
39
40
|
"exsolve": "^1.0.5",
|