bunup 0.8.52 → 0.8.54

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,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-kk5yc8cy.js";
3
+ } from "./chunk-cakmscpb.js";
4
4
 
5
5
  // src/cli/utils.ts
6
6
  import pc from "picocolors";
@@ -1,37 +1,30 @@
1
- type Resolve = boolean | (string | RegExp)[];
2
- type GenerateDtsOptions = {
3
- preferredTsConfigPath?: string;
4
- resolve?: Resolve;
5
- cwd?: string;
6
- splitting?: boolean;
7
- minify?: boolean;
8
- };
1
+ import { GenerateDtsOptions } from "typeroll";
9
2
  import { BunPlugin } from "bun";
10
3
  type PackageJson = {
11
4
  /** The parsed content of the package.json file */
12
- data: Record<string, any> | null;
5
+ data: Record<string, any> | null
13
6
  /** The path to the package.json file */
14
- path: string | null;
7
+ path: string | null
15
8
  };
16
9
  /**
17
10
  * Represents a Bun plugin that can be used with Bunup
18
11
  */
19
12
  type BunupBunPlugin = {
20
13
  /** Identifies this as a native Bun plugin */
21
- type: "bun";
14
+ type: "bun"
22
15
  /** Optional name for the plugin */
23
- name?: string;
16
+ name?: string
24
17
  /** The actual Bun plugin implementation */
25
- plugin: BunPlugin;
18
+ plugin: BunPlugin
26
19
  };
27
20
  /**
28
21
  * Represents the meta data of the build
29
22
  */
30
23
  type BuildMeta = {
31
24
  /** The package.json file */
32
- packageJson: PackageJson;
25
+ packageJson: PackageJson
33
26
  /** The root directory of the build */
34
- rootDir: string;
27
+ rootDir: string
35
28
  };
36
29
  type BuildOutputFile = {
37
30
  /**
@@ -39,37 +32,37 @@ type BuildOutputFile = {
39
32
  *
40
33
  * Undefined for non-entry point files (e.g., assets, sourcemaps, chunks)
41
34
  */
42
- entrypoint: string | undefined;
35
+ entrypoint: string | undefined
43
36
  /** The kind of the file */
44
- kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode";
37
+ kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
45
38
  /** Path to the generated file */
46
- fullPath: string;
39
+ fullPath: string
47
40
  /** Path to the generated file relative to the root directory */
48
- relativePathToRootDir: string;
41
+ relativePathToRootDir: string
49
42
  /** Path to the generated file relative to the output directory */
50
- relativePathToOutputDir: string;
43
+ relativePathToOutputDir: string
51
44
  /** Whether the file is a dts file */
52
- dts: boolean;
45
+ dts: boolean
53
46
  /** The format of the output file */
54
- format: Format;
47
+ format: Format
55
48
  };
56
49
  /**
57
50
  * Represents the output of a build operation
58
51
  */
59
52
  type BuildOutput = {
60
53
  /** Array of generated files with their paths and contents */
61
- files: BuildOutputFile[];
54
+ files: BuildOutputFile[]
62
55
  };
63
56
  /**
64
57
  * Context provided to build hooks
65
58
  */
66
59
  type BuildContext = {
67
60
  /** The build options that were used */
68
- options: BuildOptions;
61
+ options: BuildOptions
69
62
  /** The output of the build */
70
- output: BuildOutput;
63
+ output: BuildOutput
71
64
  /** The meta data of the build */
72
- meta: BuildMeta;
65
+ meta: BuildMeta
73
66
  };
74
67
  /**
75
68
  * Hooks that can be implemented by Bunup plugins
@@ -79,23 +72,23 @@ type BunupPluginHooks = {
79
72
  * Called when a build is successfully completed
80
73
  * @param ctx Build context containing options and output
81
74
  */
82
- onBuildDone?: (ctx: BuildContext) => MaybePromise<void>;
75
+ onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
83
76
  /**
84
77
  * Called before a build starts
85
78
  * @param options Build options that will be used
86
79
  */
87
- onBuildStart?: (options: BuildOptions) => MaybePromise<void>;
80
+ onBuildStart?: (options: BuildOptions) => MaybePromise<void>
88
81
  };
89
82
  /**
90
83
  * Represents a Bunup-specific plugin
91
84
  */
92
85
  type BunupPlugin = {
93
86
  /** Identifies this as a Bunup-specific plugin */
94
- type: "bunup";
87
+ type: "bunup"
95
88
  /** Optional name for the plugin */
96
- name?: string;
89
+ name?: string
97
90
  /** The hooks implemented by this plugin */
98
- hooks: BunupPluginHooks;
91
+ hooks: BunupPluginHooks
99
92
  };
100
93
  /**
101
94
  * Union type representing all supported plugin types
@@ -170,7 +163,7 @@ interface BuildOptions {
170
163
  * Can also be configured with DtsOptions for more control
171
164
  */
172
165
  dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify"> & {
173
- entry?: string | string[];
166
+ entry?: string | string[]
174
167
  });
175
168
  /**
176
169
  * Path to a preferred tsconfig.json file to use for declaration generation
@@ -228,6 +221,7 @@ interface BuildOptions {
228
221
  * sourcemap: true // equivalent to 'inline'
229
222
  */
230
223
  sourcemap?: Sourcemap;
224
+ /**\\n\\t* Define global constants for the build\\n\\t* These values will be replaced at build time\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#define\\n\\t*\\n\\t* @example\\n\\t* define: {\\n\\t* 'process.env.NODE_ENV': '"production"',\\n\\t* 'PACKAGE_VERSION': '"1.0.0"'\\n\\t* }\\n\\t*/
231
225
  define?: Define;
232
226
  /**
233
227
  * A callback function that runs after the build process completes
@@ -239,6 +233,7 @@ interface BuildOptions {
239
233
  * @param options The build options that were used
240
234
  */
241
235
  onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
236
+ /**\\n\\t* A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.\\n\\t*\\n\\t* @see https://bun.sh/docs/bundler#banner\\n\\t*\\n\\t* @example\\n\\t* banner: '"use client";'\\n\\t*/
242
237
  banner?: string;
243
238
  /**
244
239
  * A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
@@ -340,6 +335,7 @@ interface BuildOptions {
340
335
  * Force emitting @__PURE__ annotations even if minify.whitespace is true.
341
336
  */
342
337
  emitDCEAnnotations?: boolean;
338
+ /**\\n\\t* Plugins to extend the build process functionality\\n\\t*\\n\\t* The Plugin type uses a discriminated union pattern with the 'type' field\\n\\t* to support different plugin systems. Both "bun" and "bunup" plugins are supported.\\n\\t*\\n\\t* Each plugin type has its own specific plugin implementation:\\n\\t* - "bun": Uses Bun's native plugin system (BunPlugin)\\n\\t* - "bunup": Uses bunup's own plugin system with lifecycle hooks\\n\\t*\\n\\t* This architecture allows for extensibility as more plugin systems are added.\\n\\t*\\n\\t* @see https://bunup.dev/docs/advanced/plugin-development for more information on plugins\\n\\t*\\n\\t* @example\\n\\t* plugins: [\\n\\t* {\\n\\t* type: "bun",\\n\\t* plugin: myBunPlugin()\\n\\t* },\\n\\t* {\\n\\t* type: "bunup",\\n\\t* hooks: {\\n\\t* onBuildStart: (options) => {\\n\\t* console.log('Build started with options:', options)\\n\\t* },\\n\\t* onBuildDone: ({ options, output }) => {\\n\\t* console.log('Build completed with output:', output)\\n\\t* }\\n\\t* }\\n\\t* }\\n\\t* ]\\n\\t*/
343
339
  plugins?: Plugin[];
344
340
  }
345
341
  type MaybePromise<T> = Promise<T> | T;
@@ -350,8 +346,8 @@ type WithOptional<
350
346
  type Arrayable<T> = T | T[];
351
347
  type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
352
348
  type DefineWorkspaceItem = {
353
- name: string;
354
- root: string;
355
- config: DefineConfigItem | DefineConfigItem[];
349
+ name: string
350
+ root: string
351
+ config: DefineConfigItem | DefineConfigItem[]
356
352
  };
357
353
  export { MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin, Plugin, BuildOptions };
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  displayBunupGradientArt
4
- } from "./chunk-mf58dgyw.js";
4
+ } from "./chunk-4cgw2ywa.js";
5
5
  import {
6
6
  link,
7
7
  pathExistsSync
8
- } from "./chunk-kk5yc8cy.js";
8
+ } from "./chunk-cakmscpb.js";
9
9
 
10
10
  // src/cli/new.ts
11
11
  import { renameSync } from "fs";
@@ -269,7 +269,81 @@ var handleErrorAndExit = (error, context) => {
269
269
  import fsSync from "fs";
270
270
  import fs from "fs/promises";
271
271
  import path, { normalize } from "path";
272
- import { isCI, isDevelopment } from "std-env";
272
+
273
+ // node_modules/std-env/dist/index.mjs
274
+ var r = Object.create(null);
275
+ var i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
276
+ var o = new Proxy(r, { get(e, s) {
277
+ return i()[s] ?? r[s];
278
+ }, has(e, s) {
279
+ const E = i();
280
+ return s in E || s in r;
281
+ }, set(e, s, E) {
282
+ const B = i(true);
283
+ return B[s] = E, true;
284
+ }, deleteProperty(e, s) {
285
+ if (!s)
286
+ return false;
287
+ const E = i(true);
288
+ return delete E[s], true;
289
+ }, ownKeys() {
290
+ const e = i(true);
291
+ return Object.keys(e);
292
+ } });
293
+ var t = typeof process < "u" && process.env && "development" || "";
294
+ var f = [["APPVEYOR"], ["AWS_AMPLIFY", "AWS_APP_ID", { ci: true }], ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"], ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"], ["APPCIRCLE", "AC_APPCIRCLE"], ["BAMBOO", "bamboo_planKey"], ["BITBUCKET", "BITBUCKET_COMMIT"], ["BITRISE", "BITRISE_IO"], ["BUDDY", "BUDDY_WORKSPACE_ID"], ["BUILDKITE"], ["CIRCLE", "CIRCLECI"], ["CIRRUS", "CIRRUS_CI"], ["CLOUDFLARE_PAGES", "CF_PAGES", { ci: true }], ["CLOUDFLARE_WORKERS", "WORKERS_CI", { ci: true }], ["CODEBUILD", "CODEBUILD_BUILD_ARN"], ["CODEFRESH", "CF_BUILD_ID"], ["DRONE"], ["DRONE", "DRONE_BUILD_EVENT"], ["DSARI"], ["GITHUB_ACTIONS"], ["GITLAB", "GITLAB_CI"], ["GITLAB", "CI_MERGE_REQUEST_ID"], ["GOCD", "GO_PIPELINE_LABEL"], ["LAYERCI"], ["HUDSON", "HUDSON_URL"], ["JENKINS", "JENKINS_URL"], ["MAGNUM"], ["NETLIFY"], ["NETLIFY", "NETLIFY_LOCAL", { ci: false }], ["NEVERCODE"], ["RENDER"], ["SAIL", "SAILCI"], ["SEMAPHORE"], ["SCREWDRIVER"], ["SHIPPABLE"], ["SOLANO", "TDDIUM"], ["STRIDER"], ["TEAMCITY", "TEAMCITY_VERSION"], ["TRAVIS"], ["VERCEL", "NOW_BUILDER"], ["VERCEL", "VERCEL", { ci: false }], ["VERCEL", "VERCEL_ENV", { ci: false }], ["APPCENTER", "APPCENTER_BUILD_ID"], ["CODESANDBOX", "CODESANDBOX_SSE", { ci: false }], ["CODESANDBOX", "CODESANDBOX_HOST", { ci: false }], ["STACKBLITZ"], ["STORMKIT"], ["CLEAVR"], ["ZEABUR"], ["CODESPHERE", "CODESPHERE_APP_ID", { ci: true }], ["RAILWAY", "RAILWAY_PROJECT_ID"], ["RAILWAY", "RAILWAY_SERVICE_ID"], ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"], ["FIREBASE_APP_HOSTING", "FIREBASE_APP_HOSTING", { ci: true }]];
295
+ function b() {
296
+ if (globalThis.process?.env)
297
+ for (const e of f) {
298
+ const s = e[1] || e[0];
299
+ if (globalThis.process?.env[s])
300
+ return { name: e[0].toLowerCase(), ...e[2] };
301
+ }
302
+ return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? { name: "stackblitz", ci: false } : { name: "", ci: false };
303
+ }
304
+ var l = b();
305
+ var p = l.name;
306
+ function n(e) {
307
+ return e ? e !== "false" : false;
308
+ }
309
+ var I = globalThis.process?.platform || "";
310
+ var T = n(o.CI) || l.ci !== false;
311
+ var R = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
312
+ var U = typeof window < "u";
313
+ var d = n(o.DEBUG);
314
+ var a = t === "test" || n(o.TEST);
315
+ var v = n(o.MINIMAL) || T || a || !R;
316
+ var A = /^win/i.test(I);
317
+ var M = /^linux/i.test(I);
318
+ var m = /^darwin/i.test(I);
319
+ var Y = !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (R || A) && o.TERM !== "dumb" || T);
320
+ var C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
321
+ var V = Number(C?.split(".")[0]) || null;
322
+ var W = globalThis.process || Object.create(null);
323
+ var _ = { versions: {} };
324
+ var y = new Proxy(W, { get(e, s) {
325
+ if (s === "env")
326
+ return o;
327
+ if (s in e)
328
+ return e[s];
329
+ if (s in _)
330
+ return _[s];
331
+ } });
332
+ var O = globalThis.process?.release?.name === "node";
333
+ var c = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
334
+ var D = !!globalThis.Deno;
335
+ var L = !!globalThis.fastly;
336
+ var S = !!globalThis.Netlify;
337
+ var u = !!globalThis.EdgeRuntime;
338
+ var N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
339
+ var F = [[S, "netlify"], [u, "edge-light"], [N, "workerd"], [L, "fastly"], [D, "deno"], [c, "bun"], [O, "node"]];
340
+ function G() {
341
+ const e = F.find((s) => s[0]);
342
+ if (e)
343
+ return { name: e[1] };
344
+ }
345
+ var P = G();
346
+ var K = P?.name || "";
273
347
 
274
348
  // src/constants/re.ts
275
349
  var JS_RE = /\.(js|jsx|cjs|mjs)$/;
@@ -278,7 +352,6 @@ var DTS_RE = /\.(d\.(ts|mts|cts))$/;
278
352
  var JS_TS_RE = new RegExp(`${JS_RE.source}|${TS_RE.source}`);
279
353
  var JS_DTS_RE = new RegExp(`${JS_RE.source}|${DTS_RE.source}`);
280
354
  var CSS_RE = /\.(css)$/;
281
- var EXTENSION_REGEX = /\.(d\.(ts|cts|mts)|[cm]?[jt]s)$/;
282
355
 
283
356
  // src/utils.ts
284
357
  function ensureArray(value) {
@@ -304,13 +377,6 @@ function getDefaultDtsExtention(format, packageType) {
304
377
  return ".global.d.ts";
305
378
  }
306
379
  }
307
- function getDeclarationExtensionFromJsExtension(ext) {
308
- if (ext === ".mjs")
309
- return ".d.mts";
310
- if (ext === ".cjs")
311
- return ".d.cts";
312
- return ".d.ts";
313
- }
314
380
  function isModulePackage(packageType) {
315
381
  return packageType === "module";
316
382
  }
@@ -329,10 +395,10 @@ function formatFileSize(bytes) {
329
395
  if (bytes === 0)
330
396
  return "0 B";
331
397
  const units = ["B", "KB", "MB", "GB"];
332
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
333
- if (i === 0)
334
- return `${bytes} ${units[i]}`;
335
- return `${(bytes / 1024 ** i).toFixed(2)} ${units[i]}`;
398
+ const i2 = Math.floor(Math.log(bytes) / Math.log(1024));
399
+ if (i2 === 0)
400
+ return `${bytes} ${units[i2]}`;
401
+ return `${(bytes / 1024 ** i2).toFixed(2)} ${units[i2]}`;
336
402
  }
337
403
  function getShortFilePath(filePath, maxLength = 3) {
338
404
  const fileParts = filePath.split("/");
@@ -373,8 +439,8 @@ function formatListWithAnd(arr) {
373
439
  }).format(arr);
374
440
  }
375
441
  async function getFilesFromGlobs(patterns, cwd) {
376
- const includePatterns = patterns.filter((p) => !p.startsWith("!"));
377
- const excludePatterns = patterns.filter((p) => p.startsWith("!")).map((p) => p.slice(1));
442
+ const includePatterns = patterns.filter((p2) => !p2.startsWith("!"));
443
+ const excludePatterns = patterns.filter((p2) => p2.startsWith("!")).map((p2) => p2.slice(1));
378
444
  const includedFiles = new Set;
379
445
  for (const pattern of includePatterns) {
380
446
  const glob = new Bun.Glob(pattern);
@@ -392,38 +458,5 @@ async function getFilesFromGlobs(patterns, cwd) {
392
458
  }
393
459
  return Array.from(includedFiles);
394
460
  }
395
- function isDev() {
396
- return isDevelopment || !isCI;
397
- }
398
- function generateRandomString(length = 10) {
399
- return Array.from({ length }, () => String.fromCharCode(97 + Math.floor(Math.random() * 26))).join("");
400
- }
401
- function isNullOrUndefined(value) {
402
- return value === null || value === undefined;
403
- }
404
- function isTypeScriptFile(path2) {
405
- if (!path2)
406
- return false;
407
- return TS_RE.test(path2);
408
- }
409
- function getExtension(filename) {
410
- const match = filename.match(EXTENSION_REGEX);
411
- if (!match)
412
- return "";
413
- const ext = match[0];
414
- return ext;
415
- }
416
- function replaceExtension(filename, newExt) {
417
- if (EXTENSION_REGEX.test(filename)) {
418
- return filename.replace(EXTENSION_REGEX, newExt);
419
- }
420
- return filename + newExt;
421
- }
422
- function deleteExtension(filename) {
423
- return filename.replace(EXTENSION_REGEX, "");
424
- }
425
- function returnPathIfExists(path2) {
426
- return pathExistsSync(path2) ? path2 : null;
427
- }
428
461
 
429
- export { __toESM, __require, setSilent, logTable, link, logger, JS_RE, JS_TS_RE, JS_DTS_RE, CSS_RE, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage, handleError, handleErrorAndExit, ensureArray, getDefaultOutputExtension, getDefaultDtsExtention, getDeclarationExtensionFromJsExtension, formatTime, getPackageDeps, formatFileSize, getShortFilePath, cleanOutDir, cleanPath, isDirectoryPath, pathExistsSync, formatListWithAnd, getFilesFromGlobs, isDev, generateRandomString, isNullOrUndefined, isTypeScriptFile, getExtension, replaceExtension, deleteExtension, returnPathIfExists };
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 };