bunup 0.1.28 → 0.1.29

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.
Files changed (2) hide show
  1. package/README.md +12 -515
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,8 +1,4 @@
1
- # Bunup
2
-
3
- A extremely fast, zero-config bundler for TypeScript & JavaScript, powered by [Bun](https://bun.sh) and [oxc](https://oxc.rs/).
4
-
5
- ![Demo](/demo.gif)
1
+ ![Og](https://bunup.arshadyaseen.com/og.png)
6
2
 
7
3
  ## Benchmarks
8
4
 
@@ -17,38 +13,18 @@ Bunup outperforms other popular bundlers by a significant margin:
17
13
 
18
14
  _Lower build time is better. Benchmark run on the same code with identical output formats._
19
15
 
20
- ## Table of Contents
16
+ ## Prerequisites
21
17
 
22
- 1. [Quick Start](#quick-start)
23
- 2. [Configuration](#configuration)
24
- - [Configuration File](#configuration-file)
25
- - [CLI Options](#cli-options)
26
- 3. [Entry Points](#entry-points)
27
- 4. [Output Formats](#output-formats)
28
- 5. [TypeScript Declarations](#typescript-declarations)
29
- 6. [External Dependencies](#external-dependencies)
30
- 7. [Code Splitting](#code-splitting)
31
- 8. [Minification](#minification)
32
- 9. [Watch Mode](#watch-mode)
33
- 10. [API Reference](#api-reference)
34
- 11. [Examples](#examples)
18
+ Bunup requires [Bun](https://bun.sh) to be installed on your system. Bun is a fast all-in-one JavaScript runtime that powers Bunup's exceptional performance. Without Bun, Bunup cannot execute as it leverages Bun's bundling capabilities and runtime environment.
19
+
20
+ To install Bun, please visit the [official Bun installation page](https://bun.sh/docs/installation).
35
21
 
36
22
  ## Quick Start
37
23
 
38
24
  ### Installation
39
25
 
40
26
  ```bash
41
- # Install bunup
42
27
  npm install --save-dev bunup
43
-
44
- # Or with yarn
45
- yarn add --dev bunup
46
-
47
- # Or with pnpm
48
- pnpm add --save-dev bunup
49
-
50
- # Or with bun
51
- bun add --dev bunup
52
28
  ```
53
29
 
54
30
  ### Basic Usage
@@ -65,7 +41,7 @@ export function greet(name: string): string {
65
41
  Bundle it with bunup:
66
42
 
67
43
  ```bash
68
- bunup --entry src/index.ts
44
+ bunup src/index.ts
69
45
  ```
70
46
 
71
47
  This will create a bundled output in the `dist` directory.
@@ -78,7 +54,7 @@ Add a build script to your `package.json`:
78
54
  {
79
55
  "name": "my-package",
80
56
  "scripts": {
81
- "build": "bunup --entry src/index.ts --format esm,cjs --dts"
57
+ "build": "bunup src/index.ts --format esm,cjs --dts"
82
58
  }
83
59
  }
84
60
  ```
@@ -105,491 +81,12 @@ export default defineConfig({
105
81
  });
106
82
  ```
107
83
 
108
- ## Configuration
109
-
110
- ### Configuration File
111
-
112
- Bunup supports configuration files in multiple formats:
113
-
114
- - `bunup.config.ts`
115
- - `bunup.config.js`
116
- - `bunup.config.mjs`
117
- - `bunup.config.cjs`
118
- - `bunup.config.json`
119
- - `bunup.config.jsonc`
120
-
121
- Example configuration:
122
-
123
- ```typescript
124
- import {defineConfig} from 'bunup';
125
-
126
- export default defineConfig({
127
- // Name for this build configuration (used in logs)
128
- name: 'my-library',
129
-
130
- // Entry points (can be an array or object)
131
- entry: ['src/index.ts', 'src/cli.ts'],
132
-
133
- // Output directory
134
- outDir: 'dist',
135
-
136
- // Output formats
137
- format: ['esm', 'cjs'],
138
-
139
- // TypeScript declaration generation
140
- dts: true,
141
-
142
- // Target environment
143
- target: 'node',
144
-
145
- // Minification options
146
- minify: true,
147
-
148
- // External dependencies
149
- external: ['react', 'react-dom'],
150
-
151
- // Clean output directory before build
152
- clean: true,
153
- });
154
- ```
155
-
156
- You can also export an array of configurations:
157
-
158
- ```typescript
159
- export default defineConfig([
160
- {
161
- name: 'node',
162
- entry: ['src/index.ts'],
163
- format: ['cjs'],
164
- target: 'node',
165
- },
166
- {
167
- name: 'browser',
168
- entry: ['src/index.ts'],
169
- format: ['esm', 'iife'],
170
- target: 'browser',
171
- },
172
- ]);
173
- ```
174
-
175
- ### CLI Options
176
-
177
- Bunup supports various command-line options:
178
-
179
- | Option | Alias | Description |
180
- | ----------------------- | ----- | ---------------------------------------------- |
181
- | `--entry <path>` | | Entry file path |
182
- | `--entry.<name> <path>` | | Named entry file path |
183
- | `--out-dir <dir>` | `-o` | Output directory |
184
- | `--format <formats>` | `-f` | Output formats (comma-separated: esm,cjs,iife) |
185
- | `--minify` | `-m` | Enable all minification options |
186
- | `--minify-whitespace` | `-mw` | Minify whitespace |
187
- | `--minify-identifiers` | `-mi` | Minify identifiers |
188
- | `--minify-syntax` | `-ms` | Minify syntax |
189
- | `--watch` | `-w` | Watch mode |
190
- | `--dts` | `-d` | Generate TypeScript declarations |
191
- | `--external <deps>` | `-e` | External dependencies (comma-separated) |
192
- | `--no-external <deps>` | `-ne` | Force include dependencies (comma-separated) |
193
- | `--target <target>` | `-t` | Target environment (node, browser, bun) |
194
- | `--clean` | `-c` | Clean output directory before build |
195
- | `--splitting` | `-s` | Enable code splitting |
196
- | `--name <name>` | `-n` | Name for this build configuration |
197
-
198
- Examples:
199
-
200
- ```bash
201
- # Basic usage
202
- bunup --entry src/index.ts
203
-
204
- # Multiple formats with TypeScript declarations
205
- bunup --entry src/index.ts --format esm,cjs --dts
206
-
207
- # Named entries
208
- bunup --entry.main src/index.ts --entry.cli src/cli.ts
209
-
210
- # Watch mode
211
- bunup --entry src/index.ts --watch
212
- ```
213
-
214
- ## Entry Points
215
-
216
- Bunup supports multiple ways to define entry points:
217
-
218
- ### Array of Paths
219
-
220
- ```typescript
221
- export default defineConfig({
222
- entry: ['src/index.ts', 'src/cli.ts'],
223
- });
224
- ```
225
-
226
- This will generate output files named after the input files (e.g., `index.js` and `cli.js`).
227
-
228
- ### Named Entries
229
-
230
- ```typescript
231
- export default defineConfig({
232
- entry: {
233
- main: 'src/index.ts',
234
- cli: 'src/cli.ts',
235
- utils: 'src/utils/index.ts',
236
- },
237
- });
238
- ```
239
-
240
- This will generate output files with the specified names (e.g., `main.js`, `cli.js`, and `utils.js`).
241
-
242
- ## Output Formats
243
-
244
- Bunup supports three output formats:
245
-
246
- - **esm**: ECMAScript modules (`.mjs` extension)
247
- - **cjs**: CommonJS modules (`.js` or `.cjs` extension)
248
- - **iife**: Immediately Invoked Function Expression (`.global.js` extension)
249
-
250
- ```typescript
251
- export default defineConfig({
252
- entry: ['src/index.ts'],
253
- format: ['esm', 'cjs', 'iife'],
254
- });
255
- ```
256
-
257
- The file extensions are determined automatically based on the format and your package.json `type` field:
258
-
259
- | Format | package.json type: "module" | package.json type: "commonjs" or unspecified |
260
- | ------ | --------------------------- | -------------------------------------------- |
261
- | esm | `.mjs` | `.mjs` |
262
- | cjs | `.cjs` | `.js` |
263
- | iife | `.global.js` | `.global.js` |
264
-
265
- ## TypeScript Declarations
266
-
267
- Bunup can generate TypeScript declaration files (`.d.ts`) for your code:
268
-
269
- ```typescript
270
- export default defineConfig({
271
- entry: ['src/index.ts'],
272
- dts: true,
273
- });
274
- ```
275
-
276
- For more control, you can specify custom entry points for declarations:
277
-
278
- ```typescript
279
- export default defineConfig({
280
- entry: ['src/index.ts', 'src/cli.ts'],
281
- dts: {
282
- entry: ['src/index.ts'], // Only generate declarations for index.ts
283
- },
284
- });
285
- ```
286
-
287
- Or use named entries:
288
-
289
- ```typescript
290
- export default defineConfig({
291
- entry: {
292
- main: 'src/index.ts',
293
- cli: 'src/cli.ts',
294
- },
295
- dts: {
296
- entry: {
297
- types: 'src/index.ts', // Generate types.d.ts from index.ts
298
- },
299
- },
300
- });
301
- ```
302
-
303
- You can also specify a custom tsconfig file for declaration generation:
304
-
305
- ```typescript
306
- export default defineConfig({
307
- entry: ['src/index.ts'],
308
- dts: true,
309
- preferredTsconfigPath: './tsconfig.build.json',
310
- });
311
- ```
312
-
313
- Declaration file extensions follow the same pattern as JavaScript files:
314
-
315
- | Format | package.json type: "module" | package.json type: "commonjs" or unspecified |
316
- | ------ | --------------------------- | -------------------------------------------- |
317
- | esm | `.d.mts` | `.d.mts` |
318
- | cjs | `.d.cts` | `.d.ts` |
319
- | iife | `.d.ts` | `.d.ts` |
84
+ ## Documentation
320
85
 
321
- ## External Dependencies
86
+ For complete documentation, visit [the full documentation](https://bunup.arshadyaseen.com/).
322
87
 
323
- By default, Bunup treats all dependencies from your `package.json` (`dependencies` and `peerDependencies`) as external. This means they won't be included in your bundle.
324
-
325
- You can explicitly mark additional packages as external:
326
-
327
- ```typescript
328
- export default defineConfig({
329
- entry: ['src/index.ts'],
330
- external: ['lodash', 'react', '@some/package'],
331
- });
332
- ```
88
+ ## Contributing
333
89
 
334
- You can also force include specific dependencies that would otherwise be external:
90
+ For guidelines on contributing, please read the [contributing guide](https://github.com/arshad-yaseen/bunup/blob/main/CONTRIBUTING.md).
335
91
 
336
- ```typescript
337
- export default defineConfig({
338
- entry: ['src/index.ts'],
339
- external: ['lodash'],
340
- noExternal: ['lodash/merge'], // Include lodash/merge even though lodash is external
341
- });
342
- ```
343
-
344
- Both `external` and `noExternal` support string patterns and regular expressions.
345
-
346
- ## Code Splitting
347
-
348
- Bunup supports code splitting for the ESM format:
349
-
350
- ```typescript
351
- export default defineConfig({
352
- entry: ['src/index.ts'],
353
- format: ['esm'],
354
- splitting: true, // Default is true for ESM
355
- });
356
- ```
357
-
358
- Code splitting is enabled by default for ESM format and disabled for CJS and IIFE formats. You can explicitly enable or disable it:
359
-
360
- ```typescript
361
- export default defineConfig({
362
- entry: ['src/index.ts'],
363
- format: ['esm', 'cjs'],
364
- splitting: false, // Disable code splitting for all formats
365
- });
366
- ```
367
-
368
- ## Minification
369
-
370
- Bunup provides several minification options:
371
-
372
- ```typescript
373
- export default defineConfig({
374
- entry: ['src/index.ts'],
375
-
376
- // Enable all minification options
377
- minify: true,
378
-
379
- // Or configure individual options
380
- minifyWhitespace: true,
381
- minifyIdentifiers: false,
382
- minifySyntax: true,
383
- });
384
- ```
385
-
386
- The `minify` option is a shorthand that enables all three specific options. If you set individual options, they take precedence over the `minify` setting.
387
-
388
- ## Watch Mode
389
-
390
- Bunup can watch your files for changes and rebuild automatically:
391
-
392
- ```typescript
393
- export default defineConfig({
394
- entry: ['src/index.ts'],
395
- watch: true,
396
- });
397
- ```
398
-
399
- Or use the CLI flag:
400
-
401
- ```bash
402
- bunup --entry src/index.ts --watch
403
- ```
404
-
405
- In watch mode, Bunup will monitor your source files and their dependencies, rebuilding only what's necessary when files change.
406
-
407
- ## API Reference
408
-
409
- ### BunupOptions
410
-
411
- The complete configuration options interface:
412
-
413
- ```typescript
414
- interface BunupOptions {
415
- /**
416
- * Name of the build configuration
417
- * Used for logging and identification purposes
418
- */
419
- name?: string;
420
-
421
- /**
422
- * Entry point files for the build
423
- * Can be an array of file paths or an object with named entries
424
- */
425
- entry: string[] | Record<string, string>;
426
-
427
- /**
428
- * Output directory for the bundled files
429
- * Defaults to 'dist'
430
- */
431
- outDir: string;
432
-
433
- /**
434
- * Output formats for the bundle
435
- * Can include 'esm', 'cjs', and/or 'iife'
436
- * Defaults to ['cjs']
437
- */
438
- format: ('esm' | 'cjs' | 'iife')[];
439
-
440
- /**
441
- * Whether to enable all minification options
442
- */
443
- minify?: boolean;
444
-
445
- /**
446
- * Whether to enable code splitting
447
- * Defaults to true for ESM format, false for CJS format
448
- */
449
- splitting?: boolean;
450
-
451
- /**
452
- * Whether to minify whitespace in the output
453
- */
454
- minifyWhitespace?: boolean;
455
-
456
- /**
457
- * Whether to minify identifiers in the output
458
- */
459
- minifyIdentifiers?: boolean;
460
-
461
- /**
462
- * Whether to minify syntax in the output
463
- */
464
- minifySyntax?: boolean;
465
-
466
- /**
467
- * Whether to watch for file changes and rebuild automatically
468
- */
469
- watch?: boolean;
470
-
471
- /**
472
- * Whether to generate TypeScript declaration files (.d.ts)
473
- * When set to true, generates declaration files for all entry points
474
- * Can also be configured with DtsOptions for more control
475
- */
476
- dts?:
477
- | boolean
478
- | {
479
- entry: string[] | Record<string, string>;
480
- };
481
-
482
- /**
483
- * Path to a preferred tsconfig.json file to use for declaration generation
484
- */
485
- preferredTsconfigPath?: string;
486
-
487
- /**
488
- * External packages that should not be bundled
489
- */
490
- external?: string[];
491
-
492
- /**
493
- * Packages that should be bundled even if they are in external
494
- */
495
- noExternal?: string[];
496
-
497
- /**
498
- * The target environment for the bundle
499
- * Can be 'browser', 'bun', 'node'
500
- * Defaults to 'node'
501
- */
502
- target?: 'browser' | 'bun' | 'node';
503
-
504
- /**
505
- * Whether to clean the output directory before building
506
- * Defaults to true
507
- */
508
- clean?: boolean;
509
- }
510
- ```
511
-
512
- ### Default Options
513
-
514
- ```typescript
515
- const DEFAULT_OPTIONS = {
516
- entry: [],
517
- format: ['cjs'],
518
- outDir: 'dist',
519
- minify: false,
520
- watch: false,
521
- dts: false,
522
- target: 'node',
523
- external: [],
524
- clean: true,
525
- };
526
- ```
527
-
528
- ## Examples
529
-
530
- ### Basic Library
531
-
532
- ```typescript
533
- // bunup.config.ts
534
- import {defineConfig} from 'bunup';
535
-
536
- export default defineConfig({
537
- entry: ['src/index.ts'],
538
- format: ['esm', 'cjs'],
539
- dts: true,
540
- });
541
- ```
542
-
543
- ### Multiple Entry Points
544
-
545
- ```typescript
546
- // bunup.config.ts
547
- import {defineConfig} from 'bunup';
548
-
549
- export default defineConfig({
550
- entry: {
551
- index: 'src/index.ts',
552
- cli: 'src/cli.ts',
553
- },
554
- format: ['esm', 'cjs'],
555
- dts: true,
556
- });
557
- ```
558
-
559
- ### Browser and Node Targets
560
-
561
- ```typescript
562
- // bunup.config.ts
563
- import {defineConfig} from 'bunup';
564
-
565
- export default defineConfig([
566
- {
567
- name: 'node',
568
- entry: ['src/index.ts'],
569
- format: ['cjs', 'esm'],
570
- target: 'node',
571
- outDir: 'dist/node',
572
- },
573
- {
574
- name: 'browser',
575
- entry: ['src/index.ts'],
576
- format: ['esm', 'iife'],
577
- target: 'browser',
578
- outDir: 'dist/browser',
579
- },
580
- ]);
581
- ```
582
-
583
- ### With Minification
584
-
585
- ```typescript
586
- // bunup.config.ts
587
- import {defineConfig} from 'bunup';
588
-
589
- export default defineConfig({
590
- entry: ['src/index.ts'],
591
- format: ['esm', 'cjs'],
592
- minify: true,
593
- dts: true,
594
- });
595
- ```
92
+ We welcome contributions from the community to enhance Bunup's capabilities and make it even more powerful. ❤️
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.1.28",
4
- "description": "A extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
3
+ "version": "0.1.29",
4
+ "description": "An extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
7
7
  "module": "./build/index.mjs",
@@ -42,6 +42,7 @@
42
42
  "type": "git",
43
43
  "url": "git+https://github.com/arshad-yaseen/bunup.git"
44
44
  },
45
+ "homepage": "https://bunup.arshadyaseen.com",
45
46
  "maintainers": [
46
47
  {
47
48
  "name": "Arshad Yaseen",