bunup 0.8.69 → 0.8.71
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 +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index.d.ts +1 -352
- package/dist/plugins.d.ts +3 -343
- package/dist/shared/chunk-95p7cdc9.d.ts +353 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Bunup is the **blazing-fast build tool** for TypeScript libraries, designed for
|
|
|
16
16
|
|
|
17
17
|

|
|
18
18
|
|
|
19
|
-
*The benchmark above shows build times for a project with 1,000 files
|
|
19
|
+
*The benchmark above shows build times for a project with 1,000 files with TypeScript declaration generation enabled. For detailed benchmarks, visit [here](https://gugustinette.github.io/bundler-benchmark/)*;
|
|
20
20
|
|
|
21
21
|
</div>
|
|
22
22
|
<!-- markdownlint-restore -->
|
package/dist/cli/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,355 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BunPlugin } from "bun";
|
|
3
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
4
|
-
type WithOptional<
|
|
5
|
-
T,
|
|
6
|
-
K extends keyof T
|
|
7
|
-
> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
|
-
type Arrayable<T> = T | T[];
|
|
9
|
-
type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
|
|
10
|
-
type DefineWorkspaceItem = {
|
|
11
|
-
name: string
|
|
12
|
-
root: string
|
|
13
|
-
config: DefineConfigItem | DefineConfigItem[]
|
|
14
|
-
};
|
|
15
|
-
type PackageJson = {
|
|
16
|
-
/** The parsed content of the package.json file */
|
|
17
|
-
data: Record<string, any> | null
|
|
18
|
-
/** The path to the package.json file */
|
|
19
|
-
path: string | null
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Represents a Bun plugin that can be used with Bunup
|
|
23
|
-
*/
|
|
24
|
-
type BunupBunPlugin = {
|
|
25
|
-
/** Identifies this as a native Bun plugin */
|
|
26
|
-
type: "bun"
|
|
27
|
-
/** Optional name for the plugin */
|
|
28
|
-
name?: string
|
|
29
|
-
/** The actual Bun plugin implementation */
|
|
30
|
-
plugin: BunPlugin
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Represents the meta data of the build
|
|
34
|
-
*/
|
|
35
|
-
type BuildMeta = {
|
|
36
|
-
/** The package.json file */
|
|
37
|
-
packageJson: PackageJson
|
|
38
|
-
/** The root directory of the build */
|
|
39
|
-
rootDir: string
|
|
40
|
-
};
|
|
41
|
-
type BuildOutputFile = {
|
|
42
|
-
/**
|
|
43
|
-
* The entry point for which this file was generated
|
|
44
|
-
*
|
|
45
|
-
* Undefined for non-entry point files (e.g., assets, sourcemaps, chunks)
|
|
46
|
-
*/
|
|
47
|
-
entrypoint: string | undefined
|
|
48
|
-
/** The kind of the file */
|
|
49
|
-
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
50
|
-
/** Path to the generated file */
|
|
51
|
-
fullPath: string
|
|
52
|
-
/** Path to the generated file relative to the root directory */
|
|
53
|
-
relativePathToRootDir: string
|
|
54
|
-
/** Path to the generated file relative to the output directory */
|
|
55
|
-
relativePathToOutputDir: string
|
|
56
|
-
/** Whether the file is a dts file */
|
|
57
|
-
dts: boolean
|
|
58
|
-
/** The format of the output file */
|
|
59
|
-
format: Format
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Represents the output of a build operation
|
|
63
|
-
*/
|
|
64
|
-
type BuildOutput = {
|
|
65
|
-
/** Array of generated files with their paths and contents */
|
|
66
|
-
files: BuildOutputFile[]
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Context provided to build hooks
|
|
70
|
-
*/
|
|
71
|
-
type BuildContext = {
|
|
72
|
-
/** The build options that were used */
|
|
73
|
-
options: BuildOptions
|
|
74
|
-
/** The output of the build */
|
|
75
|
-
output: BuildOutput
|
|
76
|
-
/** The meta data of the build */
|
|
77
|
-
meta: BuildMeta
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Hooks that can be implemented by Bunup plugins
|
|
81
|
-
*/
|
|
82
|
-
type BunupPluginHooks = {
|
|
83
|
-
/**
|
|
84
|
-
* Called when a build is successfully completed
|
|
85
|
-
* @param ctx Build context containing options and output
|
|
86
|
-
*/
|
|
87
|
-
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
88
|
-
/**
|
|
89
|
-
* Called before a build starts
|
|
90
|
-
* @param options Build options that will be used
|
|
91
|
-
*/
|
|
92
|
-
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Represents a Bunup-specific plugin
|
|
96
|
-
*/
|
|
97
|
-
type BunupPlugin = {
|
|
98
|
-
/** Identifies this as a Bunup-specific plugin */
|
|
99
|
-
type: "bunup"
|
|
100
|
-
/** Optional name for the plugin */
|
|
101
|
-
name?: string
|
|
102
|
-
/** The hooks implemented by this plugin */
|
|
103
|
-
hooks: BunupPluginHooks
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Union type representing all supported plugin types
|
|
107
|
-
*/
|
|
108
|
-
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
109
|
-
type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
|
|
110
|
-
type Define = Record<string, string>;
|
|
111
|
-
type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
|
|
112
|
-
type Format = "esm" | "cjs" | "iife";
|
|
113
|
-
type Target = "bun" | "node" | "browser";
|
|
114
|
-
type External = (string | RegExp)[];
|
|
115
|
-
type Env = "inline" | "disable" | `${string}*` | Record<string, string>;
|
|
116
|
-
interface BuildOptions {
|
|
117
|
-
/**
|
|
118
|
-
* Name of the build configuration
|
|
119
|
-
* Used for logging and identification purposes
|
|
120
|
-
*/
|
|
121
|
-
name?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Entry point files for the build
|
|
124
|
-
*
|
|
125
|
-
* This can be:
|
|
126
|
-
* - A string path to a file
|
|
127
|
-
* - An array of file paths
|
|
128
|
-
*
|
|
129
|
-
* @see https://bunup.dev/docs/#entry-points
|
|
130
|
-
*/
|
|
131
|
-
entry: string | string[];
|
|
132
|
-
/**
|
|
133
|
-
* Output directory for the bundled files
|
|
134
|
-
* Defaults to 'dist' if not specified
|
|
135
|
-
*/
|
|
136
|
-
outDir: string;
|
|
137
|
-
/**
|
|
138
|
-
* Output formats for the bundle
|
|
139
|
-
* Can include 'esm', 'cjs', and/or 'iife'
|
|
140
|
-
* Defaults to ['esm'] if not specified
|
|
141
|
-
*/
|
|
142
|
-
format: Format[];
|
|
143
|
-
/**
|
|
144
|
-
* Whether to enable all minification options
|
|
145
|
-
* When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
|
|
146
|
-
*/
|
|
147
|
-
minify?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* Whether to enable code splitting
|
|
150
|
-
* Defaults to true for ESM format, false for CJS format
|
|
151
|
-
*/
|
|
152
|
-
splitting?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Whether to minify whitespace in the output
|
|
155
|
-
* Removes unnecessary whitespace to reduce file size
|
|
156
|
-
*/
|
|
157
|
-
minifyWhitespace?: boolean;
|
|
158
|
-
/**
|
|
159
|
-
* Whether to minify identifiers in the output
|
|
160
|
-
* Renames variables and functions to shorter names
|
|
161
|
-
*/
|
|
162
|
-
minifyIdentifiers?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Whether to minify syntax in the output
|
|
165
|
-
* Optimizes code structure for smaller file size
|
|
166
|
-
*/
|
|
167
|
-
minifySyntax?: boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Whether to watch for file changes and rebuild automatically
|
|
170
|
-
*/
|
|
171
|
-
watch?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Whether to generate TypeScript declaration files (.d.ts)
|
|
174
|
-
* When set to true, generates declaration files for all entry points
|
|
175
|
-
* Can also be configured with DtsOptions for more control
|
|
176
|
-
*/
|
|
177
|
-
dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify"> & {
|
|
178
|
-
entry?: string | string[]
|
|
179
|
-
});
|
|
180
|
-
/**
|
|
181
|
-
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
182
|
-
*
|
|
183
|
-
* If not specified, the tsconfig.json in the project root will be used.
|
|
184
|
-
* This option allows you to use a different TypeScript configuration
|
|
185
|
-
* specifically for declaration file generation.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* preferredTsconfigPath: './tsconfig.build.json'
|
|
189
|
-
*/
|
|
190
|
-
preferredTsconfigPath?: string;
|
|
191
|
-
/**
|
|
192
|
-
* External packages that should not be bundled
|
|
193
|
-
* Useful for dependencies that should be kept as external imports
|
|
194
|
-
*/
|
|
195
|
-
external?: External;
|
|
196
|
-
/**
|
|
197
|
-
* Packages that should be bundled even if they are in external
|
|
198
|
-
* Useful for dependencies that should be included in the bundle
|
|
199
|
-
*/
|
|
200
|
-
noExternal?: External;
|
|
201
|
-
/**
|
|
202
|
-
* The target environment for the bundle.
|
|
203
|
-
* Can be 'browser', 'bun', 'node', etc.
|
|
204
|
-
* Defaults to 'node' if not specified.
|
|
205
|
-
*
|
|
206
|
-
* Bun target is for generating bundles that are intended to be run by the Bun runtime. In many cases,
|
|
207
|
-
* it isn't necessary to bundle server-side code; you can directly execute the source code
|
|
208
|
-
* without modification. However, bundling your server code can reduce startup times and
|
|
209
|
-
* improve running performance.
|
|
210
|
-
*
|
|
211
|
-
* All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which
|
|
212
|
-
* indicates to the Bun runtime that there's no need to re-transpile the file before execution.
|
|
213
|
-
*/
|
|
214
|
-
target?: Target;
|
|
215
|
-
/**
|
|
216
|
-
* Whether to clean the output directory before building
|
|
217
|
-
* When true, removes all files in the outDir before starting a new build
|
|
218
|
-
* Defaults to true if not specified
|
|
219
|
-
*/
|
|
220
|
-
clean?: boolean;
|
|
221
|
-
/**
|
|
222
|
-
* Specifies the type of sourcemap to generate
|
|
223
|
-
* Can be 'none', 'linked', 'external', or 'inline'
|
|
224
|
-
* Can also be a boolean - when true, it will use 'inline'
|
|
225
|
-
*
|
|
226
|
-
* @see https://bun.sh/docs/bundler#sourcemap
|
|
227
|
-
*
|
|
228
|
-
* @default 'none'
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* sourcemap: 'linked'
|
|
232
|
-
* // or
|
|
233
|
-
* sourcemap: true // equivalent to 'inline'
|
|
234
|
-
*/
|
|
235
|
-
sourcemap?: Sourcemap;
|
|
236
|
-
/**\\n\\t* Define global constants for the build\\n\\t* These values will be replaced at build time\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#define\\n\\t*\\n\\t* @example\\n\\t* define: {\\n\\t* 'process.env.NODE_ENV': '"production"',\\n\\t* 'PACKAGE_VERSION': '"1.0.0"'\\n\\t* }\\n\\t*/
|
|
237
|
-
define?: Define;
|
|
238
|
-
/**
|
|
239
|
-
* A callback function that runs after the build process completes
|
|
240
|
-
* This can be used for custom post-build operations like copying files,
|
|
241
|
-
* running additional tools, or logging build information
|
|
242
|
-
*
|
|
243
|
-
* If watch mode is enabled, this callback runs after each rebuild
|
|
244
|
-
*
|
|
245
|
-
* @param options The build options that were used
|
|
246
|
-
*/
|
|
247
|
-
onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
|
|
248
|
-
/**\\n\\t* A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#banner\\n\\t*\\n\\t* @example\\n\\t* banner: '"use client";'\\n\\t*/
|
|
249
|
-
banner?: string;
|
|
250
|
-
/**
|
|
251
|
-
* A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
|
|
252
|
-
*
|
|
253
|
-
* @see https://bun.sh/docs/bundler#footer
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* footer: '// built with love in SF'
|
|
257
|
-
*/
|
|
258
|
-
footer?: string;
|
|
259
|
-
/**
|
|
260
|
-
* Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
|
|
261
|
-
*
|
|
262
|
-
* @see https://bun.sh/docs/bundler#drop
|
|
263
|
-
*
|
|
264
|
-
* @example
|
|
265
|
-
* drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
|
|
266
|
-
*/
|
|
267
|
-
drop?: string[];
|
|
268
|
-
/**
|
|
269
|
-
* A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
|
270
|
-
*
|
|
271
|
-
* @see https://bun.sh/docs/bundler#loader
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* loader: {
|
|
275
|
-
* ".png": "dataurl",
|
|
276
|
-
* ".txt": "file",
|
|
277
|
-
* }
|
|
278
|
-
*/
|
|
279
|
-
loader?: { [k in string] : Loader };
|
|
280
|
-
/**
|
|
281
|
-
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
282
|
-
*
|
|
283
|
-
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
284
|
-
*
|
|
285
|
-
* Must be target: "bun"
|
|
286
|
-
*
|
|
287
|
-
* @see https://bun.sh/docs/bundler#bytecode
|
|
288
|
-
*
|
|
289
|
-
* @default false
|
|
290
|
-
*/
|
|
291
|
-
bytecode?: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
294
|
-
*
|
|
295
|
-
* @default false
|
|
296
|
-
*/
|
|
297
|
-
silent?: boolean;
|
|
298
|
-
/**
|
|
299
|
-
* You can specify a prefix to be added to specific import paths in your bundled code
|
|
300
|
-
*
|
|
301
|
-
* Used for assets, external modules, and chunk files when splitting is enabled
|
|
302
|
-
*
|
|
303
|
-
* @see https://bunup.dev/docs#public-path for more information
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* publicPath: 'https://cdn.example.com/'
|
|
307
|
-
*/
|
|
308
|
-
publicPath?: string;
|
|
309
|
-
/**
|
|
310
|
-
* Controls how environment variables are handled during bundling.
|
|
311
|
-
*
|
|
312
|
-
* Can be one of:
|
|
313
|
-
* - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
|
|
314
|
-
* of those environment variables at the time the build runs.
|
|
315
|
-
* - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
|
|
316
|
-
* - A string ending in `*`: Only inlines environment variables matching the given prefix.
|
|
317
|
-
* For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
|
|
318
|
-
* - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
|
|
319
|
-
* with the provided values, regardless of the runtime environment.
|
|
320
|
-
*
|
|
321
|
-
* Note: Values are injected at build time. Secrets or private keys should be excluded
|
|
322
|
-
* from inlining when targeting browser environments.
|
|
323
|
-
*
|
|
324
|
-
* @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* // Inline all environment variables available at build time
|
|
328
|
-
* env: "inline"
|
|
329
|
-
*
|
|
330
|
-
* // Disable all environment variable injection
|
|
331
|
-
* env: "disable"
|
|
332
|
-
*
|
|
333
|
-
* // Only inline environment variables with a specific prefix
|
|
334
|
-
* env: "PUBLIC_*"
|
|
335
|
-
*
|
|
336
|
-
* // Provide specific environment variables manually
|
|
337
|
-
* env: { API_URL: "https://api.example.com", DEBUG: "false" }
|
|
338
|
-
*/
|
|
339
|
-
env?: Env;
|
|
340
|
-
/**
|
|
341
|
-
* Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
|
|
342
|
-
* "sideEffects" fields. This should only be used as a temporary workaround for incorrect
|
|
343
|
-
* annotations in libraries.
|
|
344
|
-
*/
|
|
345
|
-
ignoreDCEAnnotations?: boolean;
|
|
346
|
-
/**
|
|
347
|
-
* Force emitting @__PURE__ annotations even if minify.whitespace is true.
|
|
348
|
-
*/
|
|
349
|
-
emitDCEAnnotations?: boolean;
|
|
350
|
-
/**\\n\\t* Plugins to extend the build process functionality\\n\\t*\\n\\t* The Plugin type uses a discriminated union pattern with the 'type' field\\n\\t* to support different plugin systems. Both "bun" and "bunup" plugins are supported.\\n\\t*\\n\\t* Each plugin type has its own specific plugin implementation:\\n\\t* - "bun": Uses Bun's native plugin system (BunPlugin)\\n\\t* - "bunup": Uses bunup's own plugin system with lifecycle hooks\\n\\t*\\n\\t* This architecture allows for extensibility as more plugin systems are added.\\n\\t*\\n\\t* @see https://bunup.dev/docs/advanced/plugin-development for more information on plugins\\n\\t*\\n\\t* @example\\n\\t* plugins: [\\n\\t* {\\n\\t* type: "bun",\\n\\t* plugin: myBunPlugin()\\n\\t* },\\n\\t* {\\n\\t* type: "bunup",\\n\\t* hooks: {\\n\\t* onBuildStart: (options) => {\\n\\t* console.log('Build started with options:', options)\\n\\t* },\\n\\t* onBuildDone: ({ options, output }) => {\\n\\t* console.log('Build completed with output:', output)\\n\\t* }\\n\\t* }\\n\\t* }\\n\\t* ]\\n\\t*/
|
|
351
|
-
plugins?: Plugin[];
|
|
352
|
-
}
|
|
1
|
+
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, WithOptional } from "./shared/chunk-95p7cdc9";
|
|
353
2
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
|
354
3
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
355
4
|
declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: DefineConfigItem): DefineWorkspaceItem[];
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,344 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GenerateDtsOptions } from "typeroll";
|
|
3
|
-
type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
|
|
4
|
-
type Define = Record<string, string>;
|
|
5
|
-
type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
|
|
6
|
-
type Format = "esm" | "cjs" | "iife";
|
|
7
|
-
type Target = "bun" | "node" | "browser";
|
|
8
|
-
type External = (string | RegExp)[];
|
|
9
|
-
type Env = "inline" | "disable" | `${string}*` | Record<string, string>;
|
|
10
|
-
interface BuildOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Name of the build configuration
|
|
13
|
-
* Used for logging and identification purposes
|
|
14
|
-
*/
|
|
15
|
-
name?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Entry point files for the build
|
|
18
|
-
*
|
|
19
|
-
* This can be:
|
|
20
|
-
* - A string path to a file
|
|
21
|
-
* - An array of file paths
|
|
22
|
-
*
|
|
23
|
-
* @see https://bunup.dev/docs/#entry-points
|
|
24
|
-
*/
|
|
25
|
-
entry: string | string[];
|
|
26
|
-
/**
|
|
27
|
-
* Output directory for the bundled files
|
|
28
|
-
* Defaults to 'dist' if not specified
|
|
29
|
-
*/
|
|
30
|
-
outDir: string;
|
|
31
|
-
/**
|
|
32
|
-
* Output formats for the bundle
|
|
33
|
-
* Can include 'esm', 'cjs', and/or 'iife'
|
|
34
|
-
* Defaults to ['esm'] if not specified
|
|
35
|
-
*/
|
|
36
|
-
format: Format[];
|
|
37
|
-
/**
|
|
38
|
-
* Whether to enable all minification options
|
|
39
|
-
* When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
|
|
40
|
-
*/
|
|
41
|
-
minify?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Whether to enable code splitting
|
|
44
|
-
* Defaults to true for ESM format, false for CJS format
|
|
45
|
-
*/
|
|
46
|
-
splitting?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether to minify whitespace in the output
|
|
49
|
-
* Removes unnecessary whitespace to reduce file size
|
|
50
|
-
*/
|
|
51
|
-
minifyWhitespace?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Whether to minify identifiers in the output
|
|
54
|
-
* Renames variables and functions to shorter names
|
|
55
|
-
*/
|
|
56
|
-
minifyIdentifiers?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Whether to minify syntax in the output
|
|
59
|
-
* Optimizes code structure for smaller file size
|
|
60
|
-
*/
|
|
61
|
-
minifySyntax?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Whether to watch for file changes and rebuild automatically
|
|
64
|
-
*/
|
|
65
|
-
watch?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Whether to generate TypeScript declaration files (.d.ts)
|
|
68
|
-
* When set to true, generates declaration files for all entry points
|
|
69
|
-
* Can also be configured with DtsOptions for more control
|
|
70
|
-
*/
|
|
71
|
-
dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify"> & {
|
|
72
|
-
entry?: string | string[]
|
|
73
|
-
});
|
|
74
|
-
/**
|
|
75
|
-
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
76
|
-
*
|
|
77
|
-
* If not specified, the tsconfig.json in the project root will be used.
|
|
78
|
-
* This option allows you to use a different TypeScript configuration
|
|
79
|
-
* specifically for declaration file generation.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* preferredTsconfigPath: './tsconfig.build.json'
|
|
83
|
-
*/
|
|
84
|
-
preferredTsconfigPath?: string;
|
|
85
|
-
/**
|
|
86
|
-
* External packages that should not be bundled
|
|
87
|
-
* Useful for dependencies that should be kept as external imports
|
|
88
|
-
*/
|
|
89
|
-
external?: External;
|
|
90
|
-
/**
|
|
91
|
-
* Packages that should be bundled even if they are in external
|
|
92
|
-
* Useful for dependencies that should be included in the bundle
|
|
93
|
-
*/
|
|
94
|
-
noExternal?: External;
|
|
95
|
-
/**
|
|
96
|
-
* The target environment for the bundle.
|
|
97
|
-
* Can be 'browser', 'bun', 'node', etc.
|
|
98
|
-
* Defaults to 'node' if not specified.
|
|
99
|
-
*
|
|
100
|
-
* Bun target is for generating bundles that are intended to be run by the Bun runtime. In many cases,
|
|
101
|
-
* it isn't necessary to bundle server-side code; you can directly execute the source code
|
|
102
|
-
* without modification. However, bundling your server code can reduce startup times and
|
|
103
|
-
* improve running performance.
|
|
104
|
-
*
|
|
105
|
-
* All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which
|
|
106
|
-
* indicates to the Bun runtime that there's no need to re-transpile the file before execution.
|
|
107
|
-
*/
|
|
108
|
-
target?: Target;
|
|
109
|
-
/**
|
|
110
|
-
* Whether to clean the output directory before building
|
|
111
|
-
* When true, removes all files in the outDir before starting a new build
|
|
112
|
-
* Defaults to true if not specified
|
|
113
|
-
*/
|
|
114
|
-
clean?: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Specifies the type of sourcemap to generate
|
|
117
|
-
* Can be 'none', 'linked', 'external', or 'inline'
|
|
118
|
-
* Can also be a boolean - when true, it will use 'inline'
|
|
119
|
-
*
|
|
120
|
-
* @see https://bun.sh/docs/bundler#sourcemap
|
|
121
|
-
*
|
|
122
|
-
* @default 'none'
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* sourcemap: 'linked'
|
|
126
|
-
* // or
|
|
127
|
-
* sourcemap: true // equivalent to 'inline'
|
|
128
|
-
*/
|
|
129
|
-
sourcemap?: Sourcemap;
|
|
130
|
-
/**\\n\\t* Define global constants for the build\\n\\t* These values will be replaced at build time\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#define\\n\\t*\\n\\t* @example\\n\\t* define: {\\n\\t* 'process.env.NODE_ENV': '"production"',\\n\\t* 'PACKAGE_VERSION': '"1.0.0"'\\n\\t* }\\n\\t*/
|
|
131
|
-
define?: Define;
|
|
132
|
-
/**
|
|
133
|
-
* A callback function that runs after the build process completes
|
|
134
|
-
* This can be used for custom post-build operations like copying files,
|
|
135
|
-
* running additional tools, or logging build information
|
|
136
|
-
*
|
|
137
|
-
* If watch mode is enabled, this callback runs after each rebuild
|
|
138
|
-
*
|
|
139
|
-
* @param options The build options that were used
|
|
140
|
-
*/
|
|
141
|
-
onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
|
|
142
|
-
/**\\n\\t* A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#banner\\n\\t*\\n\\t* @example\\n\\t* banner: '"use client";'\\n\\t*/
|
|
143
|
-
banner?: string;
|
|
144
|
-
/**
|
|
145
|
-
* A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
|
|
146
|
-
*
|
|
147
|
-
* @see https://bun.sh/docs/bundler#footer
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* footer: '// built with love in SF'
|
|
151
|
-
*/
|
|
152
|
-
footer?: string;
|
|
153
|
-
/**
|
|
154
|
-
* Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
|
|
155
|
-
*
|
|
156
|
-
* @see https://bun.sh/docs/bundler#drop
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
|
|
160
|
-
*/
|
|
161
|
-
drop?: string[];
|
|
162
|
-
/**
|
|
163
|
-
* A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
|
164
|
-
*
|
|
165
|
-
* @see https://bun.sh/docs/bundler#loader
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* loader: {
|
|
169
|
-
* ".png": "dataurl",
|
|
170
|
-
* ".txt": "file",
|
|
171
|
-
* }
|
|
172
|
-
*/
|
|
173
|
-
loader?: { [k in string] : Loader };
|
|
174
|
-
/**
|
|
175
|
-
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
176
|
-
*
|
|
177
|
-
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
178
|
-
*
|
|
179
|
-
* Must be target: "bun"
|
|
180
|
-
*
|
|
181
|
-
* @see https://bun.sh/docs/bundler#bytecode
|
|
182
|
-
*
|
|
183
|
-
* @default false
|
|
184
|
-
*/
|
|
185
|
-
bytecode?: boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
188
|
-
*
|
|
189
|
-
* @default false
|
|
190
|
-
*/
|
|
191
|
-
silent?: boolean;
|
|
192
|
-
/**
|
|
193
|
-
* You can specify a prefix to be added to specific import paths in your bundled code
|
|
194
|
-
*
|
|
195
|
-
* Used for assets, external modules, and chunk files when splitting is enabled
|
|
196
|
-
*
|
|
197
|
-
* @see https://bunup.dev/docs#public-path for more information
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* publicPath: 'https://cdn.example.com/'
|
|
201
|
-
*/
|
|
202
|
-
publicPath?: string;
|
|
203
|
-
/**
|
|
204
|
-
* Controls how environment variables are handled during bundling.
|
|
205
|
-
*
|
|
206
|
-
* Can be one of:
|
|
207
|
-
* - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
|
|
208
|
-
* of those environment variables at the time the build runs.
|
|
209
|
-
* - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
|
|
210
|
-
* - A string ending in `*`: Only inlines environment variables matching the given prefix.
|
|
211
|
-
* For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
|
|
212
|
-
* - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
|
|
213
|
-
* with the provided values, regardless of the runtime environment.
|
|
214
|
-
*
|
|
215
|
-
* Note: Values are injected at build time. Secrets or private keys should be excluded
|
|
216
|
-
* from inlining when targeting browser environments.
|
|
217
|
-
*
|
|
218
|
-
* @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* // Inline all environment variables available at build time
|
|
222
|
-
* env: "inline"
|
|
223
|
-
*
|
|
224
|
-
* // Disable all environment variable injection
|
|
225
|
-
* env: "disable"
|
|
226
|
-
*
|
|
227
|
-
* // Only inline environment variables with a specific prefix
|
|
228
|
-
* env: "PUBLIC_*"
|
|
229
|
-
*
|
|
230
|
-
* // Provide specific environment variables manually
|
|
231
|
-
* env: { API_URL: "https://api.example.com", DEBUG: "false" }
|
|
232
|
-
*/
|
|
233
|
-
env?: Env;
|
|
234
|
-
/**
|
|
235
|
-
* Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
|
|
236
|
-
* "sideEffects" fields. This should only be used as a temporary workaround for incorrect
|
|
237
|
-
* annotations in libraries.
|
|
238
|
-
*/
|
|
239
|
-
ignoreDCEAnnotations?: boolean;
|
|
240
|
-
/**
|
|
241
|
-
* Force emitting @__PURE__ annotations even if minify.whitespace is true.
|
|
242
|
-
*/
|
|
243
|
-
emitDCEAnnotations?: boolean;
|
|
244
|
-
/**\\n\\t* Plugins to extend the build process functionality\\n\\t*\\n\\t* The Plugin type uses a discriminated union pattern with the 'type' field\\n\\t* to support different plugin systems. Both "bun" and "bunup" plugins are supported.\\n\\t*\\n\\t* Each plugin type has its own specific plugin implementation:\\n\\t* - "bun": Uses Bun's native plugin system (BunPlugin)\\n\\t* - "bunup": Uses bunup's own plugin system with lifecycle hooks\\n\\t*\\n\\t* This architecture allows for extensibility as more plugin systems are added.\\n\\t*\\n\\t* @see https://bunup.dev/docs/advanced/plugin-development for more information on plugins\\n\\t*\\n\\t* @example\\n\\t* plugins: [\\n\\t* {\\n\\t* type: "bun",\\n\\t* plugin: myBunPlugin()\\n\\t* },\\n\\t* {\\n\\t* type: "bunup",\\n\\t* hooks: {\\n\\t* onBuildStart: (options) => {\\n\\t* console.log('Build started with options:', options)\\n\\t* },\\n\\t* onBuildDone: ({ options, output }) => {\\n\\t* console.log('Build completed with output:', output)\\n\\t* }\\n\\t* }\\n\\t* }\\n\\t* ]\\n\\t*/
|
|
245
|
-
plugins?: Plugin[];
|
|
246
|
-
}
|
|
247
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
248
|
-
type PackageJson = {
|
|
249
|
-
/** The parsed content of the package.json file */
|
|
250
|
-
data: Record<string, any> | null
|
|
251
|
-
/** The path to the package.json file */
|
|
252
|
-
path: string | null
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* Represents a Bun plugin that can be used with Bunup
|
|
256
|
-
*/
|
|
257
|
-
type BunupBunPlugin = {
|
|
258
|
-
/** Identifies this as a native Bun plugin */
|
|
259
|
-
type: "bun"
|
|
260
|
-
/** Optional name for the plugin */
|
|
261
|
-
name?: string
|
|
262
|
-
/** The actual Bun plugin implementation */
|
|
263
|
-
plugin: BunPlugin
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Represents the meta data of the build
|
|
267
|
-
*/
|
|
268
|
-
type BuildMeta = {
|
|
269
|
-
/** The package.json file */
|
|
270
|
-
packageJson: PackageJson
|
|
271
|
-
/** The root directory of the build */
|
|
272
|
-
rootDir: string
|
|
273
|
-
};
|
|
274
|
-
type BuildOutputFile = {
|
|
275
|
-
/**
|
|
276
|
-
* The entry point for which this file was generated
|
|
277
|
-
*
|
|
278
|
-
* Undefined for non-entry point files (e.g., assets, sourcemaps, chunks)
|
|
279
|
-
*/
|
|
280
|
-
entrypoint: string | undefined
|
|
281
|
-
/** The kind of the file */
|
|
282
|
-
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
283
|
-
/** Path to the generated file */
|
|
284
|
-
fullPath: string
|
|
285
|
-
/** Path to the generated file relative to the root directory */
|
|
286
|
-
relativePathToRootDir: string
|
|
287
|
-
/** Path to the generated file relative to the output directory */
|
|
288
|
-
relativePathToOutputDir: string
|
|
289
|
-
/** Whether the file is a dts file */
|
|
290
|
-
dts: boolean
|
|
291
|
-
/** The format of the output file */
|
|
292
|
-
format: Format
|
|
293
|
-
};
|
|
294
|
-
/**
|
|
295
|
-
* Represents the output of a build operation
|
|
296
|
-
*/
|
|
297
|
-
type BuildOutput = {
|
|
298
|
-
/** Array of generated files with their paths and contents */
|
|
299
|
-
files: BuildOutputFile[]
|
|
300
|
-
};
|
|
301
|
-
/**
|
|
302
|
-
* Context provided to build hooks
|
|
303
|
-
*/
|
|
304
|
-
type BuildContext = {
|
|
305
|
-
/** The build options that were used */
|
|
306
|
-
options: BuildOptions
|
|
307
|
-
/** The output of the build */
|
|
308
|
-
output: BuildOutput
|
|
309
|
-
/** The meta data of the build */
|
|
310
|
-
meta: BuildMeta
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Hooks that can be implemented by Bunup plugins
|
|
314
|
-
*/
|
|
315
|
-
type BunupPluginHooks = {
|
|
316
|
-
/**
|
|
317
|
-
* Called when a build is successfully completed
|
|
318
|
-
* @param ctx Build context containing options and output
|
|
319
|
-
*/
|
|
320
|
-
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
321
|
-
/**
|
|
322
|
-
* Called before a build starts
|
|
323
|
-
* @param options Build options that will be used
|
|
324
|
-
*/
|
|
325
|
-
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* Represents a Bunup-specific plugin
|
|
329
|
-
*/
|
|
330
|
-
type BunupPlugin = {
|
|
331
|
-
/** Identifies this as a Bunup-specific plugin */
|
|
332
|
-
type: "bunup"
|
|
333
|
-
/** Optional name for the plugin */
|
|
334
|
-
name?: string
|
|
335
|
-
/** The hooks implemented by this plugin */
|
|
336
|
-
hooks: BunupPluginHooks
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* Union type representing all supported plugin types
|
|
340
|
-
*/
|
|
341
|
-
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./shared/chunk-95p7cdc9";
|
|
342
2
|
/**
|
|
343
3
|
* A plugin that copies files and directories to the output directory.
|
|
344
4
|
*
|
|
@@ -348,7 +8,7 @@ type Plugin = BunupBunPlugin | BunupPlugin;
|
|
|
348
8
|
*/
|
|
349
9
|
declare function copy(patterns: string[], outPath?: string): BunupPlugin;
|
|
350
10
|
type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
|
|
351
|
-
type
|
|
11
|
+
type Exclude = ((ctx: BuildContext) => string[] | undefined) | string[];
|
|
352
12
|
interface ExportsPluginOptions {
|
|
353
13
|
/**
|
|
354
14
|
* Additional export fields to preserve alongside automatically generated exports
|
|
@@ -361,7 +21,7 @@ interface ExportsPluginOptions {
|
|
|
361
21
|
*
|
|
362
22
|
* @see https://bunup.dev/docs/plugins/exports#exclude
|
|
363
23
|
*/
|
|
364
|
-
exclude?:
|
|
24
|
+
exclude?: Exclude;
|
|
365
25
|
}
|
|
366
26
|
/**
|
|
367
27
|
* A plugin that generates the exports field in the package.json file automatically.
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { GenerateDtsOptions } from "typeroll";
|
|
2
|
+
import { BunPlugin } from "bun";
|
|
3
|
+
type PackageJson = {
|
|
4
|
+
/** The parsed content of the package.json file */
|
|
5
|
+
data: Record<string, any> | null
|
|
6
|
+
/** The path to the package.json file */
|
|
7
|
+
path: string | null
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Represents a Bun plugin that can be used with Bunup
|
|
11
|
+
*/
|
|
12
|
+
type BunupBunPlugin = {
|
|
13
|
+
/** Identifies this as a native Bun plugin */
|
|
14
|
+
type: "bun"
|
|
15
|
+
/** Optional name for the plugin */
|
|
16
|
+
name?: string
|
|
17
|
+
/** The actual Bun plugin implementation */
|
|
18
|
+
plugin: BunPlugin
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Represents the meta data of the build
|
|
22
|
+
*/
|
|
23
|
+
type BuildMeta = {
|
|
24
|
+
/** The package.json file */
|
|
25
|
+
packageJson: PackageJson
|
|
26
|
+
/** The root directory of the build */
|
|
27
|
+
rootDir: string
|
|
28
|
+
};
|
|
29
|
+
type BuildOutputFile = {
|
|
30
|
+
/**
|
|
31
|
+
* The entry point for which this file was generated
|
|
32
|
+
*
|
|
33
|
+
* Undefined for non-entry point files (e.g., assets, sourcemaps, chunks)
|
|
34
|
+
*/
|
|
35
|
+
entrypoint: string | undefined
|
|
36
|
+
/** The kind of the file */
|
|
37
|
+
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
38
|
+
/** Path to the generated file */
|
|
39
|
+
fullPath: string
|
|
40
|
+
/** Path to the generated file relative to the root directory */
|
|
41
|
+
relativePathToRootDir: string
|
|
42
|
+
/** Path to the generated file relative to the output directory */
|
|
43
|
+
relativePathToOutputDir: string
|
|
44
|
+
/** Whether the file is a dts file */
|
|
45
|
+
dts: boolean
|
|
46
|
+
/** The format of the output file */
|
|
47
|
+
format: Format
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Represents the output of a build operation
|
|
51
|
+
*/
|
|
52
|
+
type BuildOutput = {
|
|
53
|
+
/** Array of generated files with their paths and contents */
|
|
54
|
+
files: BuildOutputFile[]
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Context provided to build hooks
|
|
58
|
+
*/
|
|
59
|
+
type BuildContext = {
|
|
60
|
+
/** The build options that were used */
|
|
61
|
+
options: BuildOptions
|
|
62
|
+
/** The output of the build */
|
|
63
|
+
output: BuildOutput
|
|
64
|
+
/** The meta data of the build */
|
|
65
|
+
meta: BuildMeta
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Hooks that can be implemented by Bunup plugins
|
|
69
|
+
*/
|
|
70
|
+
type BunupPluginHooks = {
|
|
71
|
+
/**
|
|
72
|
+
* Called when a build is successfully completed
|
|
73
|
+
* @param ctx Build context containing options and output
|
|
74
|
+
*/
|
|
75
|
+
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
76
|
+
/**
|
|
77
|
+
* Called before a build starts
|
|
78
|
+
* @param options Build options that will be used
|
|
79
|
+
*/
|
|
80
|
+
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Represents a Bunup-specific plugin
|
|
84
|
+
*/
|
|
85
|
+
type BunupPlugin = {
|
|
86
|
+
/** Identifies this as a Bunup-specific plugin */
|
|
87
|
+
type: "bunup"
|
|
88
|
+
/** Optional name for the plugin */
|
|
89
|
+
name?: string
|
|
90
|
+
/** The hooks implemented by this plugin */
|
|
91
|
+
hooks: BunupPluginHooks
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Union type representing all supported plugin types
|
|
95
|
+
*/
|
|
96
|
+
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
97
|
+
type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
|
|
98
|
+
type Define = Record<string, string>;
|
|
99
|
+
type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
|
|
100
|
+
type Format = "esm" | "cjs" | "iife";
|
|
101
|
+
type Target = "bun" | "node" | "browser";
|
|
102
|
+
type External = (string | RegExp)[];
|
|
103
|
+
type Env = "inline" | "disable" | `${string}*` | Record<string, string>;
|
|
104
|
+
interface BuildOptions {
|
|
105
|
+
/**
|
|
106
|
+
* Name of the build configuration
|
|
107
|
+
* Used for logging and identification purposes
|
|
108
|
+
*/
|
|
109
|
+
name?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Entry point files for the build
|
|
112
|
+
*
|
|
113
|
+
* This can be:
|
|
114
|
+
* - A string path to a file
|
|
115
|
+
* - An array of file paths
|
|
116
|
+
*
|
|
117
|
+
* @see https://bunup.dev/docs/#entry-points
|
|
118
|
+
*/
|
|
119
|
+
entry: string | string[];
|
|
120
|
+
/**
|
|
121
|
+
* Output directory for the bundled files
|
|
122
|
+
* Defaults to 'dist' if not specified
|
|
123
|
+
*/
|
|
124
|
+
outDir: string;
|
|
125
|
+
/**
|
|
126
|
+
* Output formats for the bundle
|
|
127
|
+
* Can include 'esm', 'cjs', and/or 'iife'
|
|
128
|
+
* Defaults to ['esm'] if not specified
|
|
129
|
+
*/
|
|
130
|
+
format: Format[];
|
|
131
|
+
/**
|
|
132
|
+
* Whether to enable all minification options
|
|
133
|
+
* When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
|
|
134
|
+
*/
|
|
135
|
+
minify?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether to enable code splitting
|
|
138
|
+
* Defaults to true for ESM format, false for CJS format
|
|
139
|
+
*/
|
|
140
|
+
splitting?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether to minify whitespace in the output
|
|
143
|
+
* Removes unnecessary whitespace to reduce file size
|
|
144
|
+
*/
|
|
145
|
+
minifyWhitespace?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether to minify identifiers in the output
|
|
148
|
+
* Renames variables and functions to shorter names
|
|
149
|
+
*/
|
|
150
|
+
minifyIdentifiers?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Whether to minify syntax in the output
|
|
153
|
+
* Optimizes code structure for smaller file size
|
|
154
|
+
*/
|
|
155
|
+
minifySyntax?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Whether to watch for file changes and rebuild automatically
|
|
158
|
+
*/
|
|
159
|
+
watch?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Whether to generate TypeScript declaration files (.d.ts)
|
|
162
|
+
* When set to true, generates declaration files for all entry points
|
|
163
|
+
* Can also be configured with DtsOptions for more control
|
|
164
|
+
*/
|
|
165
|
+
dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify"> & {
|
|
166
|
+
entry?: string | string[]
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
170
|
+
*
|
|
171
|
+
* If not specified, the tsconfig.json in the project root will be used.
|
|
172
|
+
* This option allows you to use a different TypeScript configuration
|
|
173
|
+
* specifically for declaration file generation.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* preferredTsconfigPath: './tsconfig.build.json'
|
|
177
|
+
*/
|
|
178
|
+
preferredTsconfigPath?: string;
|
|
179
|
+
/**
|
|
180
|
+
* External packages that should not be bundled
|
|
181
|
+
* Useful for dependencies that should be kept as external imports
|
|
182
|
+
*/
|
|
183
|
+
external?: External;
|
|
184
|
+
/**
|
|
185
|
+
* Packages that should be bundled even if they are in external
|
|
186
|
+
* Useful for dependencies that should be included in the bundle
|
|
187
|
+
*/
|
|
188
|
+
noExternal?: External;
|
|
189
|
+
/**
|
|
190
|
+
* The target environment for the bundle.
|
|
191
|
+
* Can be 'browser', 'bun', 'node', etc.
|
|
192
|
+
* Defaults to 'node' if not specified.
|
|
193
|
+
*
|
|
194
|
+
* Bun target is for generating bundles that are intended to be run by the Bun runtime. In many cases,
|
|
195
|
+
* it isn't necessary to bundle server-side code; you can directly execute the source code
|
|
196
|
+
* without modification. However, bundling your server code can reduce startup times and
|
|
197
|
+
* improve running performance.
|
|
198
|
+
*
|
|
199
|
+
* All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which
|
|
200
|
+
* indicates to the Bun runtime that there's no need to re-transpile the file before execution.
|
|
201
|
+
*/
|
|
202
|
+
target?: Target;
|
|
203
|
+
/**
|
|
204
|
+
* Whether to clean the output directory before building
|
|
205
|
+
* When true, removes all files in the outDir before starting a new build
|
|
206
|
+
* Defaults to true if not specified
|
|
207
|
+
*/
|
|
208
|
+
clean?: boolean;
|
|
209
|
+
/**
|
|
210
|
+
* Specifies the type of sourcemap to generate
|
|
211
|
+
* Can be 'none', 'linked', 'external', or 'inline'
|
|
212
|
+
* Can also be a boolean - when true, it will use 'inline'
|
|
213
|
+
*
|
|
214
|
+
* @see https://bun.sh/docs/bundler#sourcemap
|
|
215
|
+
*
|
|
216
|
+
* @default 'none'
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* sourcemap: 'linked'
|
|
220
|
+
* // or
|
|
221
|
+
* sourcemap: true // equivalent to 'inline'
|
|
222
|
+
*/
|
|
223
|
+
sourcemap?: Sourcemap;
|
|
224
|
+
/**\\n\\t* Define global constants for the build\\n\\t* These values will be replaced at build time\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#define\\n\\t*\\n\\t* @example\\n\\t* define: {\\n\\t* 'process.env.NODE_ENV': '"production"',\\n\\t* 'PACKAGE_VERSION': '"1.0.0"'\\n\\t* }\\n\\t*/
|
|
225
|
+
define?: Define;
|
|
226
|
+
/**
|
|
227
|
+
* A callback function that runs after the build process completes
|
|
228
|
+
* This can be used for custom post-build operations like copying files,
|
|
229
|
+
* running additional tools, or logging build information
|
|
230
|
+
*
|
|
231
|
+
* If watch mode is enabled, this callback runs after each rebuild
|
|
232
|
+
*
|
|
233
|
+
* @param options The build options that were used
|
|
234
|
+
*/
|
|
235
|
+
onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
|
|
236
|
+
/**\\n\\t* A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#banner\\n\\t*\\n\\t* @example\\n\\t* banner: '"use client";'\\n\\t*/
|
|
237
|
+
banner?: string;
|
|
238
|
+
/**
|
|
239
|
+
* A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
|
|
240
|
+
*
|
|
241
|
+
* @see https://bun.sh/docs/bundler#footer
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* footer: '// built with love in SF'
|
|
245
|
+
*/
|
|
246
|
+
footer?: string;
|
|
247
|
+
/**
|
|
248
|
+
* Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
|
|
249
|
+
*
|
|
250
|
+
* @see https://bun.sh/docs/bundler#drop
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
|
|
254
|
+
*/
|
|
255
|
+
drop?: string[];
|
|
256
|
+
/**
|
|
257
|
+
* A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
|
258
|
+
*
|
|
259
|
+
* @see https://bun.sh/docs/bundler#loader
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* loader: {
|
|
263
|
+
* ".png": "dataurl",
|
|
264
|
+
* ".txt": "file",
|
|
265
|
+
* }
|
|
266
|
+
*/
|
|
267
|
+
loader?: { [k in string] : Loader };
|
|
268
|
+
/**
|
|
269
|
+
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
270
|
+
*
|
|
271
|
+
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
272
|
+
*
|
|
273
|
+
* Must be target: "bun"
|
|
274
|
+
*
|
|
275
|
+
* @see https://bun.sh/docs/bundler#bytecode
|
|
276
|
+
*
|
|
277
|
+
* @default false
|
|
278
|
+
*/
|
|
279
|
+
bytecode?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
282
|
+
*
|
|
283
|
+
* @default false
|
|
284
|
+
*/
|
|
285
|
+
silent?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* You can specify a prefix to be added to specific import paths in your bundled code
|
|
288
|
+
*
|
|
289
|
+
* Used for assets, external modules, and chunk files when splitting is enabled
|
|
290
|
+
*
|
|
291
|
+
* @see https://bunup.dev/docs#public-path for more information
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* publicPath: 'https://cdn.example.com/'
|
|
295
|
+
*/
|
|
296
|
+
publicPath?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Controls how environment variables are handled during bundling.
|
|
299
|
+
*
|
|
300
|
+
* Can be one of:
|
|
301
|
+
* - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
|
|
302
|
+
* of those environment variables at the time the build runs.
|
|
303
|
+
* - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
|
|
304
|
+
* - A string ending in `*`: Only inlines environment variables matching the given prefix.
|
|
305
|
+
* For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
|
|
306
|
+
* - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
|
|
307
|
+
* with the provided values, regardless of the runtime environment.
|
|
308
|
+
*
|
|
309
|
+
* Note: Values are injected at build time. Secrets or private keys should be excluded
|
|
310
|
+
* from inlining when targeting browser environments.
|
|
311
|
+
*
|
|
312
|
+
* @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* // Inline all environment variables available at build time
|
|
316
|
+
* env: "inline"
|
|
317
|
+
*
|
|
318
|
+
* // Disable all environment variable injection
|
|
319
|
+
* env: "disable"
|
|
320
|
+
*
|
|
321
|
+
* // Only inline environment variables with a specific prefix
|
|
322
|
+
* env: "PUBLIC_*"
|
|
323
|
+
*
|
|
324
|
+
* // Provide specific environment variables manually
|
|
325
|
+
* env: { API_URL: "https://api.example.com", DEBUG: "false" }
|
|
326
|
+
*/
|
|
327
|
+
env?: Env;
|
|
328
|
+
/**
|
|
329
|
+
* Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
|
|
330
|
+
* "sideEffects" fields. This should only be used as a temporary workaround for incorrect
|
|
331
|
+
* annotations in libraries.
|
|
332
|
+
*/
|
|
333
|
+
ignoreDCEAnnotations?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Force emitting @__PURE__ annotations even if minify.whitespace is true.
|
|
336
|
+
*/
|
|
337
|
+
emitDCEAnnotations?: boolean;
|
|
338
|
+
/**\\n\\t* Plugins to extend the build process functionality\\n\\t*\\n\\t* The Plugin type uses a discriminated union pattern with the 'type' field\\n\\t* to support different plugin systems. Both "bun" and "bunup" plugins are supported.\\n\\t*\\n\\t* Each plugin type has its own specific plugin implementation:\\n\\t* - "bun": Uses Bun's native plugin system (BunPlugin)\\n\\t* - "bunup": Uses bunup's own plugin system with lifecycle hooks\\n\\t*\\n\\t* This architecture allows for extensibility as more plugin systems are added.\\n\\t*\\n\\t* @see https://bunup.dev/docs/advanced/plugin-development for more information on plugins\\n\\t*\\n\\t* @example\\n\\t* plugins: [\\n\\t* {\\n\\t* type: "bun",\\n\\t* plugin: myBunPlugin()\\n\\t* },\\n\\t* {\\n\\t* type: "bunup",\\n\\t* hooks: {\\n\\t* onBuildStart: (options) => {\\n\\t* console.log('Build started with options:', options)\\n\\t* },\\n\\t* onBuildDone: ({ options, output }) => {\\n\\t* console.log('Build completed with output:', output)\\n\\t* }\\n\\t* }\\n\\t* }\\n\\t* ]\\n\\t*/
|
|
339
|
+
plugins?: Plugin[];
|
|
340
|
+
}
|
|
341
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
342
|
+
type WithOptional<
|
|
343
|
+
T,
|
|
344
|
+
K extends keyof T
|
|
345
|
+
> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
346
|
+
type Arrayable<T> = T | T[];
|
|
347
|
+
type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
|
|
348
|
+
type DefineWorkspaceItem = {
|
|
349
|
+
name: string
|
|
350
|
+
root: string
|
|
351
|
+
config: DefineConfigItem | DefineConfigItem[]
|
|
352
|
+
};
|
|
353
|
+
export { MaybePromise, WithOptional, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin, Plugin, BuildOptions };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
3
|
"description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.71",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"picocolors": "^1.1.1",
|
|
55
55
|
"replace-in-file": "^8.3.0",
|
|
56
56
|
"tinyexec": "^1.0.1",
|
|
57
|
-
"typeroll": "^0.6.
|
|
57
|
+
"typeroll": "^0.6.21"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@babel/types": "^7.28.1",
|