robuild 0.0.6 → 0.0.8
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 +35 -109
- package/dist/_chunks/build-CHtyq9DQ.mjs +2283 -0
- package/dist/_chunks/config-CeOzkcue.d.mts +492 -0
- package/dist/_chunks/package-DgQX21eh.mjs +84 -0
- package/dist/cli.mjs +134 -13
- 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-DuPhfTzX.mjs +0 -563
- package/dist/_chunks/config-BZW4dLYD.d.mts +0 -138
package/README.md
CHANGED
|
@@ -6,53 +6,56 @@
|
|
|
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
|
-
|
|
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
38
|
|
|
34
|
-
#
|
|
39
|
+
# Watch mode for development
|
|
35
40
|
npx robuild ./src/index.ts --watch
|
|
36
41
|
```
|
|
37
42
|
|
|
38
|
-
|
|
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
|
-
|
|
45
|
+
```sh
|
|
46
|
+
# Bundle your library
|
|
47
|
+
npx robuild ./src/index.ts
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
# Transform source files
|
|
50
|
+
npx robuild ./src/runtime/:./dist/runtime
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
entries: ['./src/index.ts'],
|
|
50
|
-
})
|
|
52
|
+
# Watch mode for development
|
|
53
|
+
npx robuild ./src/index.ts --watch
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
##
|
|
56
|
+
## Configuration
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
Create `build.config.ts` in your project root:
|
|
56
59
|
|
|
57
60
|
```js
|
|
58
61
|
import { defineConfig } from 'robuild'
|
|
@@ -61,100 +64,23 @@ export default defineConfig({
|
|
|
61
64
|
entries: [
|
|
62
65
|
{
|
|
63
66
|
type: 'bundle',
|
|
64
|
-
input:
|
|
65
|
-
|
|
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
|
-
},
|
|
88
|
-
})
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Watch Mode
|
|
92
|
-
|
|
93
|
-
For development, robuild provides a watch mode that automatically rebuilds your project when files change.
|
|
94
|
-
|
|
95
|
-
### CLI Usage
|
|
96
|
-
|
|
97
|
-
```sh
|
|
98
|
-
# Enable watch mode for any build
|
|
99
|
-
npx robuild ./src/index.ts --watch
|
|
100
|
-
|
|
101
|
-
# Watch mode with transform
|
|
102
|
-
npx robuild ./src/runtime/:./dist/runtime --watch
|
|
103
|
-
|
|
104
|
-
# Watch mode with custom working directory
|
|
105
|
-
npx robuild ./src/index.ts --watch --dir ./my-project
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Configuration
|
|
109
|
-
|
|
110
|
-
You can configure watch behavior in your `build.config.ts`:
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
import { defineConfig } from 'robuild'
|
|
114
|
-
|
|
115
|
-
export default defineConfig({
|
|
116
|
-
entries: ['./src/index.ts'],
|
|
117
|
-
watch: {
|
|
118
|
-
enabled: true, // Enable watch mode by default
|
|
119
|
-
include: ['src/**/*'], // Files to watch
|
|
120
|
-
exclude: ['**/*.test.ts'], // Files to ignore
|
|
121
|
-
delay: 100, // Rebuild delay in ms
|
|
122
|
-
ignoreInitial: false, // Skip initial build
|
|
123
|
-
watchNewFiles: true, // Watch for new files
|
|
124
|
-
},
|
|
125
76
|
})
|
|
126
77
|
```
|
|
127
78
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
- **Real-time rebuilding**: Automatically rebuilds when source files change
|
|
131
|
-
- **Smart file detection**: Automatically determines what files to watch based on your entries
|
|
132
|
-
- **Debounced rebuilds**: Configurable delay to prevent excessive rebuilds
|
|
133
|
-
- **Error recovery**: Continues watching even after build errors
|
|
134
|
-
- **Clear feedback**: Shows file changes and rebuild status
|
|
135
|
-
- **Graceful shutdown**: Clean exit with Ctrl+C
|
|
136
|
-
|
|
137
|
-
## Stub Mode
|
|
138
|
-
|
|
139
|
-
When working on a package locally, it can be tedious to rebuild or run the watch command every time.
|
|
140
|
-
|
|
141
|
-
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.
|
|
142
|
-
|
|
143
|
-
- For bundle entries, `.mjs` and `.d.mts` files re-export the source file.
|
|
144
|
-
- For transpile entries, src dir is symlinked to dist.
|
|
145
|
-
|
|
146
|
-
**Caveats:**
|
|
147
|
-
|
|
148
|
-
- You need a runtime that natively supports TypeScript. Deno, Bun, Vite, and Node.js (1)
|
|
149
|
-
- For transpile mode, you need to configure your bundler to resolve either `.ts` or `.mjs` extensions.
|
|
150
|
-
- For bundle mode, if you add a new entry or add/remove a `default` export, you need to run the stub build again.
|
|
79
|
+
## Documentation
|
|
151
80
|
|
|
152
|
-
|
|
81
|
+
📖 **[Complete Documentation](https://sunny-117.github.io/robuild/)**
|
|
153
82
|
|
|
154
|
-
|
|
155
|
-
- Using [jiti](https://github.com/unjs/jiti) (`node --import jiti/register`)
|
|
156
|
-
- Using [oxc-node](https://github.com/oxc-project/oxc-node) (`node --import @oxc-node/core/register`)
|
|
157
|
-
- Using [unloader](https://github.com/sxzz/unloader) (`node --import unloader/register`)
|
|
83
|
+
Visit our documentation site for detailed guides, API reference, and examples.
|
|
158
84
|
|
|
159
85
|
## Prior Arts
|
|
160
86
|
|