bunup 0.8.49 → 0.8.51
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 +3 -1
- package/dist/{chunk-qy8akfev.js → chunk-1y38m6th.js} +1 -1
- package/dist/{chunk-63s8ht8p.js → chunk-4wtd9wfc.js} +2 -2
- package/dist/{chunk-b38k5sg1.js → chunk-6xsgpvht.js} +117 -141
- package/dist/{chunk-y0jgbvca.js → chunk-aq91x0fe.js} +1 -1
- package/dist/{chunk-t9xma3m6.js → chunk-p2gc4tkm.js} +1 -1
- package/dist/{chunk-nsmdhpdd.d.ts → chunk-p2wczz52.d.ts} +32 -32
- package/dist/{chunk-htbpffg4.js → chunk-tamy0g3r.js} +2 -2
- package/dist/cli/index.js +11 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/bunup) [](https://npmjs.com/package/bunup) [](https://bun.sh) [](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 and JavaScript libraries, designed for flawless developer experience and speed, **powered by Bun**.
|
|
16
|
+
|
|
17
|
+
It's the fastest library bundler out there - [see benchmarks](https://gugustinette.github.io/bundler-benchmark/).
|
|
16
18
|
|
|
17
19
|

|
|
18
20
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
displayBunupGradientArt
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-1y38m6th.js";
|
|
5
5
|
import {
|
|
6
6
|
link,
|
|
7
7
|
pathExistsSync
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-aq91x0fe.js";
|
|
9
9
|
|
|
10
10
|
// src/cli/new.ts
|
|
11
11
|
import { renameSync } from "fs";
|
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
filterBunupPlugins,
|
|
4
4
|
runPluginBuildDoneHooks,
|
|
5
5
|
runPluginBuildStartHooks
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-p2gc4tkm.js";
|
|
7
7
|
import {
|
|
8
8
|
loadPackageJson,
|
|
9
9
|
loadTsConfig
|
|
10
10
|
} from "./chunk-5v78yfze.js";
|
|
11
11
|
import {
|
|
12
12
|
BunupBuildError,
|
|
13
|
+
BunupDTSBuildError,
|
|
13
14
|
JS_RE,
|
|
14
15
|
cleanOutDir,
|
|
15
16
|
cleanPath,
|
|
@@ -30,10 +31,11 @@ import {
|
|
|
30
31
|
link,
|
|
31
32
|
logTable,
|
|
32
33
|
logger,
|
|
34
|
+
parseErrorMessage,
|
|
33
35
|
replaceExtension,
|
|
34
36
|
returnPathIfExists,
|
|
35
37
|
setSilent
|
|
36
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-aq91x0fe.js";
|
|
37
39
|
|
|
38
40
|
// src/build.ts
|
|
39
41
|
import path2 from "path";
|
|
@@ -106,13 +108,8 @@ function getName(node, source) {
|
|
|
106
108
|
}
|
|
107
109
|
break;
|
|
108
110
|
case "TSModuleDeclaration":
|
|
109
|
-
if (node.id) {
|
|
110
|
-
|
|
111
|
-
return node.id.name;
|
|
112
|
-
}
|
|
113
|
-
if (node.id.type === "StringLiteral" && typeof node.id.value === "string") {
|
|
114
|
-
return node.id.value;
|
|
115
|
-
}
|
|
111
|
+
if (node.id && node.id.type === "Identifier") {
|
|
112
|
+
return node.id.name;
|
|
116
113
|
}
|
|
117
114
|
break;
|
|
118
115
|
case "VariableDeclaration": {
|
|
@@ -311,88 +308,79 @@ function handleNamespace(stmt) {
|
|
|
311
308
|
|
|
312
309
|
// src/dts/logger.ts
|
|
313
310
|
import pc from "picocolors";
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
logSingle(error);
|
|
311
|
+
var SEVERITY_CONFIG = {
|
|
312
|
+
dev: {
|
|
313
|
+
Error: { color: pc.yellow, prefix: "WARN" },
|
|
314
|
+
Warning: { color: pc.yellow, prefix: "WARN" },
|
|
315
|
+
Advice: { color: pc.blue, prefix: "ADVICE" },
|
|
316
|
+
default: { color: pc.blue, prefix: "WARN" }
|
|
317
|
+
},
|
|
318
|
+
prod: {
|
|
319
|
+
Error: { color: pc.red, prefix: "Error" },
|
|
320
|
+
Warning: { color: pc.yellow, prefix: "Warning" },
|
|
321
|
+
Advice: { color: pc.blue, prefix: "Advice" },
|
|
322
|
+
default: { color: pc.red, prefix: "Error" }
|
|
327
323
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
`);
|
|
336
|
-
|
|
324
|
+
};
|
|
325
|
+
var ISOLATED_DECLARATION_ERRORS = {
|
|
326
|
+
TS9007: `Function requires an explicit return type, e.g., \`function foo(): ${pc.green("string")} { ... }\`.`,
|
|
327
|
+
TS9008: `Method requires an explicit return type, e.g., \`myMethod(): ${pc.green("number")} { ... }\`.`,
|
|
328
|
+
TS9009: "Ensure at least one accessor (getter/setter) has an explicit return type.",
|
|
329
|
+
TS9010: `Variable requires an explicit type annotation, e.g., \`let name: ${pc.green("string")} = "Bob";\`.`,
|
|
330
|
+
TS9011: `Function parameter requires an explicit type, e.g., \`(param: ${pc.green("number")}) => {}\`.`,
|
|
331
|
+
TS9012: `Class property requires an explicit type, e.g., \`class MyClass { id: ${pc.green("number")}; }\`.`,
|
|
332
|
+
TS9013: "Expression type cannot be inferred. Add a type annotation where this expression is assigned or used.",
|
|
333
|
+
TS9014: "Computed property names must be simple (e.g., string/number literals or basic identifiers).",
|
|
334
|
+
TS9015: "Object spread properties prevent type inference. Either add an explicit type to the object or avoid spread.",
|
|
335
|
+
TS9016: "Object shorthand properties prevent type inference. Either add an explicit type to the object or use full `key: value` syntax.",
|
|
336
|
+
TS9017: `For array type inference, use \`as const\` (e.g., \`[1, 2, 3] ${pc.green("as const")}\`).`,
|
|
337
|
+
TS9018: "Array spread elements prevent type inference. Either add an explicit type to the array or avoid spread.",
|
|
338
|
+
TS9019: `Avoid direct export of destructured bindings. Instead, declare and then export, e.g., \`const { x } = obj; ${pc.green("export { x };")}\`.`,
|
|
339
|
+
TS9020: "Enum member initializers must be simple, constant values (like numbers or strings), not expressions or external references.",
|
|
340
|
+
TS9021: "The `extends` clause must refer to a direct class name, not an expression.",
|
|
341
|
+
TS9022: `Class expressions cannot infer types. Assign the class expression to an explicitly typed variable, e.g., \`const MyClass: ${pc.green("typeof OtherClass")} = class { ... };\`.`,
|
|
342
|
+
TS9023: `Properties assigned to functions must be explicitly declared on the function type/interface, e.g., \`interface MyFunc { (): void; ${pc.green("myProp: string;")} }\`.`,
|
|
343
|
+
TS9025: `Parameter can implicitly be \`undefined\`. Explicitly add \`| undefined\` to its type, e.g., \`param?: string\` becomes \`param: ${pc.green("string | undefined")}\`.`,
|
|
344
|
+
TS9037: `Default export requires an explicit type, e.g., \`const MyValue: ${pc.green("number")} = 42; export default MyValue;\`.`,
|
|
345
|
+
TS9038: "Computed property names in class/object literals must be simple (string/number literals or plain identifiers), not complex expressions.",
|
|
346
|
+
TS9039: "A type references a private class member (`{name}`). Private members cannot be part of publicly exposed types."
|
|
347
|
+
};
|
|
348
|
+
function logIsolatedDeclarationErrors(errors) {
|
|
349
|
+
if (!errors.length)
|
|
350
|
+
return;
|
|
351
|
+
const hasErrors = errors.some(({ error }) => error.severity === "Error");
|
|
352
|
+
errors.forEach(logSingle);
|
|
353
|
+
if (hasErrors) {
|
|
354
|
+
if (!isDev())
|
|
337
355
|
process.exit(1);
|
|
338
|
-
}
|
|
339
356
|
}
|
|
340
357
|
}
|
|
341
|
-
function logSingle(error) {
|
|
342
|
-
const label = error.
|
|
343
|
-
const
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
const
|
|
349
|
-
const
|
|
350
|
-
|
|
358
|
+
function logSingle({ error, file, content }) {
|
|
359
|
+
const label = error.labels?.[0];
|
|
360
|
+
const errorCode = extractErrorCode(error.message);
|
|
361
|
+
const errorMessage = ISOLATED_DECLARATION_ERRORS[errorCode];
|
|
362
|
+
if (!errorMessage)
|
|
363
|
+
return;
|
|
364
|
+
const position = label ? calculatePosition(content, label.start) : "";
|
|
365
|
+
const shortPath = getShortFilePath(file);
|
|
366
|
+
const { color, prefix } = getSeverityFormatting(error.severity);
|
|
367
|
+
const formattedMessage = `${color(prefix)} ${shortPath}${position}: ${errorCode} ${errorMessage}`;
|
|
368
|
+
const codeFrame = label ? generateOxcCodeFrame(content, label.start, label.end) : error.codeframe || "";
|
|
369
|
+
const helpMessage = error.helpMessage ? `
|
|
370
|
+
${pc.cyan("Help:")} ${error.helpMessage}` : "";
|
|
351
371
|
console.log(`
|
|
352
372
|
${formattedMessage}${helpMessage}
|
|
353
373
|
|
|
354
374
|
${pc.gray(codeFrame)}`);
|
|
355
375
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
358
|
-
switch (severity) {
|
|
359
|
-
case "Error":
|
|
360
|
-
return {
|
|
361
|
-
color: pc.blue,
|
|
362
|
-
prefix: "Suggestion"
|
|
363
|
-
};
|
|
364
|
-
case "Warning":
|
|
365
|
-
return { color: pc.yellow, prefix: "Suggestion" };
|
|
366
|
-
case "Advice":
|
|
367
|
-
return { color: pc.blue, prefix: "Advice" };
|
|
368
|
-
default:
|
|
369
|
-
return {
|
|
370
|
-
color: pc.blue,
|
|
371
|
-
prefix: "Suggestion"
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
switch (severity) {
|
|
376
|
-
case "Error":
|
|
377
|
-
return {
|
|
378
|
-
color: pc.red,
|
|
379
|
-
prefix: "ERROR"
|
|
380
|
-
};
|
|
381
|
-
case "Warning":
|
|
382
|
-
return { color: pc.yellow, prefix: "WARNING" };
|
|
383
|
-
case "Advice":
|
|
384
|
-
return { color: pc.blue, prefix: "ADVICE" };
|
|
385
|
-
default:
|
|
386
|
-
return {
|
|
387
|
-
color: pc.red,
|
|
388
|
-
prefix: "ERROR"
|
|
389
|
-
};
|
|
390
|
-
}
|
|
376
|
+
function extractErrorCode(message) {
|
|
377
|
+
return message.split(":")[0];
|
|
391
378
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
379
|
+
function getSeverityFormatting(severity) {
|
|
380
|
+
const config = SEVERITY_CONFIG[isDev() ? "dev" : "prod"];
|
|
381
|
+
return config[severity] || config.default;
|
|
394
382
|
}
|
|
395
|
-
function
|
|
383
|
+
function calculatePosition(sourceText, labelStart) {
|
|
396
384
|
if (labelStart === undefined)
|
|
397
385
|
return "";
|
|
398
386
|
const lines = sourceText.slice(0, labelStart).split(`
|
|
@@ -401,34 +389,21 @@ function calculateDtsErrorLineAndColumn(sourceText, labelStart) {
|
|
|
401
389
|
const columnStart = lines[lines.length - 1].length + 1;
|
|
402
390
|
return ` (${lineNumber}:${columnStart})`;
|
|
403
391
|
}
|
|
404
|
-
function
|
|
392
|
+
function generateOxcCodeFrame(sourceText, start, end) {
|
|
405
393
|
const lines = sourceText.split(`
|
|
406
394
|
`);
|
|
407
395
|
const errorLine = sourceText.slice(0, start).split(`
|
|
408
396
|
`).length;
|
|
409
397
|
const lineContent = lines[errorLine - 1];
|
|
410
|
-
const
|
|
411
|
-
`)
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
const
|
|
398
|
+
const lastNewlineIndex = sourceText.slice(0, start).lastIndexOf(`
|
|
399
|
+
`);
|
|
400
|
+
const startCol = start - lastNewlineIndex - 1;
|
|
401
|
+
const endCol = end ? Math.min(end - lastNewlineIndex - 1, lineContent.length) : startCol + 1;
|
|
402
|
+
const underlineLength = Math.max(1, endCol - startCol);
|
|
403
|
+
const arrowLine = " ".repeat(startCol) + pc.dim(pc.blue("\u23AF".repeat(underlineLength)));
|
|
415
404
|
return `${lineContent}
|
|
416
405
|
${arrowLine}`;
|
|
417
406
|
}
|
|
418
|
-
function handleBunBuildLogs(logs) {
|
|
419
|
-
for (const log of logs) {
|
|
420
|
-
if (log.level === "error") {
|
|
421
|
-
logger.error(`${log.message} in ${log.position?.file}`);
|
|
422
|
-
throw new Error("Failed to generate declaration file");
|
|
423
|
-
}
|
|
424
|
-
if (log.level === "warning") {
|
|
425
|
-
logger.warn(log.message);
|
|
426
|
-
}
|
|
427
|
-
if (log.level === "info") {
|
|
428
|
-
logger.info(log.message);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
407
|
|
|
433
408
|
// src/dts/resolver.ts
|
|
434
409
|
import { dirname } from "path";
|
|
@@ -561,11 +536,16 @@ async function generateDts(entrypoints, options) {
|
|
|
561
536
|
target: "node",
|
|
562
537
|
splitting: options.splitting,
|
|
563
538
|
plugins: [fakeJsPlugin],
|
|
564
|
-
throw: false,
|
|
565
539
|
packages: "external",
|
|
566
|
-
minify: options.minify
|
|
540
|
+
minify: options.minify,
|
|
541
|
+
throw: false
|
|
567
542
|
});
|
|
568
|
-
|
|
543
|
+
if (collectedErrors.length) {
|
|
544
|
+
logIsolatedDeclarationErrors(collectedErrors);
|
|
545
|
+
}
|
|
546
|
+
if (!result.success) {
|
|
547
|
+
throw new Error(`DTS bundling failed: ${result.logs}`);
|
|
548
|
+
}
|
|
569
549
|
try {
|
|
570
550
|
const outputs = result.outputs.filter((output) => output.kind === "chunk" || output.kind === "entry-point");
|
|
571
551
|
const bundledFiles = [];
|
|
@@ -589,14 +569,7 @@ async function generateDts(entrypoints, options) {
|
|
|
589
569
|
});
|
|
590
570
|
}
|
|
591
571
|
return {
|
|
592
|
-
files: bundledFiles
|
|
593
|
-
errors: collectedErrors
|
|
594
|
-
};
|
|
595
|
-
} catch (error) {
|
|
596
|
-
console.error(error);
|
|
597
|
-
return {
|
|
598
|
-
files: [],
|
|
599
|
-
errors: collectedErrors
|
|
572
|
+
files: bundledFiles
|
|
600
573
|
};
|
|
601
574
|
} finally {
|
|
602
575
|
await fs.rm(tempOutDir, { recursive: true, force: true });
|
|
@@ -897,38 +870,41 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
897
870
|
});
|
|
898
871
|
await Promise.all(buildPromises);
|
|
899
872
|
if (options.dts) {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
873
|
+
try {
|
|
874
|
+
const { entry, splitting, ...dtsOptions } = typeof options.dts === "object" ? options.dts : {};
|
|
875
|
+
const dtsResult = await generateDts(ensureArray(entry ?? entrypoints), {
|
|
876
|
+
cwd: rootDir,
|
|
877
|
+
preferredTsConfigPath: options.preferredTsconfigPath,
|
|
878
|
+
splitting: getResolvedDtsSplitting(splitting),
|
|
879
|
+
...dtsOptions
|
|
880
|
+
});
|
|
881
|
+
for (const fmt of options.format) {
|
|
882
|
+
for (const file of dtsResult.files) {
|
|
883
|
+
const dtsExtension = getDefaultDtsExtention(fmt, packageType);
|
|
884
|
+
const relativePathToOutputDir = cleanPath(`${file.pathInfo.outputPathWithoutExtension}${dtsExtension}`);
|
|
885
|
+
const relativePathToRootDir = cleanPath(`${options.outDir}/${relativePathToOutputDir}`);
|
|
886
|
+
if (file.kind === "entry-point") {
|
|
887
|
+
logger.success(`${pc3.dim(`${options.outDir}/`)}${relativePathToOutputDir}`, {
|
|
888
|
+
identifier: options.name
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
const fullPath = path2.join(rootDir, relativePathToRootDir);
|
|
892
|
+
await Bun.write(fullPath, file.dts);
|
|
893
|
+
buildOutput.files.push({
|
|
894
|
+
fullPath,
|
|
895
|
+
relativePathToRootDir,
|
|
896
|
+
relativePathToOutputDir,
|
|
897
|
+
dts: true,
|
|
898
|
+
format: fmt,
|
|
899
|
+
kind: file.kind,
|
|
900
|
+
entrypoint: file.entrypoint ? cleanPath(file.entrypoint) : undefined
|
|
918
901
|
});
|
|
919
902
|
}
|
|
920
|
-
const fullPath = path2.join(rootDir, relativePathToRootDir);
|
|
921
|
-
await Bun.write(fullPath, file.dts);
|
|
922
|
-
buildOutput.files.push({
|
|
923
|
-
fullPath,
|
|
924
|
-
relativePathToRootDir,
|
|
925
|
-
relativePathToOutputDir,
|
|
926
|
-
dts: true,
|
|
927
|
-
format: fmt,
|
|
928
|
-
kind: file.kind,
|
|
929
|
-
entrypoint: file.entrypoint ? cleanPath(file.entrypoint) : undefined
|
|
930
|
-
});
|
|
931
903
|
}
|
|
904
|
+
} catch (error) {
|
|
905
|
+
throw new BunupDTSBuildError(parseErrorMessage(error));
|
|
906
|
+
} finally {
|
|
907
|
+
logger.space();
|
|
932
908
|
}
|
|
933
909
|
}
|
|
934
910
|
await runPluginBuildDoneHooks(bunupPlugins, options, buildOutput, {
|
|
@@ -946,4 +922,4 @@ function getRelativePathToOutputDir(relativePathToRootDir, outDir) {
|
|
|
946
922
|
return cleanPath(relativePathToRootDir).replace(`${cleanPath(outDir)}/`, "");
|
|
947
923
|
}
|
|
948
924
|
|
|
949
|
-
export {
|
|
925
|
+
export { createBuildOptions, build };
|
|
@@ -426,4 +426,4 @@ function returnPathIfExists(path2) {
|
|
|
426
426
|
return pathExistsSync(path2) ? path2 : null;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
export { __toESM, __require, JS_RE, JS_TS_RE, JS_DTS_RE, CSS_RE, setSilent, logTable, link, logger, BunupBuildError, 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 };
|
|
429
|
+
export { __toESM, __require, JS_RE, JS_TS_RE, JS_DTS_RE, CSS_RE, setSilent, logTable, link, logger, 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 };
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
type Resolve = boolean | (string | RegExp)[];
|
|
2
2
|
type GenerateDtsOptions = {
|
|
3
|
-
preferredTsConfigPath?: string
|
|
4
|
-
resolve?: Resolve
|
|
5
|
-
cwd?: string
|
|
6
|
-
splitting?: boolean
|
|
7
|
-
minify?: boolean
|
|
3
|
+
preferredTsConfigPath?: string;
|
|
4
|
+
resolve?: Resolve;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
splitting?: boolean;
|
|
7
|
+
minify?: boolean;
|
|
8
8
|
};
|
|
9
9
|
import { BunPlugin } from "bun";
|
|
10
10
|
type PackageJson = {
|
|
11
11
|
/** The parsed content of the package.json file */
|
|
12
|
-
data: Record<string, any> | null
|
|
12
|
+
data: Record<string, any> | null;
|
|
13
13
|
/** The path to the package.json file */
|
|
14
|
-
path: string | null
|
|
14
|
+
path: string | null;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Represents a Bun plugin that can be used with Bunup
|
|
18
18
|
*/
|
|
19
19
|
type BunupBunPlugin = {
|
|
20
20
|
/** Identifies this as a native Bun plugin */
|
|
21
|
-
type: "bun"
|
|
21
|
+
type: "bun";
|
|
22
22
|
/** Optional name for the plugin */
|
|
23
|
-
name?: string
|
|
23
|
+
name?: string;
|
|
24
24
|
/** The actual Bun plugin implementation */
|
|
25
|
-
plugin: BunPlugin
|
|
25
|
+
plugin: BunPlugin;
|
|
26
26
|
};
|
|
27
27
|
/**
|
|
28
28
|
* Represents the meta data of the build
|
|
29
29
|
*/
|
|
30
30
|
type BuildMeta = {
|
|
31
31
|
/** The package.json file */
|
|
32
|
-
packageJson: PackageJson
|
|
32
|
+
packageJson: PackageJson;
|
|
33
33
|
/** The root directory of the build */
|
|
34
|
-
rootDir: string
|
|
34
|
+
rootDir: string;
|
|
35
35
|
};
|
|
36
36
|
type BuildOutputFile = {
|
|
37
37
|
/**
|
|
@@ -39,37 +39,37 @@ type BuildOutputFile = {
|
|
|
39
39
|
*
|
|
40
40
|
* Undefined for non-entry point files (e.g., assets, sourcemaps, chunks)
|
|
41
41
|
*/
|
|
42
|
-
entrypoint: string | undefined
|
|
42
|
+
entrypoint: string | undefined;
|
|
43
43
|
/** The kind of the file */
|
|
44
|
-
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode"
|
|
44
|
+
kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode";
|
|
45
45
|
/** Path to the generated file */
|
|
46
|
-
fullPath: string
|
|
46
|
+
fullPath: string;
|
|
47
47
|
/** Path to the generated file relative to the root directory */
|
|
48
|
-
relativePathToRootDir: string
|
|
48
|
+
relativePathToRootDir: string;
|
|
49
49
|
/** Path to the generated file relative to the output directory */
|
|
50
|
-
relativePathToOutputDir: string
|
|
50
|
+
relativePathToOutputDir: string;
|
|
51
51
|
/** Whether the file is a dts file */
|
|
52
|
-
dts: boolean
|
|
52
|
+
dts: boolean;
|
|
53
53
|
/** The format of the output file */
|
|
54
|
-
format: Format
|
|
54
|
+
format: Format;
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Represents the output of a build operation
|
|
58
58
|
*/
|
|
59
59
|
type BuildOutput = {
|
|
60
60
|
/** Array of generated files with their paths and contents */
|
|
61
|
-
files: BuildOutputFile[]
|
|
61
|
+
files: BuildOutputFile[];
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
64
|
* Context provided to build hooks
|
|
65
65
|
*/
|
|
66
66
|
type BuildContext = {
|
|
67
67
|
/** The build options that were used */
|
|
68
|
-
options: BuildOptions
|
|
68
|
+
options: BuildOptions;
|
|
69
69
|
/** The output of the build */
|
|
70
|
-
output: BuildOutput
|
|
70
|
+
output: BuildOutput;
|
|
71
71
|
/** The meta data of the build */
|
|
72
|
-
meta: BuildMeta
|
|
72
|
+
meta: BuildMeta;
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Hooks that can be implemented by Bunup plugins
|
|
@@ -79,23 +79,23 @@ type BunupPluginHooks = {
|
|
|
79
79
|
* Called when a build is successfully completed
|
|
80
80
|
* @param ctx Build context containing options and output
|
|
81
81
|
*/
|
|
82
|
-
onBuildDone?: (ctx: BuildContext) => MaybePromise<void
|
|
82
|
+
onBuildDone?: (ctx: BuildContext) => MaybePromise<void>;
|
|
83
83
|
/**
|
|
84
84
|
* Called before a build starts
|
|
85
85
|
* @param options Build options that will be used
|
|
86
86
|
*/
|
|
87
|
-
onBuildStart?: (options: BuildOptions) => MaybePromise<void
|
|
87
|
+
onBuildStart?: (options: BuildOptions) => MaybePromise<void>;
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
* Represents a Bunup-specific plugin
|
|
91
91
|
*/
|
|
92
92
|
type BunupPlugin = {
|
|
93
93
|
/** Identifies this as a Bunup-specific plugin */
|
|
94
|
-
type: "bunup"
|
|
94
|
+
type: "bunup";
|
|
95
95
|
/** Optional name for the plugin */
|
|
96
|
-
name?: string
|
|
96
|
+
name?: string;
|
|
97
97
|
/** The hooks implemented by this plugin */
|
|
98
|
-
hooks: BunupPluginHooks
|
|
98
|
+
hooks: BunupPluginHooks;
|
|
99
99
|
};
|
|
100
100
|
/**
|
|
101
101
|
* Union type representing all supported plugin types
|
|
@@ -170,7 +170,7 @@ interface BuildOptions {
|
|
|
170
170
|
* Can also be configured with DtsOptions for more control
|
|
171
171
|
*/
|
|
172
172
|
dts?: boolean | (Pick<GenerateDtsOptions, "resolve" | "splitting" | "minify"> & {
|
|
173
|
-
entry?: string | string[]
|
|
173
|
+
entry?: string | string[];
|
|
174
174
|
});
|
|
175
175
|
/**
|
|
176
176
|
* Path to a preferred tsconfig.json file to use for declaration generation
|
|
@@ -350,8 +350,8 @@ type WithOptional<
|
|
|
350
350
|
type Arrayable<T> = T | T[];
|
|
351
351
|
type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
|
|
352
352
|
type DefineWorkspaceItem = {
|
|
353
|
-
name: string
|
|
354
|
-
root: string
|
|
355
|
-
config: DefineConfigItem | DefineConfigItem[]
|
|
353
|
+
name: string;
|
|
354
|
+
root: string;
|
|
355
|
+
config: DefineConfigItem | DefineConfigItem[];
|
|
356
356
|
};
|
|
357
357
|
export { MaybePromise, Arrayable, DefineConfigItem, DefineWorkspaceItem, BuildContext, BunupPlugin, Plugin, BuildOptions };
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-5v78yfze.js";
|
|
5
5
|
import {
|
|
6
6
|
displayBunupGradientArt
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-1y38m6th.js";
|
|
8
8
|
import {
|
|
9
9
|
formatListWithAnd,
|
|
10
10
|
link
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-aq91x0fe.js";
|
|
12
12
|
|
|
13
13
|
// src/cli/init.ts
|
|
14
14
|
import fs from "fs";
|
package/dist/cli/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
import {
|
|
4
|
-
BUNUP_DOCS_URL,
|
|
5
4
|
build,
|
|
6
5
|
createBuildOptions
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import"../chunk-
|
|
6
|
+
} from "../chunk-6xsgpvht.js";
|
|
7
|
+
import"../chunk-p2gc4tkm.js";
|
|
9
8
|
import {
|
|
10
9
|
processLoadedConfigs
|
|
11
10
|
} from "../chunk-5v78yfze.js";
|
|
@@ -22,14 +21,14 @@ import {
|
|
|
22
21
|
logger,
|
|
23
22
|
parseErrorMessage,
|
|
24
23
|
setSilent
|
|
25
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-aq91x0fe.js";
|
|
26
25
|
|
|
27
26
|
// src/cli/index.ts
|
|
28
27
|
import { loadConfig } from "coffi";
|
|
29
28
|
import pc3 from "picocolors";
|
|
30
29
|
import { exec } from "tinyexec";
|
|
31
30
|
// package.json
|
|
32
|
-
var version = "0.8.
|
|
31
|
+
var version = "0.8.51";
|
|
33
32
|
|
|
34
33
|
// src/watch.ts
|
|
35
34
|
import path from "path";
|
|
@@ -88,6 +87,11 @@ async function watch(partialOptions, rootDir) {
|
|
|
88
87
|
|
|
89
88
|
// src/cli/options.ts
|
|
90
89
|
import pc2 from "picocolors";
|
|
90
|
+
|
|
91
|
+
// src/constants/index.ts
|
|
92
|
+
var BUNUP_DOCS_URL = "https://bunup.dev/docs";
|
|
93
|
+
|
|
94
|
+
// src/cli/options.ts
|
|
91
95
|
var createHandlers = () => ({
|
|
92
96
|
boolean: (key) => (value, options) => {
|
|
93
97
|
options[key] = value === true || value === "true";
|
|
@@ -481,12 +485,12 @@ var parseCliOptions = (argv) => {
|
|
|
481
485
|
async function main(args = Bun.argv.slice(2)) {
|
|
482
486
|
const cliOptions = parseCliOptions(args);
|
|
483
487
|
if (cliOptions.new) {
|
|
484
|
-
const { newProject } = await import("../chunk-
|
|
488
|
+
const { newProject } = await import("../chunk-4wtd9wfc.js");
|
|
485
489
|
await newProject();
|
|
486
490
|
return;
|
|
487
491
|
}
|
|
488
492
|
if (cliOptions.init) {
|
|
489
|
-
const { init } = await import("../chunk-
|
|
493
|
+
const { init } = await import("../chunk-tamy0g3r.js");
|
|
490
494
|
await init();
|
|
491
495
|
return;
|
|
492
496
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-
|
|
1
|
+
import { Arrayable, BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin } from "./chunk-p2wczz52";
|
|
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[];
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
build
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import"./chunk-
|
|
4
|
+
} from "./chunk-6xsgpvht.js";
|
|
5
|
+
import"./chunk-p2gc4tkm.js";
|
|
6
6
|
import"./chunk-5v78yfze.js";
|
|
7
|
-
import"./chunk-
|
|
7
|
+
import"./chunk-aq91x0fe.js";
|
|
8
8
|
// src/define.ts
|
|
9
9
|
function defineConfig(options) {
|
|
10
10
|
return options;
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-
|
|
1
|
+
import { BuildContext, BunupPlugin, MaybePromise, Plugin } from "./chunk-p2wczz52";
|
|
2
2
|
/**
|
|
3
3
|
* A plugin that copies files and directories to the output directory.
|
|
4
4
|
*
|
|
@@ -30,7 +30,7 @@ interface ExportsPluginOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
declare function exports(options?: ExportsPluginOptions): BunupPlugin;
|
|
32
32
|
type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
33
|
-
inject?: (css: string, filePath: string) => MaybePromise<string
|
|
33
|
+
inject?: (css: string, filePath: string) => MaybePromise<string>;
|
|
34
34
|
};
|
|
35
35
|
/**
|
|
36
36
|
* A plugin that injects styles into the document head.
|
package/dist/plugins.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
getPackageForPlugin
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-p2gc4tkm.js";
|
|
5
5
|
import {
|
|
6
6
|
CSS_RE,
|
|
7
7
|
JS_DTS_RE,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
cleanPath,
|
|
10
10
|
isDirectoryPath,
|
|
11
11
|
logger
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-aq91x0fe.js";
|
|
13
13
|
|
|
14
14
|
// src/plugins/built-in/copy.ts
|
|
15
15
|
import { basename, join } from "path";
|