bunup 0.16.18 → 0.16.19
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 +6 -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-4m73cpyq.js → bunup-ckz4nzjs.js} +91 -89
- package/dist/shared/{bunup-a77gk35v.d.ts → bunup-fsp3sxr6.d.ts} +7 -0
- package/dist/shared/{bunup-rmbrx2hr.js → bunup-t32tjrqy.js} +1 -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-ckz4nzjs.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-t32tjrqy.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.16.
|
|
30
|
+
var version = "0.16.19";
|
|
31
31
|
|
|
32
32
|
// packages/bunup/src/printer/print-build-report.ts
|
|
33
33
|
import { promisify } from "util";
|
|
@@ -248,12 +248,13 @@ var program = cli().name("bunup").version(version).description("A blazing-fast b
|
|
|
248
248
|
}).example([
|
|
249
249
|
pc3.gray(`${pc3.blue("bunup")} # Basic build`),
|
|
250
250
|
pc3.gray(`${pc3.blue("bunup src/index.ts")} # Single entry file`),
|
|
251
|
-
pc3.gray(`${pc3.blue("bunup src/**/*.ts")}
|
|
251
|
+
pc3.gray(`${pc3.blue("bunup src/**/*.ts")} # Glob pattern for multiple files`),
|
|
252
252
|
pc3.gray(`${pc3.blue("bunup --watch")} # Watch mode`),
|
|
253
253
|
pc3.gray(`${pc3.blue("bunup --format cjs,esm")} # Multiple formats`),
|
|
254
254
|
pc3.gray(`${pc3.blue("bunup --target bun")} # Bun target`),
|
|
255
255
|
pc3.gray(`${pc3.blue("bunup src/cli.ts")} # Multiple entries`),
|
|
256
256
|
pc3.gray(`${pc3.blue("bunup --dts.splitting")} # Declaration splitting`),
|
|
257
|
+
pc3.gray(`${pc3.blue("bunup --dts-only")} # Only emit declaration files`),
|
|
257
258
|
pc3.gray(`${pc3.blue("bunup --no-clean")} # Disable cleaning output directory before build`)
|
|
258
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 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("packages", z.string().choices(["bundle", "external"]).describe('Bundle all dependencies or externalize all dependencies. Use "bundle" to include all deps in output, or "external" to exclude all deps').optional()).option("shims", z.boolean().describe("Enable shims for Node.js globals and ESM/CJS interoperability").optional()).option("report", z.object({
|
|
259
260
|
gzip: z.boolean().describe("Enable gzip compression size calculation").default(true),
|
|
@@ -266,7 +267,7 @@ var program = cli().name("bunup").version(version).description("A blazing-fast b
|
|
|
266
267
|
minify: z.boolean().describe("Minify generated declaration files").optional(),
|
|
267
268
|
"infer-types": z.boolean().describe("Use TypeScript compiler (tsc) for declarations generation (removes need for explicit type annotations)").optional(),
|
|
268
269
|
tsgo: z.boolean().describe("Use TypeScript's native compiler (tsgo), 10x faster than tsc (only applicable with inferTypes enabled)").optional()
|
|
269
|
-
})).default(true)).option("preferred-tsconfig", z.string().describe("Path to a custom tsconfig.json file used for path resolution during both bundling and TypeScript 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([
|
|
270
|
+
})).default(true)).option("dts-only", z.boolean().describe("Only emit TypeScript declaration files without building JavaScript output").optional()).option("preferred-tsconfig", z.string().describe("Path to a custom tsconfig.json file used for path resolution during both bundling and TypeScript 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([
|
|
270
271
|
"js",
|
|
271
272
|
"jsx",
|
|
272
273
|
"ts",
|
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-fsp3sxr6";
|
|
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-ckz4nzjs.js";
|
|
5
|
+
import"./shared/bunup-t32tjrqy.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-fsp3sxr6";
|
|
2
2
|
type CopyOptions = {
|
|
3
3
|
/** Whether to follow symbolic links when copying files. */
|
|
4
4
|
followSymlinks?: boolean;
|
package/dist/plugins.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
parseErrorMessage,
|
|
20
20
|
shims,
|
|
21
21
|
unused
|
|
22
|
-
} from "./bunup-
|
|
22
|
+
} from "./bunup-t32tjrqy.js";
|
|
23
23
|
|
|
24
24
|
// packages/bunup/src/loaders.ts
|
|
25
25
|
import path from "path";
|
|
@@ -469,95 +469,97 @@ async function build(userOptions, rootDir = process.cwd()) {
|
|
|
469
469
|
throw new BunupBuildError(formatInvalidEntryPointsError(entryArray));
|
|
470
470
|
}
|
|
471
471
|
const buildOutputFiles = [];
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
for (const file of result.outputs) {
|
|
523
|
-
if (options.compile) {
|
|
524
|
-
const fullPath2 = file.path;
|
|
525
|
-
const pathRelativeToRootDir2 = path4.relative(rootDir, fullPath2);
|
|
526
|
-
const absoluteOutDir = path4.resolve(rootDir, options.outDir);
|
|
527
|
-
const pathRelativeToOutdir2 = path4.relative(absoluteOutDir, fullPath2);
|
|
528
|
-
buildOutputFiles.push({
|
|
529
|
-
fullPath: fullPath2,
|
|
530
|
-
pathRelativeToRootDir: pathRelativeToRootDir2,
|
|
531
|
-
pathRelativeToOutdir: pathRelativeToOutdir2,
|
|
532
|
-
dts: false,
|
|
533
|
-
format: fmt,
|
|
534
|
-
kind: "executable",
|
|
535
|
-
entrypoint: entryArray[0],
|
|
536
|
-
size: Bun.file(fullPath2).size
|
|
537
|
-
});
|
|
538
|
-
continue;
|
|
472
|
+
if (!options.dtsOnly) {
|
|
473
|
+
const absoluteEntrypoints = entrypoints.map((file) => `${rootDir}/${file}`);
|
|
474
|
+
const resolvedDefine = getResolvedDefine(options.define, options.env);
|
|
475
|
+
const resolvedMinify = getResolvedMinify(options);
|
|
476
|
+
const resolvedTarget = getResolvedTarget(options.target);
|
|
477
|
+
const resolvedSourcemap = getResolvedSourcemap(options.sourcemap);
|
|
478
|
+
const resolvedEnv = getResolvedEnv(options.env);
|
|
479
|
+
const chunkNaming = getDefaultChunkNaming(options.name);
|
|
480
|
+
const buildPromises = ensureArray(options.format).map(async (fmt) => {
|
|
481
|
+
const result = await Bun.build({
|
|
482
|
+
entrypoints: absoluteEntrypoints,
|
|
483
|
+
format: fmt,
|
|
484
|
+
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
485
|
+
define: resolvedDefine,
|
|
486
|
+
minify: resolvedMinify,
|
|
487
|
+
target: resolvedTarget,
|
|
488
|
+
sourcemap: resolvedSourcemap,
|
|
489
|
+
loader: options.loader,
|
|
490
|
+
drop: options.drop,
|
|
491
|
+
naming: {
|
|
492
|
+
chunk: chunkNaming,
|
|
493
|
+
entry: options.compile ? getCompileNaming(entryArray, options.compile, fmt) : undefined
|
|
494
|
+
},
|
|
495
|
+
conditions: options.conditions,
|
|
496
|
+
banner: options.banner,
|
|
497
|
+
footer: options.footer,
|
|
498
|
+
publicPath: options.publicPath,
|
|
499
|
+
root: options.sourceBase ? path4.resolve(rootDir, options.sourceBase) : undefined,
|
|
500
|
+
env: resolvedEnv,
|
|
501
|
+
ignoreDCEAnnotations: options.ignoreDCEAnnotations,
|
|
502
|
+
emitDCEAnnotations: options.emitDCEAnnotations,
|
|
503
|
+
packages: options.packages,
|
|
504
|
+
jsx: options.jsx,
|
|
505
|
+
compile: options.compile,
|
|
506
|
+
outdir: options.compile ? path4.resolve(rootDir, options.outDir) : undefined,
|
|
507
|
+
throw: false,
|
|
508
|
+
plugins: bunPlugins,
|
|
509
|
+
tsconfig: options.preferredTsconfig ? path4.resolve(rootDir, options.preferredTsconfig) : undefined,
|
|
510
|
+
metafile: true
|
|
511
|
+
});
|
|
512
|
+
for (const log of result.logs) {
|
|
513
|
+
if (log.level === "error") {
|
|
514
|
+
throw new BunupBuildError(formatBunBuildError(log));
|
|
515
|
+
}
|
|
516
|
+
if (log.level === "warning")
|
|
517
|
+
logger.warn(log.message);
|
|
518
|
+
if (log.level === "verbose")
|
|
519
|
+
logger.log(log.message);
|
|
520
|
+
else if (log.level === "info")
|
|
521
|
+
logger.info(log.message);
|
|
539
522
|
}
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
523
|
+
for (const file of result.outputs) {
|
|
524
|
+
if (options.compile) {
|
|
525
|
+
const fullPath2 = file.path;
|
|
526
|
+
const pathRelativeToRootDir2 = path4.relative(rootDir, fullPath2);
|
|
527
|
+
const absoluteOutDir = path4.resolve(rootDir, options.outDir);
|
|
528
|
+
const pathRelativeToOutdir2 = path4.relative(absoluteOutDir, fullPath2);
|
|
529
|
+
buildOutputFiles.push({
|
|
530
|
+
fullPath: fullPath2,
|
|
531
|
+
pathRelativeToRootDir: pathRelativeToRootDir2,
|
|
532
|
+
pathRelativeToOutdir: pathRelativeToOutdir2,
|
|
533
|
+
dts: false,
|
|
534
|
+
format: fmt,
|
|
535
|
+
kind: "executable",
|
|
536
|
+
entrypoint: entryArray[0],
|
|
537
|
+
size: Bun.file(fullPath2).size
|
|
538
|
+
});
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
const content = await file.text();
|
|
542
|
+
const pathRelativeToOutdir = cleanPath(isJavascriptFile(file.path) && file.kind === "entry-point" ? replaceExtension(file.path, getDefaultJsOutputExtension(fmt, packageType)) : file.path);
|
|
543
|
+
const pathRelativeToRootDir = path4.join(options.outDir, pathRelativeToOutdir);
|
|
544
|
+
const fullPath = path4.resolve(rootDir, pathRelativeToRootDir);
|
|
545
|
+
await Bun.write(fullPath, content);
|
|
546
|
+
if (!buildOutputFiles.some((f) => f.fullPath === fullPath)) {
|
|
547
|
+
buildOutputFiles.push({
|
|
548
|
+
fullPath,
|
|
549
|
+
pathRelativeToRootDir,
|
|
550
|
+
pathRelativeToOutdir,
|
|
551
|
+
dts: false,
|
|
552
|
+
format: fmt,
|
|
553
|
+
kind: file.kind,
|
|
554
|
+
entrypoint: file.kind === "entry-point" ? getOriginalEntrypointFromOutputPath(result.metafile, file.path, rootDir) : undefined,
|
|
555
|
+
size: file.size
|
|
556
|
+
});
|
|
557
|
+
}
|
|
556
558
|
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
if (options.dts && !options.compile) {
|
|
559
|
+
});
|
|
560
|
+
await Promise.all(buildPromises);
|
|
561
|
+
}
|
|
562
|
+
if ((options.dts || options.dtsOnly) && !options.compile) {
|
|
561
563
|
try {
|
|
562
564
|
const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
|
|
563
565
|
const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
|
|
@@ -623,7 +625,7 @@ async function build(userOptions, rootDir = process.cwd()) {
|
|
|
623
625
|
muted: true,
|
|
624
626
|
noIcon: true
|
|
625
627
|
})}`);
|
|
626
|
-
|
|
628
|
+
logger.log("");
|
|
627
629
|
return buildResult;
|
|
628
630
|
}
|
|
629
631
|
|
|
@@ -427,6 +427,13 @@ interface BuildOptions {
|
|
|
427
427
|
entry?: Arrayable<string>;
|
|
428
428
|
});
|
|
429
429
|
/**
|
|
430
|
+
* When enabled, only emit TypeScript declaration files (.d.ts) without building JavaScript output.
|
|
431
|
+
* This is useful when you only need to generate type definitions.
|
|
432
|
+
*
|
|
433
|
+
* @default false
|
|
434
|
+
*/
|
|
435
|
+
dtsOnly?: boolean;
|
|
436
|
+
/**
|
|
430
437
|
* Path to a custom tsconfig.json file used for path resolution during
|
|
431
438
|
* both bundling and TypeScript declaration generation.
|
|
432
439
|
*
|
|
@@ -926,7 +926,7 @@ function unused(options = {}) {
|
|
|
926
926
|
hooks: {
|
|
927
927
|
onBuildDone: async (ctx) => {
|
|
928
928
|
const { options: buildOptions, meta, files } = ctx;
|
|
929
|
-
if (buildOptions.watch || buildOptions.compile)
|
|
929
|
+
if (buildOptions.watch || buildOptions.compile || buildOptions.dtsOnly)
|
|
930
930
|
return;
|
|
931
931
|
const usedDeps = await collectUsedDependencies(files, buildOptions);
|
|
932
932
|
const pkgDeps = extractPackageDependencies(meta.packageJson.data?.dependencies);
|