@hypernym/bundler 0.14.4 → 0.20.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/dist/index.d.mts CHANGED
@@ -1,647 +1,618 @@
1
- import { OutputOptions, Plugin, LogLevel, RollupLog } from 'rollup';
2
- import { RollupReplaceOptions } from '@rollup/plugin-replace';
3
- import { RollupJsonOptions } from '@rollup/plugin-json';
4
- import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
5
- import { RollupAliasOptions, Alias } from '@rollup/plugin-alias';
6
- import { TransformOptions } from 'esbuild';
7
- import { Options as Options$1 } from 'rollup-plugin-dts';
1
+ import { InputOptions, LogLevel, LogOrStringHandler, OutputOptions, RolldownPluginOption, RollupLog } from "rolldown";
2
+ import { Options as Options$1 } from "rolldown-plugin-dts";
8
3
 
9
- interface TransformersChunk {
10
- esbuild?: TransformOptions;
11
- resolve?: RollupNodeResolveOptions | true;
12
- replace?: RollupReplaceOptions;
13
- json?: RollupJsonOptions | true;
14
- alias?: RollupAliasOptions;
4
+ //#region src/bin/build.d.ts
5
+ declare function build(options: Options): Promise<BuildStats>;
6
+ //#endregion
7
+ //#region src/types/build.d.ts
8
+ interface BuildLogs {
9
+ level: LogLevel;
10
+ log: RollupLog;
15
11
  }
16
- interface TransformersDeclaration {
17
- dts?: Options$1;
18
- alias?: RollupAliasOptions;
12
+ interface BuildEntryStats {
13
+ /**
14
+ * The root path of the project.
15
+ */
16
+ cwd: string;
17
+ /**
18
+ * Module output path.
19
+ */
20
+ path: string;
21
+ /**
22
+ * Module size.
23
+ */
24
+ size: number;
25
+ /**
26
+ * Build time of individual module.
27
+ */
28
+ buildTime: number;
29
+ /**
30
+ * Module format.
31
+ */
32
+ format: string;
33
+ /**
34
+ * List of warnings from build plugins.
35
+ */
36
+ logs: BuildLogs[];
19
37
  }
20
-
38
+ interface BuildStats {
39
+ /**
40
+ * The root path of the project.
41
+ */
42
+ cwd: string;
43
+ /**
44
+ * Final bundle size.
45
+ */
46
+ size: number;
47
+ /**
48
+ * Total bundle build time.
49
+ */
50
+ buildTime: number;
51
+ /**
52
+ * List of generated bundle modules.
53
+ */
54
+ files: BuildEntryStats[];
55
+ }
56
+ type PickEntryChunkOptions = 'input' | 'name' | 'globals' | 'extend' | 'minify';
57
+ type PickEntryDtsOptions = 'dts' | 'dtsPlugin';
58
+ interface BuildEntryOptions extends EntryBase, Partial<Pick<EntryChunk, PickEntryChunkOptions>>, Partial<Pick<EntryDts, PickEntryDtsOptions>> {
59
+ /**
60
+ * Specifies the path to the processed file.
61
+ *
62
+ * @default undefined
63
+ */
64
+ output?: string;
65
+ }
66
+ //#endregion
67
+ //#region src/types/entries.d.ts
21
68
  interface EntryBase {
22
- /**
23
- * Specifies the format of the generated module.
24
- *
25
- * @default 'esm'
26
- */
27
- format?: OutputOptions['format'];
28
- /**
29
- * Specifies the module IDs, or regular expressions to match module IDs,
30
- * that should remain external to the bundle.
31
- *
32
- * If not specified, infers the IDs from the global `options.externals` option.
33
- *
34
- * @default undefined
35
- */
36
- externals?: (string | RegExp)[];
37
- /**
38
- * Specifies the string to be inserted at the beginning of the module.
39
- *
40
- * @default undefined
41
- */
42
- banner?: OutputOptions['banner'];
43
- /**
44
- * Specifies the string to be inserted at the end of the module.
45
- *
46
- * @default undefined
47
- */
48
- footer?: OutputOptions['footer'];
49
- /**
50
- * Specifies the code at the beginning that goes inside any _format-specific_ wrapper.
51
- *
52
- * @default undefined
53
- */
54
- intro?: OutputOptions['intro'];
55
- /**
56
- * Specifies the code at the end that goes inside any _format-specific_ wrapper.
57
- *
58
- * @default undefined
59
- */
60
- outro?: OutputOptions['outro'];
61
- /**
62
- * Maps external module IDs to paths.
63
- *
64
- * @default undefined
65
- */
66
- paths?: OutputOptions['paths'];
67
- /**
68
- * Specifies custom filters that will display only certain log messages.
69
- *
70
- * @default undefined
71
- */
72
- logFilter?: string[];
73
- /**
74
- * Specifies `rollup` plugins.
75
- *
76
- * Adding custom plugins disables all built-in `transformers` for full customization.
77
- *
78
- * @default undefined
79
- */
80
- plugins?: Plugin[];
69
+ /**
70
+ * Specifies the format of the generated module.
71
+ *
72
+ * - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
73
+ * - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
74
+ * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
75
+ * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
76
+ *
77
+ * @default 'esm'
78
+ */
79
+ format?: OutputOptions['format'];
80
+ /**
81
+ * Specifies the module IDs or regular expressions that match module IDs to be treated as external and excluded from the bundle.
82
+ *
83
+ * The IDs and regular expressions provided in this option are applied globally across all entries.
84
+ *
85
+ * Alternatively, externals can be defined individually for each entry using the `entry.externals` property.
86
+ *
87
+ * @default undefined
88
+ */
89
+ externals?: (string | RegExp)[];
90
+ /**
91
+ * Maps external module IDs to paths.
92
+ *
93
+ * @default undefined
94
+ */
95
+ paths?: {
96
+ find: string | RegExp;
97
+ replacement: string | ((path: string, match: RegExpExecArray | null) => string);
98
+ }[];
99
+ /**
100
+ * Specifies the string to be inserted at the beginning of the module.
101
+ *
102
+ * @default undefined
103
+ */
104
+ banner?: OutputOptions['banner'];
105
+ /**
106
+ * Specifies the string to be inserted at the end of the module.
107
+ *
108
+ * @default undefined
109
+ */
110
+ footer?: OutputOptions['footer'];
111
+ /**
112
+ * Specifies the code at the beginning that goes inside any _format-specific_ wrapper.
113
+ *
114
+ * @default undefined
115
+ */
116
+ intro?: OutputOptions['intro'];
117
+ /**
118
+ * Specifies the code at the end that goes inside any _format-specific_ wrapper.
119
+ *
120
+ * @default undefined
121
+ */
122
+ outro?: OutputOptions['outro'];
123
+ /**
124
+ * Intercepts log messages. If not supplied, logs are printed to the console.
125
+ *
126
+ * @default undefined
127
+ */
128
+ onLog?: (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler, buildLogs: BuildLogs[]) => void;
129
+ /**
130
+ * Specifies Rolldown `resolve` options.
131
+ *
132
+ * @default undefined
133
+ */
134
+ resolve?: InputOptions['resolve'];
135
+ /**
136
+ * Specifies Rolldown `define` options.
137
+ *
138
+ * @default undefined
139
+ */
140
+ define?: InputOptions['define'];
141
+ /**
142
+ * Specifies Rolldown plugins.
143
+ *
144
+ * @default undefined
145
+ */
146
+ plugins?: RolldownPluginOption;
81
147
  }
82
148
  interface EntryChunk extends EntryBase {
83
- /**
84
- * Specifies the path of the build source.
85
- *
86
- * @example
87
- *
88
- * ```ts
89
- * export default defineConfig({
90
- * entries: [
91
- * { input: './src/index.ts' }, // => './dist/index.mjs'
92
- * ]
93
- * })
94
- * ```
95
- */
96
- input?: string;
97
- /**
98
- * Specifies the path of the transformed file.
99
- *
100
- * @example
101
- *
102
- * ```ts
103
- * export default defineConfig({
104
- * entries: [
105
- * {
106
- * input: './src/index.ts',
107
- * output: './out/index.js', // => './out/index.js'
108
- * },
109
- * ]
110
- * })
111
- * ```
112
- *
113
- * @default undefined
114
- */
115
- output?: string;
116
- /**
117
- * Specifies the built-in `transformers` options.
118
- *
119
- * Available transformers:
120
- *
121
- * - `esbuild`
122
- * - `resolve`
123
- * - `replace`
124
- * - `json`
125
- * - `alias`
126
- *
127
- * @default undefined
128
- */
129
- transformers?: TransformersChunk;
130
- /**
131
- * Specifies the global variable name that representing exported bundle.
132
- *
133
- * Intended for `umd/iife` formats.
134
- *
135
- * @default undefined
136
- */
137
- name?: OutputOptions['name'];
138
- /**
139
- * Specifies global _module ID_ and _variable name_ pairs necessary for external imports.
140
- *
141
- * Intended for `umd/iife` formats.
142
- *
143
- * @default undefined
144
- */
145
- globals?: OutputOptions['globals'];
146
- /**
147
- * Specifies whether to extend the global variable defined by the `name` option.
148
- *
149
- * Intended for `umd/iife` formats.
150
- */
151
- extend?: OutputOptions['extend'];
152
- /**
153
- * Minifies the generated code if enabled.
154
- *
155
- * @default undefined
156
- */
157
- minify?: boolean;
158
- declaration?: never;
159
- dts?: never;
160
- copy?: never;
161
- template?: never;
162
- }
163
- interface EntryDeclaration extends EntryBase {
164
- /**
165
- * Specifies the path of the TypeScript `declaration` build source.
166
- *
167
- * @example
168
- *
169
- * ```ts
170
- * export default defineConfig({
171
- * entries: [
172
- * { dts: './src/types.ts' }, // => './dist/types.d.mts'
173
- * ]
174
- * })
175
- * ```
176
- */
177
- dts?: string;
178
- /**
179
- * Specifies the path of the TypeScript `declaration` build source.
180
- *
181
- * Also, it is possible to use `dts` alias.
182
- *
183
- * @example
184
- *
185
- * ```ts
186
- * export default defineConfig({
187
- * entries: [
188
- * { declaration: './src/types.ts' }, // => './dist/types.d.mts'
189
- * ]
190
- * })
191
- * ```
192
- */
193
- declaration?: string;
194
- /**
195
- * Specifies the path of the TypeScript transformed `declaration` file.
196
- *
197
- * @example
198
- *
199
- * ```ts
200
- * export default defineConfig({
201
- * entries: [
202
- * {
203
- * dts: './src/types.ts',
204
- * output: './out/types.d.ts', // => './out/types.d.ts'
205
- * },
206
- * ]
207
- * })
208
- * ```
209
- *
210
- * @default undefined
211
- */
212
- output?: string;
213
- /**
214
- * Specifies the built-in `transformers` options.
215
- *
216
- * Available transformers:
217
- *
218
- * - `dts`
219
- * - `alias`
220
- *
221
- * @default undefined
222
- */
223
- transformers?: TransformersDeclaration;
224
- input?: never;
225
- copy?: never;
226
- template?: never;
227
- name?: never;
228
- globals?: never;
229
- extend?: never;
230
- minify?: never;
149
+ /**
150
+ * Specifies the path to the build source.
151
+ *
152
+ * @example
153
+ *
154
+ * ```ts
155
+ * export default defineConfig({
156
+ * entries: [
157
+ * { input: './src/index.ts' }, // outputs './dist/index.mjs'
158
+ * ]
159
+ * })
160
+ * ```
161
+ */
162
+ input: string;
163
+ /**
164
+ * Specifies the path to the processed file.
165
+ *
166
+ * @example
167
+ *
168
+ * ```ts
169
+ * export default defineConfig({
170
+ * entries: [
171
+ * {
172
+ * input: './src/index.ts',
173
+ * output: './out/index.js', // outputs './out/index.js'
174
+ * },
175
+ * ]
176
+ * })
177
+ * ```
178
+ *
179
+ * @default undefined
180
+ */
181
+ output?: string;
182
+ /**
183
+ * Specifies the global variable name that representing exported bundle.
184
+ *
185
+ * Intended for `umd/iife` formats.
186
+ *
187
+ * @default undefined
188
+ */
189
+ name?: OutputOptions['name'];
190
+ /**
191
+ * Specifies global _module ID_ and _variable name_ pairs necessary for external imports.
192
+ *
193
+ * Intended for `umd/iife` formats.
194
+ *
195
+ * @default undefined
196
+ */
197
+ globals?: OutputOptions['globals'];
198
+ /**
199
+ * Specifies whether to extend the global variable defined by the `name` option.
200
+ *
201
+ * Intended for `umd/iife` formats.
202
+ */
203
+ extend?: OutputOptions['extend'];
204
+ /**
205
+ * Minifies the generated code if enabled.
206
+ *
207
+ * @default undefined
208
+ */
209
+ minify?: boolean;
210
+ dts?: never;
211
+ dtsPlugin?: never;
212
+ copy?: never;
213
+ recursive?: never;
214
+ filter?: never;
215
+ template?: never;
231
216
  }
232
- interface CopyOptions {
233
- /**
234
- * Specifies the path of the source.
235
- */
236
- input: string | string[];
237
- /**
238
- * Specifies the path of the destination directory.
239
- */
240
- output: string;
241
- /**
242
- * Copy directories recursively.
243
- *
244
- * @default true
245
- */
246
- recursive?: boolean;
247
- /**
248
- * Filters copied `files/directories`.
249
- *
250
- * Returns `true` to copy the item, `false` to ignore it.
251
- *
252
- * @default undefined
253
- */
254
- filter?(source: string, destination: string): boolean;
217
+ interface EntryDts extends EntryBase {
218
+ /**
219
+ * Specifies the path to the TypeScript `declaration` build source.
220
+ *
221
+ * @example
222
+ *
223
+ * ```ts
224
+ * export default defineConfig({
225
+ * entries: [
226
+ * { dts: './src/types.ts' }, // outputs './dist/types.d.mts'
227
+ * ]
228
+ * })
229
+ * ```
230
+ */
231
+ dts: string;
232
+ /**
233
+ * Specifies the path to the processed file.
234
+ *
235
+ * @example
236
+ *
237
+ * ```ts
238
+ * export default defineConfig({
239
+ * entries: [
240
+ * {
241
+ * dts: './src/types.ts',
242
+ * output: './out/types.d.ts', // outputs './out/types.d.ts'
243
+ * },
244
+ * ]
245
+ * })
246
+ * ```
247
+ *
248
+ * @default undefined
249
+ */
250
+ output?: string;
251
+ /**
252
+ * Specifies options for the `rolldown-plugin-dts` plugin.
253
+ */
254
+ dtsPlugin?: Options$1;
255
+ input?: never;
256
+ name?: never;
257
+ globals?: never;
258
+ extend?: never;
259
+ minify?: never;
260
+ copy?: never;
261
+ recursive?: never;
262
+ filter?: never;
263
+ template?: never;
255
264
  }
256
265
  interface EntryCopy {
257
- /**
258
- * Copies the single `file` or entire `directory` structure from source to destination, including subdirectories and files.
259
- *
260
- * This can be very useful for copying some assets that don't need a transformation process, but a simple copy paste feature.
261
- *
262
- * @example
263
- *
264
- * ```ts
265
- * export default defineConfig({
266
- * entries: [
267
- * {
268
- * copy: {
269
- * input: './src/path/file.ts', // or ['path-dir', 'path-file.ts', ...]
270
- * output: './dist/out', // path to output dir
271
- * }
272
- * }
273
- * ]
274
- * })
275
- * ```
276
- *
277
- * @default undefined
278
- */
279
- copy?: CopyOptions;
280
- input?: never;
281
- declaration?: never;
282
- dts?: never;
283
- template?: never;
284
- name?: never;
285
- globals?: never;
286
- extend?: never;
287
- minify?: never;
266
+ /**
267
+ * Copies either a single `file` or an entire `directory` structure from the source to the destination, including all subdirectories and files.
268
+ *
269
+ * This is especially useful for transferring assets that don't require any transformation, just a straightforward copy-paste operation.
270
+ *
271
+ * @example
272
+ *
273
+ * ```ts
274
+ * export default defineConfig({
275
+ * entries: [
276
+ * {
277
+ * // copies a single file
278
+ * copy: './src/path/file.ts', // outputs './dist/path/file.ts'
279
+ * },
280
+ * {
281
+ * // copies a single file
282
+ * copy: './src/path/file.ts',
283
+ * output: './dist/subdir/custom-file-name.ts',
284
+ * },
285
+ * {
286
+ * // copies the entire directory
287
+ * input: './src/path/srcdir',
288
+ * output: './dist/outdir',
289
+ * },
290
+ * ]
291
+ * })
292
+ * ```
293
+ *
294
+ * @default undefined
295
+ */
296
+ copy: string;
297
+ /**
298
+ * Specifies the path to the destination file or directory.
299
+ */
300
+ output?: string;
301
+ /**
302
+ * Copy directories recursively.
303
+ *
304
+ * @default true
305
+ */
306
+ recursive?: boolean;
307
+ /**
308
+ * Filters copied `files/directories`.
309
+ *
310
+ * Returns `true` to copy the item, `false` to ignore it.
311
+ *
312
+ * @default undefined
313
+ */
314
+ filter?(source: string, destination: string): boolean;
315
+ input?: never;
316
+ name?: never;
317
+ globals?: never;
318
+ extend?: never;
319
+ minify?: never;
320
+ dts?: never;
321
+ dtsPlugin?: never;
322
+ template?: never;
288
323
  }
289
324
  interface EntryTemplate {
290
- /**
291
- * Specifies the content of the `template` file.
292
- *
293
- * Provides the ability to dynamically inject template content during the build phase.
294
- *
295
- * @example
296
- *
297
- * ```ts
298
- * export default defineConfig({
299
- * entries: [
300
- * {
301
- * template: `// TypeScript code...`,
302
- * output: './dist/template.ts',
303
- * },
304
- * ]
305
- * })
306
- * ```
307
- */
308
- template: string;
309
- /**
310
- * Specifies the path of the transformed `template` file.
311
- */
312
- output: string;
313
- input?: never;
314
- declaration?: never;
315
- dts?: never;
316
- copy?: never;
317
- name?: never;
318
- globals?: never;
319
- extend?: never;
320
- minify?: never;
325
+ /**
326
+ * Specifies the content of the `template` file.
327
+ *
328
+ * Provides the ability to dynamically inject template content during the build phase.
329
+ *
330
+ * @example
331
+ *
332
+ * ```ts
333
+ * import { name, version } from './package.json'
334
+ *
335
+ * export default defineConfig({
336
+ * entries: [
337
+ * {
338
+ * template: `// Package ${name} v${version} ...`,
339
+ * output: './dist/template.ts',
340
+ * },
341
+ * ]
342
+ * })
343
+ * ```
344
+ */
345
+ template: string;
346
+ /**
347
+ * Specifies the path to the destination file.
348
+ */
349
+ output: string;
350
+ input?: never;
351
+ name?: never;
352
+ globals?: never;
353
+ extend?: never;
354
+ minify?: never;
355
+ dts?: never;
356
+ dtsPlugin?: never;
357
+ copy?: never;
358
+ recursive?: never;
359
+ filter?: never;
321
360
  }
322
- type EntryOptions = EntryChunk | EntryDeclaration | EntryCopy | EntryTemplate;
323
-
361
+ type EntryOptions = EntryChunk | EntryDts | EntryCopy | EntryTemplate;
362
+ //#endregion
363
+ //#region src/types/options.d.ts
324
364
  interface Options {
325
- /**
326
- * Specifies the bundle's entry points.
327
- *
328
- * It allows you to manually set all build entries and adjust options for each one individually.
329
- *
330
- * @example
331
- *
332
- * ```ts
333
- * export default defineConfig({
334
- * entries: [
335
- * { input: './src/index.ts' }, // => './dist/index.mjs'
336
- * { dts: './src/types.ts' }, // => './dist/types.d.mts'
337
- * // ...
338
- * ]
339
- * })
340
- * ```
341
- */
342
- entries: EntryOptions[];
343
- /**
344
- * Specifies the output directory for production bundle.
345
- *
346
- * @example
347
- *
348
- * ```ts
349
- * export default defineConfig({
350
- * outDir: 'output',
351
- * })
352
- * ```
353
- *
354
- * @default 'dist'
355
- */
356
- outDir?: string;
357
- /**
358
- * Specifies the module IDs, or regular expressions to match module IDs,
359
- * that should remain external to the bundle.
360
- *
361
- * IDs and regexps from this option are applied globally to all entries.
362
- *
363
- * Also, it is possible to define externals individually per entry (`entry.externals`).
364
- *
365
- * @example
366
- *
367
- * ```ts
368
- * export default defineConfig({
369
- * externals: ['id-1', 'id-2', /regexp/],
370
- * })
371
- * ```
372
- *
373
- * @default [/^node:/, /^@types/, /^@rollup/, /^@hypernym/, /^rollup/, ...pkg.dependencies]
374
- */
375
- externals?: (string | RegExp)[];
376
- /**
377
- * Provides a powerful hooking system to further expand bundling mode.
378
- *
379
- * @example
380
- *
381
- * ```ts
382
- * export default defineConfig({
383
- * hooks: {
384
- * 'build:end': async (options, buildStats) => {
385
- * // ...
386
- * }
387
- * }
388
- * })
389
- * ```
390
- *
391
- * @default undefined
392
- */
393
- hooks?: HooksOptions;
394
- /**
395
- * Specifies prefixes that will resolve imports with custom paths.
396
- *
397
- * Enables these `alias` by default:
398
- *
399
- * ```ts
400
- * // Imports module from './src/utils/index.js'
401
- * import { module } from '@/utils' // @
402
- * import { module } from '~/utils' // ~
403
- * ```
404
- *
405
- * Also, it is possible to completely override the default aliases by setting custom ones.
406
- *
407
- * @example
408
- *
409
- * ```ts
410
- * export default defineConfig({
411
- * alias: [
412
- * { find: /^#/, replacement: resolve('./src') },
413
- * ]
414
- * })
415
- * ```
416
- *
417
- * Now imports can be used like this:
418
- *
419
- * ```ts
420
- * // Imports module from './src/utils/index.js'
421
- * import { module } from '#/utils' // #
422
- * ```
423
- *
424
- * @default undefined
425
- */
426
- alias?: Alias[];
427
- /**
428
- * Specifies the minification for all `chunk` entries.
429
- *
430
- * @example
431
- *
432
- * ```ts
433
- * export default defineConfig({
434
- * minify: true,
435
- * })
436
- * ```
437
- *
438
- * It can also be set per entry.
439
- *
440
- * ```ts
441
- * export default defineConfig({
442
- * entries: [
443
- * {
444
- * input: './src/index.ts',
445
- * minify: true,
446
- * },
447
- * ],
448
- * })
449
- * ```
450
- *
451
- * @default undefined
452
- */
453
- minify?: boolean;
365
+ /**
366
+ * Specifies the bundle's entry points.
367
+ *
368
+ * It allows you to manually set all build entries and adjust options for each one individually.
369
+ *
370
+ * @example
371
+ *
372
+ * ```ts
373
+ * export default defineConfig({
374
+ * entries: [
375
+ * { input: './src/index.ts' }, // outputs './dist/index.mjs'
376
+ * { dts: './src/types.ts' }, // outputs './dist/types.d.mts'
377
+ * // ...
378
+ * ]
379
+ * })
380
+ * ```
381
+ */
382
+ entries: EntryOptions[];
383
+ /**
384
+ * Specifies the output directory for production bundle.
385
+ *
386
+ * @example
387
+ *
388
+ * ```ts
389
+ * export default defineConfig({
390
+ * outDir: 'output',
391
+ * })
392
+ * ```
393
+ *
394
+ * @default 'dist'
395
+ */
396
+ outDir?: string;
397
+ /**
398
+ * Specifies the module IDs, or regular expressions to match module IDs,
399
+ * that should remain external to the bundle.
400
+ *
401
+ * IDs and regexps from this option are applied globally to all entries.
402
+ *
403
+ * Also, it is possible to define externals individually per entry (`entry.externals`).
404
+ *
405
+ * @example
406
+ *
407
+ * ```ts
408
+ * export default defineConfig({
409
+ * externals: ['id-1', 'id-2', /regexp/],
410
+ * })
411
+ * ```
412
+ *
413
+ * @default [/^node:/,/^@types/,/^@rollup/,/^@rolldown/,/^@hypernym/,/^rollup/,/^rolldown/,...pkg.dependencies]
414
+ */
415
+ externals?: (string | RegExp)[];
416
+ /**
417
+ * Provides a powerful hooking system to further expand bundling mode.
418
+ *
419
+ * @example
420
+ *
421
+ * ```ts
422
+ * export default defineConfig({
423
+ * hooks: {
424
+ * 'build:end': async (options, buildStats) => {
425
+ * // ...
426
+ * }
427
+ * }
428
+ * })
429
+ * ```
430
+ *
431
+ * @default undefined
432
+ */
433
+ hooks?: HooksOptions;
434
+ /**
435
+ * Specifies the minification for all `chunk` entries.
436
+ *
437
+ * @example
438
+ *
439
+ * ```ts
440
+ * export default defineConfig({
441
+ * minify: true,
442
+ * })
443
+ * ```
444
+ *
445
+ * It can also be set per entry.
446
+ *
447
+ * ```ts
448
+ * export default defineConfig({
449
+ * entries: [
450
+ * {
451
+ * input: './src/index.ts',
452
+ * minify: true,
453
+ * },
454
+ * ],
455
+ * })
456
+ * ```
457
+ *
458
+ * @default undefined
459
+ */
460
+ minify?: boolean;
461
+ /**
462
+ * Specifies the path to the project root (current working directory).
463
+ *
464
+ * @example
465
+ *
466
+ * ```ts
467
+ * export default defineConfig({
468
+ * cwd: './dir',
469
+ * })
470
+ * ```
471
+ *
472
+ * @default undefined
473
+ */
474
+ cwd?: string;
475
+ /**
476
+ * Specifies the path to the `tsconfig` file.
477
+ *
478
+ * By default, if the file `tsconfig.json` exists in the project root, it will be used as the default config file.
479
+ *
480
+ * @example
481
+ *
482
+ * ```ts
483
+ * export default defineConfig({
484
+ * tsconfig: './path/to/tsconfig.json',
485
+ * })
486
+ * ```
487
+ *
488
+ * @default undefined
489
+ */
490
+ tsconfig?: string;
454
491
  }
455
-
456
- interface BuildLogs {
457
- level: LogLevel;
458
- log: RollupLog;
459
- }
460
- interface BuildEntryStats {
461
- /**
462
- * The root path of the project.
463
- */
464
- cwd: string;
465
- /**
466
- * Module output path.
467
- */
468
- path: string;
469
- /**
470
- * Module size.
471
- */
472
- size: number;
473
- /**
474
- * Build time of individual module.
475
- */
476
- buildTime: number;
477
- /**
478
- * Module format.
479
- */
480
- format: string;
481
- /**
482
- * List of warnings from build plugins.
483
- */
484
- logs: BuildLogs[];
485
- }
486
- interface BuildStats {
487
- /**
488
- * The root path of the project.
489
- */
490
- cwd: string;
491
- /**
492
- * Final bundle size.
493
- */
494
- size: number;
495
- /**
496
- * Total bundle build time.
497
- */
498
- buildTime: number;
499
- /**
500
- * List of generated bundle modules.
501
- */
502
- files: BuildEntryStats[];
503
- }
504
- type PickEntryChunkOptions = 'input' | 'name' | 'globals' | 'extend' | 'minify' | 'transformers';
505
- type PickEntryDtsOptions = 'declaration' | 'dts' | 'transformers';
506
- interface BuildEntryOptions extends EntryBase, Pick<EntryChunk, PickEntryChunkOptions>, Pick<EntryDeclaration, PickEntryDtsOptions> {
507
- /**
508
- * Specifies the path of the transformed file.
509
- *
510
- * @default undefined
511
- */
512
- output?: string;
513
- /**
514
- * Specifies options for default plugins.
515
- *
516
- * @default undefined
517
- */
518
- transformers?: TransformersChunk & TransformersDeclaration;
519
- /**
520
- * Specifies list of default plugins.
521
- */
522
- defaultPlugins: Plugin[];
523
- }
524
-
492
+ //#endregion
493
+ //#region src/types/hooks.d.ts
525
494
  interface HooksOptions {
526
- /**
527
- * Called at the beginning of bundling.
528
- *
529
- * @example
530
- *
531
- * ```ts
532
- * export default defineConfig({
533
- * hooks: {
534
- * 'bundle:start': async (options) => {
535
- * // ...
536
- * }
537
- * }
538
- * })
539
- * ```
540
- *
541
- * @default undefined
542
- */
543
- 'bundle:start'?: (options: Options) => void | Promise<void>;
544
- /**
545
- * Called at the beginning of building.
546
- *
547
- * @example
548
- *
549
- * ```ts
550
- * export default defineConfig({
551
- * hooks: {
552
- * 'build:start': async (options, stats) => {
553
- * // ...
554
- * }
555
- * }
556
- * })
557
- * ```
558
- *
559
- * @default undefined
560
- */
561
- 'build:start'?: (options: Options, stats: BuildStats) => void | Promise<void>;
562
- /**
563
- * Called on each entry just before the build process.
564
- *
565
- * Provides the ability to customize entry options before they are passed to the next phase.
566
- *
567
- * @example
568
- *
569
- * ```ts
570
- * export default defineConfig({
571
- * hooks: {
572
- * 'build:entry:start': async (entry, stats) => {
573
- * // ...
574
- * }
575
- * }
576
- * })
577
- * ```
578
- *
579
- * @default undefined
580
- */
581
- 'build:entry:start'?: (entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>;
582
- /**
583
- * Called on each entry right after the build process is completed.
584
- *
585
- * @example
586
- *
587
- * ```ts
588
- * export default defineConfig({
589
- * hooks: {
590
- * 'build:entry:end': async (entry, stats) => {
591
- * // ...
592
- * }
593
- * }
594
- * })
595
- * ```
596
- *
597
- * @default undefined
598
- */
599
- 'build:entry:end'?: (entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>;
600
- /**
601
- * Called right after building is complete.
602
- *
603
- * @example
604
- *
605
- * ```ts
606
- * export default defineConfig({
607
- * hooks: {
608
- * 'build:end': async (options, stats) => {
609
- * // ...
610
- * }
611
- * }
612
- * })
613
- * ```
614
- *
615
- * @default undefined
616
- */
617
- 'build:end'?: (options: Options, stats: BuildStats) => void | Promise<void>;
618
- /**
619
- * Called right after bundling is complete.
620
- *
621
- * @example
622
- *
623
- * ```ts
624
- * export default defineConfig({
625
- * hooks: {
626
- * 'bundle:end': async (options) => {
627
- * // ...
628
- * }
629
- * }
630
- * })
631
- * ```
632
- *
633
- * @default undefined
634
- */
635
- 'bundle:end'?: (options: Options) => void | Promise<void>;
495
+ /**
496
+ * Called at the beginning of bundling.
497
+ *
498
+ * @example
499
+ *
500
+ * ```ts
501
+ * export default defineConfig({
502
+ * hooks: {
503
+ * 'bundle:start': async (options) => {
504
+ * // ...
505
+ * }
506
+ * }
507
+ * })
508
+ * ```
509
+ *
510
+ * @default undefined
511
+ */
512
+ 'bundle:start'?: (options: Options) => void | Promise<void>;
513
+ /**
514
+ * Called at the beginning of building.
515
+ *
516
+ * @example
517
+ *
518
+ * ```ts
519
+ * export default defineConfig({
520
+ * hooks: {
521
+ * 'build:start': async (options, stats) => {
522
+ * // ...
523
+ * }
524
+ * }
525
+ * })
526
+ * ```
527
+ *
528
+ * @default undefined
529
+ */
530
+ 'build:start'?: (options: Options, stats: BuildStats) => void | Promise<void>;
531
+ /**
532
+ * Called on each entry just before the build process.
533
+ *
534
+ * Provides the ability to customize entry options before they are passed to the next phase.
535
+ *
536
+ * @example
537
+ *
538
+ * ```ts
539
+ * export default defineConfig({
540
+ * hooks: {
541
+ * 'build:entry:start': async (entry, stats) => {
542
+ * // ...
543
+ * }
544
+ * }
545
+ * })
546
+ * ```
547
+ *
548
+ * @default undefined
549
+ */
550
+ 'build:entry:start'?: (entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>;
551
+ /**
552
+ * Called on each entry right after the build process is completed.
553
+ *
554
+ * @example
555
+ *
556
+ * ```ts
557
+ * export default defineConfig({
558
+ * hooks: {
559
+ * 'build:entry:end': async (entry, stats) => {
560
+ * // ...
561
+ * }
562
+ * }
563
+ * })
564
+ * ```
565
+ *
566
+ * @default undefined
567
+ */
568
+ 'build:entry:end'?: (entry: BuildEntryOptions, stats: BuildEntryStats) => void | Promise<void>;
569
+ /**
570
+ * Called right after building is complete.
571
+ *
572
+ * @example
573
+ *
574
+ * ```ts
575
+ * export default defineConfig({
576
+ * hooks: {
577
+ * 'build:end': async (options, stats) => {
578
+ * // ...
579
+ * }
580
+ * }
581
+ * })
582
+ * ```
583
+ *
584
+ * @default undefined
585
+ */
586
+ 'build:end'?: (options: Options, stats: BuildStats) => void | Promise<void>;
587
+ /**
588
+ * Called right after bundling is complete.
589
+ *
590
+ * @example
591
+ *
592
+ * ```ts
593
+ * export default defineConfig({
594
+ * hooks: {
595
+ * 'bundle:end': async (options) => {
596
+ * // ...
597
+ * }
598
+ * }
599
+ * })
600
+ * ```
601
+ *
602
+ * @default undefined
603
+ */
604
+ 'bundle:end'?: (options: Options) => void | Promise<void>;
636
605
  }
637
-
606
+ //#endregion
607
+ //#region src/types/loader.d.ts
638
608
  interface ConfigLoader {
639
- options: Options;
640
- path: string;
609
+ options: Options;
610
+ path: string;
641
611
  }
642
-
612
+ //#endregion
613
+ //#region src/config.d.ts
643
614
  /**
644
- * List of global defaults for externals.
615
+ * List of global default patterns for external module identifiers.
645
616
  *
646
617
  * @example
647
618
  *
@@ -660,7 +631,9 @@ interface ConfigLoader {
660
631
  */
661
632
  declare const externals: RegExp[];
662
633
  /**
663
- * `Hyperbundler` automatically detects custom configuration from the project root that can override or extend the build behavior.
634
+ * ESM & TS module bundler.
635
+ *
636
+ * Automatically detects a custom configuration file at the project root, which can override or extend the build behavior.
664
637
  *
665
638
  * Configuration file also accepts `.js`, `.mjs`, `.ts`, `.mts` formats.
666
639
  *
@@ -673,37 +646,9 @@ declare const externals: RegExp[];
673
646
  * // ...
674
647
  * })
675
648
  * ```
676
- */
677
- declare function defineConfig(options: Options): Options;
678
-
679
- /**
680
- * Resolves external module IDs into custom paths.
681
- *
682
- * @example
683
649
  *
684
- * ```ts
685
- * import { defineConfig, resolvePaths } from '@hypernym/bundler'
686
- *
687
- * export default defineConfig({
688
- * entries: [
689
- * {
690
- * input: './src/index.ts',
691
- * externals: [/^@\/path/],
692
- * paths: resolvePaths([
693
- * // replaces `@/path` with `./path/index.mjs`
694
- * { find: /^@\/path/, replacement: './path/index.mjs', }
695
- * ]),
696
- * },
697
- * ]
698
- * })
699
- * ```
650
+ * @see [Repository](https://github.com/hypernym-studio/bundler)
700
651
  */
701
- declare function resolvePaths(options: ResolvePathsOptions[]): (id: string) => string;
702
-
703
- interface ResolvePathsOptions {
704
- find: string | RegExp;
705
- replacement: string;
706
- }
707
-
708
- export { defineConfig, externals, resolvePaths };
709
- export type { BuildLogs, BuildStats, ConfigLoader, CopyOptions, EntryBase, EntryChunk, EntryCopy, EntryDeclaration, EntryOptions, EntryTemplate, HooksOptions, Options, ResolvePathsOptions, TransformersChunk, TransformersDeclaration };
652
+ declare function defineConfig(options: Options): Options;
653
+ //#endregion
654
+ export { BuildEntryOptions, BuildEntryStats, BuildLogs, BuildStats, ConfigLoader, EntryBase, EntryChunk, EntryCopy, EntryDts, EntryOptions, EntryTemplate, HooksOptions, Options, build, defineConfig, externals };