bunup 0.8.5 → 0.8.7
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/dist/cli.js +28 -22
- package/dist/index.cjs +2 -6
- package/dist/index.js +2 -6
- package/dist/plugins.cjs +29 -3
- package/dist/plugins.d.cts +2 -3
- package/dist/plugins.d.ts +2 -3
- package/dist/plugins.js +29 -5
- package/package.json +3 -5
package/dist/cli.js
CHANGED
|
@@ -251,7 +251,7 @@ var init_logger = __esm(() => {
|
|
|
251
251
|
});
|
|
252
252
|
|
|
253
253
|
// src/errors.ts
|
|
254
|
-
var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, parseErrorMessage = (error) => {
|
|
254
|
+
var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCLIError, BunupWatchError, BunupPluginError, parseErrorMessage = (error) => {
|
|
255
255
|
if (error instanceof Error) {
|
|
256
256
|
return error.message;
|
|
257
257
|
}
|
|
@@ -268,6 +268,8 @@ var import_picocolors2, BunupError, BunupBuildError, BunupDTSBuildError, BunupCL
|
|
|
268
268
|
errorType = "CLI ERROR";
|
|
269
269
|
} else if (error instanceof BunupWatchError) {
|
|
270
270
|
errorType = "WATCH ERROR";
|
|
271
|
+
} else if (error instanceof BunupPluginError) {
|
|
272
|
+
errorType = "PLUGIN ERROR";
|
|
271
273
|
} else if (error instanceof BunupError) {
|
|
272
274
|
errorType = "BUNUP ERROR";
|
|
273
275
|
}
|
|
@@ -321,6 +323,12 @@ var init_errors = __esm(() => {
|
|
|
321
323
|
this.name = "BunupWatchError";
|
|
322
324
|
}
|
|
323
325
|
};
|
|
326
|
+
BunupPluginError = class BunupPluginError extends BunupError {
|
|
327
|
+
constructor(message) {
|
|
328
|
+
super(message);
|
|
329
|
+
this.name = "BunupPluginError";
|
|
330
|
+
}
|
|
331
|
+
};
|
|
324
332
|
KNOWN_ERRORS = [
|
|
325
333
|
{
|
|
326
334
|
pattern: /Could not resolve: "bun"/i,
|
|
@@ -430,12 +438,12 @@ import {
|
|
|
430
438
|
import { downloadTemplate } from "giget";
|
|
431
439
|
import { replaceInFile } from "replace-in-file";
|
|
432
440
|
async function newProject() {
|
|
433
|
-
intro(
|
|
441
|
+
intro(import_picocolors6.default.bgCyan(import_picocolors6.default.black(" Scaffold a new project with Bunup ")));
|
|
434
442
|
const selectedTemplateDir = await select({
|
|
435
443
|
message: "Select a template",
|
|
436
444
|
options: TEMPLATES.map((template2) => ({
|
|
437
445
|
value: template2.dir,
|
|
438
|
-
label:
|
|
446
|
+
label: import_picocolors6.default.blue(template2.name)
|
|
439
447
|
}))
|
|
440
448
|
});
|
|
441
449
|
const template = TEMPLATES.find((t) => t.dir === selectedTemplateDir);
|
|
@@ -521,23 +529,23 @@ async function newProject() {
|
|
|
521
529
|
}
|
|
522
530
|
]);
|
|
523
531
|
outro(`
|
|
524
|
-
${
|
|
532
|
+
${import_picocolors6.default.green("\u2728 Project scaffolded successfully! \u2728")}
|
|
525
533
|
|
|
526
|
-
${
|
|
534
|
+
${import_picocolors6.default.bold("Ready to launch your awesome new project?")}
|
|
527
535
|
|
|
528
|
-
${
|
|
529
|
-
${
|
|
530
|
-
${
|
|
536
|
+
${import_picocolors6.default.cyan("cd")} ${projectName}
|
|
537
|
+
${import_picocolors6.default.cyan("bun install")}
|
|
538
|
+
${import_picocolors6.default.cyan("bun run dev")}
|
|
531
539
|
|
|
532
|
-
${
|
|
540
|
+
${import_picocolors6.default.yellow("Happy coding!")} \uD83D\uDE80
|
|
533
541
|
`);
|
|
534
542
|
}
|
|
535
543
|
function getProjectPath(projectName) {
|
|
536
544
|
return path5.join(process.cwd(), projectName);
|
|
537
545
|
}
|
|
538
|
-
var
|
|
546
|
+
var import_picocolors6, TEMPLATE_OWNER = "arshad-yaseen", TEMPLATE_REPO = "bunup-new", GITHUB_USERNAME_PLACEHOLDER = "username", GITHUB_REPO_PLACEHOLDER = "repo-name", MONOREPO_FIRST_PACKAGE_NAME_PLACEHOLDER = "package-1", MONOREPO_PACKAGES_DIR = "packages", TEMPLATES;
|
|
539
547
|
var init_new = __esm(() => {
|
|
540
|
-
|
|
548
|
+
import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
541
549
|
init_utils();
|
|
542
550
|
TEMPLATES = [
|
|
543
551
|
{
|
|
@@ -552,7 +560,7 @@ var init_new = __esm(() => {
|
|
|
552
560
|
// src/cli/index.ts
|
|
553
561
|
import { exec } from "tinyexec";
|
|
554
562
|
// package.json
|
|
555
|
-
var version = "0.8.
|
|
563
|
+
var version = "0.8.7";
|
|
556
564
|
|
|
557
565
|
// src/cli/index.ts
|
|
558
566
|
init_errors();
|
|
@@ -783,7 +791,7 @@ function parseCliOptions(argv) {
|
|
|
783
791
|
}
|
|
784
792
|
|
|
785
793
|
// src/cli/index.ts
|
|
786
|
-
var
|
|
794
|
+
var import_picocolors7 = __toESM(require_picocolors(), 1);
|
|
787
795
|
import { loadConfig as loadConfig2 } from "coffi";
|
|
788
796
|
|
|
789
797
|
// src/build.ts
|
|
@@ -969,6 +977,8 @@ function externalOptionPlugin(options, packageJson) {
|
|
|
969
977
|
}
|
|
970
978
|
|
|
971
979
|
// src/plugins/utils.ts
|
|
980
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
981
|
+
init_errors();
|
|
972
982
|
function filterBunupBunPlugins(plugins) {
|
|
973
983
|
if (!plugins)
|
|
974
984
|
return [];
|
|
@@ -1058,12 +1068,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
1058
1068
|
});
|
|
1059
1069
|
for (const log of result.logs) {
|
|
1060
1070
|
if (log.level === "error") {
|
|
1061
|
-
|
|
1062
|
-
`);
|
|
1063
|
-
console.log(log);
|
|
1064
|
-
console.log(`
|
|
1065
|
-
`);
|
|
1066
|
-
throw new Error;
|
|
1071
|
+
throw new BunupBuildError(log.message);
|
|
1067
1072
|
}
|
|
1068
1073
|
if (log.level === "warning")
|
|
1069
1074
|
logger.warn(log.message);
|
|
@@ -1145,7 +1150,7 @@ function getRelativePathToRootDir(filePath, rootDir) {
|
|
|
1145
1150
|
init_utils();
|
|
1146
1151
|
|
|
1147
1152
|
// src/watch.ts
|
|
1148
|
-
var
|
|
1153
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
1149
1154
|
import path4 from "path";
|
|
1150
1155
|
init_errors();
|
|
1151
1156
|
init_logger();
|
|
@@ -1182,10 +1187,11 @@ async function watch(partialOptions, rootDir) {
|
|
|
1182
1187
|
}
|
|
1183
1188
|
isRebuilding = true;
|
|
1184
1189
|
try {
|
|
1190
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
1185
1191
|
const start = performance.now();
|
|
1186
1192
|
await build(options, rootDir);
|
|
1187
1193
|
if (!initial) {
|
|
1188
|
-
logger.cli(`\uD83D\uDCE6 Rebuild finished in ${
|
|
1194
|
+
logger.cli(`\uD83D\uDCE6 Rebuild finished in ${import_picocolors5.default.green(formatTime(performance.now() - start))}`);
|
|
1189
1195
|
}
|
|
1190
1196
|
} catch (error) {
|
|
1191
1197
|
handleError(error);
|
|
@@ -1251,7 +1257,7 @@ async function main(args = Bun.argv.slice(2)) {
|
|
|
1251
1257
|
}));
|
|
1252
1258
|
const buildTimeMs = performance.now() - startTime;
|
|
1253
1259
|
const timeDisplay = formatTime(buildTimeMs);
|
|
1254
|
-
logger.cli(`\u26A1\uFE0F Build completed in ${
|
|
1260
|
+
logger.cli(`\u26A1\uFE0F Build completed in ${import_picocolors7.default.green(timeDisplay)}`);
|
|
1255
1261
|
if (cliOptions.watch) {
|
|
1256
1262
|
logger.cli("\uD83D\uDC40 Watching for file changes");
|
|
1257
1263
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -511,6 +511,7 @@ function externalOptionPlugin(options, packageJson) {
|
|
|
511
511
|
}
|
|
512
512
|
|
|
513
513
|
// src/plugins/utils.ts
|
|
514
|
+
var import_picocolors3 = __toESM(require_picocolors());
|
|
514
515
|
function filterBunupBunPlugins(plugins) {
|
|
515
516
|
if (!plugins)
|
|
516
517
|
return [];
|
|
@@ -599,12 +600,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
599
600
|
});
|
|
600
601
|
for (const log of result.logs) {
|
|
601
602
|
if (log.level === "error") {
|
|
602
|
-
|
|
603
|
-
`);
|
|
604
|
-
console.log(log);
|
|
605
|
-
console.log(`
|
|
606
|
-
`);
|
|
607
|
-
throw new Error;
|
|
603
|
+
throw new BunupBuildError(log.message);
|
|
608
604
|
}
|
|
609
605
|
if (log.level === "warning")
|
|
610
606
|
logger.warn(log.message);
|
package/dist/index.js
CHANGED
|
@@ -478,6 +478,7 @@ function externalOptionPlugin(options, packageJson) {
|
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
// src/plugins/utils.ts
|
|
481
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
481
482
|
function filterBunupBunPlugins(plugins) {
|
|
482
483
|
if (!plugins)
|
|
483
484
|
return [];
|
|
@@ -566,12 +567,7 @@ async function build(partialOptions, rootDir = process.cwd()) {
|
|
|
566
567
|
});
|
|
567
568
|
for (const log of result.logs) {
|
|
568
569
|
if (log.level === "error") {
|
|
569
|
-
|
|
570
|
-
`);
|
|
571
|
-
console.log(log);
|
|
572
|
-
console.log(`
|
|
573
|
-
`);
|
|
574
|
-
throw new Error;
|
|
570
|
+
throw new BunupBuildError(log.message);
|
|
575
571
|
}
|
|
576
572
|
if (log.level === "warning")
|
|
577
573
|
logger.warn(log.message);
|
package/dist/plugins.cjs
CHANGED
|
@@ -367,6 +367,18 @@ var import_node_path = __toESM(require("path"));
|
|
|
367
367
|
|
|
368
368
|
// src/errors.ts
|
|
369
369
|
var import_picocolors2 = __toESM(require_picocolors());
|
|
370
|
+
class BunupError extends Error {
|
|
371
|
+
constructor(message) {
|
|
372
|
+
super(message);
|
|
373
|
+
this.name = "BunupError";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
class BunupPluginError extends BunupError {
|
|
377
|
+
constructor(message) {
|
|
378
|
+
super(message);
|
|
379
|
+
this.name = "BunupPluginError";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
370
382
|
|
|
371
383
|
// src/utils.ts
|
|
372
384
|
function getJsonSpaceCount(fileContent) {
|
|
@@ -552,7 +564,20 @@ function report(options = {}) {
|
|
|
552
564
|
}
|
|
553
565
|
// src/plugins/built-in/css/inject-styles.ts
|
|
554
566
|
var import_node_path2 = __toESM(require("path"));
|
|
555
|
-
|
|
567
|
+
|
|
568
|
+
// src/plugins/utils.ts
|
|
569
|
+
var import_picocolors4 = __toESM(require_picocolors());
|
|
570
|
+
async function getPackageForPlugin(name, pluginName) {
|
|
571
|
+
let pkg;
|
|
572
|
+
try {
|
|
573
|
+
pkg = await import(name);
|
|
574
|
+
} catch {
|
|
575
|
+
throw new BunupPluginError(`[${import_picocolors4.default.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${import_picocolors4.default.blue(`bun add ${name} --dev`)}`);
|
|
576
|
+
}
|
|
577
|
+
return pkg;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// src/plugins/built-in/css/inject-styles.ts
|
|
556
581
|
function injectStyles(options) {
|
|
557
582
|
const { inject, ...transformOptions } = options ?? {};
|
|
558
583
|
return {
|
|
@@ -560,7 +585,8 @@ function injectStyles(options) {
|
|
|
560
585
|
name: "inject-styles",
|
|
561
586
|
plugin: {
|
|
562
587
|
name: "bunup:inject-styles",
|
|
563
|
-
setup(build) {
|
|
588
|
+
async setup(build) {
|
|
589
|
+
const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
|
|
564
590
|
build.onResolve({ filter: /^__inject-style$/ }, () => {
|
|
565
591
|
return {
|
|
566
592
|
path: "__inject-style",
|
|
@@ -589,7 +615,7 @@ function injectStyles(options) {
|
|
|
589
615
|
});
|
|
590
616
|
build.onLoad({ filter: CSS_RE }, async (args) => {
|
|
591
617
|
const source = await Bun.file(args.path).text();
|
|
592
|
-
const { code, warnings } =
|
|
618
|
+
const { code, warnings } = lightningcss.transform({
|
|
593
619
|
...transformOptions,
|
|
594
620
|
filename: import_node_path2.default.basename(args.path),
|
|
595
621
|
code: Buffer.from(source),
|
package/dist/plugins.d.cts
CHANGED
|
@@ -401,14 +401,13 @@ type ReportPluginOptions = {
|
|
|
401
401
|
* @param options - The options for the report plugin.
|
|
402
402
|
*/
|
|
403
403
|
declare function report(options?: ReportPluginOptions): BunupPlugin;
|
|
404
|
-
|
|
405
|
-
type InjectStylesPluginOptions = Pick<TransformOptions<CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
404
|
+
type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
406
405
|
inject?: (css: string, filePath: string) => MaybePromise<string>
|
|
407
406
|
};
|
|
408
407
|
/**
|
|
409
408
|
* A plugin that injects styles into the document head.
|
|
410
409
|
*
|
|
411
|
-
* @see https://bunup.dev/docs/plugins/css#
|
|
410
|
+
* @see https://bunup.dev/docs/plugins/css#injectstyles
|
|
412
411
|
*/
|
|
413
412
|
declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
|
|
414
413
|
export { shims, report, injectStyles, filterJsDtsFiles, exports };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -401,14 +401,13 @@ type ReportPluginOptions = {
|
|
|
401
401
|
* @param options - The options for the report plugin.
|
|
402
402
|
*/
|
|
403
403
|
declare function report(options?: ReportPluginOptions): BunupPlugin;
|
|
404
|
-
|
|
405
|
-
type InjectStylesPluginOptions = Pick<TransformOptions<CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
404
|
+
type InjectStylesPluginOptions = Pick<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>, "sourceMap" | "inputSourceMap" | "targets" | "nonStandard" | "minify" | "pseudoClasses" | "unusedSymbols" | "errorRecovery" | "visitor" | "customAtRules" | "include" | "exclude" | "drafts"> & {
|
|
406
405
|
inject?: (css: string, filePath: string) => MaybePromise<string>
|
|
407
406
|
};
|
|
408
407
|
/**
|
|
409
408
|
* A plugin that injects styles into the document head.
|
|
410
409
|
*
|
|
411
|
-
* @see https://bunup.dev/docs/plugins/css#
|
|
410
|
+
* @see https://bunup.dev/docs/plugins/css#injectstyles
|
|
412
411
|
*/
|
|
413
412
|
declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
|
|
414
413
|
export { shims, report, injectStyles, filterJsDtsFiles, exports };
|
package/dist/plugins.js
CHANGED
|
@@ -332,6 +332,18 @@ import path, { normalize } from "path";
|
|
|
332
332
|
|
|
333
333
|
// src/errors.ts
|
|
334
334
|
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
335
|
+
class BunupError extends Error {
|
|
336
|
+
constructor(message) {
|
|
337
|
+
super(message);
|
|
338
|
+
this.name = "BunupError";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
class BunupPluginError extends BunupError {
|
|
342
|
+
constructor(message) {
|
|
343
|
+
super(message);
|
|
344
|
+
this.name = "BunupPluginError";
|
|
345
|
+
}
|
|
346
|
+
}
|
|
335
347
|
|
|
336
348
|
// src/utils.ts
|
|
337
349
|
function getJsonSpaceCount(fileContent) {
|
|
@@ -517,9 +529,20 @@ function report(options = {}) {
|
|
|
517
529
|
}
|
|
518
530
|
// src/plugins/built-in/css/inject-styles.ts
|
|
519
531
|
import path2 from "path";
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
532
|
+
|
|
533
|
+
// src/plugins/utils.ts
|
|
534
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
535
|
+
async function getPackageForPlugin(name, pluginName) {
|
|
536
|
+
let pkg;
|
|
537
|
+
try {
|
|
538
|
+
pkg = await import(name);
|
|
539
|
+
} catch {
|
|
540
|
+
throw new BunupPluginError(`[${import_picocolors4.default.cyan(name)}] is required for the ${pluginName} plugin. Please install it with: ${import_picocolors4.default.blue(`bun add ${name} --dev`)}`);
|
|
541
|
+
}
|
|
542
|
+
return pkg;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/plugins/built-in/css/inject-styles.ts
|
|
523
546
|
function injectStyles(options) {
|
|
524
547
|
const { inject, ...transformOptions } = options ?? {};
|
|
525
548
|
return {
|
|
@@ -527,7 +550,8 @@ function injectStyles(options) {
|
|
|
527
550
|
name: "inject-styles",
|
|
528
551
|
plugin: {
|
|
529
552
|
name: "bunup:inject-styles",
|
|
530
|
-
setup(build) {
|
|
553
|
+
async setup(build) {
|
|
554
|
+
const lightningcss = await getPackageForPlugin("lightningcss", "inject-styles");
|
|
531
555
|
build.onResolve({ filter: /^__inject-style$/ }, () => {
|
|
532
556
|
return {
|
|
533
557
|
path: "__inject-style",
|
|
@@ -556,7 +580,7 @@ function injectStyles(options) {
|
|
|
556
580
|
});
|
|
557
581
|
build.onLoad({ filter: CSS_RE }, async (args) => {
|
|
558
582
|
const source = await Bun.file(args.path).text();
|
|
559
|
-
const { code, warnings } = transform({
|
|
583
|
+
const { code, warnings } = lightningcss.transform({
|
|
560
584
|
...transformOptions,
|
|
561
585
|
filename: path2.basename(args.path),
|
|
562
586
|
code: Buffer.from(source),
|
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.
|
|
4
|
+
"version": "0.8.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -47,11 +47,10 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@clack/prompts": "^0.10.1",
|
|
50
|
-
"bun-dts": "^0.1.
|
|
50
|
+
"bun-dts": "^0.1.28",
|
|
51
51
|
"chokidar": "^4.0.3",
|
|
52
52
|
"coffi": "^0.1.29",
|
|
53
53
|
"giget": "^2.0.0",
|
|
54
|
-
"package-manager-detector": "^1.2.0",
|
|
55
54
|
"replace-in-file": "^8.3.0",
|
|
56
55
|
"tinyexec": "^1.0.1"
|
|
57
56
|
},
|
|
@@ -61,8 +60,7 @@
|
|
|
61
60
|
"bumpp": "^10.1.0",
|
|
62
61
|
"husky": "^9.1.7",
|
|
63
62
|
"lint-staged": "^15.5.1",
|
|
64
|
-
"typescript": "^5.8.3"
|
|
65
|
-
"lightningcss": "^1.30.1"
|
|
63
|
+
"typescript": "^5.8.3"
|
|
66
64
|
},
|
|
67
65
|
"peerDependencies": {
|
|
68
66
|
"typescript": ">=4.5.0",
|