bunup 0.14.12 → 0.14.14

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,33 +2,153 @@
2
2
  // @bun
3
3
  import {
4
4
  build,
5
- printBuildReport,
6
5
  processLoadedConfigs,
7
6
  resolveBuildOptions
8
- } from "../shared/bunup-6xvphypm.js";
7
+ } from "../shared/bunup-jccqd6kz.js";
9
8
  import {
10
9
  BunupCLIError,
11
10
  BunupWatchError,
12
11
  __require,
13
12
  __toESM,
14
13
  ensureArray,
14
+ formatFileSize,
15
15
  getShortFilePath,
16
16
  handleError,
17
17
  handleErrorAndExit,
18
+ isJavascriptFile,
19
+ isTypeScriptFile,
18
20
  logTime,
19
21
  logger,
20
22
  parseErrorMessage
21
- } from "../shared/bunup-es9v2p5v.js";
23
+ } from "../shared/bunup-025ckbke.js";
22
24
 
23
25
  // packages/bunup/src/cli/index.ts
24
26
  import { loadConfig } from "coffi";
25
- import pc3 from "picocolors";
27
+ import pc4 from "picocolors";
26
28
  // packages/bunup/package.json
27
- var version = "0.14.12";
29
+ var version = "0.14.14";
30
+
31
+ // packages/bunup/src/printer/print-build-report.ts
32
+ import { promisify } from "util";
33
+ import { brotliCompress } from "zlib";
34
+ import pc from "picocolors";
35
+ var brotliAsync = promisify(brotliCompress);
36
+ async function printBuildReport(buildOutput) {
37
+ const options = buildOutput.options;
38
+ const { gzip = true, brotli = false, maxBundleSize } = options.report ?? {};
39
+ const showCompression = gzip || brotli;
40
+ const files = await Promise.all(buildOutput.files.map(async (file) => {
41
+ const pathRelative = file.pathRelativeToOutdir;
42
+ const bunFile = Bun.file(file.fullPath);
43
+ const size = bunFile.size;
44
+ const isDts = file.dts && file.kind === "entry-point";
45
+ const isJs = isTypeScriptFile(file.fullPath) || isJavascriptFile(file.fullPath);
46
+ let gzipSize;
47
+ let brotliSize;
48
+ if (showCompression) {
49
+ const uint8 = new Uint8Array(await bunFile.arrayBuffer());
50
+ const [gzipResult, brotliResult] = await Promise.all([
51
+ gzip ? Promise.resolve(Bun.gzipSync(uint8)) : Promise.resolve(null),
52
+ brotli ? brotliAsync(uint8) : Promise.resolve(null)
53
+ ]);
54
+ gzipSize = gzipResult?.length;
55
+ brotliSize = brotliResult?.length;
56
+ }
57
+ return {
58
+ path: pathRelative,
59
+ fullPath: `${options.outDir}/${pathRelative}`,
60
+ size,
61
+ gzipSize,
62
+ brotliSize,
63
+ format: file.format,
64
+ isDts,
65
+ isJs
66
+ };
67
+ }));
68
+ const totalSize = files.reduce((sum, file) => sum + file.size, 0);
69
+ const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
70
+ const totalBrotliSize = files.reduce((sum, file) => sum + (file.brotliSize || 0), 0);
71
+ const formats = ensureArray(options.format);
72
+ const showFormat = formats.length > 1 || formats[0] === "cjs";
73
+ const formatLabelWidth = showFormat ? Math.max(...formats.map((f) => `[${f}] `.length)) : 0;
74
+ const pathWidth = Math.max(...files.map((f) => f.fullPath.length), "Output".length);
75
+ const sizeWidth = Math.max(formatFileSize(totalSize).length, "Raw".length);
76
+ const gzipWidth = gzip ? Math.max(formatFileSize(totalGzipSize).length, "Gzip".length) : 0;
77
+ const brotliWidth = brotli ? Math.max(formatFileSize(totalBrotliSize).length, "Brotli".length) : 0;
78
+ const pad = (str, width, align = "left") => {
79
+ const diff = width - str.length;
80
+ return align === "left" ? str + " ".repeat(Math.max(0, diff)) : " ".repeat(Math.max(0, diff)) + str;
81
+ };
82
+ console.log("");
83
+ if (options.name) {
84
+ console.log("");
85
+ console.log(` ${pc.bgBlueBright(` ${options.name} `)}`);
86
+ }
87
+ console.log("");
88
+ const headers = [
89
+ pad(" Output", pathWidth + formatLabelWidth + 2),
90
+ pad("Raw", sizeWidth, "right")
91
+ ];
92
+ if (gzip)
93
+ headers.push(pad("Gzip", gzipWidth, "right"));
94
+ if (brotli)
95
+ headers.push(pad("Brotli", brotliWidth, "right"));
96
+ console.log(pc.dim(headers.join(" ")));
97
+ console.log("");
98
+ for (const file of files) {
99
+ let formatLabel = "";
100
+ if (showFormat) {
101
+ let plainFormatLabel = "";
102
+ if (file.isJs) {
103
+ plainFormatLabel = `[${file.format}] `;
104
+ }
105
+ formatLabel = pc.dim(pad(plainFormatLabel, formatLabelWidth));
106
+ }
107
+ const outDirWithSlash = `${options.outDir}/`;
108
+ const fileName = file.isDts ? pc.green(pc.bold(file.path)) : file.path;
109
+ const styledPath = `${pc.dim(outDirWithSlash)}${fileName}`;
110
+ const plainPath = `${outDirWithSlash}${file.path}`;
111
+ const filePathColumn = ` ${formatLabel}${styledPath}${" ".repeat(Math.max(0, pathWidth - plainPath.length))}`;
112
+ const fileRow = [
113
+ filePathColumn,
114
+ pad(formatFileSize(file.size), sizeWidth, "right")
115
+ ];
116
+ if (gzip) {
117
+ const gzipStr = file.gzipSize ? formatFileSize(file.gzipSize) : pc.dim("-");
118
+ fileRow.push(pad(gzipStr, gzipWidth, "right"));
119
+ }
120
+ if (brotli) {
121
+ const brotliStr = file.brotliSize ? formatFileSize(file.brotliSize) : pc.dim("-");
122
+ fileRow.push(pad(brotliStr, brotliWidth, "right"));
123
+ }
124
+ console.log(fileRow.join(" "));
125
+ }
126
+ console.log("");
127
+ const summaryRow = [
128
+ ` ${pc.bold(pad(`${files.length} files`, pathWidth + formatLabelWidth))}`,
129
+ pc.bold(pad(formatFileSize(totalSize), sizeWidth, "right"))
130
+ ];
131
+ if (gzip && totalGzipSize > 0) {
132
+ summaryRow.push(pc.bold(pad(formatFileSize(totalGzipSize), gzipWidth, "right")));
133
+ } else if (gzip) {
134
+ summaryRow.push(pad("", gzipWidth));
135
+ }
136
+ if (brotli && totalBrotliSize > 0) {
137
+ summaryRow.push(pc.bold(pad(formatFileSize(totalBrotliSize), brotliWidth, "right")));
138
+ } else if (brotli) {
139
+ summaryRow.push(pad("", brotliWidth));
140
+ }
141
+ console.log(summaryRow.join(" "));
142
+ if (maxBundleSize && totalSize > maxBundleSize) {
143
+ console.log("");
144
+ console.warn(pc.yellow(` Bundle size ${pc.bold(formatFileSize(totalSize))} exceeds limit ${pc.bold(formatFileSize(maxBundleSize))}`));
145
+ }
146
+ console.log("");
147
+ }
28
148
 
29
149
  // packages/bunup/src/watch.ts
30
150
  import path from "path";
31
- import pc from "picocolors";
151
+ import pc2 from "picocolors";
32
152
  async function watch(userOptions, rootDir, configFilePath) {
33
153
  const watchPaths = new Set;
34
154
  const options = resolveBuildOptions(userOptions);
@@ -70,14 +190,14 @@ async function watch(userOptions, rootDir, configFilePath) {
70
190
  lastChangedFile = changed;
71
191
  if (!initial) {
72
192
  console.log(`
73
- ${buildCount > 1 ? pc.magentaBright(`[x${buildCount}] `) : ""}${pc.green(`Changed:`)} ${changed}${options.name ? ` ${pc.bgBlueBright(` ${options.name} `)}` : ""}`);
193
+ ${buildCount > 1 ? pc2.magentaBright(`[x${buildCount}] `) : ""}${pc2.green(`Changed:`)} ${changed}${options.name ? ` ${pc2.bgBlueBright(` ${options.name} `)}` : ""}`);
74
194
  }
75
195
  const start = performance.now();
76
196
  const buildOutput = await build(userOptions, rootDir);
77
- await printBuildReport(buildOutput, options);
197
+ await printBuildReport(buildOutput);
78
198
  if (!initial) {
79
199
  console.log(`
80
- ${pc.green("\u2713")} Rebuild completed in ${pc.green(logTime(performance.now() - start))}`);
200
+ ${pc2.green("\u2713")} Rebuild completed in ${pc2.green(logTime(performance.now() - start))}`);
81
201
  }
82
202
  } catch (error) {
83
203
  handleError(error);
@@ -87,7 +207,7 @@ async function watch(userOptions, rootDir, configFilePath) {
87
207
  };
88
208
  watcher.on("change", (changedPath) => {
89
209
  if (configFilePath && changedPath === configFilePath) {
90
- console.log(pc.yellow(` Please restart watch mode to apply configuration changes.
210
+ console.log(pc2.yellow(` Please restart watch mode to apply configuration changes.
91
211
  `));
92
212
  cleanup();
93
213
  return;
@@ -107,20 +227,20 @@ async function watch(userOptions, rootDir, configFilePath) {
107
227
  }
108
228
 
109
229
  // packages/bunup/src/cli/options.ts
110
- import pc2 from "picocolors";
230
+ import pc3 from "picocolors";
111
231
  import { cli, z } from "zlye";
112
232
  var program = cli().name("bunup").version(version).description("A blazing-fast build tool for your TypeScript/React libraries - built on Bun").with({
113
233
  ignoreOptionDefaultValue: true
114
234
  }).example([
115
- pc2.gray(`${pc2.blue("bunup")} # Basic build`),
116
- pc2.gray(`${pc2.blue("bunup src/index.ts")} # Single entry file`),
117
- pc2.gray(`${pc2.blue("bunup src/**/*.ts")} # Glob pattern for multiple files`),
118
- pc2.gray(`${pc2.blue("bunup --watch")} # Watch mode`),
119
- pc2.gray(`${pc2.blue("bunup --format cjs,esm")} # Multiple formats`),
120
- pc2.gray(`${pc2.blue("bunup --target bun")} # Bun target`),
121
- pc2.gray(`${pc2.blue("bunup src/cli.ts")} # Multiple entries`),
122
- pc2.gray(`${pc2.blue("bunup --dts.splitting")} # Declaration splitting`),
123
- pc2.gray(`${pc2.blue("bunup --no-clean")} # Disable cleaning output directory before build`)
235
+ pc3.gray(`${pc3.blue("bunup")} # Basic build`),
236
+ pc3.gray(`${pc3.blue("bunup src/index.ts")} # Single entry file`),
237
+ pc3.gray(`${pc3.blue("bunup src/**/*.ts")} # Glob pattern for multiple files`),
238
+ pc3.gray(`${pc3.blue("bunup --watch")} # Watch mode`),
239
+ pc3.gray(`${pc3.blue("bunup --format cjs,esm")} # Multiple formats`),
240
+ pc3.gray(`${pc3.blue("bunup --target bun")} # Bun target`),
241
+ pc3.gray(`${pc3.blue("bunup src/cli.ts")} # Multiple entries`),
242
+ pc3.gray(`${pc3.blue("bunup --dts.splitting")} # Declaration splitting`),
243
+ pc3.gray(`${pc3.blue("bunup --no-clean")} # Disable cleaning output directory before build`)
124
244
  ]).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.union(z.string().describe("Path to a custom configuration file").alias("c").example("./configs/custom.bunup.config.js"), z.boolean().describe("Whether to use a configuration file").default(true)).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({
125
245
  gzip: z.boolean().describe("Enable gzip compression size calculation").default(true),
126
246
  brotli: z.boolean().describe("Enable brotli compression size calculation").optional(),
@@ -200,6 +320,7 @@ async function main(args = Bun.argv.slice(2)) {
200
320
  }
201
321
  logger.info("Build started");
202
322
  const startTime = performance.now();
323
+ const buildOutputs = [];
203
324
  await Promise.all(configsToProcess.flatMap(({ options, rootDir }) => {
204
325
  const optionsArray = ensureArray(options);
205
326
  return optionsArray.map(async (o) => {
@@ -210,18 +331,21 @@ async function main(args = Bun.argv.slice(2)) {
210
331
  if (userOptions.watch) {
211
332
  await watch(userOptions, rootDir, filepath);
212
333
  } else {
213
- await build(userOptions, rootDir);
334
+ buildOutputs.push(await build(userOptions, rootDir));
214
335
  }
215
336
  });
216
337
  }));
338
+ const buildTimeMs = performance.now() - startTime;
339
+ if (!cliOptions.watch && !shouldSilent) {
340
+ await Promise.all(buildOutputs.map((o) => printBuildReport(o)));
341
+ }
217
342
  if (cliOptions.watch) {
218
343
  console.log(`
219
- ${pc3.bgMagentaBright(" WATCH ")} Watching for file changes...
344
+ ${pc4.bgMagentaBright(" WATCH ")} Watching for file changes...
220
345
  `);
221
346
  }
222
- const buildTimeMs = performance.now() - startTime;
223
347
  logger.space();
224
- logger.success(`Build completed in ${pc3.green(logTime(buildTimeMs))}`);
348
+ logger.success(`Build completed in ${pc4.green(logTime(buildTimeMs))}`);
225
349
  }
226
350
  var CLI_ONLY_OPTIONS = ["config", "filter"];
227
351
  function removeCliOnlyOptions(options) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-fwrvv30e";
1
+ import { Arrayable, BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional } from "./shared/bunup-kgz99eee";
2
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[];
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./shared/bunup-6xvphypm.js";
5
- import"./shared/bunup-es9v2p5v.js";
4
+ } from "./shared/bunup-jccqd6kz.js";
5
+ import"./shared/bunup-025ckbke.js";
6
6
  // packages/bunup/src/define.ts
7
7
  function defineConfig(options) {
8
8
  return options;
package/dist/plugins.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-fwrvv30e";
1
+ import { BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-kgz99eee";
2
2
  type CopyOptions = {
3
3
  /** Whether to follow symbolic links when copying files. */
4
4
  followSymlinks?: boolean
package/dist/plugins.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  logger,
8
8
  shims,
9
9
  unused
10
- } from "./shared/bunup-es9v2p5v.js";
10
+ } from "./shared/bunup-025ckbke.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
13
  import { basename, extname, join } from "path";
@@ -369,32 +369,29 @@ async function cleanOutDir(rootDir, outDir) {
369
369
  }
370
370
  }
371
371
  function cleanPath(path2) {
372
- let cleaned = normalize(path2).replace(/\\/g, "/");
373
- cleaned = cleaned.replace(/^[a-zA-Z]:\//, "");
374
- cleaned = cleaned.replace(/^\/+/, "");
375
- cleaned = cleaned.replace(/\/+/g, "/");
376
- return cleaned;
372
+ return normalize(path2).replace(/\\/g, "/").replace(/^[a-zA-Z]:\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
377
373
  }
374
+ var listFormatter = new Intl.ListFormat("en", {
375
+ style: "long",
376
+ type: "conjunction"
377
+ });
378
378
  function formatListWithAnd(arr) {
379
- return new Intl.ListFormat("en", {
380
- style: "long",
381
- type: "conjunction"
382
- }).format(arr);
379
+ return listFormatter.format(arr);
383
380
  }
384
- async function getFilesFromGlobs(patterns, cwd) {
381
+ function getFilesFromGlobs(patterns, cwd) {
385
382
  const includePatterns = patterns.filter((p) => !p.startsWith("!"));
386
383
  const excludePatterns = patterns.filter((p) => p.startsWith("!")).map((p) => p.slice(1));
387
384
  const includedFiles = new Set;
388
385
  for (const pattern of includePatterns) {
389
386
  const glob = new Bun.Glob(pattern);
390
- for await (const file of glob.scan(cwd)) {
387
+ for (const file of glob.scanSync(cwd)) {
391
388
  includedFiles.add(file);
392
389
  }
393
390
  }
394
391
  if (excludePatterns.length > 0) {
395
392
  for (const pattern of excludePatterns) {
396
393
  const glob = new Bun.Glob(pattern);
397
- for await (const file of glob.scan(cwd)) {
394
+ for (const file of glob.scanSync(cwd)) {
398
395
  includedFiles.delete(file);
399
396
  }
400
397
  }
@@ -7,7 +7,6 @@ import {
7
7
  ensureArray,
8
8
  ensureObject,
9
9
  exports,
10
- formatFileSize,
11
10
  formatListWithAnd,
12
11
  getDefaultDtsOutputExtention,
13
12
  getDefaultJsOutputExtension,
@@ -17,14 +16,13 @@ import {
17
16
  injectStyles,
18
17
  invalidEntryPointsError,
19
18
  isJavascriptFile,
20
- isTypeScriptFile,
21
19
  logger,
22
20
  noEntryPointsFoundError,
23
21
  parseErrorMessage,
24
22
  replaceExtension,
25
23
  shims,
26
24
  unused
27
- } from "./bunup-es9v2p5v.js";
25
+ } from "./bunup-025ckbke.js";
28
26
 
29
27
  // packages/bunup/src/loaders.ts
30
28
  import path from "path";
@@ -320,123 +318,6 @@ async function runPluginBuildDoneHooks(bunupPlugins, options, output, meta) {
320
318
  }
321
319
  }
322
320
 
323
- // packages/bunup/src/printer/print-build-report.ts
324
- import { promisify } from "util";
325
- import { brotliCompress } from "zlib";
326
- import pc from "picocolors";
327
- var brotliAsync = promisify(brotliCompress);
328
- async function printBuildReport(buildOutput, options) {
329
- const { gzip = true, brotli = false, maxBundleSize } = options.report ?? {};
330
- const showCompression = gzip || brotli;
331
- const files = await Promise.all(buildOutput.files.map(async (file) => {
332
- const pathRelative = file.pathRelativeToOutdir;
333
- const size = Bun.file(file.fullPath).size;
334
- const isDts = file.dts && file.kind === "entry-point";
335
- const isJs = isTypeScriptFile(file.fullPath) || isJavascriptFile(file.fullPath);
336
- let gzipSize;
337
- let brotliSize;
338
- if (showCompression) {
339
- const buffer = await Bun.file(file.fullPath).arrayBuffer();
340
- const uint8 = new Uint8Array(buffer);
341
- const [gzipResult, brotliResult] = await Promise.all([
342
- gzip ? Promise.resolve(Bun.gzipSync(uint8)) : Promise.resolve(null),
343
- brotli ? brotliAsync(uint8) : Promise.resolve(null)
344
- ]);
345
- gzipSize = gzipResult?.length;
346
- brotliSize = brotliResult?.length;
347
- }
348
- return {
349
- path: pathRelative,
350
- fullPath: `${options.outDir}/${pathRelative}`,
351
- size,
352
- gzipSize,
353
- brotliSize,
354
- format: file.format,
355
- isDts,
356
- isJs
357
- };
358
- }));
359
- const totalSize = files.reduce((sum, file) => sum + file.size, 0);
360
- const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
361
- const totalBrotliSize = files.reduce((sum, file) => sum + (file.brotliSize || 0), 0);
362
- const formats = ensureArray(options.format);
363
- const showFormat = formats.length > 1 || formats[0] === "cjs";
364
- const formatLabelWidth = showFormat ? Math.max(...formats.map((f) => `[${f}] `.length)) : 0;
365
- const pathWidth = Math.max(...files.map((f) => f.fullPath.length), "Output".length);
366
- const sizeWidth = Math.max(formatFileSize(totalSize).length, "Raw".length);
367
- const gzipWidth = gzip ? Math.max(formatFileSize(totalGzipSize).length, "Gzip".length) : 0;
368
- const brotliWidth = brotli ? Math.max(formatFileSize(totalBrotliSize).length, "Brotli".length) : 0;
369
- const pad = (str, width, align = "left") => {
370
- const diff = width - str.length;
371
- return align === "left" ? str + " ".repeat(Math.max(0, diff)) : " ".repeat(Math.max(0, diff)) + str;
372
- };
373
- console.log("");
374
- if (options.name) {
375
- console.log("");
376
- console.log(` ${pc.bgBlueBright(` ${options.name} `)}`);
377
- }
378
- console.log("");
379
- const headers = [
380
- pad(" Output", pathWidth + formatLabelWidth + 2),
381
- pad("Raw", sizeWidth, "right")
382
- ];
383
- if (gzip)
384
- headers.push(pad("Gzip", gzipWidth, "right"));
385
- if (brotli)
386
- headers.push(pad("Brotli", brotliWidth, "right"));
387
- console.log(pc.dim(headers.join(" ")));
388
- console.log("");
389
- for (const file of files) {
390
- let formatLabel = "";
391
- if (showFormat) {
392
- let plainFormatLabel = "";
393
- if (file.isJs) {
394
- plainFormatLabel = `[${file.format}] `;
395
- }
396
- formatLabel = pc.dim(pad(plainFormatLabel, formatLabelWidth));
397
- }
398
- const outDirWithSlash = `${options.outDir}/`;
399
- const fileName = file.isDts ? pc.green(pc.bold(file.path)) : file.path;
400
- const styledPath = `${pc.dim(outDirWithSlash)}${fileName}`;
401
- const plainPath = `${outDirWithSlash}${file.path}`;
402
- const filePathColumn = ` ${formatLabel}${styledPath}${" ".repeat(Math.max(0, pathWidth - plainPath.length))}`;
403
- const fileRow = [
404
- filePathColumn,
405
- pad(formatFileSize(file.size), sizeWidth, "right")
406
- ];
407
- if (gzip) {
408
- const gzipStr = file.gzipSize ? formatFileSize(file.gzipSize) : pc.dim("-");
409
- fileRow.push(pad(gzipStr, gzipWidth, "right"));
410
- }
411
- if (brotli) {
412
- const brotliStr = file.brotliSize ? formatFileSize(file.brotliSize) : pc.dim("-");
413
- fileRow.push(pad(brotliStr, brotliWidth, "right"));
414
- }
415
- console.log(fileRow.join(" "));
416
- }
417
- console.log("");
418
- const summaryRow = [
419
- ` ${pc.bold(pad(`${files.length} files`, pathWidth + formatLabelWidth))}`,
420
- pc.bold(pad(formatFileSize(totalSize), sizeWidth, "right"))
421
- ];
422
- if (gzip && totalGzipSize > 0) {
423
- summaryRow.push(pc.bold(pad(formatFileSize(totalGzipSize), gzipWidth, "right")));
424
- } else if (gzip) {
425
- summaryRow.push(pad("", gzipWidth));
426
- }
427
- if (brotli && totalBrotliSize > 0) {
428
- summaryRow.push(pc.bold(pad(formatFileSize(totalBrotliSize), brotliWidth, "right")));
429
- } else if (brotli) {
430
- summaryRow.push(pad("", brotliWidth));
431
- }
432
- console.log(summaryRow.join(" "));
433
- if (maxBundleSize && totalSize > maxBundleSize) {
434
- console.log("");
435
- console.warn(pc.yellow(` Bundle size ${pc.bold(formatFileSize(totalSize))} exceeds limit ${pc.bold(formatFileSize(maxBundleSize))}`));
436
- }
437
- console.log("");
438
- }
439
-
440
321
  // packages/bunup/src/build.ts
441
322
  var ac = null;
442
323
  async function build(userOptions, rootDir = process.cwd()) {
@@ -444,10 +325,11 @@ async function build(userOptions, rootDir = process.cwd()) {
444
325
  ac.abort();
445
326
  }
446
327
  ac = new AbortController;
328
+ const options = resolveBuildOptions(userOptions);
447
329
  const buildOutput = {
448
- files: []
330
+ files: [],
331
+ options
449
332
  };
450
- const options = resolveBuildOptions(userOptions);
451
333
  if (options.silent) {
452
334
  logger.setSilent(options.silent);
453
335
  }
@@ -468,7 +350,7 @@ async function build(userOptions, rootDir = process.cwd()) {
468
350
  const bunPlugins = filterBunPlugins(allPlugins);
469
351
  await runPluginBuildStartHooks(bunupPlugins, options);
470
352
  const entryArray = ensureArray(options.entry);
471
- const entrypoints = await getFilesFromGlobs(entryArray, rootDir);
353
+ const entrypoints = getFilesFromGlobs(entryArray, rootDir);
472
354
  if (!entrypoints.length) {
473
355
  if (!ensureArray(userOptions.entry).length) {
474
356
  throw new BunupBuildError(noEntryPointsFoundError(DEFAULT_ENTYPOINTS));
@@ -480,25 +362,32 @@ async function build(userOptions, rootDir = process.cwd()) {
480
362
  once: options.name,
481
363
  muted: true
482
364
  });
483
- const buildPromises = ensureArray(options.format).flatMap(async (fmt) => {
365
+ const absoluteEntrypoints = entrypoints.map((file) => `${rootDir}/${file}`);
366
+ const resolvedDefine = getResolvedDefine(options.define, options.env);
367
+ const resolvedMinify = getResolvedMinify(options);
368
+ const resolvedTarget = getResolvedTarget(options.target);
369
+ const resolvedSourcemap = getResolvedSourcemap(options.sourcemap);
370
+ const resolvedEnv = getResolvedEnv(options.env);
371
+ const chunkNaming = getDefaultChunkNaming(options.name);
372
+ const buildPromises = ensureArray(options.format).map(async (fmt) => {
484
373
  const result = await Bun.build({
485
- entrypoints: entrypoints.map((file) => `${rootDir}/${file}`),
374
+ entrypoints: absoluteEntrypoints,
486
375
  format: fmt,
487
376
  splitting: getResolvedSplitting(options.splitting, fmt),
488
- define: getResolvedDefine(options.define, options.env),
489
- minify: getResolvedMinify(options),
490
- target: getResolvedTarget(options.target),
491
- sourcemap: getResolvedSourcemap(options.sourcemap),
377
+ define: resolvedDefine,
378
+ minify: resolvedMinify,
379
+ target: resolvedTarget,
380
+ sourcemap: resolvedSourcemap,
492
381
  loader: options.loader,
493
382
  drop: options.drop,
494
383
  naming: {
495
- chunk: getDefaultChunkNaming(options.name)
384
+ chunk: chunkNaming
496
385
  },
497
386
  conditions: options.conditions,
498
387
  banner: options.banner,
499
388
  footer: options.footer,
500
389
  publicPath: options.publicPath,
501
- env: getResolvedEnv(options.env),
390
+ env: resolvedEnv,
502
391
  ignoreDCEAnnotations: options.ignoreDCEAnnotations,
503
392
  emitDCEAnnotations: options.emitDCEAnnotations,
504
393
  throw: false,
@@ -581,10 +470,7 @@ async function build(userOptions, rootDir = process.cwd()) {
581
470
  if (options.onSuccess) {
582
471
  await executeOnSuccess(options.onSuccess, options, ac.signal);
583
472
  }
584
- if (!options.watch && !logger.isSilent()) {
585
- await printBuildReport(buildOutput, options);
586
- }
587
473
  return buildOutput;
588
474
  }
589
475
 
590
- export { processLoadedConfigs, resolveBuildOptions, printBuildReport, build };
476
+ export { processLoadedConfigs, resolveBuildOptions, build };
@@ -41,6 +41,8 @@ type BuildOutputFile = {
41
41
  type BuildOutput = {
42
42
  /** Array of generated files with their paths and contents */
43
43
  files: BuildOutputFile[]
44
+ /** Options used for the build */
45
+ options: BuildOptions
44
46
  };
45
47
  /**
46
48
  * Context provided to build hooks
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.14.12",
4
+ "version": "0.14.14",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -47,7 +47,7 @@
47
47
  "bunup": "dist/cli/index.js"
48
48
  },
49
49
  "dependencies": {
50
- "@bunup/dts": "0.14.12",
50
+ "@bunup/dts": "0.14.14",
51
51
  "chokidar": "^4.0.3",
52
52
  "coffi": "^0.1.35",
53
53
  "lightningcss": "^1.30.1",
@@ -55,7 +55,7 @@
55
55
  "tinyexec": "^1.0.1",
56
56
  "tree-kill": "^1.2.2",
57
57
  "zlye": "^0.4.4",
58
- "@bunup/shared": "0.14.12"
58
+ "@bunup/shared": "0.14.14"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "typescript": ">=4.5.0"