bunup 0.15.3 → 0.15.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
@@ -4,7 +4,7 @@ import {
4
4
  build,
5
5
  processLoadedConfigs,
6
6
  resolveBuildOptions
7
- } from "../shared/bunup-04me8aq6.js";
7
+ } from "../shared/bunup-x9dadf6b.js";
8
8
  import {
9
9
  BunupCLIError,
10
10
  BunupWatchError,
@@ -20,13 +20,13 @@ import {
20
20
  logTime,
21
21
  logger,
22
22
  parseErrorMessage
23
- } from "../shared/bunup-wssv441a.js";
23
+ } from "../shared/bunup-1svmcpnr.js";
24
24
 
25
25
  // packages/bunup/src/cli/index.ts
26
26
  import { loadConfig } from "coffi";
27
27
  import pc4 from "picocolors";
28
28
  // packages/bunup/package.json
29
- var version = "0.15.3";
29
+ var version = "0.15.4";
30
30
 
31
31
  // packages/bunup/src/printer/print-build-report.ts
32
32
  import { promisify } from "util";
@@ -275,6 +275,7 @@ var program = cli().name("bunup").version(version).description("A blazing-fast b
275
275
  development: z.boolean().describe("Use jsx-dev runtime for development").optional()
276
276
  }).describe("Configure JSX transform behavior").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("exports", z.union(z.boolean(), z.object({
277
277
  exclude: z.array(z.string()).describe("Entry points to exclude from exports field").optional(),
278
+ "exclude-cli": z.boolean().describe("Whether to exclude CLI entry points (cli/bin files) from exports field").default(true),
278
279
  "exclude-css": z.boolean().describe("Whether to exclude CSS files from exports field").optional(),
279
280
  "include-package-json": z.boolean().describe('Whether to include "./package.json" in exports field').default(true),
280
281
  all: z.boolean().describe("Whether to add wildcard export for deep imports").optional()
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional, WithRequired } from "./shared/bunup-zhf51h48";
1
+ import { BuildContext, BuildMeta, BuildOptions, BuildOutput, BuildOutputFile, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional, WithRequired } from "./shared/bunup-zbep6g87";
2
2
  declare function build(userOptions: Partial<BuildOptions>, rootDir?: string): Promise<BuildOutput>;
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-04me8aq6.js";
5
- import"./shared/bunup-wssv441a.js";
4
+ } from "./shared/bunup-x9dadf6b.js";
5
+ import"./shared/bunup-1svmcpnr.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-zhf51h48";
1
+ import { BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-zbep6g87";
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-wssv441a.js";
10
+ } from "./shared/bunup-1svmcpnr.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
13
  import { basename, extname, join } from "path";
@@ -369,6 +369,7 @@ var handleErrorAndExit = (error, context) => {
369
369
 
370
370
  // packages/bunup/src/plugins/exports.ts
371
371
  import path2 from "path";
372
+ import pc3 from "picocolors";
372
373
 
373
374
  // packages/bunup/src/constants/re.ts
374
375
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
@@ -470,11 +471,12 @@ async function processPackageJsonExports(ctx, options) {
470
471
  return;
471
472
  }
472
473
  try {
473
- const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCss, ctx);
474
+ const { exportsField, entryPoints } = generateExportsFields(output.files, options.exclude, options.excludeCli, options.excludeCss, ctx);
474
475
  const updatedFiles = createUpdatedFilesArray(meta.packageJson.data, buildOptions.outDir);
475
476
  const mergedExports = mergeCustomExportsWithGenerated(exportsField, options.customExports, ctx);
476
477
  const finalExports = addPackageJsonOrWildcardExport(mergedExports, options.includePackageJson, options.all);
477
478
  const newPackageJson = createUpdatedPackageJson(meta.packageJson.data, entryPoints, finalExports, updatedFiles);
479
+ await validateBinFields(meta.packageJson.data, buildOptions.name, meta.packageJson.path);
478
480
  if (Bun.deepEquals(newPackageJson, meta.packageJson.data)) {
479
481
  return;
480
482
  }
@@ -489,8 +491,8 @@ async function processPackageJsonExports(ctx, options) {
489
491
  logger.error("Failed to update package.json");
490
492
  }
491
493
  }
492
- function generateExportsFields(files, exclude, excludeCss, ctx) {
493
- const filteredFiles = filterFiles(files, exclude, ctx);
494
+ function generateExportsFields(files, exclude, excludeCli, excludeCss, ctx) {
495
+ const filteredFiles = filterFiles(files, exclude, excludeCli, ctx);
494
496
  const { filesByExportKey, allDtsFiles, cssFiles } = groupFilesByExportKey(filteredFiles);
495
497
  const exportsField = createExportEntries(filesByExportKey);
496
498
  if (!excludeCss) {
@@ -657,18 +659,19 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
657
659
  }
658
660
  return newPackageJson;
659
661
  }
660
- function filterFiles(files, exclude, ctx) {
661
- 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, ctx)));
662
+ function filterFiles(files, exclude, excludeCli, ctx) {
663
+ 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)));
662
664
  }
663
- var DEFAULT_CLI_EXCLUSIONS = [
664
- "cli.ts",
665
- "cli/index.ts",
666
- "src/cli.ts",
667
- "src/cli/index.ts"
665
+ var CLI_EXCLUSION_PATTERNS = [
666
+ "**/cli.{ts,tsx,js,jsx,mjs,cjs}",
667
+ "**/cli/index.{ts,tsx,js,jsx,mjs,cjs}",
668
+ "**/bin.{ts,tsx,js,jsx,mjs,cjs}",
669
+ "**/bin/index.{ts,tsx,js,jsx,mjs,cjs}"
668
670
  ];
669
- function isExcluded(entrypoint, exclude, ctx) {
671
+ function isExcluded(entrypoint, exclude, excludeCli, ctx) {
670
672
  const userPatterns = typeof exclude === "function" ? exclude(ctx) : exclude;
671
- const allPatterns = [...DEFAULT_CLI_EXCLUSIONS, ...userPatterns ?? []];
673
+ const cliPatterns = excludeCli !== false ? CLI_EXCLUSION_PATTERNS : [];
674
+ const allPatterns = [...cliPatterns, ...userPatterns ?? []];
672
675
  return allPatterns.some((pattern) => new Bun.Glob(pattern).match(entrypoint));
673
676
  }
674
677
  function getExportKey(pathRelativeToOutdir) {
@@ -730,6 +733,42 @@ function exportFieldToEntryPoint(exportField) {
730
733
  return "module";
731
734
  }
732
735
  }
736
+ async function validateBinFields(packageJsonData, projectName, packageJsonPath) {
737
+ if (!packageJsonData?.bin)
738
+ return;
739
+ const bin = packageJsonData.bin;
740
+ const invalidBins = [];
741
+ if (typeof bin === "string") {
742
+ const exists = await Bun.file(bin).exists();
743
+ if (!exists) {
744
+ invalidBins.push(`bin field points to ${pc3.yellow(bin)}`);
745
+ }
746
+ } else if (typeof bin === "object" && bin !== null) {
747
+ for (const [name, binPath] of Object.entries(bin)) {
748
+ if (typeof binPath === "string") {
749
+ const exists = await Bun.file(binPath).exists();
750
+ if (!exists) {
751
+ invalidBins.push(`${pc3.yellow(pc3.bold(name))} points to ${pc3.red(binPath)}`);
752
+ }
753
+ }
754
+ }
755
+ }
756
+ if (invalidBins.length === 0)
757
+ return;
758
+ const project = projectName ? ` ${projectName}` : "";
759
+ const count = invalidBins.length;
760
+ const depText = count === 1 ? "binary" : "binaries";
761
+ const verb = count === 1 ? "points" : "point";
762
+ const fileText = count === 1 ? "file" : "files";
763
+ const pathPrefix = packageJsonPath ? pc3.cyan(getShortFilePath(packageJsonPath)) : "";
764
+ const message = `
765
+ Your project${project} has ${count} ${depText} in the bin field that ${verb} to invalid ${fileText}:
766
+
767
+ ${pathPrefix}:
768
+ ${invalidBins.join(`
769
+ `)}`;
770
+ logger.log(message, { leftPadding: true });
771
+ }
733
772
 
734
773
  // packages/bunup/src/plugins/inject-styles.ts
735
774
  import path3 from "path";
@@ -840,7 +879,7 @@ const importMetaUrl = pathToFileURL(__filename).href;
840
879
  }
841
880
 
842
881
  // packages/bunup/src/plugins/unused.ts
843
- import pc3 from "picocolors";
882
+ import pc4 from "picocolors";
844
883
  function unused(options = {}) {
845
884
  const { level = "warn", ignore = [] } = options;
846
885
  return {
@@ -911,11 +950,11 @@ function reportIssue(deps, type, projectName, level) {
911
950
  if (deps.length === 0)
912
951
  return;
913
952
  const count = deps.length;
914
- const coloredDeps = formatListWithAnd(deps.map((d) => pc3.yellow(d)));
953
+ const coloredDeps = formatListWithAnd(deps.map((d) => pc4.yellow(d)));
915
954
  const project = projectName ? ` ${projectName}` : "";
916
955
  const message = buildMessage(type, count, coloredDeps, project, deps);
917
956
  if (level === "error") {
918
- logger.log(pc3.red(message), { leftPadding: true });
957
+ logger.log(pc4.red(message), { leftPadding: true });
919
958
  process.exit(1);
920
959
  } else {
921
960
  logger.log(message, { leftPadding: true });
@@ -925,12 +964,12 @@ function buildMessage(type, count, coloredDeps, project, deps) {
925
964
  const plural = count === 1 ? "it" : "them";
926
965
  if (type === "unused") {
927
966
  const depText2 = count === 1 ? "dependency" : "dependencies";
928
- const cmd2 = pc3.cyan(`bun remove ${deps.join(" ")}`);
967
+ const cmd2 = pc4.cyan(`bun remove ${deps.join(" ")}`);
929
968
  return `
930
969
  Your project${project} has ${count} unused ${depText2}: ${coloredDeps}. You can remove ${plural} with ${cmd2}`;
931
970
  }
932
971
  const depText = count === 1 ? "package" : "packages";
933
- const cmd = pc3.cyan(`bun remove ${deps.join(" ")} && bun add --dev ${deps.join(" ")}`);
972
+ const cmd = pc4.cyan(`bun remove ${deps.join(" ")} && bun add --dev ${deps.join(" ")}`);
934
973
  return `
935
974
  Your project${project} has ${count} type ${depText} that should be in devDependencies: ${coloredDeps}. Move ${plural} to devDependencies with ${cmd}`;
936
975
  }
@@ -20,7 +20,7 @@ import {
20
20
  parseErrorMessage,
21
21
  shims,
22
22
  unused
23
- } from "./bunup-wssv441a.js";
23
+ } from "./bunup-1svmcpnr.js";
24
24
 
25
25
  // packages/bunup/src/loaders.ts
26
26
  import path from "path";
@@ -97,6 +97,25 @@ interface ExportsOptions {
97
97
  */
98
98
  exclude?: Exclude2;
99
99
  /**
100
+ * Whether to automatically exclude CLI entry points from the exports field
101
+ *
102
+ * When enabled (default), CLI-related entry points are automatically excluded
103
+ * from package exports since they are typically used for binaries and should
104
+ * not be exposed as importable package exports.
105
+ *
106
+ * The plugin uses glob patterns to match common CLI entry point patterns:
107
+ * - Files or directories named "cli" (e.g., `cli.ts`, `cli/index.ts`)
108
+ * - Files or directories named "bin" (e.g., `bin.ts`, `bin/index.ts`)
109
+ * - CLI-related paths in src directory (e.g., `src/cli.ts`, `src/bin/index.ts`)
110
+ *
111
+ * If you want to include CLI entries in your exports, set this to `false` and
112
+ * optionally use the `exclude` option for more granular control.
113
+ *
114
+ * @default true
115
+ * @see https://bunup.dev/docs/extra-options/exports#excludecli
116
+ */
117
+ excludeCli?: boolean;
118
+ /**
100
119
  * Whether to exclude CSS files from being added to the exports field
101
120
  *
102
121
  * @default false
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.3",
4
+ "version": "0.15.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"