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 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 [**oxc**](https://oxc.rs/), [**rolldown**](https://rolldown.rs/) and [**rolldown-plugin-dts**](https://github.com/sxzz/rolldown-plugin-dts).
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,100 +64,23 @@ 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
- },
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
- ### Features
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
- (1) For Node.js, you have several options:
81
+ 📖 **[Complete Documentation](https://sunny-117.github.io/robuild/)**
153
82
 
154
- - Using `node --experimental-strip-types` (Available in [22.6](https://nodejs.org/en/blog/release/v22.6.0))
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