bunup 0.15.9 → 0.15.11

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
@@ -4,7 +4,7 @@ import {
4
4
  build,
5
5
  processLoadedConfigs,
6
6
  resolveBuildOptions
7
- } from "../shared/bunup-jcxzbsay.js";
7
+ } from "../shared/bunup-2waee6qa.js";
8
8
  import {
9
9
  BunupBuildError,
10
10
  BunupCLIError,
@@ -21,13 +21,13 @@ import {
21
21
  logTime,
22
22
  logger,
23
23
  parseErrorMessage
24
- } from "../shared/bunup-s36t5vc4.js";
24
+ } from "../shared/bunup-857264mj.js";
25
25
 
26
26
  // packages/bunup/src/cli/index.ts
27
27
  import { loadConfig } from "coffi";
28
28
  import pc4 from "picocolors";
29
29
  // packages/bunup/package.json
30
- var version = "0.15.9";
30
+ var version = "0.15.11";
31
31
 
32
32
  // packages/bunup/src/printer/print-build-report.ts
33
33
  import { promisify } from "util";
@@ -79,7 +79,10 @@ async function printBuildReport(buildResult) {
79
79
  const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
80
80
  const totalBrotliSize = files.reduce((sum, file) => sum + (file.brotliSize || 0), 0);
81
81
  const hasExecutable = files.some((f) => f.isExecutable);
82
- const labels = [...ensureArray(options.format), hasExecutable && "executable"];
82
+ const labels = [
83
+ ...ensureArray(options.format),
84
+ ...hasExecutable ? ["executable"] : []
85
+ ];
83
86
  const showLabel = labels.length > 1 || labels[0] === "cjs" || hasExecutable;
84
87
  const labelWidth = showLabel ? Math.max(...labels.map((f) => `[${f}] `.length)) : 0;
85
88
  const pathWidth = Math.max(...files.map((f) => f.fullPath.length), "Output".length);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildContext, BuildMeta, BuildOptions, BuildOutputFile, BuildResult, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional, WithRequired } from "./shared/bunup-0k10417c";
1
+ import { BuildContext, BuildMeta, BuildOptions, BuildOutputFile, BuildResult, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional, WithRequired } from "./shared/bunup-sfnfcavb";
2
2
  declare function build(userOptions: Partial<BuildOptions>, rootDir?: string): Promise<BuildResult>;
3
3
  declare function defineConfig(options: DefineConfigItem | WithRequired<DefineConfigItem, "name">[]): DefineConfigItem | WithRequired<DefineConfigItem, "name">[];
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-jcxzbsay.js";
5
- import"./shared/bunup-s36t5vc4.js";
4
+ } from "./shared/bunup-2waee6qa.js";
5
+ import"./shared/bunup-857264mj.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 { Arrayable, BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-0k10417c";
1
+ import { Arrayable, BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-sfnfcavb";
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-s36t5vc4.js";
10
+ } from "./shared/bunup-857264mj.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
13
  import { basename, extname, join } from "path";
@@ -20,7 +20,7 @@ import {
20
20
  parseErrorMessage,
21
21
  shims,
22
22
  unused
23
- } from "./bunup-s36t5vc4.js";
23
+ } from "./bunup-857264mj.js";
24
24
 
25
25
  // packages/bunup/src/loaders.ts
26
26
  import path from "path";
@@ -280,33 +280,6 @@ function resolvePlugins(options, packageJsonData) {
280
280
  plugins.push(externalOptionPlugin(options, packageJsonData));
281
281
  return plugins;
282
282
  }
283
- function getResolvedCompile(entry, compile, format) {
284
- if (compile) {
285
- let resolvedEntry;
286
- const compileObj = typeof compile === "object" ? compile : {};
287
- const target = typeof compile === "string" ? compile : compileObj.target;
288
- if (entry.length > 1) {
289
- throw new BunupBuildError("Can only compile one entrypoint at a time. If you want to compile multiple entries, use build config array. Check https://bunup.dev/docs/advanced/compile#multiple-entrypoints for more information.");
290
- } else {
291
- resolvedEntry = entry[0];
292
- }
293
- const { name: entryName } = path2.parse(resolvedEntry);
294
- const parentDirName = path2.basename(path2.dirname(resolvedEntry));
295
- const execName = compileObj.outfile ?? (entryName === "index" && parentDirName !== "src" ? parentDirName : entryName);
296
- const name = [execName];
297
- if (format !== "esm") {
298
- name.push(`-${format}`);
299
- }
300
- if (target && !compileObj.outfile) {
301
- name.push(`-${target.replace("bun-", "")}`);
302
- }
303
- return {
304
- ...compileObj,
305
- outfile: name.join("")
306
- };
307
- }
308
- return;
309
- }
310
283
  function getResolvedMinify(options) {
311
284
  const { minify, minifyWhitespace, minifyIdentifiers, minifySyntax } = options;
312
285
  const defaultValue = minify === true;
@@ -339,6 +312,27 @@ function getResolvedDefine(define, env) {
339
312
  function getDefaultChunkNaming(name) {
340
313
  return `shared/${name ?? "chunk"}-[hash].[ext]`;
341
314
  }
315
+ function getCompileNaming(entry, compile, format) {
316
+ let resolvedEntry;
317
+ const compileObj = typeof compile === "object" ? compile : {};
318
+ const target = typeof compile === "string" ? compile : compileObj.target;
319
+ if (entry.length > 1) {
320
+ throw new BunupBuildError("Can only compile one entrypoint at a time. If you want to compile multiple entries, use build config array. Check https://bunup.dev/docs/advanced/compile#multiple-entrypoints for more information.");
321
+ } else {
322
+ resolvedEntry = entry[0];
323
+ }
324
+ const { name: entryName } = path2.parse(resolvedEntry);
325
+ const parentDirName = path2.basename(path2.dirname(resolvedEntry));
326
+ const execName = compileObj.outfile ?? (entryName === "index" && parentDirName !== "src" ? parentDirName : entryName);
327
+ const name = [execName];
328
+ if (format !== "esm") {
329
+ name.push(`-${format}`);
330
+ }
331
+ if (target) {
332
+ name.push(`-${target.replace("bun-", "")}`);
333
+ }
334
+ return `[dir]/${name.join("")}-[hash].[ext]`;
335
+ }
342
336
  function getResolvedSplitting(splitting, format) {
343
337
  return splitting === undefined ? format === "esm" : splitting;
344
338
  }
@@ -482,7 +476,8 @@ async function build(userOptions, rootDir = process.cwd()) {
482
476
  loader: options.loader,
483
477
  drop: options.drop,
484
478
  naming: {
485
- chunk: chunkNaming
479
+ chunk: chunkNaming,
480
+ entry: options.compile ? getCompileNaming(entryArray, options.compile, fmt) : undefined
486
481
  },
487
482
  conditions: options.conditions,
488
483
  banner: options.banner,
@@ -493,7 +488,7 @@ async function build(userOptions, rootDir = process.cwd()) {
493
488
  ignoreDCEAnnotations: options.ignoreDCEAnnotations,
494
489
  emitDCEAnnotations: options.emitDCEAnnotations,
495
490
  jsx: options.jsx,
496
- compile: getResolvedCompile(entryArray, options.compile, fmt),
491
+ compile: options.compile,
497
492
  outdir: options.compile ? options.outDir : undefined,
498
493
  throw: false,
499
494
  plugins: bunPlugins,
@@ -492,14 +492,16 @@ async function processPackageJsonExports(ctx, options) {
492
492
  }
493
493
  }
494
494
  function generateExportsFields(files, exclude, excludeCli, excludeCss, ctx) {
495
- const filteredFiles = filterFiles(files, exclude, excludeCli, ctx);
495
+ const filteredFiles = filterFiles(files, excludeCli);
496
496
  const { filesByExportKey, allDtsFiles, cssFiles } = groupFilesByExportKey(filteredFiles);
497
497
  const exportsField = createExportEntries(filesByExportKey);
498
498
  if (!excludeCss) {
499
499
  addCssToExports(exportsField, cssFiles);
500
500
  }
501
- const entryPoints = extractEntryPoints(exportsField, allDtsFiles);
502
- return { exportsField, entryPoints };
501
+ const filteredExportsField = filterExportKeys(exportsField, exclude, ctx);
502
+ const filteredAllDtsFiles = filterDtsFiles(allDtsFiles, exclude, ctx);
503
+ const entryPoints = extractEntryPoints(filteredExportsField, filteredAllDtsFiles);
504
+ return { exportsField: filteredExportsField, entryPoints };
503
505
  }
504
506
  function groupFilesByExportKey(files) {
505
507
  const filesByExportKey = new Map;
@@ -662,8 +664,8 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
662
664
  }
663
665
  return newPackageJson;
664
666
  }
665
- function filterFiles(files, exclude, excludeCli, ctx) {
666
- return files.filter((file) => (JS_DTS_RE.test(file.fullPath) || CSS_RE.test(file.fullPath)) && (file.kind === "entry-point" || file.kind === "asset") && (file.format === "esm" || file.format === "cjs" || CSS_RE.test(file.fullPath)) && (!file.entrypoint || !isExcluded(file.entrypoint, exclude, excludeCli, ctx)));
667
+ function filterFiles(files, excludeCli) {
668
+ return files.filter((file) => (JS_DTS_RE.test(file.fullPath) || CSS_RE.test(file.fullPath)) && (file.kind === "entry-point" || file.kind === "asset") && (file.format === "esm" || file.format === "cjs" || CSS_RE.test(file.fullPath)) && (!file.entrypoint || !isCliEntrypoint(file.entrypoint, excludeCli)));
667
669
  }
668
670
  var CLI_EXCLUSION_PATTERNS = [
669
671
  "**/cli.{ts,tsx,js,jsx,mjs,cjs}",
@@ -671,11 +673,43 @@ var CLI_EXCLUSION_PATTERNS = [
671
673
  "**/bin.{ts,tsx,js,jsx,mjs,cjs}",
672
674
  "**/bin/index.{ts,tsx,js,jsx,mjs,cjs}"
673
675
  ];
674
- function isExcluded(entrypoint, exclude, excludeCli, ctx) {
675
- const userPatterns = typeof exclude === "function" ? exclude({ options: ctx.options, meta: ctx.meta }) : exclude;
676
+ function isCliEntrypoint(entrypoint, excludeCli) {
676
677
  const cliPatterns = excludeCli !== false ? CLI_EXCLUSION_PATTERNS : [];
677
- const allPatterns = [...cliPatterns, ...userPatterns ?? []];
678
- return allPatterns.some((pattern) => new Bun.Glob(pattern).match(entrypoint));
678
+ return cliPatterns.some((pattern) => new Bun.Glob(pattern).match(entrypoint));
679
+ }
680
+ function filterExportKeys(exportsField, exclude, ctx) {
681
+ if (!exclude) {
682
+ return exportsField;
683
+ }
684
+ const userPatterns = typeof exclude === "function" ? exclude({ options: ctx.options, meta: ctx.meta }) : exclude;
685
+ if (!userPatterns || userPatterns.length === 0) {
686
+ return exportsField;
687
+ }
688
+ const filteredExports = {};
689
+ for (const [exportKey, value] of Object.entries(exportsField)) {
690
+ const shouldExclude = userPatterns.some((pattern) => new Bun.Glob(pattern).match(exportKey));
691
+ if (!shouldExclude) {
692
+ filteredExports[exportKey] = value;
693
+ }
694
+ }
695
+ return filteredExports;
696
+ }
697
+ function filterDtsFiles(allDtsFiles, exclude, ctx) {
698
+ if (!exclude) {
699
+ return allDtsFiles;
700
+ }
701
+ const userPatterns = typeof exclude === "function" ? exclude({ options: ctx.options, meta: ctx.meta }) : exclude;
702
+ if (!userPatterns || userPatterns.length === 0) {
703
+ return allDtsFiles;
704
+ }
705
+ const filteredDtsFiles = new Map;
706
+ for (const [exportKey, files] of allDtsFiles.entries()) {
707
+ const shouldExclude = userPatterns.some((pattern) => new Bun.Glob(pattern).match(exportKey));
708
+ if (!shouldExclude) {
709
+ filteredDtsFiles.set(exportKey, files);
710
+ }
711
+ }
712
+ return filteredDtsFiles;
679
713
  }
680
714
  function getExportKey(pathRelativeToOutdir) {
681
715
  const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
@@ -106,7 +106,26 @@ interface ExportsOptions {
106
106
  */
107
107
  customExports?: (ctx: BuildContext) => CustomExports | undefined;
108
108
  /**
109
- * Entry points to exclude from the exports field
109
+ * Export keys to exclude from the generated exports field in package.json
110
+ *
111
+ * This option filters out specific keys from the final exports object
112
+ * after all exports have been internally generated. Use glob patterns or exact
113
+ * key strings (e.g., ".", "./utils", "./components/*") to match the
114
+ * keys you want to exclude.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // Exclude specific keys
119
+ * exclude: ["./internal", "./utils"]
120
+ *
121
+ * // Exclude using glob patterns
122
+ * exclude: ["./internal/*", "./private-*"]
123
+ *
124
+ * // Dynamic exclusion based on build context
125
+ * exclude: (ctx) => {
126
+ * return ["./debug"]
127
+ * }
128
+ * ```
110
129
  *
111
130
  * @see https://bunup.dev/docs/extra-options/exports#exclude
112
131
  */
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.15.9",
4
+ "version": "0.15.11",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"