bunup 0.8.56 → 0.8.58

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/README.md CHANGED
@@ -12,11 +12,11 @@
12
12
 
13
13
  [![NPM Downloads](https://img.shields.io/npm/dm/bunup?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAtOTYwIDk2MCA5NjAiIHdpZHRoPSIyNHB4IiBmaWxsPSIjMDAwMDAwIj48cGF0aCBkPSJNNDgwLTMyMCAyODAtNTIwbDU2LTU4IDEwNCAxMDR2LTMyNmg4MHYzMjZsMTA0LTEwNCA1NiA1OC0yMDAgMjAwWk0xNjAtMTYwdi0yMDBoODB2MTIwaDQ4MHYtMTIwaDgwdjIwMEgxNjBaIi8%2BPC9zdmc%2B&labelColor=ffc44e&color=212121)](https://www.npmjs.com/package/bunup) [![NPM Version](https://img.shields.io/npm/v/bunup?logo=npm&logoColor=212121&label=version&labelColor=ffc44e&color=212121)](https://npmjs.com/package/bunup) [![Built with Bun](https://img.shields.io/badge/Built_with-Bun-fbf0df?logo=bun&labelColor=212121)](https://bun.sh) [![sponsor](https://img.shields.io/badge/sponsor-EA4AAA?logo=githubsponsors&labelColor=FAFAFA)](https://github.com/sponsors/arshad-yaseen)
14
14
 
15
- Bunup is the **blazing-fast build tool** for TypeScript and JavaScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
15
+ Bunup is the **blazing-fast build tool** for TypeScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
16
16
 
17
- It's the fastest library bundler out there - [see benchmarks](https://gugustinette.github.io/bundler-benchmark/).
17
+ ![Bunup benchmarks](/assets/benchmarks.png)
18
18
 
19
- ![bunup-demo](/assets/demo.gif)
19
+ *The benchmark above shows build times for a project with 1,000 files, functions, and types, with TypeScript declaration generation enabled. For detailed benchmarks, visit [here](https://gugustinette.github.io/bundler-benchmark/)*
20
20
 
21
21
  </div>
22
22
  <!-- markdownlint-restore -->
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BunupPluginError
3
- } from "./chunk-cakmscpb.js";
3
+ } from "./chunk-2g0gpaee.js";
4
4
 
5
5
  // src/plugins/utils.ts
6
6
  import pc from "picocolors";
@@ -69,7 +69,7 @@ class Logger {
69
69
  tick = false,
70
70
  type = "info"
71
71
  } = options;
72
- const icon = this.getIcon(type, tick);
72
+ const icon = options.icon ?? this.getIcon(type, tick);
73
73
  const styledMessage = muted ? pc.dim(message) : type === "error" ? pc.red(message) : type === "warn" ? pc.yellow(message) : message;
74
74
  const identifierPart = this.formatIdentifier(identifier);
75
75
  return `${icon} ${styledMessage}${identifierPart}`;
@@ -458,5 +458,10 @@ async function getFilesFromGlobs(patterns, cwd) {
458
458
  }
459
459
  return Array.from(includedFiles);
460
460
  }
461
+ function isTypeScriptFile(path2) {
462
+ if (!path2)
463
+ return false;
464
+ return TS_RE.test(path2);
465
+ }
461
466
 
462
- export { __toESM, __require, setSilent, logTable, link, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs };
467
+ export { __toESM, __require, setSilent, logTable, link, logger, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, JS_TS_RE, JS_DTS_RE, CSS_RE, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs, isTypeScriptFile };
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-gh7z7s46.js";
5
5
  import {
6
6
  displayBunupGradientArt
7
- } from "./chunk-4cgw2ywa.js";
7
+ } from "./chunk-qteft286.js";
8
8
  import {
9
9
  formatListWithAnd,
10
10
  link
11
- } from "./chunk-cakmscpb.js";
11
+ } from "./chunk-2g0gpaee.js";
12
12
 
13
13
  // src/cli/init.ts
14
14
  import fs from "fs";
@@ -65,10 +65,9 @@ async function initializeWorkspace(packageJsonPath) {
65
65
  async function initializeSinglePackage(packageJsonPath) {
66
66
  const entryFiles = await collectEntryFiles();
67
67
  const outputFormats = await selectOutputFormats();
68
- const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
69
68
  const configMethod = await selectConfigurationMethod();
70
- await generateConfiguration(configMethod, entryFiles, outputFormats, shouldGenerateDts, packageJsonPath);
71
- await handleBuildScripts(packageJsonPath, entryFiles, outputFormats, shouldGenerateDts, configMethod);
69
+ await generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath);
70
+ await handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod);
72
71
  }
73
72
  async function collectWorkspacePackages() {
74
73
  const packages = [];
@@ -98,13 +97,11 @@ async function collectWorkspacePackages() {
98
97
  });
99
98
  const entryFiles = await collectEntryFilesForPackage(packageRoot, packageName);
100
99
  const outputFormats = await selectOutputFormats();
101
- const shouldGenerateDts = await promptForTypeScriptDeclarations(entryFiles);
102
100
  packages.push({
103
101
  name: packageName,
104
102
  root: packageRoot,
105
103
  entryFiles,
106
- outputFormats,
107
- shouldGenerateDts
104
+ outputFormats
108
105
  });
109
106
  const shouldAddMore = await confirm({
110
107
  message: "Do you want to add another package?",
@@ -183,15 +180,6 @@ async function selectOutputFormats() {
183
180
  initialValues: ["esm", "cjs"]
184
181
  });
185
182
  }
186
- async function promptForTypeScriptDeclarations(entryFiles) {
187
- const hasTypeScriptFiles = entryFiles.some((file) => file.endsWith(".ts") || file.endsWith(".tsx"));
188
- if (!hasTypeScriptFiles)
189
- return false;
190
- return await confirm({
191
- message: "Generate TypeScript declarations?",
192
- initialValue: true
193
- });
194
- }
195
183
  async function selectWorkspaceConfigurationMethod() {
196
184
  return await select({
197
185
  message: "How would you like to configure your workspace?",
@@ -222,18 +210,18 @@ async function generateWorkspaceConfiguration(configMethod, workspacePackages) {
222
210
  const configContent = createWorkspaceConfigFileContent(workspacePackages);
223
211
  await Bun.write(`bunup.config.${configMethod}`, configContent);
224
212
  }
225
- async function generateConfiguration(configMethod, entryFiles, outputFormats, shouldGenerateDts, packageJsonPath) {
213
+ async function generateConfiguration(configMethod, entryFiles, outputFormats, packageJsonPath) {
226
214
  if (configMethod === "none") {
227
215
  log.info("If you need more control (such as adding plugins or customizing output), you can always create a config file later.");
228
216
  return;
229
217
  }
230
218
  if (configMethod === "ts" || configMethod === "js") {
231
- await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats, shouldGenerateDts));
219
+ await Bun.write(`bunup.config.${configMethod}`, createConfigFileContent(entryFiles, outputFormats));
232
220
  } else if (configMethod === "json") {
233
221
  const { data: packageJsonConfig } = await loadPackageJson();
234
222
  const updatedConfig = {
235
223
  ...packageJsonConfig,
236
- bunup: createPackageJsonConfig(entryFiles, outputFormats, shouldGenerateDts)
224
+ bunup: createPackageJsonConfig(entryFiles, outputFormats)
237
225
  };
238
226
  await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
239
227
  }
@@ -259,10 +247,10 @@ async function handleWorkspaceBuildScripts(packageJsonPath) {
259
247
  };
260
248
  await Bun.write(packageJsonPath, JSON.stringify(updatedConfig, null, 2));
261
249
  }
262
- async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats, shouldGenerateDts, configMethod) {
250
+ async function handleBuildScripts(packageJsonPath, entryFiles, outputFormats, configMethod) {
263
251
  const { data: packageJsonConfig } = await loadPackageJson();
264
252
  const existingScripts = packageJsonConfig?.scripts ?? {};
265
- const newScripts = createBuildScripts(entryFiles, outputFormats, shouldGenerateDts, configMethod);
253
+ const newScripts = createBuildScripts(entryFiles, outputFormats, configMethod);
266
254
  const conflictingScripts = Object.keys(newScripts).filter((script) => existingScripts[script]);
267
255
  if (conflictingScripts.length > 0) {
268
256
  const shouldOverride = await confirm({
@@ -287,8 +275,7 @@ function createWorkspaceConfigFileContent(workspacePackages) {
287
275
  root: '${pkg.root}',
288
276
  config: {
289
277
  entry: [${pkg.entryFiles.map((file) => `'${file}'`).join(", ")}],
290
- format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}],${pkg.shouldGenerateDts ? `
291
- dts: true,` : ""}
278
+ format: [${pkg.outputFormats.map((format) => `'${format}'`).join(", ")}],
292
279
  },
293
280
  }`;
294
281
  }).join(`,
@@ -300,21 +287,19 @@ ${packagesConfig}
300
287
  ])
301
288
  `;
302
289
  }
303
- function createConfigFileContent(entryFiles, outputFormats, shouldGenerateDts) {
290
+ function createConfigFileContent(entryFiles, outputFormats) {
304
291
  return `import { defineConfig } from 'bunup'
305
292
 
306
293
  export default defineConfig({
307
294
  entry: [${entryFiles.map((file) => `'${file}'`).join(", ")}],
308
- format: [${outputFormats.map((format) => `'${format}'`).join(", ")}],${shouldGenerateDts ? `
309
- dts: true,` : ""}
295
+ format: [${outputFormats.map((format) => `'${format}'`).join(", ")}],
310
296
  })
311
297
  `;
312
298
  }
313
- function createPackageJsonConfig(entryFiles, outputFormats, shouldGenerateDts) {
299
+ function createPackageJsonConfig(entryFiles, outputFormats) {
314
300
  return {
315
301
  entry: entryFiles,
316
- format: outputFormats,
317
- ...shouldGenerateDts && { dts: true }
302
+ format: outputFormats
318
303
  };
319
304
  }
320
305
  function createWorkspaceBuildScripts() {
@@ -323,8 +308,8 @@ function createWorkspaceBuildScripts() {
323
308
  dev: "bunup --watch"
324
309
  };
325
310
  }
326
- function createBuildScripts(entryFiles, outputFormats, shouldGenerateDts, configMethod) {
327
- const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}${shouldGenerateDts ? " --dts" : ""}` : "";
311
+ function createBuildScripts(entryFiles, outputFormats, configMethod) {
312
+ const cliOptions = configMethod === "none" ? ` ${entryFiles.join(" ")} --format ${outputFormats.join(",")}` : "";
328
313
  return {
329
314
  build: `bunup${cliOptions}`,
330
315
  dev: `bunup${cliOptions} --watch`
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  displayBunupGradientArt
4
- } from "./chunk-4cgw2ywa.js";
4
+ } from "./chunk-qteft286.js";
5
5
  import {
6
6
  link,
7
7
  pathExistsSync
8
- } from "./chunk-cakmscpb.js";
8
+ } from "./chunk-2g0gpaee.js";
9
9
 
10
10
  // src/cli/new.ts
11
11
  import { renameSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-cakmscpb.js";
3
+ } from "./chunk-2g0gpaee.js";
4
4
 
5
5
  // src/cli/utils.ts
6
6
  import pc from "picocolors";
@@ -3,7 +3,7 @@ import {
3
3
  filterBunupPlugins,
4
4
  runPluginBuildDoneHooks,
5
5
  runPluginBuildStartHooks
6
- } from "./chunk-zpjpa5th.js";
6
+ } from "./chunk-0j56xynx.js";
7
7
  import {
8
8
  loadPackageJson
9
9
  } from "./chunk-gh7z7s46.js";
@@ -19,12 +19,13 @@ import {
19
19
  getFilesFromGlobs,
20
20
  getPackageDeps,
21
21
  getShortFilePath,
22
+ isTypeScriptFile,
22
23
  link,
23
24
  logTable,
24
25
  logger,
25
26
  parseErrorMessage,
26
27
  setSilent
27
- } from "./chunk-cakmscpb.js";
28
+ } from "./chunk-2g0gpaee.js";
28
29
 
29
30
  // src/build.ts
30
31
  import path from "path";
@@ -145,7 +146,7 @@ ${text}`;
145
146
  // src/options.ts
146
147
  var DEFAULT_OPTIONS = {
147
148
  entry: ["src/index.ts"],
148
- format: ["cjs"],
149
+ format: ["esm", "cjs"],
149
150
  outDir: "dist",
150
151
  target: "node",
151
152
  clean: true
@@ -193,7 +194,7 @@ function getResolvedSplitting(splitting, format) {
193
194
  return splitting === undefined ? format === "esm" : splitting;
194
195
  }
195
196
  function getResolvedDtsSplitting(buildSplitting, dtsSplitting) {
196
- return dtsSplitting ?? buildSplitting ?? true;
197
+ return dtsSplitting ?? buildSplitting ?? false;
197
198
  }
198
199
  var DEFAULT_ENTRY_NAMING = "[dir]/[name].[ext]";
199
200
  function getResolvedNaming(fmt, packageType) {
@@ -325,7 +326,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
325
326
  }
326
327
  });
327
328
  await Promise.all(buildPromises);
328
- if (options.dts) {
329
+ if (options.dts ?? entrypoints.some(isTypeScriptFile)) {
329
330
  try {
330
331
  const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
331
332
  const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
package/dist/cli/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import {
4
4
  build,
5
5
  createBuildOptions
6
- } from "../chunk-zgjvecs6.js";
7
- import"../chunk-zpjpa5th.js";
6
+ } from "../chunk-wav05ehp.js";
7
+ import"../chunk-0j56xynx.js";
8
8
  import {
9
9
  processLoadedConfigs
10
10
  } from "../chunk-gh7z7s46.js";
@@ -21,14 +21,14 @@ import {
21
21
  logger,
22
22
  parseErrorMessage,
23
23
  setSilent
24
- } from "../chunk-cakmscpb.js";
24
+ } from "../chunk-2g0gpaee.js";
25
25
 
26
26
  // src/cli/index.ts
27
27
  import { loadConfig } from "coffi";
28
28
  import pc3 from "picocolors";
29
29
  import { exec } from "tinyexec";
30
30
  // package.json
31
- var version = "0.8.56";
31
+ var version = "0.8.58";
32
32
 
33
33
  // src/watch.ts
34
34
  import path from "path";
@@ -63,7 +63,9 @@ async function watch(partialOptions, rootDir) {
63
63
  const start = performance.now();
64
64
  await build(options, rootDir);
65
65
  if (!initial) {
66
- logger.success(`\uD83D\uDCE6 Rebuild finished in ${pc.green(formatTime(performance.now() - start))}`);
66
+ logger.success(`Rebuild finished in ${pc.green(formatTime(performance.now() - start))}`, {
67
+ icon: "\uD83D\uDCE6"
68
+ });
67
69
  }
68
70
  } catch (error) {
69
71
  handleError(error);
@@ -71,12 +73,7 @@ async function watch(partialOptions, rootDir) {
71
73
  isRebuilding = false;
72
74
  }
73
75
  };
74
- watcher.on("change", (filePath) => {
75
- const changedFile = path.relative(rootDir, filePath);
76
- logger.info(`File changed: ${changedFile}`, {
77
- muted: true,
78
- once: changedFile
79
- });
76
+ watcher.on("change", () => {
80
77
  triggerRebuild();
81
78
  });
82
79
  watcher.on("error", (error) => {
@@ -485,12 +482,12 @@ var parseCliOptions = (argv) => {
485
482
  async function main(args = Bun.argv.slice(2)) {
486
483
  const cliOptions = parseCliOptions(args);
487
484
  if (cliOptions.new) {
488
- const { newProject } = await import("../chunk-c4xe90dt.js");
485
+ const { newProject } = await import("../chunk-kspt827v.js");
489
486
  await newProject();
490
487
  return;
491
488
  }
492
489
  if (cliOptions.init) {
493
- const { init } = await import("../chunk-p86qvgaa.js");
490
+ const { init } = await import("../chunk-8dk0fkzd.js");
494
491
  await init();
495
492
  return;
496
493
  }
@@ -532,7 +529,10 @@ async function main(args = Bun.argv.slice(2)) {
532
529
  const timeDisplay = formatTime(buildTimeMs);
533
530
  logger.success(`Build completed in ${pc3.green(timeDisplay)}`);
534
531
  if (cliOptions.watch) {
535
- logger.info("Watching for file changes...");
532
+ logger.info("Watching for file changes...", {
533
+ icon: "\uD83D\uDC40",
534
+ verticalSpace: true
535
+ });
536
536
  }
537
537
  if (cliOptions.onSuccess) {
538
538
  logger.info(`Running command: ${cliOptions.onSuccess}`, {