bunup 0.12.0 → 0.13.4

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.js CHANGED
@@ -2,9 +2,10 @@
2
2
  // @bun
3
3
  import {
4
4
  build,
5
- createBuildOptions,
6
- processLoadedConfigs
7
- } from "../shared/bunup-natwy29x.js";
5
+ printBuildReport,
6
+ processLoadedConfigs,
7
+ resolveBuildOptions
8
+ } from "../shared/bunup-sq2zmkp5.js";
8
9
  import {
9
10
  BunupCLIError,
10
11
  BunupWatchError,
@@ -16,22 +17,21 @@ import {
16
17
  handleErrorAndExit,
17
18
  logTime,
18
19
  logger,
19
- parseErrorMessage,
20
- setSilent
21
- } from "../shared/bunup-c7jxrymh.js";
20
+ parseErrorMessage
21
+ } from "../plugins.js";
22
22
 
23
23
  // packages/bunup/src/cli/index.ts
24
24
  import { loadConfig } from "coffi";
25
25
  import pc3 from "picocolors";
26
26
  // packages/bunup/package.json
27
- var version = "0.12.0";
27
+ var version = "0.11.30";
28
28
 
29
29
  // packages/bunup/src/watch.ts
30
30
  import path from "path";
31
31
  import pc from "picocolors";
32
- async function watch(partialOptions, rootDir) {
32
+ async function watch(userOptions, rootDir) {
33
33
  const watchPaths = new Set;
34
- const options = createBuildOptions(partialOptions);
34
+ const options = resolveBuildOptions(userOptions);
35
35
  const uniqueEntries = new Set(options.entry);
36
36
  for (const entry of uniqueEntries) {
37
37
  const entryPath = path.resolve(rootDir, entry);
@@ -49,21 +49,33 @@ async function watch(partialOptions, rootDir) {
49
49
  ]
50
50
  });
51
51
  let isRebuilding = false;
52
- let rebuildCount = 0;
52
+ let buildCount = 0;
53
+ let lastChangedFile;
53
54
  const triggerRebuild = async (initial, changed) => {
54
55
  if (isRebuilding) {
55
56
  return;
56
57
  }
57
58
  isRebuilding = true;
58
59
  try {
60
+ console.clear();
59
61
  await new Promise((resolve) => setTimeout(resolve, 20));
62
+ if (lastChangedFile === changed) {
63
+ buildCount++;
64
+ } else {
65
+ buildCount = 1;
66
+ }
67
+ lastChangedFile = changed;
68
+ if (!initial) {
69
+ console.log(`
70
+ ${buildCount > 1 ? pc.magentaBright(`[x${buildCount}] `) : ""}${pc.green(`Changed:`)} ${changed}${options.name ? ` ${pc.bgBlueBright(` ${options.name} `)}` : ""}`);
71
+ }
60
72
  const start = performance.now();
61
- await build({ ...options, silent: !initial }, rootDir);
73
+ const buildOutput = await build(options, rootDir);
74
+ await printBuildReport(buildOutput, options);
62
75
  if (!initial) {
63
- console.clear();
64
- console.log(`${rebuildCount > 1 ? pc.magenta(`[x${rebuildCount}] `) : ""}${pc.green(`Rebuilt in ${logTime(performance.now() - start)}`)}: ${changed}${options.name ? ` ${pc.bgBlueBright(` ${options.name} `)}` : ""} `);
76
+ console.log(`
77
+ ${pc.green("\u2713")} Rebuild completed in ${pc.green(logTime(performance.now() - start))}`);
65
78
  }
66
- rebuildCount++;
67
79
  } catch (error) {
68
80
  handleError(error);
69
81
  } finally {
@@ -81,396 +93,59 @@ async function watch(partialOptions, rootDir) {
81
93
 
82
94
  // packages/bunup/src/cli/options.ts
83
95
  import pc2 from "picocolors";
84
-
85
- // packages/bunup/src/constants/index.ts
86
- var BUNUP_DOCS_URL = "https://bunup.dev/docs";
87
-
88
- // packages/bunup/src/cli/options.ts
89
- var createHandlers = () => ({
90
- boolean: (key) => (value, options) => {
91
- options[key] = value === true || value === "true";
92
- },
93
- string: (key) => (value, options) => {
94
- if (typeof value !== "string") {
95
- throw new BunupCLIError(`Option --${key} requires a string value`);
96
- }
97
- options[key] = value;
98
- },
99
- array: (key) => (value, options) => {
100
- if (typeof value !== "string") {
101
- throw new BunupCLIError(`Option --${key} requires a string value`);
102
- }
103
- options[key] = value.split(",");
104
- },
105
- stringOrBoolean: (key) => (value, options) => {
106
- if (typeof value === "boolean") {
107
- options[key] = value;
108
- } else if (typeof value === "string") {
109
- const lowerValue = value.toLowerCase();
110
- if (lowerValue === "true" || lowerValue === "false") {
111
- options[key] = lowerValue === "true";
112
- } else {
113
- options[key] = value;
114
- }
115
- } else {
116
- throw new BunupCLIError(`Option --${key} requires a boolean or string value`);
117
- }
118
- },
119
- entry: (value, options) => {
120
- if (typeof value !== "string") {
121
- throw new BunupCLIError("Entry requires a string value");
122
- }
123
- const entries = Array.isArray(options.entry) ? [...options.entry] : [];
124
- if (entries.includes(value)) {
125
- logger.warn(`Duplicate entry '${value}' provided. Skipping.`);
126
- } else {
127
- entries.push(value);
128
- }
129
- options.entry = entries;
130
- },
131
- resolveDts: (value, options) => {
132
- if (!options.dts)
133
- options.dts = {};
134
- if (typeof options.dts === "boolean")
135
- options.dts = {};
136
- if (typeof value === "string") {
137
- if (value === "true" || value === "false") {
138
- options.dts.resolve = value === "true";
139
- } else {
140
- options.dts.resolve = value.split(",");
141
- }
142
- } else {
143
- options.dts.resolve = true;
144
- }
145
- },
146
- showHelp: () => {
147
- displayHelp();
148
- process.exit(0);
149
- },
150
- showVersion: () => {
151
- console.log(version);
152
- process.exit(0);
153
- }
154
- });
155
- var handlers = createHandlers();
156
- var OPTION_DEFINITIONS = {
157
- name: {
158
- flags: ["n", "name"],
159
- handler: handlers.string("name"),
160
- description: "Name of the build configuration for logging and identification",
161
- type: "string",
162
- category: "utility"
163
- },
164
- format: {
165
- flags: ["f", "format"],
166
- handler: handlers.array("format"),
167
- description: "Output formats for the bundle (esm, cjs, iife)",
168
- type: "array",
169
- default: "cjs",
170
- category: "build"
171
- },
172
- outDir: {
173
- flags: ["o", "out-dir"],
174
- handler: handlers.string("outDir"),
175
- description: "Output directory for the bundled files",
176
- type: "string",
177
- default: "dist",
178
- category: "output"
179
- },
180
- minify: {
181
- flags: ["m", "minify"],
182
- handler: handlers.boolean("minify"),
183
- description: "Enable all minification options",
184
- type: "boolean",
185
- category: "minification"
186
- },
187
- watch: {
188
- flags: ["w", "watch"],
189
- handler: handlers.boolean("watch"),
190
- description: "Watch for file changes and rebuild automatically",
191
- type: "boolean",
192
- category: "development"
193
- },
194
- dts: {
195
- flags: ["d", "dts"],
196
- handler: handlers.boolean("dts"),
197
- description: "Generate TypeScript declaration files (.d.ts)",
198
- type: "boolean",
199
- category: "development"
200
- },
201
- banner: {
202
- flags: ["bn", "banner"],
203
- handler: handlers.string("banner"),
204
- description: "A banner to be added to the final bundle",
205
- type: "string",
206
- category: "output"
207
- },
208
- footer: {
209
- flags: ["ft", "footer"],
210
- handler: handlers.string("footer"),
211
- description: "A footer to be added to the final bundle",
212
- type: "string",
213
- category: "output"
214
- },
215
- external: {
216
- flags: ["e", "external"],
217
- handler: handlers.array("external"),
218
- description: "External packages that should not be bundled",
219
- type: "array",
220
- category: "build"
221
- },
222
- sourcemap: {
223
- flags: ["sm", "sourcemap"],
224
- handler: handlers.stringOrBoolean("sourcemap"),
225
- description: "Type of sourcemap to generate (none, linked, external, inline)",
226
- type: "string|boolean",
227
- default: "none",
228
- category: "output"
229
- },
230
- target: {
231
- flags: ["t", "target"],
232
- handler: handlers.string("target"),
233
- description: "The target environment for the bundle",
234
- type: "string",
235
- default: "node",
236
- category: "build"
237
- },
238
- minifyWhitespace: {
239
- flags: ["mw", "minify-whitespace"],
240
- handler: handlers.boolean("minifyWhitespace"),
241
- description: "Minify whitespace in the output",
242
- type: "boolean",
243
- category: "minification"
244
- },
245
- minifyIdentifiers: {
246
- flags: ["mi", "minify-identifiers"],
247
- handler: handlers.boolean("minifyIdentifiers"),
248
- description: "Minify identifiers in the output",
249
- type: "boolean",
250
- category: "minification"
251
- },
252
- minifySyntax: {
253
- flags: ["ms", "minify-syntax"],
254
- handler: handlers.boolean("minifySyntax"),
255
- description: "Minify syntax in the output",
256
- type: "boolean",
257
- category: "minification"
258
- },
259
- clean: {
260
- flags: ["c", "clean"],
261
- handler: handlers.boolean("clean"),
262
- description: "Clean the output directory before building",
263
- type: "boolean",
264
- default: "true",
265
- category: "output"
266
- },
267
- splitting: {
268
- flags: ["s", "splitting"],
269
- handler: handlers.boolean("splitting"),
270
- description: "Enable code splitting",
271
- type: "boolean",
272
- category: "build"
273
- },
274
- noExternal: {
275
- flags: ["ne", "no-external"],
276
- handler: handlers.array("noExternal"),
277
- description: "Packages that should be bundled even if they are in external",
278
- type: "array",
279
- category: "build"
280
- },
281
- preferredTsconfigPath: {
282
- flags: ["preferred-tsconfig-path"],
283
- handler: handlers.string("preferredTsconfigPath"),
284
- description: "Path to a preferred tsconfig.json file for declaration generation",
285
- type: "string",
286
- category: "development"
287
- },
288
- silent: {
289
- flags: ["silent"],
290
- handler: handlers.boolean("silent"),
291
- description: "Disable logging during the build process",
292
- type: "boolean",
293
- default: "false",
294
- category: "utility"
295
- },
296
- config: {
297
- flags: ["config"],
298
- handler: handlers.string("config"),
299
- description: "Path to a specific configuration file to use",
300
- type: "string",
301
- category: "utility"
302
- },
303
- publicPath: {
304
- flags: ["pp", "public-path"],
305
- handler: handlers.string("publicPath"),
306
- description: "Prefix to be added to specific import paths in bundled code",
307
- type: "string",
308
- category: "output"
309
- },
310
- env: {
311
- flags: ["env"],
312
- handler: handlers.string("env"),
313
- description: "Controls how environment variables are handled during bundling",
314
- type: "string",
315
- category: "build"
316
- },
317
- filter: {
318
- flags: ["filter"],
319
- handler: handlers.array("filter"),
320
- description: "Filter specific packages to build in a workspace",
321
- type: "array",
322
- category: "workspace"
323
- },
324
- new: {
325
- flags: ["new"],
326
- handler: handlers.boolean("new"),
327
- description: "Create a new project with bunup",
328
- type: "boolean",
329
- category: "utility"
330
- },
331
- init: {
332
- flags: ["init"],
333
- handler: handlers.boolean("init"),
334
- description: "Initialize bunup in an existing project",
335
- type: "boolean",
336
- category: "utility"
337
- },
338
- entry: {
339
- flags: ["entry"],
340
- handler: handlers.entry,
341
- description: "Entry point files for the build",
342
- type: "string",
343
- category: "build"
344
- },
345
- resolveDts: {
346
- flags: ["rd", "resolve-dts"],
347
- handler: handlers.resolveDts,
348
- description: "Configure DTS resolution options",
349
- type: "string|boolean",
350
- category: "development"
351
- },
352
- onSuccess: {
353
- flags: ["onSuccess"],
354
- handler: handlers.string("onSuccess"),
355
- description: "Command to run after the build process completes",
356
- type: "string",
357
- category: "utility"
358
- },
359
- help: {
360
- flags: ["h", "help"],
361
- handler: handlers.showHelp,
362
- description: "Show this help message",
363
- type: "boolean",
364
- category: "utility"
365
- },
366
- version: {
367
- flags: ["v", "version"],
368
- handler: handlers.showVersion,
369
- description: "Show version number",
370
- type: "boolean",
371
- category: "utility"
372
- }
373
- };
374
- var createFlagLookupMap = () => {
375
- const lookup = {};
376
- for (const definition of Object.values(OPTION_DEFINITIONS)) {
377
- for (const flag of definition.flags) {
378
- lookup[flag] = definition.handler;
379
- }
380
- }
381
- return lookup;
382
- };
383
- var flagToHandler = createFlagLookupMap();
384
- var displayHelp = () => {
385
- const categoryLabels = {
386
- build: "Build Options",
387
- output: "Output Options",
388
- development: "Development Options",
389
- minification: "Minification Options",
390
- workspace: "Workspace Options",
391
- utility: "Utility Options"
392
- };
393
- console.log();
394
- console.log(pc2.cyan(pc2.bold("bunup")));
395
- console.log();
396
- console.log("\u26A1\uFE0F A blazing-fast build tool for your libraries built with Bun");
397
- console.log();
398
- console.log(pc2.cyan("Usage:"));
399
- console.log(" bunup [entry...] [options]");
400
- console.log(" bunup --init");
401
- console.log(" bunup --new");
402
- console.log();
403
- for (const [categoryKey, categoryName] of Object.entries(categoryLabels)) {
404
- const categoryOptions = Object.values(OPTION_DEFINITIONS).filter((option) => option.category === categoryKey);
405
- if (categoryOptions.length === 0)
406
- return;
407
- console.log(pc2.cyan(`${categoryName}:`));
408
- for (const option of categoryOptions) {
409
- const flags = option.flags.map((flag) => flag.length === 1 ? `-${flag}` : `--${flag}`).join(", ");
410
- const flagsDisplay = pc2.green(flags);
411
- const typeDisplay = pc2.dim(`<${option.type}>`);
412
- const defaultDisplay = option.default ? pc2.yellow(`(default: ${option.default})`) : "";
413
- console.log(` ${flagsDisplay} ${typeDisplay}`);
414
- console.log(` ${pc2.dim(option.description)} ${defaultDisplay}`);
415
- console.log();
416
- }
417
- }
418
- console.log(pc2.cyan("Examples:"));
419
- console.log(" bunup src/**/*.ts");
420
- console.log(" bunup src/index.ts src/cli.ts --format esm,cjs");
421
- console.log(" bunup src/index.ts --watch --dts");
422
- console.log();
423
- console.log(pc2.dim("For more information:"));
424
- console.log(` ${pc2.cyan(pc2.underline(BUNUP_DOCS_URL))}`);
425
- console.log();
426
- };
427
- var parseArgument = (arg, nextArg) => {
428
- if (arg.startsWith("--")) {
429
- if (arg.includes("=")) {
430
- const [key, value] = arg.slice(2).split("=", 2);
431
- return { key, value, skipNext: false };
432
- } else {
433
- const key = arg.slice(2);
434
- const value = nextArg && !nextArg.startsWith("-") ? nextArg : true;
435
- return { key, value, skipNext: typeof value === "string" };
436
- }
437
- } else if (arg.startsWith("-")) {
438
- const key = arg.slice(1);
439
- const value = nextArg && !nextArg.startsWith("-") ? nextArg : true;
440
- return { key, value, skipNext: typeof value === "string" };
441
- }
442
- return null;
443
- };
96
+ import { cli, z } from "zlye";
97
+ var program = cli().name("bunup").version(version).description("A blazing-fast build tool for your TypeScript/React libraries \u2014 built on Bun").with({
98
+ ignoreOptionDefaultValue: true
99
+ }).example([
100
+ pc2.gray(`${pc2.blue("bunup src/index.ts")} # Basic build`),
101
+ pc2.gray(`${pc2.blue("bunup src/**/*.ts")} # Glob pattern for multiple files`),
102
+ pc2.gray(`${pc2.blue("bunup src/index.ts --watch")} # Watch mode`),
103
+ pc2.gray(`${pc2.blue("bunup src/index.ts --format cjs,esm")} # Multiple formats`),
104
+ pc2.gray(`${pc2.blue("bunup src/index.ts --target bun")} # Bun target`),
105
+ pc2.gray(`${pc2.blue("bunup src/index.ts src/cli.ts")} # Multiple entries`),
106
+ pc2.gray(`${pc2.blue("bunup src/index.ts --dts.splitting")} # Declaration splitting`),
107
+ pc2.gray(`${pc2.blue("bunup src/index.ts --no-clean")} # Disable cleaning output directory before build`)
108
+ ]).option("entry", z.union(z.string().describe("Entry file or glob pattern"), z.array(z.string()).describe("Multiple entry files or globs")).alias("e").optional()).option("config", z.string().describe("Path to configuration file").alias("c").example("./configs/custom.bunup.config.js").optional()).option("filter", z.array(z.string()).describe("Filter workspace packages by name").optional()).option("name", z.string().describe("Name of the build configuration (for logging and identification)").example("my-library").optional()).option("out-dir", z.string().describe("Output directory for bundled files").alias("o").default("dist")).option("format", z.union(z.string().choices(["esm", "cjs", "iife"]).describe("Single output format"), z.array(z.string().choices(["esm", "cjs", "iife"])).describe("Multiple output formats")).alias("f").default("esm")).option("minify", z.boolean().describe("Enable all minification options (whitespace, identifiers, syntax)").optional()).option("minify-whitespace", z.boolean().describe("Minify whitespace in the output to reduce file size").optional()).option("minify-identifiers", z.boolean().describe("Minify identifiers by renaming variables to shorter names").optional()).option("minify-syntax", z.boolean().describe("Minify syntax by optimizing code structure").optional()).option("watch", z.boolean().describe("Watch for file changes and rebuild automatically").optional()).option("clean", z.boolean().describe("Clean the output directory before building").default(true)).option("silent", z.boolean().describe("Disable logging during the build process").alias("q").optional()).option("splitting", z.boolean().describe("Enable code splitting").default(true, "enabled by default for ESM format")).option("conditions", z.array(z.string()).describe("Package.json export conditions for import resolution").optional()).option("target", z.string().choices(["bun", "node", "browser"]).describe("Target environment for the bundle").alias("t").default("node")).option("external", z.array(z.string()).describe("External packages that should not be bundled").optional()).option("no-external", z.array(z.string()).describe("Packages that should be bundled even if listed in external").optional()).option("shims", z.boolean().describe("Enable shims for Node.js globals and ESM/CJS interoperability").optional()).option("report", z.object({
109
+ gzip: z.boolean().describe("Enable gzip compression size calculation").default(true),
110
+ brotli: z.boolean().describe("Enable brotli compression size calculation").optional(),
111
+ "max-bundle-size": z.number().describe("Maximum bundle size in bytes. Will warn if exceeded").optional()
112
+ }).describe("Configuration for the build report").optional()).option("dts", z.union(z.boolean().describe("Generate TypeScript declaration files (.d.ts)"), z.object({
113
+ entry: z.union(z.string().describe("Single entrypoint for declaration file generation"), z.array(z.string()).describe("Multiple entrypoints for declaration file generation")).optional(),
114
+ resolve: z.union(z.boolean().describe("Resolve types from dependencies"), z.array(z.string()).describe("Names or patterns of packages from which to resolve types")).optional(),
115
+ splitting: z.boolean().describe("Enable declaration file splitting").optional(),
116
+ minify: z.boolean().describe("Minify generated declaration files").optional()
117
+ })).default(true)).option("preferred-tsconfig-path", z.string().describe("Path to preferred tsconfig.json for declaration generation").example("./tsconfig.build.json").optional()).option("sourcemap", z.union(z.boolean().describe("Generate a sourcemap (uses the inline type by default)"), z.string().choices(["none", "linked", "inline", "external"]).describe("Generate a sourcemap with a specific type")).optional()).option("define", z.object(z.string()).describe("Define global constants replaced at build time").example(`--define.PACKAGE_VERSION='"1.0.0"'`).optional()).option("env", z.union(z.string().choices(["inline", "disable"]).describe("inline: inject all, disable: inject none"), z.string().regex(/\*$/, "Environment prefix must end with *").describe("Inject env vars with this prefix").example("MYAPP_*").transform((val) => val), z.object(z.string()).describe("Explicit env var mapping").example('--env.NODE_ENV="production" --env.API_URL="https://api.example.com"')).optional()).option("banner", z.string().describe("Banner text added to the top of bundle files").optional()).option("footer", z.string().describe("Footer text added to the bottom of bundle files").optional()).option("drop", z.array(z.string()).describe("Remove function calls from bundle").example("--drop console,debugger").optional()).option("loader", z.object(z.string().choices([
118
+ "js",
119
+ "jsx",
120
+ "ts",
121
+ "tsx",
122
+ "json",
123
+ "toml",
124
+ "file",
125
+ "napi",
126
+ "wasm",
127
+ "text",
128
+ "css",
129
+ "html"
130
+ ])).describe("File extension to loader mapping").example("--loader.'.css'=text --loader.'.txt'=file").optional()).option("public-path", z.string().describe("Public path prefix for assets and chunk files").example("https://cdn.example.com/").optional()).option("ignore-dce-annotations", z.boolean().describe("Ignore dead code elimination annotations (@__PURE__, sideEffects)")).option("emit-dce-annotations", z.boolean().describe("Force emit @__PURE__ annotations even with minification")).option("on-success", z.string().describe("Command to run after successful build").optional()).option("css", z.object({
131
+ "typed-modules": z.boolean().describe("Generate TypeScript definitions for CSS modules").default(true)
132
+ }).optional()).rest("entries", z.string().describe("Entry point files to bundle"));
444
133
  var parseCliOptions = (argv) => {
445
- const options = {};
446
- for (let i = 0;i < argv.length; i++) {
447
- const arg = argv[i];
448
- const nextArg = argv[i + 1];
449
- if (arg.startsWith("-")) {
450
- const parsed = parseArgument(arg, nextArg);
451
- if (!parsed) {
452
- throw new BunupCLIError(`Invalid argument: ${arg}`);
453
- }
454
- const { key, value, skipNext } = parsed;
455
- const handler = flagToHandler[key];
456
- if (!handler) {
457
- throw new BunupCLIError(`Unknown option: ${arg}`);
458
- }
459
- handler(value, options);
460
- if (skipNext) {
461
- i++;
462
- }
463
- } else {
464
- OPTION_DEFINITIONS.entry.handler(arg, options);
465
- }
134
+ const result = program.parse(argv);
135
+ if (!result) {
136
+ throw new BunupCLIError("Failed to parse CLI options");
466
137
  }
467
- return options;
138
+ const { options, rest } = result;
139
+ const parsedOptions = {
140
+ ...options,
141
+ ...rest.length > 0 ? { entry: rest } : {}
142
+ };
143
+ return parsedOptions;
468
144
  };
469
145
 
470
146
  // packages/bunup/src/cli/index.ts
471
147
  async function main(args = Bun.argv.slice(2)) {
472
148
  const cliOptions = parseCliOptions(args);
473
- setSilent(cliOptions.silent);
474
149
  const cwd = process.cwd();
475
150
  const { config, filepath } = await loadConfig({
476
151
  name: "bunup.config",
@@ -480,6 +155,10 @@ async function main(args = Bun.argv.slice(2)) {
480
155
  packageJsonProperty: "bunup"
481
156
  });
482
157
  const configsToProcess = !config ? [{ rootDir: cwd, options: cliOptions }] : await processLoadedConfigs(config, cwd, cliOptions.filter);
158
+ const shouldSilent = cliOptions.watch || cliOptions.silent || configsToProcess.some((c) => ensureArray(c.options).some((o) => o.silent));
159
+ if (shouldSilent) {
160
+ logger.setSilent(true);
161
+ }
483
162
  logger.info(`Using bunup v${version} and bun v${Bun.version}`, {
484
163
  muted: true
485
164
  });
@@ -488,36 +167,40 @@ async function main(args = Bun.argv.slice(2)) {
488
167
  muted: true
489
168
  });
490
169
  }
491
- const startTime = performance.now();
492
170
  logger.info("Build started");
171
+ const startTime = performance.now();
493
172
  await Promise.all(configsToProcess.flatMap(({ options, rootDir }) => {
494
173
  const optionsArray = ensureArray(options);
495
174
  return optionsArray.map(async (o) => {
496
- const partialOptions = {
175
+ const userOptions = {
497
176
  ...o,
498
177
  ...removeCliOnlyOptions(cliOptions)
499
178
  };
500
- if (partialOptions.watch) {
501
- await watch(partialOptions, rootDir);
179
+ if (userOptions.watch) {
180
+ await watch(userOptions, rootDir);
502
181
  } else {
503
- await build(partialOptions, rootDir);
182
+ await build(userOptions, rootDir);
504
183
  }
505
184
  });
506
185
  }));
507
- const buildTimeMs = performance.now() - startTime;
508
- logger.success(`Build completed in ${pc3.green(logTime(buildTimeMs))}`);
509
186
  if (cliOptions.watch) {
510
- logger.info(pc3.dim("Watching for file changes..."));
187
+ console.log(`
188
+ ${pc3.bgMagentaBright(" WATCH ")} Watching for file changes...
189
+ `);
511
190
  }
191
+ const buildTimeMs = performance.now() - startTime;
192
+ logger.space();
193
+ logger.success(`Build completed in ${pc3.green(logTime(buildTimeMs))}`);
512
194
  if (!cliOptions.watch) {
513
195
  process.exit(process.exitCode ?? 0);
514
196
  }
515
197
  }
198
+ var CLI_ONLY_OPTIONS = ["config", "filter"];
516
199
  function removeCliOnlyOptions(options) {
517
- return {
518
- ...options,
519
- config: undefined,
520
- filter: undefined
521
- };
200
+ const cleanedOptions = { ...options };
201
+ for (const option of CLI_ONLY_OPTIONS) {
202
+ delete cleanedOptions[option];
203
+ }
204
+ return cleanedOptions;
522
205
  }
523
206
  main().catch((error) => handleErrorAndExit(error));
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-5f54ngsb";
2
- declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
1
+ import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-s6gfzz2v";
2
+ declare function build(userOptions: Partial<BuildOptions>, rootDir?: string): Promise<BuildOutput>;
3
3
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
4
4
  declare function defineWorkspace(options: WithOptional<DefineWorkspaceItem, "config">[], sharedOptions?: Partial<DefineConfigItem>): DefineWorkspaceItem[];
5
5
  export { defineWorkspace, defineConfig, build, DefineWorkspaceItem, DefineConfigItem, BunupPlugin, BuildOutputFile, BuildOutput, BuildOptions, BuildMeta, BuildContext };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./shared/bunup-natwy29x.js";
5
- import"./shared/bunup-c7jxrymh.js";
4
+ } from "./shared/bunup-sq2zmkp5.js";
5
+ import"./plugins.js";
6
6
  // packages/bunup/src/define.ts
7
7
  function defineConfig(options) {
8
8
  return options;