bunup 0.15.10 → 0.15.12
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 +8 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +1 -1
- package/dist/shared/{bunup-mzcgpyzk.js → bunup-2dnbwnp7.js} +11 -4
- package/dist/shared/{bunup-s36t5vc4.js → bunup-qb65sm3k.js} +44 -10
- package/dist/shared/{bunup-8hm7nmkc.d.ts → bunup-sfnfcavb.d.ts} +20 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
build,
|
|
5
5
|
processLoadedConfigs,
|
|
6
6
|
resolveBuildOptions
|
|
7
|
-
} from "../shared/bunup-
|
|
7
|
+
} from "../shared/bunup-2dnbwnp7.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-
|
|
24
|
+
} from "../shared/bunup-qb65sm3k.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.
|
|
30
|
+
var version = "0.15.12";
|
|
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 = [
|
|
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);
|
|
@@ -256,7 +259,7 @@ var program = cli().name("bunup").version(version).description("A blazing-fast b
|
|
|
256
259
|
pc3.gray(`${pc3.blue("bunup src/cli.ts")} # Multiple entries`),
|
|
257
260
|
pc3.gray(`${pc3.blue("bunup --dts.splitting")} # Declaration splitting`),
|
|
258
261
|
pc3.gray(`${pc3.blue("bunup --no-clean")} # Disable cleaning output directory before build`)
|
|
259
|
-
]).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({
|
|
262
|
+
]).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 or config array items 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({
|
|
260
263
|
gzip: z.boolean().describe("Enable gzip compression size calculation").default(true),
|
|
261
264
|
brotli: z.boolean().describe("Enable brotli compression size calculation").optional(),
|
|
262
265
|
"max-bundle-size": z.number().describe("Maximum bundle size in bytes. Will warn if exceeded").optional()
|
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-
|
|
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-
|
|
5
|
-
import"./shared/bunup-
|
|
4
|
+
} from "./shared/bunup-2dnbwnp7.js";
|
|
5
|
+
import"./shared/bunup-qb65sm3k.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-
|
|
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
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
parseErrorMessage,
|
|
21
21
|
shims,
|
|
22
22
|
unused
|
|
23
|
-
} from "./bunup-
|
|
23
|
+
} from "./bunup-qb65sm3k.js";
|
|
24
24
|
|
|
25
25
|
// packages/bunup/src/loaders.ts
|
|
26
26
|
import path from "path";
|
|
@@ -32,10 +32,16 @@ async function processLoadedConfigs(config, cwd, filter) {
|
|
|
32
32
|
})) : [
|
|
33
33
|
{
|
|
34
34
|
rootDir: cwd,
|
|
35
|
-
options: config
|
|
35
|
+
options: filterConfigArrayByName(config, filter)
|
|
36
36
|
}
|
|
37
37
|
];
|
|
38
38
|
}
|
|
39
|
+
function filterConfigArrayByName(config, filter) {
|
|
40
|
+
if (Array.isArray(config) && filter) {
|
|
41
|
+
return config.filter((c) => c.name ? filter.includes(c.name) : true);
|
|
42
|
+
}
|
|
43
|
+
return config;
|
|
44
|
+
}
|
|
39
45
|
function setOrSuffixField(objectOrArray, field, prefix) {
|
|
40
46
|
const addPrefix = (obj) => {
|
|
41
47
|
const existingValue = obj[field];
|
|
@@ -489,7 +495,7 @@ async function build(userOptions, rootDir = process.cwd()) {
|
|
|
489
495
|
emitDCEAnnotations: options.emitDCEAnnotations,
|
|
490
496
|
jsx: options.jsx,
|
|
491
497
|
compile: options.compile,
|
|
492
|
-
outdir: options.compile ? options.outDir : undefined,
|
|
498
|
+
outdir: options.compile ? path3.resolve(rootDir, options.outDir) : undefined,
|
|
493
499
|
throw: false,
|
|
494
500
|
plugins: bunPlugins,
|
|
495
501
|
tsconfig: options.preferredTsconfig ? path3.resolve(rootDir, options.preferredTsconfig) : undefined
|
|
@@ -510,7 +516,8 @@ async function build(userOptions, rootDir = process.cwd()) {
|
|
|
510
516
|
if (options.compile) {
|
|
511
517
|
const fullPath2 = file.path;
|
|
512
518
|
const pathRelativeToRootDir2 = path3.relative(rootDir, fullPath2);
|
|
513
|
-
const
|
|
519
|
+
const absoluteOutDir = path3.resolve(rootDir, options.outDir);
|
|
520
|
+
const pathRelativeToOutdir2 = path3.relative(absoluteOutDir, fullPath2);
|
|
514
521
|
buildOutputFiles.push({
|
|
515
522
|
fullPath: fullPath2,
|
|
516
523
|
pathRelativeToRootDir: pathRelativeToRootDir2,
|
|
@@ -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,
|
|
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
|
|
502
|
-
|
|
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,
|
|
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 || !
|
|
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
|
|
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
|
-
|
|
678
|
-
|
|
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("/");
|
|
@@ -892,7 +926,7 @@ function unused(options = {}) {
|
|
|
892
926
|
hooks: {
|
|
893
927
|
onBuildDone: async (ctx) => {
|
|
894
928
|
const { options: buildOptions, meta, files } = ctx;
|
|
895
|
-
if (buildOptions.watch)
|
|
929
|
+
if (buildOptions.watch || buildOptions.compile)
|
|
896
930
|
return;
|
|
897
931
|
const usedDeps = await collectUsedDependencies(files, buildOptions);
|
|
898
932
|
const pkgDeps = extractPackageDependencies(meta.packageJson.data?.dependencies);
|
|
@@ -106,7 +106,26 @@ interface ExportsOptions {
|
|
|
106
106
|
*/
|
|
107
107
|
customExports?: (ctx: BuildContext) => CustomExports | undefined;
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
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
|
*/
|