@hypernym/bundler 0.12.0 → 0.13.0

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
@@ -36,10 +36,6 @@
36
36
 
37
37
  1. Create a `bundler.config.ts` file at the root of your project:
38
38
 
39
- > [!NOTE]
40
- >
41
- > Configuration also accepts `.js`, `.mjs`, `.ts`, `.mts` formats.
42
-
43
39
  ```ts
44
40
  // bundler.config.ts
45
41
 
@@ -66,9 +62,7 @@ export default defineConfig({
66
62
  {
67
63
  input: './src/utils/index.ts',
68
64
  output: './dist/utils/utils.min.mjs',
69
- transformers: {
70
- esbuild: { minify: true },
71
- },
65
+ minify: true,
72
66
  },
73
67
  // ...
74
68
  ],
@@ -81,35 +75,33 @@ export default defineConfig({
81
75
  npx hyperbundler
82
76
  ```
83
77
 
84
- <details>
85
- <summary>CLI Output</summary>
78
+ ## Config
86
79
 
87
- <br>
88
- <p>Example of CLI Output:</p>
89
-
90
- ```txt
91
- ┌─────────────────┐
92
- ✦✦ HYPERBUNDLER │ v0.11.0
93
- └─────────────────┘
94
- i Config bundler.config.ts
95
- i Bundling started...
96
- * Processing [8:07:26 PM] Transforming files
97
-
98
- ├─ + esm ./dist/index.mjs (50ms) 313 B
99
- ├─ + dts ./dist/types/index.d.ts (1.23s) 13.61 KB
100
- ├─ + esm ./dist/bin/index.mjs (119ms) 16.53 KB
101
-
102
- * Succeeded [8:07:28 PM] Module transformation is done
103
- ✔ Bundling fully completed in 1.40s
104
- ✔ 3 modules transformed. Total size is 30.45 KB
105
- ✦✦ HYPERBUNDLER [8:07:28 PM] Bundle is generated and ready for production
80
+ `Hyperbundler` automatically detects custom configuration from the project root that can override or extend the build behavior.
81
+
82
+ Configuration file also accepts `.js`, `.mjs`, `.ts`, `.mts` formats.
83
+
84
+ ```ts
85
+ // bundler.config.{js,mjs,ts,mts}
86
+
87
+ import { defineConfig } from '@hypernym/bundler'
88
+
89
+ export default defineConfig({
90
+ // ...
91
+ })
106
92
  ```
107
93
 
108
- </details>
94
+ ### Custom path
95
+
96
+ Set a custom config path via the CLI command:
97
+
98
+ ```sh
99
+ npx hyperbundler --config hyper.config.ts
100
+ ```
109
101
 
110
102
  ## Options
111
103
 
112
- All options are documented with descriptions and examples, and auto-completion will be offered as you type.
104
+ All options are documented with descriptions and examples so auto-completion will be offered as you type.
113
105
 
114
106
  Simply hover over the property and see what it does in the `quickinfo`.
115
107
 
@@ -294,6 +286,36 @@ Now imports can be used like this:
294
286
  import { module } from '#/utils' // #
295
287
  ```
296
288
 
289
+ ### minify
290
+
291
+ - Type: `boolean`
292
+ - Default: `undefined`
293
+
294
+ Specifies the minification for all `chunk` entries.
295
+
296
+ ```ts
297
+ // bundler.config.ts
298
+
299
+ import { defineConfig } from '@hypernym/bundler'
300
+
301
+ export default defineConfig({
302
+ minify: true,
303
+ })
304
+ ```
305
+
306
+ It can also be set per entry.
307
+
308
+ ```ts
309
+ export default defineConfig({
310
+ entries: [
311
+ {
312
+ input: './src/index.ts',
313
+ minify: true,
314
+ },
315
+ ],
316
+ })
317
+ ```
318
+
297
319
  ## Hooks
298
320
 
299
321
  List of lifecycle hooks that are called at various phases:
@@ -468,16 +490,6 @@ export default defineConfig({
468
490
  })
469
491
  ```
470
492
 
471
- ## CLI
472
-
473
- ### Custom Config
474
-
475
- Set a custom config path via the CLI command:
476
-
477
- ```sh
478
- npx hyperbundler --config hyper.config.ts
479
- ```
480
-
481
493
  ## Community
482
494
 
483
495
  Feel free to ask questions or share new ideas.
@@ -6,7 +6,7 @@ import { read, exists, write, copy, readdir } from '@hypernym/utils/fs';
6
6
  import { dim, cyan, bold, green } from '@hypernym/colors';
7
7
  import { build as build$1, transform } from 'esbuild';
8
8
  import { stat } from 'node:fs/promises';
9
- import { isString, isObject } from '@hypernym/utils';
9
+ import { isString, isUndefined, isObject } from '@hypernym/utils';
10
10
  import { rollup } from 'rollup';
11
11
  import { getLogFilter } from 'rollup/getLogFilter';
12
12
  import replacePlugin from '@rollup/plugin-replace';
@@ -27,7 +27,7 @@ const externals = [
27
27
  const logo = `\u2726\u2726`;
28
28
  const name$1 = "hyperbundler";
29
29
  const logoname = `${logo} ${name$1}`;
30
- const version = `0.12.0`;
30
+ const version = `0.13.0`;
31
31
 
32
32
  const name = logoname.toUpperCase();
33
33
  const cl = console.log;
@@ -288,7 +288,12 @@ async function build(cwd, options) {
288
288
  externals: entry.externals || options.externals,
289
289
  format: entry.format || _format,
290
290
  transformers: entry.transformers,
291
- defaultPlugins: [esbuild(entry.transformers?.esbuild)],
291
+ defaultPlugins: [
292
+ esbuild({
293
+ minify: !isUndefined(entry.minify) ? entry.minify : options.minify,
294
+ ...entry.transformers?.esbuild
295
+ })
296
+ ],
292
297
  plugins: entry.plugins,
293
298
  banner: entry.banner,
294
299
  footer: entry.footer,
@@ -126,6 +126,12 @@ interface EntryChunk extends EntryBase {
126
126
  * Intended for `umd/iife` formats.
127
127
  */
128
128
  extend?: OutputOptions['extend'];
129
+ /**
130
+ * Minifies the generated code if enabled.
131
+ *
132
+ * @default undefined
133
+ */
134
+ minify?: boolean;
129
135
  declaration?: never;
130
136
  copy?: never;
131
137
  template?: never;
@@ -158,6 +164,7 @@ interface EntryDeclaration extends EntryBase {
158
164
  name?: never;
159
165
  globals?: never;
160
166
  extend?: never;
167
+ minify?: never;
161
168
  }
162
169
  interface CopyOptions {
163
170
  /**
@@ -213,6 +220,7 @@ interface EntryCopy {
213
220
  name?: never;
214
221
  globals?: never;
215
222
  extend?: never;
223
+ minify?: never;
216
224
  }
217
225
  interface EntryTemplate {
218
226
  /**
@@ -244,6 +252,7 @@ interface EntryTemplate {
244
252
  name?: never;
245
253
  globals?: never;
246
254
  extend?: never;
255
+ minify?: never;
247
256
  }
248
257
  type EntryOptions = EntryChunk | EntryDeclaration | EntryCopy | EntryTemplate;
249
258
 
@@ -350,6 +359,33 @@ interface Options {
350
359
  * @default undefined
351
360
  */
352
361
  alias?: Alias[];
362
+ /**
363
+ * Specifies the minification for all `chunk` entries.
364
+ *
365
+ * @example
366
+ *
367
+ * ```ts
368
+ * export default defineConfig({
369
+ * minify: true,
370
+ * })
371
+ * ```
372
+ *
373
+ * It can also be set per entry.
374
+ *
375
+ * ```ts
376
+ * export default defineConfig({
377
+ * entries: [
378
+ * {
379
+ * input: './src/index.ts',
380
+ * minify: true,
381
+ * },
382
+ * ],
383
+ * })
384
+ * ```
385
+ *
386
+ * @default undefined
387
+ */
388
+ minify?: boolean;
353
389
  }
354
390
 
355
391
  interface BuildLogs {
@@ -545,6 +581,21 @@ interface ConfigLoader {
545
581
  * ```
546
582
  */
547
583
  declare const externals: RegExp[];
584
+ /**
585
+ * `Hyperbundler` automatically detects custom configuration from the project root that can override or extend the build behavior.
586
+ *
587
+ * Configuration file also accepts `.js`, `.mjs`, `.ts`, `.mts` formats.
588
+ *
589
+ * @example
590
+ *
591
+ * ```ts
592
+ * import { defineConfig } from '@hypernym/bundler'
593
+ *
594
+ * export default defineConfig({
595
+ * // ...
596
+ * })
597
+ * ```
598
+ */
548
599
  declare function defineConfig(options: Options): Options;
549
600
 
550
601
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypernym/bundler",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "author": "Hypernym Studio",
5
5
  "description": "ESM & TS module bundler.",
6
6
  "license": "MIT",
@@ -20,14 +20,13 @@
20
20
  ],
21
21
  "keywords": [
22
22
  "module",
23
- "modules",
24
23
  "bundling",
25
24
  "javascript",
26
25
  "typescript",
27
26
  "hyperbundler",
27
+ "declarations",
28
28
  "bundler",
29
29
  "builder",
30
- "package",
31
30
  "bundle",
32
31
  "types",
33
32
  "build",
@@ -72,7 +71,7 @@
72
71
  "@rollup/plugin-replace": "^5.0.7",
73
72
  "@rollup/pluginutils": "^5.1.0",
74
73
  "esbuild": "^0.23.1",
75
- "rollup": "^4.22.2",
74
+ "rollup": "^4.22.4",
76
75
  "rollup-plugin-dts": "^6.1.1"
77
76
  },
78
77
  "devDependencies": {
@@ -80,7 +79,7 @@
80
79
  "@hypernym/prettier-config": "^3.2.0",
81
80
  "@hypernym/tsconfig": "^2.4.0",
82
81
  "@types/node": "^22.5.5",
83
- "eslint": "^9.10.0",
82
+ "eslint": "^9.11.0",
84
83
  "prettier": "^3.3.3",
85
84
  "typescript": "^5.5.4"
86
85
  }