bunup 0.8.44 → 0.8.45

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.
@@ -1,5 +1,93 @@
1
- import { BunPlugin } from "bun";
2
1
  import { DtsPluginOptions } from "bun-dts";
2
+ import { BunPlugin } from "bun";
3
+ type PackageJson = {
4
+ /** The parsed content of the package.json file */
5
+ data: Record<string, any> | null
6
+ /** The path to the package.json file */
7
+ path: string | null
8
+ };
9
+ /**
10
+ * Represents a Bun plugin that can be used with Bunup
11
+ */
12
+ type BunupBunPlugin = {
13
+ /** Identifies this as a native Bun plugin */
14
+ type: "bun"
15
+ /** Optional name for the plugin */
16
+ name?: string
17
+ /** The actual Bun plugin implementation */
18
+ plugin: BunPlugin
19
+ };
20
+ /**
21
+ * Represents the meta data of the build
22
+ */
23
+ type BuildMeta = {
24
+ /** The package.json file */
25
+ packageJson: PackageJson
26
+ /** The root directory of the build */
27
+ rootDir: string
28
+ };
29
+ type BuildOutputFile = {
30
+ /** The kind of the file */
31
+ kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
32
+ /** Path to the generated file */
33
+ fullPath: string
34
+ /** Path to the generated file relative to the root directory */
35
+ relativePathToRootDir: string
36
+ /** Path to the generated file relative to the output directory */
37
+ relativePathToOutputDir: string
38
+ /** Whether the file is a dts file */
39
+ dts: boolean
40
+ /** The format of the output file */
41
+ format: Format
42
+ };
43
+ /**
44
+ * Represents the output of a build operation
45
+ */
46
+ type BuildOutput = {
47
+ /** Array of generated files with their paths and contents */
48
+ files: BuildOutputFile[]
49
+ };
50
+ /**
51
+ * Context provided to build hooks
52
+ */
53
+ type BuildContext = {
54
+ /** The build options that were used */
55
+ options: BuildOptions
56
+ /** The output of the build */
57
+ output: BuildOutput
58
+ /** The meta data of the build */
59
+ meta: BuildMeta
60
+ };
61
+ /**
62
+ * Hooks that can be implemented by Bunup plugins
63
+ */
64
+ type BunupPluginHooks = {
65
+ /**
66
+ * Called when a build is successfully completed
67
+ * @param ctx Build context containing options and output
68
+ */
69
+ onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
70
+ /**
71
+ * Called before a build starts
72
+ * @param options Build options that will be used
73
+ */
74
+ onBuildStart?: (options: BuildOptions) => MaybePromise<void>
75
+ };
76
+ /**
77
+ * Represents a Bunup-specific plugin
78
+ */
79
+ type BunupPlugin = {
80
+ /** Identifies this as a Bunup-specific plugin */
81
+ type: "bunup"
82
+ /** Optional name for the plugin */
83
+ name?: string
84
+ /** The hooks implemented by this plugin */
85
+ hooks: BunupPluginHooks
86
+ };
87
+ /**
88
+ * Union type representing all supported plugin types
89
+ */
90
+ type Plugin = BunupBunPlugin | BunupPlugin;
3
91
  type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml" | "file" | "napi" | "wasm" | "text" | "css" | "html";
4
92
  type Define = Record<string, string>;
5
93
  type Sourcemap = "none" | "linked" | "inline" | "external" | "linked" | boolean;
@@ -251,92 +339,4 @@ type DefineWorkspaceItem = {
251
339
  root: string
252
340
  config: DefineConfigItem | DefineConfigItem[]
253
341
  };
254
- type PackageJson = {
255
- /** The parsed content of the package.json file */
256
- data: Record<string, any> | null
257
- /** The path to the package.json file */
258
- path: string | null
259
- };
260
- /**
261
- * Represents a Bun plugin that can be used with Bunup
262
- */
263
- type BunupBunPlugin = {
264
- /** Identifies this as a native Bun plugin */
265
- type: "bun"
266
- /** Optional name for the plugin */
267
- name?: string
268
- /** The actual Bun plugin implementation */
269
- plugin: BunPlugin
270
- };
271
- /**
272
- * Represents the meta data of the build
273
- */
274
- type BuildMeta = {
275
- /** The package.json file */
276
- packageJson: PackageJson
277
- /** The root directory of the build */
278
- rootDir: string
279
- };
280
- type BuildOutputFile = {
281
- /** The kind of the file */
282
- kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
283
- /** Path to the generated file */
284
- fullPath: string
285
- /** Path to the generated file relative to the root directory */
286
- relativePathToRootDir: string
287
- /** Path to the generated file relative to the output directory */
288
- relativePathToOutputDir: string
289
- /** Whether the file is a dts file */
290
- dts: boolean
291
- /** The format of the output file */
292
- format: Format
293
- };
294
- /**
295
- * Represents the output of a build operation
296
- */
297
- type BuildOutput = {
298
- /** Array of generated files with their paths and contents */
299
- files: BuildOutputFile[]
300
- };
301
- /**
302
- * Context provided to build hooks
303
- */
304
- type BuildContext = {
305
- /** The build options that were used */
306
- options: BuildOptions
307
- /** The output of the build */
308
- output: BuildOutput
309
- /** The meta data of the build */
310
- meta: BuildMeta
311
- };
312
- /**
313
- * Hooks that can be implemented by Bunup plugins
314
- */
315
- type BunupPluginHooks = {
316
- /**
317
- * Called when a build is successfully completed
318
- * @param ctx Build context containing options and output
319
- */
320
- onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
321
- /**
322
- * Called before a build starts
323
- * @param options Build options that will be used
324
- */
325
- onBuildStart?: (options: BuildOptions) => MaybePromise<void>
326
- };
327
- /**
328
- * Represents a Bunup-specific plugin
329
- */
330
- type BunupPlugin = {
331
- /** Identifies this as a Bunup-specific plugin */
332
- type: "bunup"
333
- /** Optional name for the plugin */
334
- name?: string
335
- /** The hooks implemented by this plugin */
336
- hooks: BunupPluginHooks
337
- };
338
- /**
339
- * Union type representing all supported plugin types
340
- */
341
- type Plugin = BunupBunPlugin | BunupPlugin;
342
- export { BuildContext, BunupPlugin, Plugin, BuildOptions, MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem };
342
+ export { MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin, Plugin, BuildOptions };
@@ -53,7 +53,8 @@ class Logger {
53
53
  const iconMap = {
54
54
  info: pc.blue("i"),
55
55
  warn: pc.yellow("!"),
56
- error: pc.red("\u2715")
56
+ error: pc.red("\u2715"),
57
+ recommended: pc.magenta("\u25D0")
57
58
  };
58
59
  return iconMap[type];
59
60
  }
@@ -117,6 +118,14 @@ class Logger {
117
118
  });
118
119
  this.output(formattedMessage, options);
119
120
  }
121
+ recommended(message, options = {}) {
122
+ const formattedMessage = this.formatMessage({
123
+ ...options,
124
+ message,
125
+ type: "recommended"
126
+ });
127
+ this.output(formattedMessage, options);
128
+ }
120
129
  space() {
121
130
  if (!silent) {
122
131
  console.log("");
@@ -158,6 +167,7 @@ function logTable(columns, data, footer) {
158
167
  console.log(footerRow);
159
168
  }
160
169
  }
170
+ var link = (url) => pc.underline(pc.cyan(url));
161
171
  var logger = Logger.getInstance();
162
172
 
163
173
  // src/errors.ts
@@ -247,7 +257,7 @@ var handleError = (error, context) => {
247
257
  console.log(`
248
258
  `);
249
259
  } else {
250
- console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + pc2.cyan("https://github.com/arshad-yaseen/bunup/issues/new")));
260
+ console.error(pc2.dim(pc2.white("If you think this is a bug, please open an issue at: ") + link("https://github.com/arshad-yaseen/bunup/issues/new")));
251
261
  }
252
262
  };
253
263
  var handleErrorAndExit = (error, context) => {
@@ -333,7 +343,7 @@ function pathExistsSync(filePath) {
333
343
  try {
334
344
  fsSync.accessSync(filePath);
335
345
  return true;
336
- } catch (error) {
346
+ } catch {
337
347
  return false;
338
348
  }
339
349
  }
@@ -364,4 +374,4 @@ async function getFilesFromGlobs(patterns, cwd) {
364
374
  return Array.from(includedFiles);
365
375
  }
366
376
 
367
- export { __toESM, __require, setSilent, logTable, logger, BunupBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs };
377
+ export { __toESM, __require, setSilent, logTable, link, logger, BunupBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-c1eyecm3.js";
3
+ } from "./chunk-a76fsvj7.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-6gvmfnmt.js";
6
+ } from "./chunk-snvybwa2.js";
7
7
  import {
8
8
  loadPackageJson
9
9
  } from "./chunk-gh7z7s46.js";
@@ -18,10 +18,11 @@ import {
18
18
  getFilesFromGlobs,
19
19
  getPackageDeps,
20
20
  getShortFilePath,
21
+ link,
21
22
  logTable,
22
23
  logger,
23
24
  setSilent
24
- } from "./chunk-c1eyecm3.js";
25
+ } from "./chunk-a76fsvj7.js";
25
26
 
26
27
  // src/build.ts
27
28
  import path from "path";
@@ -32,7 +33,32 @@ import pc2 from "picocolors";
32
33
  var rules = [
33
34
  {
34
35
  check: (ctx) => ctx.meta.packageJson.data?.type !== "module" && ctx.options.format.length === 1 && ctx.options.format[0] === "esm",
35
- message: 'You are using ESM format only but your package.json does not have "type": "module". This may cause issues with module resolution.'
36
+ message: 'You are using only ESM format. It is recommended to add "type": "module" to your package.json to help with module resolution.',
37
+ logLevel: "recommended"
38
+ },
39
+ {
40
+ check: (ctx) => {
41
+ const deps = ctx.meta.packageJson.data?.dependencies;
42
+ return deps && (("typescript" in deps) || ("@types/node" in deps) || ("@types/bun" in deps));
43
+ },
44
+ message: "TypeScript or @types/* packages are listed as production dependencies. Consider moving them to devDependencies since they're only needed during development.",
45
+ logLevel: "recommended"
46
+ },
47
+ {
48
+ check: (ctx) => {
49
+ const hasMinification = ctx.options.minify || ctx.options.minifyWhitespace || ctx.options.minifyIdentifiers || ctx.options.minifySyntax;
50
+ return hasMinification && !ctx.options.sourcemap;
51
+ },
52
+ message: `You are using minification without source maps. Consider enabling source maps to help with debugging minified code. Learn more: ${link("https://bunup.dev/docs/guide/options#source-maps")}`,
53
+ logLevel: "recommended"
54
+ },
55
+ {
56
+ check: (ctx) => {
57
+ const pkg = ctx.meta.packageJson.data;
58
+ return !pkg?.files && !pkg?.private;
59
+ },
60
+ message: 'Your package.json is missing a "files" field. This means all files will be published to npm. Consider adding a "files" field to control what gets published.',
61
+ logLevel: "info"
36
62
  }
37
63
  ];
38
64
  function linter() {
@@ -47,7 +73,7 @@ function linter() {
47
73
  if (!hasWarnings) {
48
74
  logger.space();
49
75
  }
50
- logger.warn(rule.message);
76
+ logger[rule.logLevel ?? "warn"](rule.message);
51
77
  hasWarnings = true;
52
78
  }
53
79
  }
@@ -137,7 +163,7 @@ ${text}`;
137
163
 
138
164
  // src/options.ts
139
165
  var DEFAULT_OPTIONS = {
140
- entry: [],
166
+ entry: ["src/index.ts"],
141
167
  format: ["cjs"],
142
168
  outDir: "dist",
143
169
  target: "node",
@@ -150,7 +176,7 @@ function createBuildOptions(partialOptions) {
150
176
  };
151
177
  return {
152
178
  ...options,
153
- plugins: [useClient(), linter(), report(), ...options.plugins ?? []]
179
+ plugins: [...options.plugins ?? [], useClient(), linter(), report()]
154
180
  };
155
181
  }
156
182
  function getResolvedMinify(options) {
@@ -4,10 +4,11 @@ import {
4
4
  } from "./chunk-gh7z7s46.js";
5
5
  import {
6
6
  displayBunupGradientArt
7
- } from "./chunk-a7j07gk7.js";
7
+ } from "./chunk-e7gp8gbh.js";
8
8
  import {
9
- formatListWithAnd
10
- } from "./chunk-c1eyecm3.js";
9
+ formatListWithAnd,
10
+ link
11
+ } from "./chunk-a76fsvj7.js";
11
12
 
12
13
  // src/cli/init.ts
13
14
  import fs from "fs";
@@ -340,7 +341,7 @@ function showSuccessOutro(isWorkspace) {
340
341
  ${devCommand}${isWorkspace ? `
341
342
  ${filterCommand}` : ""}
342
343
 
343
- ${pc.dim("Learn more:")} ${pc.underline("https://bunup.dev/docs")}
344
+ ${pc.dim("Learn more:")} ${link("https://bunup.dev/docs")}
344
345
 
345
346
  ${pc.yellow("Happy building!")} \uD83D\uDE80
346
347
  `);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BunupPluginError
3
- } from "./chunk-c1eyecm3.js";
3
+ } from "./chunk-a76fsvj7.js";
4
4
 
5
5
  // src/plugins/utils.ts
6
6
  import pc from "picocolors";
@@ -1,10 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  displayBunupGradientArt
4
- } from "./chunk-a7j07gk7.js";
4
+ } from "./chunk-e7gp8gbh.js";
5
5
  import {
6
+ link,
6
7
  pathExistsSync
7
- } from "./chunk-c1eyecm3.js";
8
+ } from "./chunk-a76fsvj7.js";
8
9
 
9
10
  // src/cli/new.ts
10
11
  import { renameSync } from "fs";
@@ -142,7 +143,7 @@ async function newProject() {
142
143
  ${pc.cyan("bun run dev")}${pc.dim(" (watch mode for development)")}${template.type === "react" ? `
143
144
  ${pc.cyan("bun run dev:test")} ${pc.dim("(preview components in a test Next.js app)")} ` : ""}
144
145
 
145
- ${pc.dim("Learn more:")} ${pc.underline("https://bunup.dev/docs")}
146
+ ${pc.dim("Learn more:")} ${link("https://bunup.dev/docs")}
146
147
 
147
148
  ${pc.yellow("Happy coding!")} \uD83D\uDE80
148
149
  `);
package/dist/cli/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  import {
4
4
  build,
5
5
  createBuildOptions
6
- } from "../chunk-8zb11ewt.js";
7
- import"../chunk-6gvmfnmt.js";
6
+ } from "../chunk-pn1qh94w.js";
7
+ import"../chunk-snvybwa2.js";
8
8
  import {
9
9
  processLoadedConfigs
10
10
  } from "../chunk-gh7z7s46.js";
@@ -21,15 +21,72 @@ import {
21
21
  logger,
22
22
  parseErrorMessage,
23
23
  setSilent
24
- } from "../chunk-c1eyecm3.js";
24
+ } from "../chunk-a76fsvj7.js";
25
25
 
26
26
  // src/cli/index.ts
27
+ import { loadConfig } from "coffi";
28
+ import pc3 from "picocolors";
27
29
  import { exec } from "tinyexec";
28
30
  // package.json
29
- var version = "0.8.44";
31
+ var version = "0.8.45";
30
32
 
31
- // src/cli/options.ts
33
+ // src/watch.ts
34
+ import path from "path";
32
35
  import pc from "picocolors";
36
+ async function watch(partialOptions, rootDir) {
37
+ const watchPaths = new Set;
38
+ const options = createBuildOptions(partialOptions);
39
+ const uniqueEntries = new Set(options.entry);
40
+ for (const entry of uniqueEntries) {
41
+ const entryPath = path.resolve(rootDir, entry);
42
+ const parentDir = path.dirname(entryPath);
43
+ watchPaths.add(parentDir);
44
+ }
45
+ const chokidar = await import("chokidar");
46
+ const watcher = chokidar.watch(Array.from(watchPaths), {
47
+ ignoreInitial: true,
48
+ ignorePermissionErrors: true,
49
+ ignored: [
50
+ /[\\/]\.git[\\/]/,
51
+ /[\\/]node_modules[\\/]/,
52
+ path.join(rootDir, options.outDir)
53
+ ]
54
+ });
55
+ let isRebuilding = false;
56
+ const triggerRebuild = async (initial = false) => {
57
+ if (isRebuilding) {
58
+ return;
59
+ }
60
+ isRebuilding = true;
61
+ try {
62
+ await new Promise((resolve) => setTimeout(resolve, 20));
63
+ const start = performance.now();
64
+ await build(options, rootDir);
65
+ if (!initial) {
66
+ logger.success(`\uD83D\uDCE6 Rebuild finished in ${pc.green(formatTime(performance.now() - start))}`);
67
+ }
68
+ } catch (error) {
69
+ handleError(error);
70
+ } finally {
71
+ isRebuilding = false;
72
+ }
73
+ };
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
+ });
80
+ triggerRebuild();
81
+ });
82
+ watcher.on("error", (error) => {
83
+ throw new BunupWatchError(`Watcher error: ${parseErrorMessage(error)}`);
84
+ });
85
+ await triggerRebuild(true);
86
+ }
87
+
88
+ // src/cli/options.ts
89
+ import pc2 from "picocolors";
33
90
 
34
91
  // src/constants/index.ts
35
92
  var BUNUP_DOCS_URL = "https://bunup.dev/docs";
@@ -348,11 +405,11 @@ var displayHelp = () => {
348
405
  utility: "Utility Options"
349
406
  };
350
407
  console.log();
351
- console.log(pc.cyan(pc.bold("bunup")));
408
+ console.log(pc2.cyan(pc2.bold("bunup")));
352
409
  console.log();
353
410
  console.log("\u26A1\uFE0F A blazing-fast build tool for your libraries built with Bun");
354
411
  console.log();
355
- console.log(pc.cyan("Usage:"));
412
+ console.log(pc2.cyan("Usage:"));
356
413
  console.log(" bunup [entry...] [options]");
357
414
  console.log(" bunup --init");
358
415
  console.log(" bunup --new");
@@ -361,24 +418,24 @@ var displayHelp = () => {
361
418
  const categoryOptions = Object.values(OPTION_DEFINITIONS).filter((option) => option.category === categoryKey);
362
419
  if (categoryOptions.length === 0)
363
420
  return;
364
- console.log(pc.cyan(`${categoryName}:`));
421
+ console.log(pc2.cyan(`${categoryName}:`));
365
422
  for (const option of categoryOptions) {
366
423
  const flags = option.flags.map((flag) => flag.length === 1 ? `-${flag}` : `--${flag}`).join(", ");
367
- const flagsDisplay = pc.green(flags);
368
- const typeDisplay = pc.dim(`<${option.type}>`);
369
- const defaultDisplay = option.default ? pc.yellow(`(default: ${option.default})`) : "";
424
+ const flagsDisplay = pc2.green(flags);
425
+ const typeDisplay = pc2.dim(`<${option.type}>`);
426
+ const defaultDisplay = option.default ? pc2.yellow(`(default: ${option.default})`) : "";
370
427
  console.log(` ${flagsDisplay} ${typeDisplay}`);
371
- console.log(` ${pc.dim(option.description)} ${defaultDisplay}`);
428
+ console.log(` ${pc2.dim(option.description)} ${defaultDisplay}`);
372
429
  console.log();
373
430
  }
374
431
  }
375
- console.log(pc.cyan("Examples:"));
432
+ console.log(pc2.cyan("Examples:"));
376
433
  console.log(" bunup src/**/*.ts");
377
434
  console.log(" bunup src/index.ts src/cli.ts --format esm,cjs");
378
435
  console.log(" bunup src/index.ts --watch --dts");
379
436
  console.log();
380
- console.log(pc.dim("For more information:"));
381
- console.log(` ${pc.cyan(pc.underline(BUNUP_DOCS_URL))}`);
437
+ console.log(pc2.dim("For more information:"));
438
+ console.log(` ${pc2.cyan(pc2.underline(BUNUP_DOCS_URL))}`);
382
439
  console.log();
383
440
  };
384
441
  var parseArgument = (arg, nextArg) => {
@@ -424,75 +481,16 @@ var parseCliOptions = (argv) => {
424
481
  return options;
425
482
  };
426
483
 
427
- // src/cli/index.ts
428
- import { loadConfig } from "coffi";
429
- import pc3 from "picocolors";
430
-
431
- // src/watch.ts
432
- import path from "path";
433
- import pc2 from "picocolors";
434
- async function watch(partialOptions, rootDir) {
435
- const watchPaths = new Set;
436
- const options = createBuildOptions(partialOptions);
437
- const uniqueEntries = new Set(options.entry);
438
- for (const entry of uniqueEntries) {
439
- const entryPath = path.resolve(rootDir, entry);
440
- const parentDir = path.dirname(entryPath);
441
- watchPaths.add(parentDir);
442
- }
443
- const chokidar = await import("chokidar");
444
- const watcher = chokidar.watch(Array.from(watchPaths), {
445
- ignoreInitial: true,
446
- ignorePermissionErrors: true,
447
- ignored: [
448
- /[\\/]\.git[\\/]/,
449
- /[\\/]node_modules[\\/]/,
450
- path.join(rootDir, options.outDir)
451
- ]
452
- });
453
- let isRebuilding = false;
454
- const triggerRebuild = async (initial = false) => {
455
- if (isRebuilding) {
456
- return;
457
- }
458
- isRebuilding = true;
459
- try {
460
- await new Promise((resolve) => setTimeout(resolve, 20));
461
- const start = performance.now();
462
- await build(options, rootDir);
463
- if (!initial) {
464
- logger.success(`\uD83D\uDCE6 Rebuild finished in ${pc2.green(formatTime(performance.now() - start))}`);
465
- }
466
- } catch (error) {
467
- handleError(error);
468
- } finally {
469
- isRebuilding = false;
470
- }
471
- };
472
- watcher.on("change", (filePath) => {
473
- const changedFile = path.relative(rootDir, filePath);
474
- logger.info(`File changed: ${changedFile}`, {
475
- muted: true,
476
- once: changedFile
477
- });
478
- triggerRebuild();
479
- });
480
- watcher.on("error", (error) => {
481
- throw new BunupWatchError(`Watcher error: ${parseErrorMessage(error)}`);
482
- });
483
- await triggerRebuild(true);
484
- }
485
-
486
484
  // src/cli/index.ts
487
485
  async function main(args = Bun.argv.slice(2)) {
488
486
  const cliOptions = parseCliOptions(args);
489
487
  if (cliOptions.new) {
490
- const { newProject } = await import("../chunk-q3kvndyh.js");
488
+ const { newProject } = await import("../chunk-xebwdvyv.js");
491
489
  await newProject();
492
490
  return;
493
491
  }
494
492
  if (cliOptions.init) {
495
- const { init } = await import("../chunk-5s4mpe5d.js");
493
+ const { init } = await import("../chunk-rnbj1nec.js");
496
494
  await init();
497
495
  return;
498
496
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-4gbrfagt";
1
+ import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-0f0jc2gd";
2
+ declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
2
3
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
3
4
  declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
4
- declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
5
5
  export { defineWorkspace, defineConfig, build, Plugin, DefineWorkspaceItem, DefineConfigItem, BuildOptions };
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  build
4
- } from "./chunk-8zb11ewt.js";
5
- import"./chunk-6gvmfnmt.js";
4
+ } from "./chunk-pn1qh94w.js";
5
+ import"./chunk-snvybwa2.js";
6
6
  import"./chunk-gh7z7s46.js";
7
- import"./chunk-c1eyecm3.js";
8
-
7
+ import"./chunk-a76fsvj7.js";
9
8
  // src/define.ts
10
9
  function defineConfig(options) {
11
10
  return options;
package/dist/plugins.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-4gbrfagt";
1
+ import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-0f0jc2gd";
2
2
  /**
3
- * A plugin that provides shims for Node.js globals and ESM/CJS interoperability.
3
+ * A plugin that copies files and directories to the output directory.
4
4
  *
5
- * @see https://bunup.dev/docs/plugins/shims
5
+ * @param patterns - Array of glob patterns to match files for copying
6
+ * @param outPath - Optional output path. If not provided, uses the build output directory
7
+ * @see https://bunup.dev/docs/plugins/copy
6
8
  */
7
- declare function shims(): Plugin;
9
+ declare function copy(patterns: string[], outPath?: string): BunupPlugin;
8
10
  type CustomExports = Record<string, string | Record<string, string | Record<string, string>>>;
9
11
  interface ExportsPluginOptions {
10
12
  /**
@@ -30,14 +32,6 @@ interface ExportsPluginOptions {
30
32
  * @see https://bunup.dev/docs/plugins/exports
31
33
  */
32
34
  declare function exports(options?: ExportsPluginOptions): BunupPlugin;
33
- /**
34
- * A plugin that copies files and directories to the output directory.
35
- *
36
- * @param patterns - Array of glob patterns to match files for copying
37
- * @param outPath - Optional output path. If not provided, uses the build output directory
38
- * @see https://bunup.dev/docs/plugins/copy
39
- */
40
- declare function copy(patterns: string[], outPath?: string): BunupPlugin;
41
35
  type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
42
36
  inject?: (css: string, filePath: string) => MaybePromise<string>
43
37
  };
@@ -47,4 +41,10 @@ type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<im
47
41
  * @see https://bunup.dev/docs/plugins/inject-styles
48
42
  */
49
43
  declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
44
+ /**
45
+ * A plugin that provides shims for Node.js globals and ESM/CJS interoperability.
46
+ *
47
+ * @see https://bunup.dev/docs/plugins/shims
48
+ */
49
+ declare function shims(): Plugin;
50
50
  export { shims, injectStyles, exports, copy };
package/dist/plugins.js CHANGED
@@ -1,12 +1,38 @@
1
1
  // @bun
2
2
  import {
3
3
  getPackageForPlugin
4
- } from "./chunk-6gvmfnmt.js";
4
+ } from "./chunk-snvybwa2.js";
5
5
  import {
6
6
  cleanPath,
7
7
  isDirectoryPath,
8
8
  logger
9
- } from "./chunk-c1eyecm3.js";
9
+ } from "./chunk-a76fsvj7.js";
10
+
11
+ // src/plugins/built-in/copy.ts
12
+ import { basename, join } from "path";
13
+ function copy(patterns, outPath) {
14
+ return {
15
+ type: "bunup",
16
+ name: "copy",
17
+ hooks: {
18
+ onBuildDone: async ({ options, meta }) => {
19
+ const destinationPath = outPath || options.outDir;
20
+ for (const pattern of patterns) {
21
+ const glob = new Bun.Glob(pattern);
22
+ for await (const filePath of glob.scan({
23
+ cwd: meta.rootDir,
24
+ dot: true
25
+ })) {
26
+ const sourceFile = Bun.file(join(meta.rootDir, filePath));
27
+ await Bun.write(outPath && isDirectoryPath(outPath) ? join(destinationPath, basename(filePath)) : destinationPath, sourceFile);
28
+ }
29
+ }
30
+ }
31
+ }
32
+ };
33
+ }
34
+ // src/plugins/built-in/exports.ts
35
+ import path from "path";
10
36
 
11
37
  // src/constants/re.ts
12
38
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
@@ -16,62 +42,7 @@ var JS_TS_RE = new RegExp(`${JS_RE.source}|${TS_RE.source}`);
16
42
  var JS_DTS_RE = new RegExp(`${JS_RE.source}|${DTS_RE.source}`);
17
43
  var CSS_RE = /\.(css)$/;
18
44
 
19
- // src/plugins/built-in/shims.ts
20
- function shims() {
21
- return {
22
- type: "bun",
23
- name: "shims",
24
- plugin: {
25
- name: "bunup:shims",
26
- setup(build) {
27
- const isNodeCompatibleTarget = build.config.target === "node" || build.config.target === "bun";
28
- const isEsm = build.config.format === "esm";
29
- const isCjs = build.config.format === "cjs";
30
- if (!isNodeCompatibleTarget || !isEsm && !isCjs) {
31
- return;
32
- }
33
- build.config.define = {
34
- ...build.config.define,
35
- ...isCjs && {
36
- "import.meta.url": "importMetaUrl"
37
- }
38
- };
39
- build.onLoad({ filter: JS_TS_RE }, async ({ path }) => {
40
- const content = await Bun.file(path).text();
41
- let shimCode = "";
42
- if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
43
- shimCode = `import { fileURLToPath } from 'url';
44
- import { dirname } from 'path';
45
-
46
- const __filename = fileURLToPath(import.meta.url);
47
- const __dirname = dirname(__filename);
48
-
49
- `;
50
- }
51
- if (isCjs && /\bimport\.meta\.url\b/.test(content)) {
52
- shimCode = `import { pathToFileURL } from 'url';
53
-
54
- const importMetaUrl = pathToFileURL(__filename).href;
55
-
56
- `;
57
- }
58
- if (!shimCode)
59
- return;
60
- const lines = content.split(`
61
- `);
62
- const firstLine = lines[0];
63
- const restLines = lines.slice(1);
64
- return {
65
- contents: [firstLine, shimCode, ...restLines].join(`
66
- `)
67
- };
68
- });
69
- }
70
- }
71
- };
72
- }
73
45
  // src/plugins/built-in/exports.ts
74
- import path from "path";
75
46
  function exports(options = {}) {
76
47
  return {
77
48
  type: "bunup",
@@ -120,7 +91,7 @@ function exports(options = {}) {
120
91
  exports: mergedExports
121
92
  };
122
93
  for (const key in restPackageJson) {
123
- if (Object.prototype.hasOwnProperty.call(restPackageJson, key) && !Object.prototype.hasOwnProperty.call(newPackageJson, key)) {
94
+ if (Object.hasOwn(restPackageJson, key) && !Object.hasOwn(newPackageJson, key)) {
124
95
  newPackageJson[key] = restPackageJson[key];
125
96
  }
126
97
  }
@@ -168,39 +139,15 @@ function formatToExportField(format, dts) {
168
139
  return dts ? "types" : format === "esm" ? "import" : "require";
169
140
  }
170
141
  function removeExtension(filePath) {
171
- const basename = path.basename(filePath);
172
- const firstDotIndex = basename.indexOf(".");
142
+ const basename2 = path.basename(filePath);
143
+ const firstDotIndex = basename2.indexOf(".");
173
144
  if (firstDotIndex === -1) {
174
145
  return filePath;
175
146
  }
176
- const nameWithoutExtensions = basename.slice(0, firstDotIndex);
147
+ const nameWithoutExtensions = basename2.slice(0, firstDotIndex);
177
148
  const directory = path.dirname(filePath);
178
149
  return directory === "." ? nameWithoutExtensions : path.join(directory, nameWithoutExtensions);
179
150
  }
180
- // src/plugins/built-in/copy.ts
181
- import { join } from "path";
182
- import { basename } from "path";
183
- function copy(patterns, outPath) {
184
- return {
185
- type: "bunup",
186
- name: "copy",
187
- hooks: {
188
- onBuildDone: async ({ options, meta }) => {
189
- const destinationPath = outPath || options.outDir;
190
- for (const pattern of patterns) {
191
- const glob = new Bun.Glob(pattern);
192
- for await (const filePath of glob.scan({
193
- cwd: meta.rootDir,
194
- dot: true
195
- })) {
196
- const sourceFile = Bun.file(join(meta.rootDir, filePath));
197
- await Bun.write(outPath && isDirectoryPath(outPath) ? join(destinationPath, basename(filePath)) : destinationPath, sourceFile);
198
- }
199
- }
200
- }
201
- }
202
- };
203
- }
204
151
  // src/plugins/built-in/inject-styles.ts
205
152
  import path2 from "path";
206
153
  function injectStyles(options) {
@@ -260,6 +207,60 @@ function injectStyles(options) {
260
207
  }
261
208
  };
262
209
  }
210
+ // src/plugins/built-in/shims.ts
211
+ function shims() {
212
+ return {
213
+ type: "bun",
214
+ name: "shims",
215
+ plugin: {
216
+ name: "bunup:shims",
217
+ setup(build) {
218
+ const isNodeCompatibleTarget = build.config.target === "node" || build.config.target === "bun";
219
+ const isEsm = build.config.format === "esm";
220
+ const isCjs = build.config.format === "cjs";
221
+ if (!isNodeCompatibleTarget || !isEsm && !isCjs) {
222
+ return;
223
+ }
224
+ build.config.define = {
225
+ ...build.config.define,
226
+ ...isCjs && {
227
+ "import.meta.url": "importMetaUrl"
228
+ }
229
+ };
230
+ build.onLoad({ filter: JS_TS_RE }, async ({ path: path3 }) => {
231
+ const content = await Bun.file(path3).text();
232
+ let shimCode = "";
233
+ if (isEsm && (/\b__dirname\b/.test(content) || /\b__filename\b/.test(content))) {
234
+ shimCode = `import { fileURLToPath } from 'url';
235
+ import { dirname } from 'path';
236
+
237
+ const __filename = fileURLToPath(import.meta.url);
238
+ const __dirname = dirname(__filename);
239
+
240
+ `;
241
+ }
242
+ if (isCjs && /\bimport\.meta\.url\b/.test(content)) {
243
+ shimCode = `import { pathToFileURL } from 'url';
244
+
245
+ const importMetaUrl = pathToFileURL(__filename).href;
246
+
247
+ `;
248
+ }
249
+ if (!shimCode)
250
+ return;
251
+ const lines = content.split(`
252
+ `);
253
+ const firstLine = lines[0];
254
+ const restLines = lines.slice(1);
255
+ return {
256
+ contents: [firstLine, shimCode, ...restLines].join(`
257
+ `)
258
+ };
259
+ });
260
+ }
261
+ }
262
+ };
263
+ }
263
264
  export {
264
265
  shims,
265
266
  injectStyles,
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.8.44",
4
+ "version": "0.8.45",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -55,7 +55,7 @@
55
55
  "tinyexec": "^1.0.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@biomejs/biome": "^1.9.4",
58
+ "@biomejs/biome": "2.0.0",
59
59
  "@types/bun": "^1.2.5",
60
60
  "bumpp": "^10.1.0",
61
61
  "husky": "^9.1.7",