@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/LICENSE.txt +2 -1
- package/README.md +126 -96
- package/dist/bin/index.mjs +178 -479
- package/dist/build/index.mjs +311 -0
- package/dist/index.d.mts +603 -658
- package/dist/index.mjs +50 -17
- package/dist/plugins/index.d.mts +14 -0
- package/dist/plugins/index.mjs +37 -0
- package/package.json +25 -30
- package/dist/index.cjs +0 -26
- package/dist/index.d.cts +0 -709
package/dist/index.d.mts
CHANGED
|
@@ -1,647 +1,618 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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 |
|
|
323
|
-
|
|
361
|
+
type EntryOptions = EntryChunk | EntryDts | EntryCopy | EntryTemplate;
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/types/options.d.ts
|
|
324
364
|
interface Options {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
-
|
|
640
|
-
|
|
609
|
+
options: Options;
|
|
610
|
+
path: string;
|
|
641
611
|
}
|
|
642
|
-
|
|
612
|
+
//#endregion
|
|
613
|
+
//#region src/config.d.ts
|
|
643
614
|
/**
|
|
644
|
-
* List of global
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
702
|
-
|
|
703
|
-
|
|
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 };
|