bunup 0.8.52 → 0.8.53

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,11 +1,4 @@
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 */
@@ -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 };
@@ -0,0 +1,384 @@
1
+ import {
2
+ filterBunupBunPlugins,
3
+ filterBunupPlugins,
4
+ runPluginBuildDoneHooks,
5
+ runPluginBuildStartHooks
6
+ } from "./chunk-zpjpa5th.js";
7
+ import {
8
+ loadPackageJson
9
+ } from "./chunk-gh7z7s46.js";
10
+ import {
11
+ BunupBuildError,
12
+ BunupDTSBuildError,
13
+ cleanOutDir,
14
+ cleanPath,
15
+ ensureArray,
16
+ formatFileSize,
17
+ getDefaultDtsExtention,
18
+ getDefaultOutputExtension,
19
+ getFilesFromGlobs,
20
+ getPackageDeps,
21
+ getShortFilePath,
22
+ link,
23
+ logTable,
24
+ logger,
25
+ parseErrorMessage,
26
+ setSilent
27
+ } from "./chunk-cakmscpb.js";
28
+
29
+ // src/build.ts
30
+ import path from "path";
31
+ import pc2 from "picocolors";
32
+ import { generateDts, logIsolatedDeclarationErrors } from "typeroll";
33
+
34
+ // src/plugins/internal/linter.ts
35
+ var rules = [
36
+ {
37
+ check: (ctx) => {
38
+ const hasMinification = !!(ctx.options.minify || ctx.options.minifyWhitespace || ctx.options.minifyIdentifiers || ctx.options.minifySyntax);
39
+ return hasMinification && !ctx.options.sourcemap;
40
+ },
41
+ 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")}`,
42
+ logLevel: "recommended"
43
+ }
44
+ ];
45
+ function linter() {
46
+ return {
47
+ type: "bunup",
48
+ name: "linter",
49
+ hooks: {
50
+ onBuildDone: (ctx) => {
51
+ let hasWarnings = false;
52
+ for (const rule of rules) {
53
+ if (rule.check(ctx)) {
54
+ if (!hasWarnings) {
55
+ logger.space();
56
+ }
57
+ logger[rule.logLevel ?? "warn"](rule.message);
58
+ hasWarnings = true;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ };
64
+ }
65
+
66
+ // src/plugins/internal/report.ts
67
+ import pc from "picocolors";
68
+ function report() {
69
+ return {
70
+ type: "bunup",
71
+ name: "report",
72
+ hooks: {
73
+ onBuildDone: async ({ options, output }) => {
74
+ if (options.watch)
75
+ return;
76
+ const files = await Promise.all(output.files.map(async (file) => {
77
+ const name = file.relativePathToRootDir;
78
+ const size = Bun.file(file.fullPath).size;
79
+ const gzipSize = Bun.gzipSync(new Uint8Array(await Bun.file(file.fullPath).arrayBuffer())).length;
80
+ const formattedGzipSize = formatFileSize(gzipSize);
81
+ return {
82
+ name,
83
+ size,
84
+ formattedSize: formatFileSize(size),
85
+ gzipSize,
86
+ formattedGzipSize
87
+ };
88
+ }));
89
+ const totalSize = files.reduce((sum, file) => sum + file.size, 0);
90
+ const formattedTotalSize = formatFileSize(totalSize);
91
+ const totalGzipSize = files.reduce((sum, file) => sum + (file.gzipSize || 0), 0);
92
+ const formattedTotalGzipSize = formatFileSize(totalGzipSize);
93
+ const columns = [
94
+ { header: "File", align: "left", color: pc.blue },
95
+ { header: "Size", align: "right", color: pc.green },
96
+ {
97
+ header: "Gzip",
98
+ align: "right",
99
+ color: pc.magenta
100
+ }
101
+ ];
102
+ const data = files.map((file) => {
103
+ return {
104
+ File: file.name,
105
+ Size: file.formattedSize,
106
+ Gzip: file.formattedGzipSize
107
+ };
108
+ });
109
+ const footer = {
110
+ File: "Total",
111
+ Size: formattedTotalSize,
112
+ Gzip: formattedTotalGzipSize
113
+ };
114
+ logger.space();
115
+ logTable(columns, data, footer);
116
+ logger.space();
117
+ }
118
+ }
119
+ };
120
+ }
121
+
122
+ // src/plugins/internal/use-client.ts
123
+ function useClient() {
124
+ return {
125
+ type: "bunup",
126
+ name: "use-client",
127
+ hooks: {
128
+ onBuildDone: async ({ output }) => {
129
+ for (const file of output.files) {
130
+ let text = await Bun.file(file.fullPath).text();
131
+ const hasUseClient = text.split(`
132
+ `).some((line) => line.trim().startsWith(`"use client";`));
133
+ if (hasUseClient) {
134
+ text = text.replaceAll(`"use client";`, "");
135
+ text = `"use client";
136
+ ${text}`;
137
+ }
138
+ await Bun.write(file.fullPath, text);
139
+ }
140
+ }
141
+ }
142
+ };
143
+ }
144
+
145
+ // src/options.ts
146
+ var DEFAULT_OPTIONS = {
147
+ entry: ["src/index.ts"],
148
+ format: ["cjs"],
149
+ outDir: "dist",
150
+ target: "node",
151
+ clean: true
152
+ };
153
+ function createBuildOptions(partialOptions) {
154
+ const options = {
155
+ ...DEFAULT_OPTIONS,
156
+ ...partialOptions
157
+ };
158
+ return {
159
+ ...options,
160
+ plugins: [...options.plugins ?? [], useClient(), linter(), report()]
161
+ };
162
+ }
163
+ function getResolvedMinify(options) {
164
+ const { minify, minifyWhitespace, minifyIdentifiers, minifySyntax } = options;
165
+ const defaultValue = minify === true;
166
+ return {
167
+ whitespace: minifyWhitespace ?? defaultValue,
168
+ identifiers: minifyIdentifiers ?? defaultValue,
169
+ syntax: minifySyntax ?? defaultValue
170
+ };
171
+ }
172
+ function getResolvedBytecode(bytecode, format) {
173
+ return format === "cjs" ? bytecode : undefined;
174
+ }
175
+ function getResolvedSourcemap(sourcemap) {
176
+ if (sourcemap === true) {
177
+ return "inline";
178
+ }
179
+ return typeof sourcemap === "string" ? sourcemap : undefined;
180
+ }
181
+ function getResolvedDefine(define, env) {
182
+ return {
183
+ ...typeof env === "object" && Object.keys(env).reduce((acc, key) => {
184
+ const value = JSON.stringify(env[key]);
185
+ acc[`process.env.${key}`] = value;
186
+ acc[`import.meta.env.${key}`] = value;
187
+ return acc;
188
+ }, {}),
189
+ ...define
190
+ };
191
+ }
192
+ function getResolvedSplitting(splitting, format) {
193
+ return splitting === undefined ? format === "esm" : splitting;
194
+ }
195
+ function getResolvedDtsSplitting(splitting) {
196
+ return splitting ?? true;
197
+ }
198
+ var DEFAULT_ENTRY_NAMING = "[dir]/[name].[ext]";
199
+ function getResolvedNaming(fmt, packageType) {
200
+ const replaceExt = (pattern) => pattern.replace(".[ext]", getDefaultOutputExtension(fmt, packageType));
201
+ return replaceExt(DEFAULT_ENTRY_NAMING);
202
+ }
203
+ function getResolvedEnv(env) {
204
+ return typeof env === "string" ? env : undefined;
205
+ }
206
+
207
+ // src/helpers/external.ts
208
+ function getPackageDepsPatterns(packageJson) {
209
+ return getPackageDeps(packageJson).map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`));
210
+ }
211
+ function matchesPattern(path, pattern) {
212
+ return typeof pattern === "string" ? pattern === path : pattern.test(path);
213
+ }
214
+ function isExternal(path, options, packageJson) {
215
+ const packageDepsPatterns = getPackageDepsPatterns(packageJson);
216
+ const matchesExternalPattern = packageDepsPatterns.some((pattern) => pattern.test(path)) || options.external?.some((pattern) => matchesPattern(path, pattern));
217
+ const isExcludedFromExternal = options.noExternal?.some((pattern) => matchesPattern(path, pattern));
218
+ return matchesExternalPattern && !isExcludedFromExternal;
219
+ }
220
+
221
+ // src/plugins/internal/external-option.ts
222
+ function externalOptionPlugin(options, packageJson) {
223
+ return {
224
+ name: "bunup:external-option-plugin",
225
+ setup(build) {
226
+ build.onResolve({ filter: /.*/ }, (args) => {
227
+ const importPath = args.path;
228
+ if (isExternal(importPath, options, packageJson)) {
229
+ return {
230
+ path: importPath,
231
+ external: true
232
+ };
233
+ }
234
+ return null;
235
+ });
236
+ }
237
+ };
238
+ }
239
+
240
+ // src/build.ts
241
+ async function build(partialOptions, rootDir = process.cwd()) {
242
+ const buildOutput = {
243
+ files: []
244
+ };
245
+ const options = createBuildOptions(partialOptions);
246
+ if (!options.entry || options.entry.length === 0 || !options.outDir) {
247
+ throw new BunupBuildError("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");
248
+ }
249
+ if (options.clean) {
250
+ cleanOutDir(rootDir, options.outDir);
251
+ }
252
+ setSilent(options.silent);
253
+ const packageJson = await loadPackageJson(rootDir);
254
+ if (packageJson.data && packageJson.path) {
255
+ logger.info(`Using ${getShortFilePath(packageJson.path, 2)}`, {
256
+ muted: true,
257
+ identifier: options.name,
258
+ once: `${packageJson.path}:${options.name}`
259
+ });
260
+ }
261
+ const bunupPlugins = filterBunupPlugins(options.plugins);
262
+ await runPluginBuildStartHooks(bunupPlugins, options);
263
+ const packageType = packageJson.data?.type;
264
+ const plugins = [
265
+ externalOptionPlugin(options, packageJson.data),
266
+ ...filterBunupBunPlugins(options.plugins).map((p) => p.plugin)
267
+ ];
268
+ const entrypoints = await getFilesFromGlobs(ensureArray(options.entry), rootDir);
269
+ if (!entrypoints.length) {
270
+ throw new BunupBuildError(`One or more of the entrypoints you provided do not exist. Please check that each entrypoint points to a valid file.`);
271
+ }
272
+ const buildPromises = options.format.flatMap(async (fmt) => {
273
+ const result = await Bun.build({
274
+ entrypoints: entrypoints.map((file) => `${rootDir}/${file}`),
275
+ format: fmt,
276
+ naming: getResolvedNaming(fmt, packageType),
277
+ splitting: getResolvedSplitting(options.splitting, fmt),
278
+ bytecode: getResolvedBytecode(options.bytecode, fmt),
279
+ define: getResolvedDefine(options.define, options.env),
280
+ minify: getResolvedMinify(options),
281
+ outdir: `${rootDir}/${options.outDir}`,
282
+ target: options.target,
283
+ sourcemap: getResolvedSourcemap(options.sourcemap),
284
+ loader: options.loader,
285
+ drop: options.drop,
286
+ banner: options.banner,
287
+ footer: options.footer,
288
+ publicPath: options.publicPath,
289
+ env: getResolvedEnv(options.env),
290
+ ignoreDCEAnnotations: options.ignoreDCEAnnotations,
291
+ emitDCEAnnotations: options.emitDCEAnnotations,
292
+ throw: false,
293
+ plugins
294
+ });
295
+ for (const log of result.logs) {
296
+ if (log.level === "error") {
297
+ throw new BunupBuildError(log.message);
298
+ }
299
+ if (log.level === "warning")
300
+ logger.warn(log.message);
301
+ else if (log.level === "info")
302
+ logger.info(log.message);
303
+ }
304
+ let entrypointIndex = 0;
305
+ for (const file of result.outputs) {
306
+ const relativePathToRootDir = getRelativePathToRootDir(file.path, rootDir);
307
+ const relativePathToOutputDir = getRelativePathToOutputDir(relativePathToRootDir, options.outDir);
308
+ if (file.kind === "entry-point") {
309
+ logger.success(`${pc2.dim(`${options.outDir}/`)}${relativePathToOutputDir}`, {
310
+ identifier: options.name
311
+ });
312
+ }
313
+ buildOutput.files.push({
314
+ fullPath: file.path,
315
+ relativePathToRootDir,
316
+ relativePathToOutputDir,
317
+ dts: false,
318
+ format: fmt,
319
+ kind: file.kind,
320
+ entrypoint: file.kind === "entry-point" ? cleanPath(entrypoints[entrypointIndex]) : undefined
321
+ });
322
+ if (file.kind === "entry-point") {
323
+ entrypointIndex++;
324
+ }
325
+ }
326
+ });
327
+ await Promise.all(buildPromises);
328
+ if (options.dts) {
329
+ try {
330
+ const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
331
+ const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
332
+ cwd: rootDir,
333
+ preferredTsConfigPath: options.preferredTsconfigPath,
334
+ splitting: getResolvedDtsSplitting(splitting),
335
+ ...dtsOptions
336
+ });
337
+ if (dtsResult.errors.length) {
338
+ logIsolatedDeclarationErrors(dtsResult.errors);
339
+ }
340
+ for (const fmt of options.format) {
341
+ for (const file of dtsResult.files) {
342
+ const dtsExtension = getDefaultDtsExtention(fmt, packageType);
343
+ const relativePathToOutputDir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
344
+ const relativePathToRootDir = cleanPath(`${options.outDir}/${relativePathToOutputDir}`);
345
+ if (file.kind === "entry-point") {
346
+ logger.success(`${pc2.dim(`${options.outDir}/`)}${relativePathToOutputDir}`, {
347
+ identifier: options.name
348
+ });
349
+ }
350
+ const fullPath = path.join(rootDir, relativePathToRootDir);
351
+ await Bun.write(fullPath, file.dts);
352
+ buildOutput.files.push({
353
+ fullPath,
354
+ relativePathToRootDir,
355
+ relativePathToOutputDir,
356
+ dts: true,
357
+ format: fmt,
358
+ kind: file.kind,
359
+ entrypoint: file.entrypoint ? cleanPath(file.entrypoint) : undefined
360
+ });
361
+ }
362
+ }
363
+ } catch (error) {
364
+ throw new BunupDTSBuildError(parseErrorMessage(error));
365
+ } finally {
366
+ logger.space();
367
+ }
368
+ }
369
+ await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
370
+ packageJson,
371
+ rootDir
372
+ });
373
+ if (options.onSuccess) {
374
+ await options.onSuccess(options);
375
+ }
376
+ }
377
+ function getRelativePathToRootDir(filePath, rootDir) {
378
+ return cleanPath(filePath).replace(`${cleanPath(rootDir)}/`, "");
379
+ }
380
+ function getRelativePathToOutputDir(relativePathToRootDir, outDir) {
381
+ return cleanPath(relativePathToRootDir).replace(`${cleanPath(outDir)}/`, "");
382
+ }
383
+
384
+ export { createBuildOptions, build };
@@ -26,14 +26,5 @@ async function loadPackageJson(cwd = process.cwd()) {
26
26
  path: filepath
27
27
  };
28
28
  }
29
- async function loadTsConfig(cwd, preferredPath) {
30
- const config = await loadConfig({
31
- name: "tsconfig",
32
- extensions: [".json"],
33
- preferredPath,
34
- cwd
35
- });
36
- return config;
37
- }
38
29
 
39
- export { processLoadedConfigs, loadPackageJson, loadTsConfig };
30
+ export { processLoadedConfigs, loadPackageJson };
@@ -1,14 +1,14 @@
1
1
  // @bun
2
2
  import {
3
3
  loadPackageJson
4
- } from "./chunk-5v78yfze.js";
4
+ } from "./chunk-gh7z7s46.js";
5
5
  import {
6
6
  displayBunupGradientArt
7
- } from "./chunk-mf58dgyw.js";
7
+ } from "./chunk-4cgw2ywa.js";
8
8
  import {
9
9
  formatListWithAnd,
10
10
  link
11
- } from "./chunk-kk5yc8cy.js";
11
+ } from "./chunk-cakmscpb.js";
12
12
 
13
13
  // src/cli/init.ts
14
14
  import fs from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BunupPluginError
3
- } from "./chunk-kk5yc8cy.js";
3
+ } from "./chunk-cakmscpb.js";
4
4
 
5
5
  // src/plugins/utils.ts
6
6
  import pc from "picocolors";
package/dist/cli/index.js CHANGED
@@ -3,11 +3,11 @@
3
3
  import {
4
4
  build,
5
5
  createBuildOptions
6
- } from "../chunk-v3nkk11v.js";
7
- import"../chunk-cv4z06x8.js";
6
+ } from "../chunk-g2khvv3w.js";
7
+ import"../chunk-zpjpa5th.js";
8
8
  import {
9
9
  processLoadedConfigs
10
- } from "../chunk-5v78yfze.js";
10
+ } from "../chunk-gh7z7s46.js";
11
11
  import {
12
12
  BunupCLIError,
13
13
  BunupWatchError,
@@ -21,14 +21,14 @@ import {
21
21
  logger,
22
22
  parseErrorMessage,
23
23
  setSilent
24
- } from "../chunk-kk5yc8cy.js";
24
+ } from "../chunk-cakmscpb.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.52";
31
+ var version = "0.8.53";
32
32
 
33
33
  // src/watch.ts
34
34
  import path from "path";
@@ -485,12 +485,12 @@ var parseCliOptions = (argv) => {
485
485
  async function main(args = Bun.argv.slice(2)) {
486
486
  const cliOptions = parseCliOptions(args);
487
487
  if (cliOptions.new) {
488
- const { newProject } = await import("../chunk-8dm3xyd7.js");
488
+ const { newProject } = await import("../chunk-c4xe90dt.js");
489
489
  await newProject();
490
490
  return;
491
491
  }
492
492
  if (cliOptions.init) {
493
- const { init } = await import("../chunk-ga9j5qp4.js");
493
+ const { init } = await import("../chunk-p86qvgaa.js");
494
494
  await init();
495
495
  return;
496
496
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-p2wczz52";
1
+ import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-80rcmwcp";
2
2
  declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
3
3
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
4
4
  declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];