bunup 0.15.7 → 0.15.8

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,8 +4,9 @@ import {
4
4
  build,
5
5
  processLoadedConfigs,
6
6
  resolveBuildOptions
7
- } from "../shared/bunup-1dt09a96.js";
7
+ } from "../shared/bunup-p9ygyewc.js";
8
8
  import {
9
+ BunupBuildError,
9
10
  BunupCLIError,
10
11
  BunupWatchError,
11
12
  __require,
@@ -20,13 +21,13 @@ import {
20
21
  logTime,
21
22
  logger,
22
23
  parseErrorMessage
23
- } from "../shared/bunup-k8ycyv8v.js";
24
+ } from "../shared/bunup-s36t5vc4.js";
24
25
 
25
26
  // packages/bunup/src/cli/index.ts
26
27
  import { loadConfig } from "coffi";
27
28
  import pc4 from "picocolors";
28
29
  // packages/bunup/package.json
29
- var version = "0.15.7";
30
+ var version = "0.15.8";
30
31
 
31
32
  // packages/bunup/src/printer/print-build-report.ts
32
33
  import { promisify } from "util";
@@ -35,13 +36,21 @@ import pc from "picocolors";
35
36
  var brotliAsync = promisify(brotliCompress);
36
37
  async function printBuildReport(buildResult) {
37
38
  const options = buildResult.build.options;
38
- const { gzip = true, brotli = false, maxBundleSize } = options.report ?? {};
39
+ const {
40
+ gzip = !options.compile,
41
+ brotli = false,
42
+ maxBundleSize
43
+ } = options.report ?? {};
44
+ if (options.compile && (brotli || gzip)) {
45
+ throw new BunupBuildError("Brotli or Gzip size report is not available when the compile option is enabled.");
46
+ }
39
47
  const showCompression = gzip || brotli;
40
48
  const files = await Promise.all(buildResult.files.map(async (file) => {
41
49
  const pathRelative = file.pathRelativeToOutdir;
42
50
  const size = file.size;
43
51
  const isDts = file.dts && file.kind === "entry-point";
44
52
  const isJs = isTypeScriptFile(file.fullPath) || isJavascriptFile(file.fullPath);
53
+ const isExecutable = file.kind === "executable";
45
54
  let gzipSize;
46
55
  let brotliSize;
47
56
  if (showCompression) {
@@ -62,15 +71,17 @@ async function printBuildReport(buildResult) {
62
71
  brotliSize,
63
72
  format: file.format,
64
73
  isDts,
65
- isJs
74
+ isJs,
75
+ isExecutable
66
76
  };
67
77
  }));
68
78
  const totalSize = files.reduce((sum, file) => sum + file.size, 0);
69
79
  const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
70
80
  const totalBrotliSize = files.reduce((sum, file) => sum + (file.brotliSize || 0), 0);
71
- const formats = ensureArray(options.format);
72
- const showFormat = formats.length > 1 || formats[0] === "cjs";
73
- const formatLabelWidth = showFormat ? Math.max(...formats.map((f) => `[${f}] `.length)) : 0;
81
+ const hasExecutable = files.some((f) => f.isExecutable);
82
+ const labels = [...ensureArray(options.format), hasExecutable && "executable"];
83
+ const showLabel = labels.length > 1 || labels[0] === "cjs" || hasExecutable;
84
+ const labelWidth = showLabel ? Math.max(...labels.map((f) => `[${f}] `.length)) : 0;
74
85
  const pathWidth = Math.max(...files.map((f) => f.fullPath.length), "Output".length);
75
86
  const sizeWidth = Math.max(formatFileSize(totalSize).length, "Raw".length);
76
87
  const gzipWidth = gzip ? Math.max(formatFileSize(totalGzipSize).length, "Gzip".length) : 0;
@@ -86,7 +97,7 @@ async function printBuildReport(buildResult) {
86
97
  }
87
98
  console.log("");
88
99
  const headers = [
89
- pad(" Output", pathWidth + formatLabelWidth + 2),
100
+ pad(" Output", pathWidth + labelWidth + 2),
90
101
  pad("Raw", sizeWidth, "right")
91
102
  ];
92
103
  if (gzip)
@@ -96,19 +107,22 @@ async function printBuildReport(buildResult) {
96
107
  console.log(pc.dim(headers.join(" ")));
97
108
  console.log("");
98
109
  for (const file of files) {
99
- let formatLabel = "";
100
- if (showFormat) {
101
- let plainFormatLabel = "";
110
+ let label = "";
111
+ if (showLabel) {
112
+ let plainLabel = "";
102
113
  if (file.isJs) {
103
- plainFormatLabel = `[${file.format}] `;
114
+ plainLabel = `[${file.format}] `;
115
+ }
116
+ if (file.isExecutable) {
117
+ plainLabel = `[executable] `;
104
118
  }
105
- formatLabel = pc.dim(pad(plainFormatLabel, formatLabelWidth));
119
+ label = pc.dim(pad(plainLabel, labelWidth));
106
120
  }
107
121
  const outDirWithSlash = `${options.outDir}/`;
108
122
  const fileName = file.isDts ? pc.green(pc.bold(file.path)) : file.path;
109
123
  const styledPath = `${pc.dim(outDirWithSlash)}${fileName}`;
110
124
  const plainPath = `${outDirWithSlash}${file.path}`;
111
- const filePathColumn = ` ${formatLabel}${styledPath}${" ".repeat(Math.max(0, pathWidth - plainPath.length))}`;
125
+ const filePathColumn = ` ${label}${styledPath}${" ".repeat(Math.max(0, pathWidth - plainPath.length))}`;
112
126
  const fileRow = [
113
127
  filePathColumn,
114
128
  pad(formatFileSize(file.size), sizeWidth, "right")
@@ -125,7 +139,7 @@ async function printBuildReport(buildResult) {
125
139
  }
126
140
  console.log("");
127
141
  const summaryRow = [
128
- ` ${pc.bold(pad(`${files.length} files`, pathWidth + formatLabelWidth))}`,
142
+ ` ${pc.bold(pad(`${files.length} ${files.length === 1 ? "file" : "files"}`, pathWidth + labelWidth))}`,
129
143
  pc.bold(pad(formatFileSize(totalSize), sizeWidth, "right"))
130
144
  ];
131
145
  if (gzip && totalGzipSize > 0) {
@@ -266,7 +280,7 @@ var program = cli().name("bunup").version(version).description("A blazing-fast b
266
280
  "text",
267
281
  "css",
268
282
  "html"
269
- ])).describe("File extension to loader mapping").example("--loader.'.css'=text --loader.'.txt'=file").optional()).option("public-path", z.string().describe("Public path prefix for assets and chunk files").example("https://cdn.example.com/").optional()).option("jsx", z.object({
283
+ ])).describe("File extension to loader mapping").example("--loader.'.css'=text --loader.'.txt'=file").optional()).option("public-path", z.string().describe("Public path prefix for assets and chunk files").example("https://cdn.example.com/").optional()).option("source-base", z.string().describe("Base directory for entry points to control output structure").example("./src").optional()).option("jsx", z.object({
270
284
  runtime: z.string().choices(["automatic", "classic"]).describe("JSX runtime mode").optional(),
271
285
  "import-source": z.string().describe("Import source for JSX functions").optional(),
272
286
  factory: z.string().describe("JSX factory function name").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-daehgh3v";
1
+ import { BuildContext, BuildMeta, BuildOptions, BuildOutputFile, BuildResult, BunupPlugin, DefineConfigItem, DefineWorkspaceItem, WithOptional, WithRequired } from "./shared/bunup-0k10417c";
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-1dt09a96.js";
5
- import"./shared/bunup-k8ycyv8v.js";
4
+ } from "./shared/bunup-p9ygyewc.js";
5
+ import"./shared/bunup-s36t5vc4.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-daehgh3v";
1
+ import { Arrayable, BuildOptions, BunupPlugin, BunupPluginHooks, exports, injectStyles, unused } from "./shared/bunup-0k10417c";
2
2
  type CopyOptions = {
3
3
  /** Whether to follow symbolic links when copying files. */
4
4
  followSymlinks?: boolean;
@@ -37,14 +37,14 @@ type TransformFunction = (context: TransformContext) => TransformResult | Promis
37
37
  *
38
38
  * @see https://bunup.dev/docs/builtin-plugins/copy
39
39
  */
40
- declare function copy(pattern: string | string[]): BunupPlugin & CopyBuilder;
40
+ declare function copy(pattern: Arrayable<string>): BunupPlugin & CopyBuilder;
41
41
  declare class CopyBuilder {
42
42
  private _patterns;
43
43
  private _destination?;
44
44
  private _options?;
45
45
  private _transform?;
46
46
  private _fileCache;
47
- constructor(pattern: string | string[]);
47
+ constructor(pattern: Arrayable<string>);
48
48
  /**
49
49
  * Sets the destination directory or file path where files will be copied.
50
50
  * Relative to the output directory.
package/dist/plugins.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  logger,
8
8
  shims,
9
9
  unused
10
- } from "./shared/bunup-k8ycyv8v.js";
10
+ } from "./shared/bunup-s36t5vc4.js";
11
11
 
12
12
  // packages/bunup/src/plugins/copy.ts
13
13
  import { basename, extname, join } from "path";
@@ -1,5 +1,5 @@
1
1
  import { GenerateDtsOptions } from "@bunup/dts";
2
- import { BunPlugin as BunPlugin2 } from "bun";
2
+ import { BunPlugin as BunPlugin2, CompileBuildOptions } from "bun";
3
3
  type PackageJson = {
4
4
  /** The parsed content of the package.json file */
5
5
  data: Record<string, any> | null;
@@ -23,7 +23,7 @@ type BuildOutputFile = {
23
23
  */
24
24
  entrypoint: string | undefined;
25
25
  /** The kind of the file */
26
- kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode";
26
+ kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode" | "executable";
27
27
  /** Absolute path to the generated file */
28
28
  fullPath: string;
29
29
  /** Path to the generated file relative to the root directory */
@@ -246,6 +246,7 @@ type CSSOptions = {
246
246
  */
247
247
  inject?: boolean | InjectStylesOptions;
248
248
  };
249
+ type Compile = boolean | Bun.Build.Target | CompileBuildOptions;
249
250
  type OnSuccess = ((options: Partial<BuildOptions>) => MaybePromise<void> | (() => void)) | string | {
250
251
  /**
251
252
  * The shell command to execute after a successful build
@@ -349,7 +350,7 @@ interface BuildOptions {
349
350
  *
350
351
  * @see https://bunup.dev/docs/guide/options#entry-points
351
352
  */
352
- entry: string | string[];
353
+ entry: Arrayable<string>;
353
354
  /**
354
355
  * Output directory for the bundled files
355
356
  * Defaults to 'dist' if not specified
@@ -397,14 +398,14 @@ interface BuildOptions {
397
398
  *
398
399
  * https://nodejs.org/api/packages.html#exports
399
400
  */
400
- conditions?: string | string[];
401
+ conditions?: Arrayable<string>;
401
402
  /**
402
403
  * Whether to generate TypeScript declaration files (.d.ts)
403
404
  * When set to true, generates declaration files for all entry points
404
405
  * Can also be configured with GenerateDtsOptions for more control
405
406
  */
406
407
  dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify" | "inferTypes" | "tsgo"> & {
407
- entry?: string | string[];
408
+ entry?: Arrayable<string>;
408
409
  });
409
410
  /**
410
411
  * Path to a custom tsconfig.json file used for path resolution during
@@ -553,6 +554,19 @@ interface BuildOptions {
553
554
  */
554
555
  publicPath?: string;
555
556
  /**
557
+ * The base directory for your entry points to control the output file structure.
558
+ *
559
+ * Sets the base directory from which relative paths are calculated.
560
+ * Preserves your source directory structure in the output.
561
+ * If not specified, Bunup automatically uses the lowest common ancestor directory of all entry points.
562
+ *
563
+ * @see https://bun.com/docs/bundler#root
564
+ *
565
+ * @example
566
+ * sourceBase: './src'
567
+ */
568
+ sourceBase?: string;
569
+ /**
556
570
  * Controls how environment variables are handled during bundling.
557
571
  *
558
572
  * Can be one of:
@@ -660,6 +674,35 @@ interface BuildOptions {
660
674
  * @see https://bunup.dev/docs/extra-options/unused
661
675
  */
662
676
  unused?: boolean | UnusedOptions;
677
+ /**
678
+ * Create a standalone executable from your code.
679
+ *
680
+ * When `true`, creates an executable for the current platform.
681
+ * When a target string is provided, creates an executable for that specific platform.
682
+ * When an object is provided, allows for advanced configuration including cross-compilation options.
683
+ *
684
+ * @see https://bunup.dev/docs/advanced/compile
685
+ *
686
+ * @example
687
+ * // Create executable for current platform
688
+ * compile: true
689
+ *
690
+ * @example
691
+ * // Cross-compile for Linux x64
692
+ * compile: 'bun-linux-x64'
693
+ *
694
+ * @example
695
+ * // Advanced configuration with options
696
+ * compile: {
697
+ * target: 'bun-linux-x64',
698
+ * outfile: './my-cli',
699
+ * windows: {
700
+ * hideConsole: true,
701
+ * icon: './icon.ico'
702
+ * }
703
+ * }
704
+ */
705
+ compile?: Compile;
663
706
  }
664
707
  type MaybePromise<T> = Promise<T> | T;
665
708
  type WithOptional<
@@ -670,10 +713,11 @@ type WithRequired<
670
713
  T,
671
714
  K extends keyof T
672
715
  > = Omit<T, K> & Required<Pick<T, K>>;
716
+ type Arrayable<T> = T | T[];
673
717
  type DefineConfigItem = WithOptional<BuildOptions, "outDir" | "format" | "entry">;
674
718
  type DefineWorkspaceItem = {
675
719
  name: string;
676
720
  root: string;
677
721
  config?: DefineConfigItem | WithRequired<DefineConfigItem, "name">[];
678
722
  };
679
- export { WithOptional, WithRequired, DefineConfigItem, DefineWorkspaceItem, BuildMeta, BuildOutputFile, BuildContext, BuildResult, BunupPluginHooks, BunupPlugin, exports, injectStyles, unused, BuildOptions };
723
+ export { WithOptional, WithRequired, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildMeta, BuildOutputFile, BuildContext, BuildResult, BunupPluginHooks, BunupPlugin, exports, injectStyles, unused, BuildOptions };
@@ -20,7 +20,7 @@ import {
20
20
  parseErrorMessage,
21
21
  shims,
22
22
  unused
23
- } from "./bunup-k8ycyv8v.js";
23
+ } from "./bunup-s36t5vc4.js";
24
24
 
25
25
  // packages/bunup/src/loaders.ts
26
26
  import path from "path";
@@ -57,7 +57,7 @@ async function loadPackageJson(cwd = process.cwd()) {
57
57
  }
58
58
 
59
59
  // packages/bunup/src/build.ts
60
- import path2 from "path";
60
+ import path3 from "path";
61
61
  import { generateDts, logIsolatedDeclarationErrors } from "@bunup/dts";
62
62
 
63
63
  // packages/bunup/src/ensure-bun-version.ts
@@ -113,6 +113,9 @@ async function executeOnSuccess(onSuccess, options, signal) {
113
113
  }
114
114
  }
115
115
 
116
+ // packages/bunup/src/options.ts
117
+ import path2 from "path";
118
+
116
119
  // packages/bunup/src/plugins/css-typed-modules.ts
117
120
  import { transform } from "lightningcss";
118
121
  function cssTypedModulesPlugin() {
@@ -154,9 +157,6 @@ export default classes;
154
157
  };
155
158
  }
156
159
 
157
- // packages/bunup/src/plugins/internal/external-option.ts
158
- import { isBuiltin } from "module";
159
-
160
160
  // packages/bunup/src/utils/package.ts
161
161
  function getPackageDeps(packageJson) {
162
162
  if (!packageJson)
@@ -188,7 +188,7 @@ function externalOptionPlugin(options, packageJson) {
188
188
  setup(build) {
189
189
  build.onResolve({ filter: /.*/ }, (args) => {
190
190
  const importPath = args.path;
191
- if (isBuiltin(importPath) || isExternalFromPackageJson(importPath, options, packageJson)) {
191
+ if (importPath.startsWith("node:") || importPath.startsWith("bun:") || isExternalFromPackageJson(importPath, options, packageJson)) {
192
192
  return {
193
193
  path: importPath,
194
194
  external: true
@@ -206,7 +206,8 @@ function useClient() {
206
206
  name: "use-client",
207
207
  hooks: {
208
208
  onBuildDone: async ({ files }) => {
209
- for (const file of files) {
209
+ const filteredFiles = files.filter((file) => isJavascriptFile(file.fullPath));
210
+ for (const file of filteredFiles) {
210
211
  let text = await Bun.file(file.fullPath).text();
211
212
  const hasUseClient = text.split(`
212
213
  `).some((line) => line.trim().startsWith(`"use client";`));
@@ -232,10 +233,11 @@ var DEFAULT_ENTYPOINTS = [
232
233
  "src/cli.ts",
233
234
  "src/cli/index.ts"
234
235
  ];
236
+ var DEFAULT_OUT_DIR = "dist";
237
+ var DEFAULT_EXECUTABLE_OUT_DIR = "bin";
235
238
  var DEFAULT_OPTIONS = {
236
239
  entry: DEFAULT_ENTYPOINTS,
237
240
  format: "esm",
238
- outDir: "dist",
239
241
  target: "node",
240
242
  dts: true,
241
243
  clean: true
@@ -243,11 +245,15 @@ var DEFAULT_OPTIONS = {
243
245
  function resolveBuildOptions(userOptions) {
244
246
  const options = {
245
247
  ...DEFAULT_OPTIONS,
248
+ outDir: userOptions.compile ? DEFAULT_EXECUTABLE_OUT_DIR : DEFAULT_OUT_DIR,
246
249
  ...userOptions
247
250
  };
248
251
  if (options.jsx) {
249
252
  ensureBunVersion("1.2.23", "jsx option");
250
253
  }
254
+ if (options.compile) {
255
+ ensureBunVersion("1.3.0", "compile option");
256
+ }
251
257
  return options;
252
258
  }
253
259
  function resolvePlugins(options, packageJsonData) {
@@ -274,6 +280,33 @@ function resolvePlugins(options, packageJsonData) {
274
280
  plugins.push(externalOptionPlugin(options, packageJsonData));
275
281
  return plugins;
276
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-entries 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) {
301
+ name.push(`-${target.replace("bun-", "")}`);
302
+ }
303
+ return {
304
+ ...compileObj,
305
+ outfile: name.join("")
306
+ };
307
+ }
308
+ return;
309
+ }
277
310
  function getResolvedMinify(options) {
278
311
  const { minify, minifyWhitespace, minifyIdentifiers, minifySyntax } = options;
279
312
  const defaultValue = minify === true;
@@ -455,13 +488,16 @@ async function build(userOptions, rootDir = process.cwd()) {
455
488
  banner: options.banner,
456
489
  footer: options.footer,
457
490
  publicPath: options.publicPath,
491
+ root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
458
492
  env: resolvedEnv,
459
493
  ignoreDCEAnnotations: options.ignoreDCEAnnotations,
460
494
  emitDCEAnnotations: options.emitDCEAnnotations,
461
495
  jsx: options.jsx,
496
+ compile: getResolvedCompile(entryArray, options.compile, fmt),
497
+ outdir: options.compile ? options.outDir : undefined,
462
498
  throw: false,
463
499
  plugins: bunPlugins,
464
- tsconfig: options.preferredTsconfig ? path2.resolve(rootDir, options.preferredTsconfig) : undefined
500
+ tsconfig: options.preferredTsconfig ? path3.resolve(rootDir, options.preferredTsconfig) : undefined
465
501
  });
466
502
  for (const log of result.logs) {
467
503
  if (log.level === "error") {
@@ -476,10 +512,26 @@ async function build(userOptions, rootDir = process.cwd()) {
476
512
  }
477
513
  let entrypointIndex = 0;
478
514
  for (const file of result.outputs) {
515
+ if (options.compile) {
516
+ const fullPath2 = file.path;
517
+ const pathRelativeToRootDir2 = path3.relative(rootDir, fullPath2);
518
+ const pathRelativeToOutdir2 = path3.relative(options.outDir, fullPath2);
519
+ buildOutputFiles.push({
520
+ fullPath: fullPath2,
521
+ pathRelativeToRootDir: pathRelativeToRootDir2,
522
+ pathRelativeToOutdir: pathRelativeToOutdir2,
523
+ dts: false,
524
+ format: fmt,
525
+ kind: "executable",
526
+ entrypoint: entryArray[0],
527
+ size: Bun.file(fullPath2).size
528
+ });
529
+ continue;
530
+ }
479
531
  const content = await file.text();
480
532
  const pathRelativeToOutdir = cleanPath(isJavascriptFile(file.path) && file.kind === "entry-point" ? replaceExtension(file.path, getDefaultJsOutputExtension(fmt, packageType)) : file.path);
481
- const pathRelativeToRootDir = path2.join(options.outDir, pathRelativeToOutdir);
482
- const fullPath = path2.resolve(rootDir, pathRelativeToRootDir);
533
+ const pathRelativeToRootDir = path3.join(options.outDir, pathRelativeToOutdir);
534
+ const fullPath = path3.resolve(rootDir, pathRelativeToRootDir);
483
535
  await Bun.write(fullPath, content);
484
536
  if (!buildOutputFiles.some((f) => f.fullPath === fullPath)) {
485
537
  buildOutputFiles.push({
@@ -499,7 +551,7 @@ async function build(userOptions, rootDir = process.cwd()) {
499
551
  }
500
552
  });
501
553
  await Promise.all(buildPromises);
502
- if (options.dts) {
554
+ if (options.dts && !options.compile) {
503
555
  try {
504
556
  const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
505
557
  const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
@@ -509,6 +561,7 @@ async function build(userOptions, rootDir = process.cwd()) {
509
561
  naming: {
510
562
  chunk: getDefaultChunkNaming(options.name)
511
563
  },
564
+ root: options.sourceBase ? path3.resolve(rootDir, options.sourceBase) : undefined,
512
565
  ...dtsOptions
513
566
  });
514
567
  if (dtsResult.errors.length && !logger.isSilent()) {
@@ -519,7 +572,7 @@ async function build(userOptions, rootDir = process.cwd()) {
519
572
  const dtsExtension = getDefaultDtsOutputExtention(fmt, packageType, file.kind);
520
573
  const pathRelativeToOutdir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
521
574
  const pathRelativeToRootDir = cleanPath(`${options.outDir}/${pathRelativeToOutdir}`);
522
- const fullPath = path2.join(rootDir, pathRelativeToRootDir);
575
+ const fullPath = path3.join(rootDir, pathRelativeToRootDir);
523
576
  await Bun.write(fullPath, file.dts);
524
577
  buildOutputFiles.push({
525
578
  fullPath,
@@ -679,10 +679,10 @@ function isExcluded(entrypoint, exclude, excludeCli, ctx) {
679
679
  }
680
680
  function getExportKey(pathRelativeToOutdir) {
681
681
  const pathSegments = cleanPath(removeExtension(pathRelativeToOutdir)).split("/");
682
- if (pathSegments.length === 1 && pathSegments[0]?.startsWith("index")) {
682
+ if (pathSegments.length === 1 && (pathSegments[0]?.startsWith("index") || pathSegments[0]?.startsWith("main"))) {
683
683
  return ".";
684
684
  }
685
- return `./${pathSegments.filter((segment) => !segment.startsWith("index")).join("/")}`;
685
+ return `./${pathSegments.filter((segment) => !segment.startsWith("index") && !segment.startsWith("main")).join("/")}`;
686
686
  }
687
687
  function removeExtension(filePath) {
688
688
  const basename = path2.basename(filePath);
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.7",
4
+ "version": "0.15.8",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -50,8 +50,8 @@
50
50
  "type-check": "tsc --noEmit"
51
51
  },
52
52
  "dependencies": {
53
- "@bunup/dts": "^0.14.34",
54
- "@bunup/shared": "0.15.6",
53
+ "@bunup/dts": "^0.14.36",
54
+ "@bunup/shared": "0.15.7",
55
55
  "chokidar": "^4.0.3",
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.0"
72
+ "@types/bun": "^1.3.1"
73
73
  }
74
74
  }