bunup 0.16.17 → 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 CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  build,
5
5
  processLoadedConfigs,
6
6
  resolveBuildOptions
7
- } from "../shared/bunup-ze2fw5ca.js";
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-qb65sm3k.js";
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.17";
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")} # Glob pattern for multiple files`),
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",
@@ -343,7 +344,7 @@ async function main(args = Bun.argv.slice(2)) {
343
344
  });
344
345
  }
345
346
  logger.info("Build started");
346
- const startTime = performance.now();
347
+ let buildTimeMs = 0;
347
348
  for (const { options, rootDir } of configsToProcess) {
348
349
  const optionsArray = ensureArray(options);
349
350
  for await (const o of optionsArray) {
@@ -354,14 +355,15 @@ async function main(args = Bun.argv.slice(2)) {
354
355
  if (userOptions.watch) {
355
356
  await watch(userOptions, rootDir, filepath);
356
357
  } else {
358
+ const startTime = performance.now();
357
359
  const result = await build(userOptions, rootDir);
360
+ buildTimeMs += performance.now() - startTime;
358
361
  if (!cliOptions.watch && !shouldSilent) {
359
362
  await printBuildReport(result);
360
363
  }
361
364
  }
362
365
  }
363
366
  }
364
- const buildTimeMs = performance.now() - startTime;
365
367
  if (cliOptions.watch) {
366
368
  console.log(`
367
369
  ${pc4.bgMagentaBright(" WATCH ")} Watching for file changes...
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-a77gk35v";
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-ze2fw5ca.js";
5
- import"./shared/bunup-qb65sm3k.js";
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-a77gk35v";
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
@@ -7,10 +7,11 @@ import {
7
7
  logger,
8
8
  shims,
9
9
  unused
10
- } from "./shared/bunup-qb65sm3k.js";
10
+ } from "./shared/bunup-t32tjrqy.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
- import { basename, extname, join } from "path";
13
+ import fs from "fs";
14
+ import { basename, isAbsolute, join } from "path";
14
15
  function copy(pattern) {
15
16
  return new CopyBuilder(pattern);
16
17
  }
@@ -80,7 +81,7 @@ class CopyBuilder {
80
81
  }
81
82
  this._fileCache.set(sourcePath, lastModified);
82
83
  }
83
- const finalDestinationPath = resolveDestinationPath(destinationPath, scannedPath, meta.rootDir);
84
+ const finalDestinationPath = resolveDestinationPath(destinationPath, sourcePath, meta.rootDir);
84
85
  const shouldOverride = this._options?.override ?? true;
85
86
  if (!shouldOverride) {
86
87
  const destinationExists = await Bun.file(finalDestinationPath).exists();
@@ -127,7 +128,7 @@ class CopyBuilder {
127
128
  }
128
129
  }
129
130
  function resolveDestinationPath(destinationPath, scannedPath, rootDir) {
130
- const fullDestinationPath = join(rootDir, destinationPath);
131
+ const fullDestinationPath = isAbsolute(destinationPath) ? destinationPath : join(rootDir, destinationPath);
131
132
  const isScannedPathDir = isDirectoryPath(scannedPath);
132
133
  const isDestinationDir = isDirectoryPath(fullDestinationPath);
133
134
  if (isDestinationDir && !isScannedPathDir) {
@@ -136,7 +137,12 @@ function resolveDestinationPath(destinationPath, scannedPath, rootDir) {
136
137
  return fullDestinationPath;
137
138
  }
138
139
  function isDirectoryPath(filePath) {
139
- return extname(filePath) === "";
140
+ try {
141
+ const stats = fs.statSync(filePath);
142
+ return stats.isDirectory();
143
+ } catch {
144
+ return false;
145
+ }
140
146
  }
141
147
  async function copyDirectory(sourcePath, finalDestinationPath) {
142
148
  await Bun.$`cp -r ${sourcePath} ${finalDestinationPath}`;
@@ -19,7 +19,7 @@ import {
19
19
  parseErrorMessage,
20
20
  shims,
21
21
  unused
22
- } from "./bunup-qb65sm3k.js";
22
+ } from "./bunup-t32tjrqy.js";
23
23
 
24
24
  // packages/bunup/src/loaders.ts
25
25
  import path from "path";
@@ -62,13 +62,13 @@ async function loadPackageJson(cwd = process.cwd()) {
62
62
  }
63
63
 
64
64
  // packages/bunup/src/build.ts
65
- import path3 from "path";
65
+ import path4 from "path";
66
66
  import { generateDts, logIsolatedDeclarationErrors } from "@bunup/dts";
67
67
  import pc2 from "picocolors";
68
68
 
69
69
  // packages/bunup/src/ensure-bun-version.ts
70
70
  import pc from "picocolors";
71
- var MINIMUM_BUN_VERSION = "1.0.11";
71
+ var MINIMUM_BUN_VERSION = "1.3.6";
72
72
  function ensureBunVersion(requiredVersion, feature) {
73
73
  const currentVersion = Bun.version;
74
74
  const satisfiesRequirement = Bun.semver.satisfies(currentVersion, `>=${requiredVersion}`);
@@ -390,6 +390,13 @@ async function runPluginBuildDoneHooks(bunupPlugins, ctx) {
390
390
  }
391
391
  }
392
392
 
393
+ // packages/bunup/src/utils/bun.ts
394
+ import path3 from "path";
395
+ function getOriginalEntrypointFromOutputPath(metafile, outputPath, rootDir) {
396
+ const entryPoint = metafile?.outputs[outputPath]?.entryPoint;
397
+ return path3.relative(rootDir, entryPoint);
398
+ }
399
+
393
400
  // packages/bunup/src/utils/extension.ts
394
401
  function getDefaultJsOutputExtension(format, packageType) {
395
402
  switch (format) {
@@ -462,98 +469,97 @@ async function build(userOptions, rootDir = process.cwd()) {
462
469
  throw new BunupBuildError(formatInvalidEntryPointsError(entryArray));
463
470
  }
464
471
  const buildOutputFiles = [];
465
- const absoluteEntrypoints = entrypoints.map((file) => `${rootDir}/${file}`);
466
- const resolvedDefine = getResolvedDefine(options.define, options.env);
467
- const resolvedMinify = getResolvedMinify(options);
468
- const resolvedTarget = getResolvedTarget(options.target);
469
- const resolvedSourcemap = getResolvedSourcemap(options.sourcemap);
470
- const resolvedEnv = getResolvedEnv(options.env);
471
- const chunkNaming = getDefaultChunkNaming(options.name);
472
- const buildPromises = ensureArray(options.format).map(async (fmt) => {
473
- const result = await Bun.build({
474
- entrypoints: absoluteEntrypoints,
475
- format: fmt,
476
- splitting: getResolvedSplitting(options.splitting, fmt),
477
- define: resolvedDefine,
478
- minify: resolvedMinify,
479
- target: resolvedTarget,
480
- sourcemap: resolvedSourcemap,
481
- loader: options.loader,
482
- drop: options.drop,
483
- naming: {
484
- chunk: chunkNaming,
485
- entry: options.compile ? getCompileNaming(entryArray, options.compile, fmt) : undefined
486
- },
487
- conditions: options.conditions,
488
- banner: options.banner,
489
- footer: options.footer,
490
- publicPath: options.publicPath,
491
- root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
492
- env: resolvedEnv,
493
- ignoreDCEAnnotations: options.ignoreDCEAnnotations,
494
- emitDCEAnnotations: options.emitDCEAnnotations,
495
- packages: options.packages,
496
- jsx: options.jsx,
497
- compile: options.compile,
498
- outdir: options.compile ? path3.resolve(rootDir, options.outDir) : undefined,
499
- throw: false,
500
- plugins: bunPlugins,
501
- tsconfig: options.preferredTsconfig ? path3.resolve(rootDir, options.preferredTsconfig) : undefined
502
- });
503
- for (const log of result.logs) {
504
- if (log.level === "error") {
505
- throw new BunupBuildError(formatBunBuildError(log));
506
- }
507
- if (log.level === "warning")
508
- logger.warn(log.message);
509
- if (log.level === "verbose")
510
- logger.log(log.message);
511
- else if (log.level === "info")
512
- logger.info(log.message);
513
- }
514
- let entrypointIndex = 0;
515
- for (const file of result.outputs) {
516
- if (options.compile) {
517
- const fullPath2 = file.path;
518
- const pathRelativeToRootDir2 = path3.relative(rootDir, fullPath2);
519
- const absoluteOutDir = path3.resolve(rootDir, options.outDir);
520
- const pathRelativeToOutdir2 = path3.relative(absoluteOutDir, fullPath2);
521
- buildOutputFiles.push({
522
- fullPath: fullPath2,
523
- pathRelativeToRootDir: pathRelativeToRootDir2,
524
- pathRelativeToOutdir: pathRelativeToOutdir2,
525
- dts: false,
526
- format: fmt,
527
- kind: "executable",
528
- entrypoint: entryArray[0],
529
- size: Bun.file(fullPath2).size
530
- });
531
- 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);
532
522
  }
533
- const content = await file.text();
534
- const pathRelativeToOutdir = cleanPath(isJavascriptFile(file.path) && file.kind === "entry-point" ? replaceExtension(file.path, getDefaultJsOutputExtension(fmt, packageType)) : file.path);
535
- const pathRelativeToRootDir = path3.join(options.outDir, pathRelativeToOutdir);
536
- const fullPath = path3.resolve(rootDir, pathRelativeToRootDir);
537
- await Bun.write(fullPath, content);
538
- if (!buildOutputFiles.some((f) => f.fullPath === fullPath)) {
539
- buildOutputFiles.push({
540
- fullPath,
541
- pathRelativeToRootDir,
542
- pathRelativeToOutdir,
543
- dts: false,
544
- format: fmt,
545
- kind: file.kind,
546
- entrypoint: file.kind === "entry-point" ? cleanPath(entrypoints[entrypointIndex] ?? "") : undefined,
547
- size: file.size
548
- });
549
- if (file.kind === "entry-point") {
550
- entrypointIndex++;
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
+ });
551
557
  }
552
558
  }
553
- }
554
- });
555
- await Promise.all(buildPromises);
556
- if (options.dts && !options.compile) {
559
+ });
560
+ await Promise.all(buildPromises);
561
+ }
562
+ if ((options.dts || options.dtsOnly) && !options.compile) {
557
563
  try {
558
564
  const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
559
565
  const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
@@ -563,7 +569,7 @@ async function build(userOptions, rootDir = process.cwd()) {
563
569
  naming: {
564
570
  chunk: getDefaultChunkNaming(options.name)
565
571
  },
566
- root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
572
+ root: options.sourceBase ? path4.resolve(rootDir, options.sourceBase) : undefined,
567
573
  ...dtsOptions
568
574
  });
569
575
  if (dtsResult.errors.length && !logger.isSilent()) {
@@ -574,7 +580,7 @@ async function build(userOptions, rootDir = process.cwd()) {
574
580
  const dtsExtension = getDefaultDtsOutputExtention(fmt, packageType, file.kind);
575
581
  const pathRelativeToOutdir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
576
582
  const pathRelativeToRootDir = cleanPath(`${options.outDir}/${pathRelativeToOutdir}`);
577
- const fullPath = path3.join(rootDir, pathRelativeToRootDir);
583
+ const fullPath = path4.join(rootDir, pathRelativeToRootDir);
578
584
  await Bun.write(fullPath, file.dts);
579
585
  buildOutputFiles.push({
580
586
  fullPath,
@@ -583,7 +589,7 @@ async function build(userOptions, rootDir = process.cwd()) {
583
589
  dts: true,
584
590
  format: fmt,
585
591
  kind: file.kind,
586
- entrypoint: file.entrypoint ? cleanPath(file.entrypoint) : undefined,
592
+ entrypoint: file.entrypoint,
587
593
  size: file.dts.length
588
594
  });
589
595
  }
@@ -613,13 +619,13 @@ async function build(userOptions, rootDir = process.cwd()) {
613
619
  if (options.onSuccess) {
614
620
  await executeOnSuccess(options.onSuccess, options, ac.signal);
615
621
  }
616
- console.log("");
617
- console.log(`${options.name ? ` ${pc2.bgBlueBright(` ${options.name} `)} ` : " "}${logger.formatMessage({
622
+ logger.log("");
623
+ logger.log(`${options.name ? ` ${pc2.bgBlueBright(` ${options.name} `)} ` : " "}${logger.formatMessage({
618
624
  message: formatListWithAnd(entrypoints),
619
625
  muted: true,
620
626
  noIcon: true
621
627
  })}`);
622
- console.log("");
628
+ logger.log("");
623
629
  return buildResult;
624
630
  }
625
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
  *
@@ -644,7 +644,7 @@ function mergeCustomExportsWithGenerated(baseExports, customExportsProvider, ctx
644
644
  return mergedExports;
645
645
  }
646
646
  function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
647
- const { main, module, types, ...restPackageJson } = originalData;
647
+ const { main: _, module: __, types: ___, ...restPackageJson } = originalData;
648
648
  const newPackageJson = {
649
649
  ...Object.fromEntries(Object.entries({
650
650
  name: originalData.name,
@@ -652,7 +652,7 @@ function createUpdatedPackageJson(originalData, entryPoints, exports2, files) {
652
652
  version: originalData.version,
653
653
  type: originalData.type,
654
654
  private: originalData.private
655
- }).filter(([_, value]) => value !== undefined)),
655
+ }).filter(([_2, value]) => value !== undefined)),
656
656
  files,
657
657
  ...entryPoints,
658
658
  exports: exports2
@@ -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);
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.16.17",
4
+ "version": "0.16.19",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -24,12 +24,12 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "license": "MIT",
27
- "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
27
+ "author": "Arshad Yaseen <arshadpyaseen@gmail.com> (https://arshad.fyi)",
28
28
  "maintainers": [
29
29
  {
30
30
  "name": "Arshad Yaseen",
31
- "email": "m@arshadyaseen.com",
32
- "url": "https://arshadyaseen.com"
31
+ "email": "arshadpyaseen@gmail.com",
32
+ "url": "https://arshad.fyi"
33
33
  }
34
34
  ],
35
35
  "repository": {
@@ -50,8 +50,8 @@
50
50
  "type-check": "tsc --noEmit"
51
51
  },
52
52
  "dependencies": {
53
- "@bunup/dts": "^0.14.46",
54
- "@bunup/shared": "0.16.12",
53
+ "@bunup/dts": "^0.14.47",
54
+ "@bunup/shared": "0.16.17",
55
55
  "chokidar": "^5.0.0",
56
56
  "coffi": "^0.1.37",
57
57
  "lightningcss": "^1.30.2",
@@ -69,6 +69,6 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@types/bun": "^1.3.5"
72
+ "@types/bun": "^1.3.6"
73
73
  }
74
74
  }