robuild 0.0.6 → 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 CHANGED
@@ -8,51 +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
- - 👌 Focus on ESM compatibility.
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
- ## Proof of concept
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
- > [!IMPORTANT]
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
- ## Usage
22
+ ```sh
23
+ npm install robuild
24
+ # or
25
+ pnpm add robuild
26
+ # or
27
+ yarn add robuild
28
+ ```
24
29
 
25
- ### CLI
30
+ ## Quick Start
26
31
 
27
32
  ```sh
28
- # bundle
33
+ # Bundle your library
29
34
  npx robuild ./src/index.ts
30
35
 
31
- # transform
36
+ # Transform source files
32
37
  npx robuild ./src/runtime/:./dist/runtime
33
38
 
34
- # watch mode - rebuild on file changes
39
+ # Watch mode for development
35
40
  npx robuild ./src/index.ts --watch
36
41
  ```
37
42
 
38
- You can use `--dir` to set the working directory and `--watch` to enable watch mode.
39
-
40
- If paths end with `/`, robuild uses transpile mode using [oxc-transform](https://www.npmjs.com/package/oxc-transform) instead of bundle mode with [rolldown](https://rolldown.rs/).
43
+ ## Usage
41
44
 
42
- ### Programmatic
45
+ ```sh
46
+ # Bundle your library
47
+ npx robuild ./src/index.ts
43
48
 
44
- ```js
45
- import { build } from 'robuild'
49
+ # Transform source files
50
+ npx robuild ./src/runtime/:./dist/runtime
46
51
 
47
- await build({
48
- cwd: '.',
49
- entries: ['./src/index.ts'],
50
- })
52
+ # Watch mode for development
53
+ npx robuild ./src/index.ts --watch
51
54
  ```
52
55
 
53
- ## Config
56
+ ## Configuration
54
57
 
55
- You can use `build.config.mjs` (or `.ts`) or pass config to `build()` function.
58
+ Create `build.config.ts` in your project root:
56
59
 
57
60
  ```js
58
61
  import { defineConfig } from 'robuild'
@@ -61,30 +64,101 @@ export default defineConfig({
61
64
  entries: [
62
65
  {
63
66
  type: 'bundle',
64
- input: ['./src/index.ts', './src/cli.ts'],
65
- // outDir: "./dist",
66
- // minify: false,
67
- // stub: false,
68
- // rolldown: {}, // https://rolldown.rs/reference/config-options
69
- // dts: {}, // https://github.com/sxzz/rolldown-plugin-dts#options
67
+ input: './src/index.ts',
68
+ format: ['esm', 'cjs'],
70
69
  },
71
70
  {
72
71
  type: 'transform',
73
72
  input: './src/runtime',
74
73
  outDir: './dist/runtime',
75
- // minify: false,
76
- // stub: false,
77
- // oxc: {},
78
- // resolve: {}
79
74
  },
80
75
  ],
81
- hooks: {
82
- // start: (ctx) => {},
83
- // end: (ctx) => {},
84
- // entries: (entries, ctx) => {},
85
- // rolldownConfig: (config, ctx) => {},
86
- // rolldownOutput: (output, res, ctx) => {},
87
- },
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
+ ]
88
162
  })
89
163
  ```
90
164
 
@@ -156,6 +230,50 @@ You can use `stub: true` (per entry config) or the `--stub` CLI flag. In this mo
156
230
  - Using [oxc-node](https://github.com/oxc-project/oxc-node) (`node --import @oxc-node/core/register`)
157
231
  - Using [unloader](https://github.com/sxzz/unloader) (`node --import unloader/register`)
158
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
+
159
277
  ## Prior Arts
160
278
 
161
279
  - [unbuild](https://github.com/unjs/unbuild): Stable solution based on rollup and [mkdist](https://github.com/unjs/mkdist).