Skip to content

Commit 7d26b19

Browse files
authored
feat: update options and improve build logic (#20)
* feat: update options and improve build logic * refactor: add parse output path util * types: update main options and entries types * refactor: improve build fn * docs: update info
1 parent 847ddd7 commit 7d26b19

File tree

8 files changed

+246
-253
lines changed

8 files changed

+246
-253
lines changed

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,32 @@ npx hyperbundler --config hyper.config.ts
105105

106106
## Formats
107107

108-
During transformation, file formats are automatically resolved and in most cases there is no need for additional configuration.
108+
During transformation, file formats are automatically resolved, and in most cases, no additional configuration is required.
109109

110-
`Hyperbundler` module environment for generated files defaults to `esm`, which means the outputs will have a `.mjs` extension unless otherwise specified. For TypeScript declarations, the appropriate extension will be `.d.mts`.
110+
The default module environment for generated files is `esm`, which means output files will have a `.mjs` extension unless otherwise specified. For TypeScript declarations, the corresponding extension will be `.d.mts`.
111111

112-
Formats can also be explicitly specified for each entry, if necessary.
112+
Formats can also be explicitly specified for each entry, if needed.
113113

114114
### Inputs
115115

116-
Default transformation behaviour for all `chunk` entries:
116+
Default transformation behavior for all `chunk` entries:
117117

118-
- `./srcDir/file.js` resolves to `./outDir/file.mjs`
119-
- `./srcDir/file.mjs` resolves to `./outDir/file.mjs`
120-
- `./srcDir/file.cjs` resolves to `./outDir/file.cjs`
121-
- `./srcDir/file.ts` resolves to `./outDir/file.mjs`
122-
- `./srcDir/file.mts` resolves to `./outDir/file.mjs`
123-
- `./srcDir/file.cts` resolves to `./outDir/file.cjs`
118+
- `./srcDir/file.js` `./outDir/file.mjs`
119+
- `./srcDir/file.mjs` `./outDir/file.mjs`
120+
- `./srcDir/file.cjs` `./outDir/file.cjs`
121+
- `./srcDir/file.ts` `./outDir/file.mjs`
122+
- `./srcDir/file.mts` `./outDir/file.mjs`
123+
- `./srcDir/file.cts` `./outDir/file.cjs`
124124

125125
### Declarations
126126

127-
Default transformation behaviour for all `dts` entries:
127+
Default transformation behavior for all `dts` entries:
128128

129-
- `./srcDir/file.ts` resolves to `./outDir/file.d.mts`
129+
- `./srcDir/file.ts` `./outDir/file.d.mts`
130130

131131
## Options
132132

133-
All options are documented with descriptions and examples so autocompletion will be offered as you type. Simply hover over the property and see what it does in the quick info tooltip.
133+
All options come with descriptions and examples. As you type, you’ll get suggestions and can see quick info by hovering over any property.
134134

135135
### entries
136136

@@ -247,7 +247,7 @@ export default defineConfig({
247247

248248
### outDir
249249

250-
- Type: `string`
250+
- Type: `string | undefined`
251251
- Default: `dist`
252252

253253
Specifies the output directory for production bundle.
@@ -258,14 +258,14 @@ Specifies the output directory for production bundle.
258258
import { defineConfig } from '@hypernym/bundler'
259259

260260
export default defineConfig({
261-
outDir: 'output',
261+
outDir: './output',
262262
})
263263
```
264264

265265
### externals
266266

267-
- Type: `(string | RegExp)[]`
268-
- Default: `[/^node:/, /^@types/, /^@rollup/, /^@hypernym/, /^rollup/, ...pkg.dependencies]`
267+
- Type: `(string | RegExp)[] | undefined`
268+
- Default: `[/^node:/, /^@types/, /^@rollup/, /^@rolldown/, /^@hypernym/, /^rollup/, /^rolldown/, ...pkg.dependencies]`
269269

270270
Specifies the module IDs or regular expressions that match module IDs to be treated as external and excluded from the bundle.
271271

@@ -296,10 +296,15 @@ export default defineConfig({
296296

297297
### minify
298298

299-
- Type: `boolean`
299+
- Type: `boolean | 'dce-only' | MinifyOptions | undefined`
300300
- Default: `undefined`
301301

302-
Specifies the minification for all `chunk` entries.
302+
Controls code minification for all `chunk` entries.
303+
304+
- `true`: Enable full minification including code compression and dead code elimination.
305+
- `false`: Disable minification (default).
306+
- `'dce-only'`: Only perform dead code elimination without code compression.
307+
- `MinifyOptions`: Fine-grained control over minification settings.
303308

304309
```ts
305310
// bundler.config.ts
@@ -339,7 +344,7 @@ List of lifecycle hooks that are called at various phases:
339344

340345
### bundle:start
341346

342-
- Type: `(options: Options) => void | Promise<void>`
347+
- Type: `(options: Options) => void | Promise<void> | undefined`
343348
- Default: `undefined`
344349

345350
Called at the beginning of bundling.
@@ -360,7 +365,7 @@ export default defineConfig({
360365

361366
### build:start
362367

363-
- Type: `(options: Options, stats: BuildStats) => void | Promise<void>`
368+
- Type: `(options: Options, stats: BuildStats) => void | Promise<void> | undefined`
364369
- Default: `undefined`
365370

366371
Called at the beginning of building.
@@ -381,7 +386,7 @@ export default defineConfig({
381386

382387
### build:entry:start
383388

384-
- Type: `(entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>`
389+
- Type: `(entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void> | undefined`
385390
- Default: `undefined`
386391

387392
Called on each entry just before the build process.
@@ -405,7 +410,7 @@ export default defineConfig({
405410

406411
### build:entry:end
407412

408-
- Type: `(entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>`
413+
- Type: `(entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void> | undefined`
409414
- Default: `undefined`
410415

411416
Called on each entry right after the build process is completed.
@@ -426,7 +431,7 @@ export default defineConfig({
426431

427432
### build:end
428433

429-
- Type: `(options: Options, stats: BuildStats) => void | Promise<void>`
434+
- Type: `(options: Options, stats: BuildStats) => void | Promise<void> | undefined`
430435
- Default: `undefined`
431436

432437
Called right after building is complete.
@@ -447,7 +452,7 @@ export default defineConfig({
447452

448453
### bundle:end
449454

450-
- Type: `(options: Options) => void | Promise<void>`
455+
- Type: `(options: Options) => void | Promise<void> | undefined`
451456
- Default: `undefined`
452457

453458
Called right after bundling is complete.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
"@hypernym/args": "^0.3.3",
6666
"@hypernym/colors": "^1.0.5",
6767
"@hypernym/utils": "^3.4.5",
68-
"rolldown": "1.0.0-beta.32",
69-
"rolldown-plugin-dts": "^0.15.7"
68+
"rolldown": "^1.0.0-beta.34",
69+
"rolldown-plugin-dts": "^0.15.9"
7070
},
7171
"devDependencies": {
7272
"@hypernym/eslint-config": "^3.6.3",

0 commit comments

Comments
 (0)