bunup 0.8.30 → 0.8.32
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/{cli/index.d.cts → chunk-8sqm3fje.d.ts} +89 -90
- package/dist/cli/index.js +68 -141
- package/dist/index.d.ts +1 -358
- package/dist/index.js +40 -111
- package/dist/plugins.d.ts +1 -347
- package/dist/plugins.js +40 -111
- package/package.json +102 -96
- package/dist/cli/index.cjs +0 -2030
- package/dist/cli/index.d.ts +0 -360
- package/dist/index.cjs +0 -1168
- package/dist/index.d.cts +0 -362
- package/dist/plugins.cjs +0 -866
- package/dist/plugins.d.cts +0 -385
package/dist/index.d.ts
CHANGED
|
@@ -1,361 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
type PackageJson = {
|
|
3
|
-
/** The parsed content of the package.json file */
|
|
4
|
-
data: Record<string, any> | null
|
|
5
|
-
/** The path to the package.json file */
|
|
6
|
-
path: string | null
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Represents a Bun plugin that can be used with Bunup
|
|
10
|
-
*/
|
|
11
|
-
type BunupBunPlugin = {
|
|
12
|
-
/** Identifies this as a native Bun plugin */
|
|
13
|
-
type: "bun"
|
|
14
|
-
/** Optional name for the plugin */
|
|
15
|
-
name?: string
|
|
16
|
-
/** The actual Bun plugin implementation */
|
|
17
|
-
plugin: BunPlugin
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Represents the meta data of the build
|
|
21
|
-
*/
|
|
22
|
-
type BuildMeta = {
|
|
23
|
-
/** The package.json file */
|
|
24
|
-
packageJson: PackageJson
|
|
25
|
-
/** The root directory of the build */
|
|
26
|
-
rootDir: string
|
|
27
|
-
};
|
|
28
|
-
type BuildOutputFile = {
|
|
29
|
-
/** The kind of the file */
|
|
30
|
-
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
31
|
-
/** Path to the generated file */
|
|
32
|
-
fullPath: string
|
|
33
|
-
/** Path to the generated file relative to the root directory */
|
|
34
|
-
relativePathToRootDir: string
|
|
35
|
-
/** Path to the generated file relative to the output directory */
|
|
36
|
-
relativePathToOutputDir: string
|
|
37
|
-
/** Whether the file is a dts file */
|
|
38
|
-
dts: boolean
|
|
39
|
-
/** The format of the output file */
|
|
40
|
-
format: Format
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Represents the output of a build operation
|
|
44
|
-
*/
|
|
45
|
-
type BuildOutput = {
|
|
46
|
-
/** Array of generated files with their paths and contents */
|
|
47
|
-
files: BuildOutputFile[]
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Context provided to build hooks
|
|
51
|
-
*/
|
|
52
|
-
type BuildContext = {
|
|
53
|
-
/** The build options that were used */
|
|
54
|
-
options: BuildOptions
|
|
55
|
-
/** The output of the build */
|
|
56
|
-
output: BuildOutput
|
|
57
|
-
/** The meta data of the build */
|
|
58
|
-
meta: BuildMeta
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Hooks that can be implemented by Bunup plugins
|
|
62
|
-
*/
|
|
63
|
-
type BunupPluginHooks = {
|
|
64
|
-
/**
|
|
65
|
-
* Called when a build is successfully completed
|
|
66
|
-
* @param ctx Build context containing options and output
|
|
67
|
-
*/
|
|
68
|
-
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
|
|
69
|
-
/**
|
|
70
|
-
* Called before a build starts
|
|
71
|
-
* @param options Build options that will be used
|
|
72
|
-
*/
|
|
73
|
-
onBuildStart?: (options: BuildOptions) => MaybePromise<void>
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Represents a Bunup-specific plugin
|
|
77
|
-
*/
|
|
78
|
-
type BunupPlugin = {
|
|
79
|
-
/** Identifies this as a Bunup-specific plugin */
|
|
80
|
-
type: "bunup"
|
|
81
|
-
/** Optional name for the plugin */
|
|
82
|
-
name?: string
|
|
83
|
-
/** The hooks implemented by this plugin */
|
|
84
|
-
hooks: BunupPluginHooks
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Union type representing all supported plugin types
|
|
88
|
-
*/
|
|
89
|
-
type Plugin = BunupBunPlugin | BunupPlugin;
|
|
90
|
-
type Loader = NonNullable<BunBuildOptions["loader"]>[string];
|
|
91
|
-
type Define = BunBuildOptions["define"];
|
|
92
|
-
type Sourcemap = BunBuildOptions["sourcemap"];
|
|
93
|
-
type Format = Exclude<BunBuildOptions["format"], undefined>;
|
|
94
|
-
type Target = BunBuildOptions["target"];
|
|
95
|
-
type External = (string | RegExp)[];
|
|
96
|
-
type Env = BunBuildOptions["env"] | Record<string, string>;
|
|
97
|
-
type DtsResolve = boolean | (string | RegExp)[];
|
|
98
|
-
type Naming = string | {
|
|
99
|
-
entry?: string
|
|
100
|
-
chunk?: string
|
|
101
|
-
asset?: string
|
|
102
|
-
};
|
|
103
|
-
type DtsOptions = {
|
|
104
|
-
/**
|
|
105
|
-
* Entry point files for TypeScript declaration file generation
|
|
106
|
-
*
|
|
107
|
-
* If not specified, the main entry points will be used for declaration file generation.
|
|
108
|
-
*
|
|
109
|
-
* @see https://bunup.dev/docs/guide/typescript-declarations#custom-entry-points
|
|
110
|
-
* @see https://bunup.dev/docs/guide/typescript-declarations#named-entries
|
|
111
|
-
*/
|
|
112
|
-
entry?: string | string[]
|
|
113
|
-
/**
|
|
114
|
-
* Resolve external types used in dts files from node_modules
|
|
115
|
-
*/
|
|
116
|
-
resolve?: DtsResolve
|
|
117
|
-
/**
|
|
118
|
-
* Whether to split declaration files when multiple entrypoints import the same files,
|
|
119
|
-
* modules, or share types. When enabled, shared types will be extracted to separate
|
|
120
|
-
* .d.ts files, and other declaration files will import these shared files.
|
|
121
|
-
*
|
|
122
|
-
* This helps reduce bundle size by preventing duplication of type definitions
|
|
123
|
-
* across multiple entrypoints.
|
|
124
|
-
*
|
|
125
|
-
* This option is enabled by default if splitting is enabled in the Bun build config or format is esm.
|
|
126
|
-
*/
|
|
127
|
-
splitting?: boolean
|
|
128
|
-
};
|
|
129
|
-
interface BuildOptions {
|
|
130
|
-
/**
|
|
131
|
-
* Name of the build configuration
|
|
132
|
-
* Used for logging and identification purposes
|
|
133
|
-
*/
|
|
134
|
-
name?: string;
|
|
135
|
-
/**
|
|
136
|
-
* Entry point files for the build
|
|
137
|
-
*
|
|
138
|
-
* This can be:
|
|
139
|
-
* - A string path to a file
|
|
140
|
-
* - An array of file paths
|
|
141
|
-
*
|
|
142
|
-
* @see https://bunup.dev/docs/#entry-points
|
|
143
|
-
*/
|
|
144
|
-
entry: string | string[];
|
|
145
|
-
/**
|
|
146
|
-
* Output directory for the bundled files
|
|
147
|
-
* Defaults to 'dist' if not specified
|
|
148
|
-
*/
|
|
149
|
-
outDir: string;
|
|
150
|
-
/**
|
|
151
|
-
* Output formats for the bundle
|
|
152
|
-
* Can include 'esm', 'cjs', and/or 'iife'
|
|
153
|
-
* Defaults to ['cjs'] if not specified
|
|
154
|
-
*/
|
|
155
|
-
format: Format[];
|
|
156
|
-
/**
|
|
157
|
-
* Whether to enable all minification options
|
|
158
|
-
* When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
|
|
159
|
-
*/
|
|
160
|
-
minify?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Whether to enable code splitting
|
|
163
|
-
* Defaults to true for ESM format, false for CJS format
|
|
164
|
-
*/
|
|
165
|
-
splitting?: boolean;
|
|
166
|
-
naming?: Naming;
|
|
167
|
-
/**
|
|
168
|
-
* Whether to minify whitespace in the output
|
|
169
|
-
* Removes unnecessary whitespace to reduce file size
|
|
170
|
-
*/
|
|
171
|
-
minifyWhitespace?: boolean;
|
|
172
|
-
/**
|
|
173
|
-
* Whether to minify identifiers in the output
|
|
174
|
-
* Renames variables and functions to shorter names
|
|
175
|
-
*/
|
|
176
|
-
minifyIdentifiers?: boolean;
|
|
177
|
-
/**
|
|
178
|
-
* Whether to minify syntax in the output
|
|
179
|
-
* Optimizes code structure for smaller file size
|
|
180
|
-
*/
|
|
181
|
-
minifySyntax?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Whether to watch for file changes and rebuild automatically
|
|
184
|
-
*/
|
|
185
|
-
watch?: boolean;
|
|
186
|
-
/**
|
|
187
|
-
* Whether to generate TypeScript declaration files (.d.ts)
|
|
188
|
-
* When set to true, generates declaration files for all entry points
|
|
189
|
-
* Can also be configured with DtsOptions for more control
|
|
190
|
-
*/
|
|
191
|
-
dts?: boolean | DtsOptions;
|
|
192
|
-
/**
|
|
193
|
-
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
194
|
-
*
|
|
195
|
-
* If not specified, the tsconfig.json in the project root will be used.
|
|
196
|
-
* This option allows you to use a different TypeScript configuration
|
|
197
|
-
* specifically for declaration file generation.
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* preferredTsconfigPath: './tsconfig.build.json'
|
|
201
|
-
*/
|
|
202
|
-
preferredTsconfigPath?: string;
|
|
203
|
-
/**
|
|
204
|
-
* External packages that should not be bundled
|
|
205
|
-
* Useful for dependencies that should be kept as external imports
|
|
206
|
-
*/
|
|
207
|
-
external?: External;
|
|
208
|
-
/**
|
|
209
|
-
* Packages that should be bundled even if they are in external
|
|
210
|
-
* Useful for dependencies that should be included in the bundle
|
|
211
|
-
*/
|
|
212
|
-
noExternal?: External;
|
|
213
|
-
/**
|
|
214
|
-
* The target environment for the bundle
|
|
215
|
-
* Can be 'browser', 'bun', 'node', etc.
|
|
216
|
-
* Defaults to 'node' if not specified
|
|
217
|
-
*/
|
|
218
|
-
target?: Target;
|
|
219
|
-
/**
|
|
220
|
-
* Whether to clean the output directory before building
|
|
221
|
-
* When true, removes all files in the outDir before starting a new build
|
|
222
|
-
* Defaults to true if not specified
|
|
223
|
-
*/
|
|
224
|
-
clean?: boolean;
|
|
225
|
-
/**
|
|
226
|
-
* Specifies the type of sourcemap to generate
|
|
227
|
-
* Can be 'none', 'linked', 'external', or 'inline'
|
|
228
|
-
* Can also be a boolean - when true, it will use 'inline'
|
|
229
|
-
*
|
|
230
|
-
* @see https://bun.sh/docs/bundler#sourcemap
|
|
231
|
-
*
|
|
232
|
-
* @default 'none'
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* sourcemap: 'linked'
|
|
236
|
-
* // or
|
|
237
|
-
* sourcemap: true // equivalent to 'inline'
|
|
238
|
-
*/
|
|
239
|
-
sourcemap?: Sourcemap;
|
|
240
|
-
define?: Define;
|
|
241
|
-
/**
|
|
242
|
-
* A callback function that runs after the build process completes
|
|
243
|
-
* This can be used for custom post-build operations like copying files,
|
|
244
|
-
* running additional tools, or logging build information
|
|
245
|
-
*
|
|
246
|
-
* If watch mode is enabled, this callback runs after each rebuild
|
|
247
|
-
*
|
|
248
|
-
* @param options The build options that were used
|
|
249
|
-
*/
|
|
250
|
-
onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
|
|
251
|
-
banner?: string;
|
|
252
|
-
/**
|
|
253
|
-
* 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.
|
|
254
|
-
*
|
|
255
|
-
* @see https://bun.sh/docs/bundler#footer
|
|
256
|
-
*
|
|
257
|
-
* @example
|
|
258
|
-
* footer: '// built with love in SF'
|
|
259
|
-
*/
|
|
260
|
-
footer?: string;
|
|
261
|
-
/**
|
|
262
|
-
* 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.
|
|
263
|
-
*
|
|
264
|
-
* @see https://bun.sh/docs/bundler#drop
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
|
|
268
|
-
*/
|
|
269
|
-
drop?: string[];
|
|
270
|
-
/**
|
|
271
|
-
* 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.
|
|
272
|
-
*
|
|
273
|
-
* @see https://bun.sh/docs/bundler#loader
|
|
274
|
-
*
|
|
275
|
-
* @example
|
|
276
|
-
* loader: {
|
|
277
|
-
* ".png": "dataurl",
|
|
278
|
-
* ".txt": "file",
|
|
279
|
-
* }
|
|
280
|
-
*/
|
|
281
|
-
loader?: Record<string, Loader>;
|
|
282
|
-
/**
|
|
283
|
-
* Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
|
|
284
|
-
*
|
|
285
|
-
* Bytecode is currently only supported for CommonJS (format: "cjs").
|
|
286
|
-
*
|
|
287
|
-
* Must be target: "bun"
|
|
288
|
-
*
|
|
289
|
-
* @see https://bun.sh/docs/bundler#bytecode
|
|
290
|
-
*
|
|
291
|
-
* @default false
|
|
292
|
-
*/
|
|
293
|
-
bytecode?: boolean;
|
|
294
|
-
/**
|
|
295
|
-
* Disable logging during the build process. When set to true, no logs will be printed to the console.
|
|
296
|
-
*
|
|
297
|
-
* @default false
|
|
298
|
-
*/
|
|
299
|
-
silent?: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* You can specify a prefix to be added to specific import paths in your bundled code
|
|
302
|
-
*
|
|
303
|
-
* Used for assets, external modules, and chunk files when splitting is enabled
|
|
304
|
-
*
|
|
305
|
-
* @see https://bunup.dev/docs#public-path for more information
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* publicPath: 'https://cdn.example.com/'
|
|
309
|
-
*/
|
|
310
|
-
publicPath?: string;
|
|
311
|
-
/**
|
|
312
|
-
* Controls how environment variables are handled during bundling.
|
|
313
|
-
*
|
|
314
|
-
* Can be one of:
|
|
315
|
-
* - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
|
|
316
|
-
* of those environment variables at the time the build runs.
|
|
317
|
-
* - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
|
|
318
|
-
* - A string ending in `*`: Only inlines environment variables matching the given prefix.
|
|
319
|
-
* For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
|
|
320
|
-
* - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
|
|
321
|
-
* with the provided values, regardless of the runtime environment.
|
|
322
|
-
*
|
|
323
|
-
* Note: Values are injected at build time. Secrets or private keys should be excluded
|
|
324
|
-
* from inlining when targeting browser environments.
|
|
325
|
-
*
|
|
326
|
-
* @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* // Inline all environment variables available at build time
|
|
330
|
-
* env: "inline"
|
|
331
|
-
*
|
|
332
|
-
* // Disable all environment variable injection
|
|
333
|
-
* env: "disable"
|
|
334
|
-
*
|
|
335
|
-
* // Only inline environment variables with a specific prefix
|
|
336
|
-
* env: "PUBLIC_*"
|
|
337
|
-
*
|
|
338
|
-
* // Provide specific environment variables manually
|
|
339
|
-
* env: { API_URL: "https://api.example.com", DEBUG: "false" }
|
|
340
|
-
*/
|
|
341
|
-
env?: Env;
|
|
342
|
-
plugins?: Plugin[];
|
|
343
|
-
}
|
|
344
|
-
type MaybePromise<T> = Promise<T> | T;
|
|
345
|
-
type WithOptional<
|
|
346
|
-
T,
|
|
347
|
-
K extends keyof T
|
|
348
|
-
> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
349
|
-
type Arrayable<T> = T | T[];
|
|
350
|
-
type Bun = typeof _Bun;
|
|
351
|
-
type BunBuildOptions = Parameters<Bun["build"]>[0];
|
|
352
|
-
type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
|
|
353
|
-
type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
|
|
354
|
-
type DefineWorkspaceItem = {
|
|
355
|
-
name: string
|
|
356
|
-
root: string
|
|
357
|
-
config: DefineConfigItem | DefineConfigItem[]
|
|
358
|
-
};
|
|
1
|
+
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-8sqm3fje";
|
|
359
2
|
declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
|
|
360
3
|
declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
|
|
361
4
|
declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
15
15
|
});
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
18
|
var __export = (target, all) => {
|
|
20
19
|
for (var name in all)
|
|
21
20
|
__defProp(target, name, {
|
|
@@ -28,77 +27,8 @@ var __export = (target, all) => {
|
|
|
28
27
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
29
28
|
var __require = import.meta.require;
|
|
30
29
|
|
|
31
|
-
// node_modules/picocolors/picocolors.js
|
|
32
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
33
|
-
var p = process || {};
|
|
34
|
-
var argv = p.argv || [];
|
|
35
|
-
var env = p.env || {};
|
|
36
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
37
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
38
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
39
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
40
|
-
};
|
|
41
|
-
var replaceClose = (string, close, replace, index) => {
|
|
42
|
-
let result = "", cursor = 0;
|
|
43
|
-
do {
|
|
44
|
-
result += string.substring(cursor, index) + replace;
|
|
45
|
-
cursor = index + close.length;
|
|
46
|
-
index = string.indexOf(close, cursor);
|
|
47
|
-
} while (~index);
|
|
48
|
-
return result + string.substring(cursor);
|
|
49
|
-
};
|
|
50
|
-
var createColors = (enabled = isColorSupported) => {
|
|
51
|
-
let f = enabled ? formatter : () => String;
|
|
52
|
-
return {
|
|
53
|
-
isColorSupported: enabled,
|
|
54
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
55
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
56
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
57
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
58
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
59
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
60
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
61
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
62
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
63
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
64
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
65
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
66
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
67
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
68
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
69
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
70
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
71
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
72
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
73
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
74
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
75
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
76
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
77
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
78
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
79
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
80
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
81
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
82
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
83
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
84
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
85
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
86
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
87
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
88
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
89
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
90
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
91
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
92
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
93
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
94
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
module.exports = createColors();
|
|
98
|
-
module.exports.createColors = createColors;
|
|
99
|
-
});
|
|
100
|
-
|
|
101
30
|
// src/logger.ts
|
|
31
|
+
import pc from "picocolors";
|
|
102
32
|
function setSilent(value) {
|
|
103
33
|
silent = value ?? false;
|
|
104
34
|
}
|
|
@@ -107,23 +37,23 @@ class Logger {
|
|
|
107
37
|
static instance;
|
|
108
38
|
loggedOnceMessages = new Set;
|
|
109
39
|
MAX_LABEL_LENGTH = 3;
|
|
110
|
-
cliColor =
|
|
111
|
-
mutedColor =
|
|
112
|
-
infoColor =
|
|
113
|
-
warnColor =
|
|
114
|
-
errorColor =
|
|
115
|
-
defaultColor =
|
|
40
|
+
cliColor = pc.blue;
|
|
41
|
+
mutedColor = pc.dim;
|
|
42
|
+
infoColor = pc.cyan;
|
|
43
|
+
warnColor = pc.yellow;
|
|
44
|
+
errorColor = pc.red;
|
|
45
|
+
defaultColor = pc.white;
|
|
116
46
|
progressFgColorMap = {
|
|
117
|
-
ESM:
|
|
118
|
-
CJS:
|
|
119
|
-
IIFE:
|
|
120
|
-
DTS:
|
|
47
|
+
ESM: pc.yellow,
|
|
48
|
+
CJS: pc.green,
|
|
49
|
+
IIFE: pc.magenta,
|
|
50
|
+
DTS: pc.blue
|
|
121
51
|
};
|
|
122
52
|
progressIdentifierBgColorMap = {
|
|
123
|
-
ESM:
|
|
124
|
-
CJS:
|
|
125
|
-
IIFE:
|
|
126
|
-
DTS:
|
|
53
|
+
ESM: pc.bgYellow,
|
|
54
|
+
CJS: pc.bgGreen,
|
|
55
|
+
IIFE: pc.bgMagenta,
|
|
56
|
+
DTS: pc.bgBlue
|
|
127
57
|
};
|
|
128
58
|
labels = {
|
|
129
59
|
cli: "CLI",
|
|
@@ -159,7 +89,7 @@ class Logger {
|
|
|
159
89
|
}) {
|
|
160
90
|
const padding = " ".repeat(Math.max(0, this.MAX_LABEL_LENGTH - label.length));
|
|
161
91
|
const formattedMessage = muted ? this.mutedColor(message) : message;
|
|
162
|
-
const identifierPart = identifier ? ` ${bgColor(
|
|
92
|
+
const identifierPart = identifier ? ` ${bgColor(pc.black(` ${identifier} `))}` : "";
|
|
163
93
|
return `${fgColor(label)} ${padding}${formattedMessage}${identifierPart}`;
|
|
164
94
|
}
|
|
165
95
|
output(message, options = {}, logFn = console.log) {
|
|
@@ -174,7 +104,7 @@ class Logger {
|
|
|
174
104
|
cli(message, options = {}) {
|
|
175
105
|
const formattedMessage = this.formatMessage({
|
|
176
106
|
fgColor: this.cliColor,
|
|
177
|
-
bgColor:
|
|
107
|
+
bgColor: pc.bgBlue,
|
|
178
108
|
label: this.labels.cli,
|
|
179
109
|
message,
|
|
180
110
|
identifier: options.identifier,
|
|
@@ -185,7 +115,7 @@ class Logger {
|
|
|
185
115
|
info(message, options = {}) {
|
|
186
116
|
const formattedMessage = this.formatMessage({
|
|
187
117
|
fgColor: this.infoColor,
|
|
188
|
-
bgColor:
|
|
118
|
+
bgColor: pc.bgCyan,
|
|
189
119
|
label: this.labels.info,
|
|
190
120
|
message,
|
|
191
121
|
identifier: options.identifier,
|
|
@@ -196,7 +126,7 @@ class Logger {
|
|
|
196
126
|
warn(message, options = {}) {
|
|
197
127
|
const formattedMessage = this.formatMessage({
|
|
198
128
|
fgColor: this.warnColor,
|
|
199
|
-
bgColor:
|
|
129
|
+
bgColor: pc.bgYellow,
|
|
200
130
|
label: this.labels.warn,
|
|
201
131
|
message,
|
|
202
132
|
identifier: options.identifier,
|
|
@@ -207,7 +137,7 @@ class Logger {
|
|
|
207
137
|
error(message, options = {}) {
|
|
208
138
|
const formattedMessage = this.formatMessage({
|
|
209
139
|
fgColor: this.errorColor,
|
|
210
|
-
bgColor:
|
|
140
|
+
bgColor: pc.bgRed,
|
|
211
141
|
label: this.labels.error,
|
|
212
142
|
message,
|
|
213
143
|
identifier: options.identifier,
|
|
@@ -232,7 +162,7 @@ class Logger {
|
|
|
232
162
|
if (label.includes(key))
|
|
233
163
|
return colorFn;
|
|
234
164
|
}
|
|
235
|
-
return
|
|
165
|
+
return pc.bgWhite;
|
|
236
166
|
}
|
|
237
167
|
progress(label, message, options = {}) {
|
|
238
168
|
const fgColor = this.getProgressFgColor(label);
|
|
@@ -261,36 +191,36 @@ function logTable(columns, data, footer) {
|
|
|
261
191
|
const pad = (str, width, align) => {
|
|
262
192
|
return align === "left" ? str.padEnd(width) : str.padStart(width);
|
|
263
193
|
};
|
|
264
|
-
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(
|
|
265
|
-
console.log(
|
|
194
|
+
const headerRow = columns.map((col) => pad(col.header, widths[col.header], col.align)).join(pc.gray(" | "));
|
|
195
|
+
console.log(pc.gray(headerRow));
|
|
266
196
|
const separator = columns.map((col) => "-".repeat(widths[col.header])).join(" | ");
|
|
267
|
-
console.log(
|
|
197
|
+
console.log(pc.gray(separator));
|
|
268
198
|
for (const row of data) {
|
|
269
199
|
const rowStr = columns.map((col) => {
|
|
270
200
|
const value = row[col.header] || "";
|
|
271
201
|
const padded = pad(value, widths[col.header], col.align);
|
|
272
202
|
return col.color ? col.color(padded) : padded;
|
|
273
|
-
}).join(
|
|
203
|
+
}).join(pc.gray(" | "));
|
|
274
204
|
console.log(rowStr);
|
|
275
205
|
}
|
|
276
|
-
console.log(
|
|
206
|
+
console.log(pc.gray(separator));
|
|
277
207
|
if (footer) {
|
|
278
208
|
const footerRow = columns.map((col) => {
|
|
279
209
|
const value = footer[col.header] || "";
|
|
280
210
|
const padded = pad(value, widths[col.header], col.align);
|
|
281
211
|
return padded;
|
|
282
|
-
}).join(
|
|
212
|
+
}).join(pc.gray(" | "));
|
|
283
213
|
console.log(footerRow);
|
|
284
214
|
}
|
|
285
215
|
}
|
|
286
|
-
var
|
|
216
|
+
var silent = false, logger;
|
|
287
217
|
var init_logger = __esm(() => {
|
|
288
|
-
import_picocolors = __toESM(require_picocolors(), 1);
|
|
289
218
|
logger = Logger.getInstance();
|
|
290
219
|
});
|
|
291
220
|
|
|
292
221
|
// src/errors.ts
|
|
293
|
-
|
|
222
|
+
import pc2 from "picocolors";
|
|
223
|
+
var BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage = (error) => {
|
|
294
224
|
if (error instanceof Error) {
|
|
295
225
|
return error.message;
|
|
296
226
|
}
|
|
@@ -314,7 +244,7 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
314
244
|
}
|
|
315
245
|
const knownError = KNOWN_ERRORS.find((error2) => error2.pattern.test(errorMessage) && (error2.errorType === errorType || !error2.errorType));
|
|
316
246
|
if (!knownError && errorType) {
|
|
317
|
-
console.error(`${
|
|
247
|
+
console.error(`${pc2.red(errorType)} ${contextPrefix}${errorMessage}`);
|
|
318
248
|
}
|
|
319
249
|
if (knownError) {
|
|
320
250
|
console.log(`
|
|
@@ -323,14 +253,13 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
323
253
|
console.log(`
|
|
324
254
|
`);
|
|
325
255
|
} else {
|
|
326
|
-
console.error(
|
|
256
|
+
console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + pc2.cyan("https://github.com/arshad-yaseen/bunup/issues/new")));
|
|
327
257
|
}
|
|
328
258
|
}, handleErrorAndExit = (error, context) => {
|
|
329
259
|
handleError(error, context);
|
|
330
260
|
process.exit(1);
|
|
331
261
|
};
|
|
332
262
|
var init_errors = __esm(() => {
|
|
333
|
-
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
334
263
|
init_logger();
|
|
335
264
|
BunupError = class BunupError extends Error {
|
|
336
265
|
constructor(message) {
|
|
@@ -373,8 +302,8 @@ var init_errors = __esm(() => {
|
|
|
373
302
|
pattern: /Could not resolve: "bun"/i,
|
|
374
303
|
errorType: "BUILD ERROR",
|
|
375
304
|
logSolution: () => {
|
|
376
|
-
logger.error(
|
|
377
|
-
`) +
|
|
305
|
+
logger.error(pc2.white("You're trying to build a project that uses Bun. ") + pc2.white("Please set the target option to ") + pc2.cyan("`bun`") + pc2.white(`.
|
|
306
|
+
`) + pc2.white("Example: ") + pc2.green("`bunup --target bun`") + pc2.white(" or in config: ") + pc2.green("{ target: 'bun' }"));
|
|
378
307
|
}
|
|
379
308
|
}
|
|
380
309
|
];
|
|
@@ -700,8 +629,8 @@ import path3 from "path";
|
|
|
700
629
|
init_logger();
|
|
701
630
|
|
|
702
631
|
// src/plugins/utils.ts
|
|
703
|
-
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
704
632
|
init_errors();
|
|
633
|
+
import pc3 from "picocolors";
|
|
705
634
|
function filterBunupBunPlugins(plugins) {
|
|
706
635
|
if (!plugins)
|
|
707
636
|
return [];
|
|
@@ -735,7 +664,7 @@ async function getPackageForPlugin(name, pluginName) {
|
|
|
735
664
|
try {
|
|
736
665
|
pkg = await import(name);
|
|
737
666
|
} catch {
|
|
738
|
-
throw new BunupPluginError(`[${
|
|
667
|
+
throw new BunupPluginError(`[${pc3.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${pc3.blue(`bun add ${name} --dev`)}`);
|
|
739
668
|
}
|
|
740
669
|
return pkg;
|
|
741
670
|
}
|
|
@@ -824,10 +753,10 @@ function copy(patterns, outPath) {
|
|
|
824
753
|
};
|
|
825
754
|
}
|
|
826
755
|
// src/plugins/internal/report.ts
|
|
827
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
828
756
|
init_logger();
|
|
829
757
|
init_logger();
|
|
830
758
|
init_utils();
|
|
759
|
+
import pc4 from "picocolors";
|
|
831
760
|
function report() {
|
|
832
761
|
return {
|
|
833
762
|
type: "bunup",
|
|
@@ -854,12 +783,12 @@ function report() {
|
|
|
854
783
|
const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
|
|
855
784
|
const formattedTotalGzipSize = formatFileSize(totalGzipSize);
|
|
856
785
|
const columns = [
|
|
857
|
-
{ header: "File", align: "left", color:
|
|
858
|
-
{ header: "Size", align: "right", color:
|
|
786
|
+
{ header: "File", align: "left", color: pc4.blue },
|
|
787
|
+
{ header: "Size", align: "right", color: pc4.green },
|
|
859
788
|
{
|
|
860
789
|
header: "Gzip",
|
|
861
790
|
align: "right",
|
|
862
|
-
color:
|
|
791
|
+
color: pc4.magenta
|
|
863
792
|
}
|
|
864
793
|
];
|
|
865
794
|
const data = files.map((file) => {
|