bunup 0.8.56 → 0.8.58

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/plugins.d.ts CHANGED
@@ -1,4 +1,344 @@
1
- import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-w6swmckt";
1
+ import { BunPlugin } from "bun";
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 ['cjs'] 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;
2
342
  /**
3
343
  * A plugin that copies files and directories to the output directory.
4
344
  *
@@ -8,7 +348,7 @@ import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-w6swmck
8
348
  */
9
349
  declare function copy(patterns: string[], outPath?: string): BunupPlugin;
10
350
  type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
11
- type Exclude = ((ctx: BuildContext) => string[] | undefined) | string[];
351
+ type Exclude2 = ((ctx: BuildContext) => string[] | undefined) | string[];
12
352
  interface ExportsPluginOptions {
13
353
  /**
14
354
  * Additional export fields to preserve alongside automatically generated exports
@@ -21,7 +361,7 @@ interface ExportsPluginOptions {
21
361
  *
22
362
  * @see https://bunup.dev/docs/plugins/exports#exclude
23
363
  */
24
- exclude?: Exclude;
364
+ exclude?: Exclude2;
25
365
  }
26
366
  /**
27
367
  * A plugin that generates the exports field in the package.json file automatically.
package/dist/plugins.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  getPackageForPlugin
4
- } from "./chunk-zpjpa5th.js";
4
+ } from "./chunk-0j56xynx.js";
5
5
  import {
6
6
  CSS_RE,
7
7
  JS_DTS_RE,
@@ -9,7 +9,7 @@ import {
9
9
  cleanPath,
10
10
  isDirectoryPath,
11
11
  logger
12
- } from "./chunk-cakmscpb.js";
12
+ } from "./chunk-2g0gpaee.js";
13
13
 
14
14
  // src/plugins/built-in/copy.ts
15
15
  import { basename, join } from "path";
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.56",
4
+ "version": "0.8.58",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -53,7 +53,7 @@
53
53
  "picocolors": "^1.1.1",
54
54
  "replace-in-file": "^8.3.0",
55
55
  "tinyexec": "^1.0.1",
56
- "typeroll": "^0.6.15"
56
+ "typeroll": "^0.6.16"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@babel/types": "^7.27.7",