bunup 0.1.4 → 0.1.5
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/build/cli.js +47 -16
- package/build/cli.mjs +47 -16
- package/build/dtsWorker.js +1 -1
- package/build/index.d.mts +2 -1
- package/build/index.d.ts +2 -1
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -38,6 +38,9 @@ var handleError = (error, context) => {
|
|
|
38
38
|
function escapeRegExp(string) {
|
|
39
39
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
40
40
|
}
|
|
41
|
+
function generateRandomSuffix(length = 8) {
|
|
42
|
+
return Math.random().toString(36).substring(2, 2 + length);
|
|
43
|
+
}
|
|
41
44
|
function getDefaultOutputExtension(format, packageType) {
|
|
42
45
|
switch (format) {
|
|
43
46
|
case "esm":
|
|
@@ -58,15 +61,9 @@ function getDefaultDtsExtention(format, packageType) {
|
|
|
58
61
|
return ".d.ts";
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
function getEntryNamingFormat(extension) {
|
|
62
|
-
return `[dir]/[name]${extension}`;
|
|
63
|
-
}
|
|
64
64
|
function isModulePackage(packageType) {
|
|
65
65
|
return packageType === "module";
|
|
66
66
|
}
|
|
67
|
-
function getEntryNameOnly(entry) {
|
|
68
|
-
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
69
|
-
}
|
|
70
67
|
function formatTime(ms) {
|
|
71
68
|
return ms >= 1e3 ? `${(ms / 1e3).toFixed(2)}s` : `${Math.round(ms)}ms`;
|
|
72
69
|
}
|
|
@@ -446,10 +443,9 @@ function validateInputs(rootDir, entry) {
|
|
|
446
443
|
self.onmessage = async (event) => {
|
|
447
444
|
const { name, rootDir, outDir, entry, format, packageType, options } = event.data;
|
|
448
445
|
try {
|
|
449
|
-
const content = await generateDts(rootDir, entry, format, options);
|
|
450
|
-
const entryName = getEntryNameOnly(entry);
|
|
446
|
+
const content = await generateDts(rootDir, entry.path, format, options);
|
|
451
447
|
const extension = getDefaultDtsExtention(format, packageType);
|
|
452
|
-
const outputRelativePath = `${outDir}/${
|
|
448
|
+
const outputRelativePath = `${outDir}/${entry.name}${extension}`;
|
|
453
449
|
const outputPath = `${rootDir}/${outputRelativePath}`;
|
|
454
450
|
await Bun.write(outputPath, content);
|
|
455
451
|
const response = {
|
|
@@ -568,6 +564,38 @@ var DtsWorker = class {
|
|
|
568
564
|
}
|
|
569
565
|
};
|
|
570
566
|
|
|
567
|
+
// src/helpers/entry.ts
|
|
568
|
+
function getEntryNameOnly(entry) {
|
|
569
|
+
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
570
|
+
}
|
|
571
|
+
function normalizeEntryToProcessableEntries(entries) {
|
|
572
|
+
const result = [];
|
|
573
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
574
|
+
function addEntry(name, path6) {
|
|
575
|
+
if (usedNames.has(name)) {
|
|
576
|
+
const randomSuffix = generateRandomSuffix();
|
|
577
|
+
result.push({ name: `${name}_${randomSuffix}`, path: path6 });
|
|
578
|
+
} else {
|
|
579
|
+
result.push({ name, path: path6 });
|
|
580
|
+
usedNames.add(name);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
for (const entry of entries) {
|
|
584
|
+
if (typeof entry === "string") {
|
|
585
|
+
const name = getEntryNameOnly(entry);
|
|
586
|
+
addEntry(name, entry);
|
|
587
|
+
} else {
|
|
588
|
+
Object.entries(entry).forEach(([name, path6]) => {
|
|
589
|
+
addEntry(name, path6);
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return result;
|
|
594
|
+
}
|
|
595
|
+
function getEntryNamingFormat(extension) {
|
|
596
|
+
return `[dir]/[name]${extension}`;
|
|
597
|
+
}
|
|
598
|
+
|
|
571
599
|
// src/plugins/external.ts
|
|
572
600
|
function externalPlugin(externalPatterns, noExternalPatterns) {
|
|
573
601
|
return {
|
|
@@ -600,8 +628,11 @@ async function build(options, rootDir) {
|
|
|
600
628
|
const externalPatterns = getExternalPatterns(options, packageJson);
|
|
601
629
|
const noExternalPatterns = getNoExternalPatterns(options);
|
|
602
630
|
const plugins = [externalPlugin(externalPatterns, noExternalPatterns)];
|
|
631
|
+
const processableEntries = normalizeEntryToProcessableEntries(
|
|
632
|
+
options.entry
|
|
633
|
+
);
|
|
603
634
|
const buildPromises = options.format.flatMap(
|
|
604
|
-
(fmt) =>
|
|
635
|
+
(fmt) => processableEntries.map(
|
|
605
636
|
(entry) => buildEntry(options, rootDir, entry, fmt, packageType, plugins)
|
|
606
637
|
)
|
|
607
638
|
);
|
|
@@ -626,7 +657,7 @@ async function build(options, rootDir) {
|
|
|
626
657
|
const dtsWorker = new DtsWorker();
|
|
627
658
|
try {
|
|
628
659
|
const dtsPromises = formatsToProcess.flatMap(
|
|
629
|
-
(fmt) =>
|
|
660
|
+
(fmt) => processableEntries.map(
|
|
630
661
|
(entry) => generateDtsForEntry(
|
|
631
662
|
options,
|
|
632
663
|
rootDir,
|
|
@@ -667,13 +698,12 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
667
698
|
);
|
|
668
699
|
const result = await Bun.build({
|
|
669
700
|
...defaultBunBuildOptions,
|
|
670
|
-
entrypoints: [`${rootDir}/${entry}`],
|
|
701
|
+
entrypoints: [`${rootDir}/${entry.path}`],
|
|
671
702
|
format: fmt,
|
|
672
703
|
naming: { entry: getEntryNamingFormat(extension) },
|
|
673
704
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
674
705
|
plugins
|
|
675
706
|
});
|
|
676
|
-
const entryName = getEntryNameOnly(entry);
|
|
677
707
|
if (!result.success) {
|
|
678
708
|
result.logs.forEach((log) => {
|
|
679
709
|
if (log.level === "error") logger.error(log.message);
|
|
@@ -684,7 +714,7 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
684
714
|
}
|
|
685
715
|
logger.progress(
|
|
686
716
|
getLoggerProgressLabel(fmt, options.name),
|
|
687
|
-
`${options.outDir}/${
|
|
717
|
+
`${options.outDir}/${entry.name}${extension}`
|
|
688
718
|
);
|
|
689
719
|
}
|
|
690
720
|
|
|
@@ -789,8 +819,9 @@ function parseCliOptions(argv) {
|
|
|
789
819
|
})();
|
|
790
820
|
async function watch(options, rootDir) {
|
|
791
821
|
const watchPaths = /* @__PURE__ */ new Set();
|
|
792
|
-
options.entry
|
|
793
|
-
|
|
822
|
+
const normalizedEntry = normalizeEntryToProcessableEntries(options.entry);
|
|
823
|
+
normalizedEntry.forEach((entry) => {
|
|
824
|
+
const entryPath = path2__default.default.resolve(rootDir, entry.path);
|
|
794
825
|
const parentDir = path2__default.default.dirname(entryPath);
|
|
795
826
|
watchPaths.add(parentDir);
|
|
796
827
|
});
|
package/build/cli.mjs
CHANGED
|
@@ -28,6 +28,9 @@ var handleError = (error, context) => {
|
|
|
28
28
|
function escapeRegExp(string) {
|
|
29
29
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
30
30
|
}
|
|
31
|
+
function generateRandomSuffix(length = 8) {
|
|
32
|
+
return Math.random().toString(36).substring(2, 2 + length);
|
|
33
|
+
}
|
|
31
34
|
function getDefaultOutputExtension(format, packageType) {
|
|
32
35
|
switch (format) {
|
|
33
36
|
case "esm":
|
|
@@ -48,15 +51,9 @@ function getDefaultDtsExtention(format, packageType) {
|
|
|
48
51
|
return ".d.ts";
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
function getEntryNamingFormat(extension) {
|
|
52
|
-
return `[dir]/[name]${extension}`;
|
|
53
|
-
}
|
|
54
54
|
function isModulePackage(packageType) {
|
|
55
55
|
return packageType === "module";
|
|
56
56
|
}
|
|
57
|
-
function getEntryNameOnly(entry) {
|
|
58
|
-
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
59
|
-
}
|
|
60
57
|
function formatTime(ms) {
|
|
61
58
|
return ms >= 1e3 ? `${(ms / 1e3).toFixed(2)}s` : `${Math.round(ms)}ms`;
|
|
62
59
|
}
|
|
@@ -436,10 +433,9 @@ function validateInputs(rootDir, entry) {
|
|
|
436
433
|
self.onmessage = async (event) => {
|
|
437
434
|
const { name, rootDir, outDir, entry, format, packageType, options } = event.data;
|
|
438
435
|
try {
|
|
439
|
-
const content = await generateDts(rootDir, entry, format, options);
|
|
440
|
-
const entryName = getEntryNameOnly(entry);
|
|
436
|
+
const content = await generateDts(rootDir, entry.path, format, options);
|
|
441
437
|
const extension = getDefaultDtsExtention(format, packageType);
|
|
442
|
-
const outputRelativePath = `${outDir}/${
|
|
438
|
+
const outputRelativePath = `${outDir}/${entry.name}${extension}`;
|
|
443
439
|
const outputPath = `${rootDir}/${outputRelativePath}`;
|
|
444
440
|
await Bun.write(outputPath, content);
|
|
445
441
|
const response = {
|
|
@@ -558,6 +554,38 @@ var DtsWorker = class {
|
|
|
558
554
|
}
|
|
559
555
|
};
|
|
560
556
|
|
|
557
|
+
// src/helpers/entry.ts
|
|
558
|
+
function getEntryNameOnly(entry) {
|
|
559
|
+
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
560
|
+
}
|
|
561
|
+
function normalizeEntryToProcessableEntries(entries) {
|
|
562
|
+
const result = [];
|
|
563
|
+
const usedNames = /* @__PURE__ */ new Set();
|
|
564
|
+
function addEntry(name, path6) {
|
|
565
|
+
if (usedNames.has(name)) {
|
|
566
|
+
const randomSuffix = generateRandomSuffix();
|
|
567
|
+
result.push({ name: `${name}_${randomSuffix}`, path: path6 });
|
|
568
|
+
} else {
|
|
569
|
+
result.push({ name, path: path6 });
|
|
570
|
+
usedNames.add(name);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
for (const entry of entries) {
|
|
574
|
+
if (typeof entry === "string") {
|
|
575
|
+
const name = getEntryNameOnly(entry);
|
|
576
|
+
addEntry(name, entry);
|
|
577
|
+
} else {
|
|
578
|
+
Object.entries(entry).forEach(([name, path6]) => {
|
|
579
|
+
addEntry(name, path6);
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
return result;
|
|
584
|
+
}
|
|
585
|
+
function getEntryNamingFormat(extension) {
|
|
586
|
+
return `[dir]/[name]${extension}`;
|
|
587
|
+
}
|
|
588
|
+
|
|
561
589
|
// src/plugins/external.ts
|
|
562
590
|
function externalPlugin(externalPatterns, noExternalPatterns) {
|
|
563
591
|
return {
|
|
@@ -590,8 +618,11 @@ async function build(options, rootDir) {
|
|
|
590
618
|
const externalPatterns = getExternalPatterns(options, packageJson);
|
|
591
619
|
const noExternalPatterns = getNoExternalPatterns(options);
|
|
592
620
|
const plugins = [externalPlugin(externalPatterns, noExternalPatterns)];
|
|
621
|
+
const processableEntries = normalizeEntryToProcessableEntries(
|
|
622
|
+
options.entry
|
|
623
|
+
);
|
|
593
624
|
const buildPromises = options.format.flatMap(
|
|
594
|
-
(fmt) =>
|
|
625
|
+
(fmt) => processableEntries.map(
|
|
595
626
|
(entry) => buildEntry(options, rootDir, entry, fmt, packageType, plugins)
|
|
596
627
|
)
|
|
597
628
|
);
|
|
@@ -616,7 +647,7 @@ async function build(options, rootDir) {
|
|
|
616
647
|
const dtsWorker = new DtsWorker();
|
|
617
648
|
try {
|
|
618
649
|
const dtsPromises = formatsToProcess.flatMap(
|
|
619
|
-
(fmt) =>
|
|
650
|
+
(fmt) => processableEntries.map(
|
|
620
651
|
(entry) => generateDtsForEntry(
|
|
621
652
|
options,
|
|
622
653
|
rootDir,
|
|
@@ -657,13 +688,12 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
657
688
|
);
|
|
658
689
|
const result = await Bun.build({
|
|
659
690
|
...defaultBunBuildOptions,
|
|
660
|
-
entrypoints: [`${rootDir}/${entry}`],
|
|
691
|
+
entrypoints: [`${rootDir}/${entry.path}`],
|
|
661
692
|
format: fmt,
|
|
662
693
|
naming: { entry: getEntryNamingFormat(extension) },
|
|
663
694
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
664
695
|
plugins
|
|
665
696
|
});
|
|
666
|
-
const entryName = getEntryNameOnly(entry);
|
|
667
697
|
if (!result.success) {
|
|
668
698
|
result.logs.forEach((log) => {
|
|
669
699
|
if (log.level === "error") logger.error(log.message);
|
|
@@ -674,7 +704,7 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
674
704
|
}
|
|
675
705
|
logger.progress(
|
|
676
706
|
getLoggerProgressLabel(fmt, options.name),
|
|
677
|
-
`${options.outDir}/${
|
|
707
|
+
`${options.outDir}/${entry.name}${extension}`
|
|
678
708
|
);
|
|
679
709
|
}
|
|
680
710
|
|
|
@@ -779,8 +809,9 @@ function parseCliOptions(argv) {
|
|
|
779
809
|
})();
|
|
780
810
|
async function watch(options, rootDir) {
|
|
781
811
|
const watchPaths = /* @__PURE__ */ new Set();
|
|
782
|
-
options.entry
|
|
783
|
-
|
|
812
|
+
const normalizedEntry = normalizeEntryToProcessableEntries(options.entry);
|
|
813
|
+
normalizedEntry.forEach((entry) => {
|
|
814
|
+
const entryPath = path2.resolve(rootDir, entry.path);
|
|
784
815
|
const parentDir = path2.dirname(entryPath);
|
|
785
816
|
watchPaths.add(parentDir);
|
|
786
817
|
});
|
package/build/dtsWorker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var h=require('path'),y=require('fs'),
|
|
1
|
+
'use strict';var h=require('path'),y=require('fs'),I=require('oxc-transform'),rollup=require('rollup'),N=require('rollup-plugin-dts');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var h__default=/*#__PURE__*/_interopDefault(h);var y__default=/*#__PURE__*/_interopDefault(y);var I__default=/*#__PURE__*/_interopDefault(I);var N__default=/*#__PURE__*/_interopDefault(N);var f=r=>r instanceof Error?r.message:String(r);function w(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b(r,t){switch(r){case "esm":return ".d.mts";case "cjs":return j(t)?".d.cts":".d.ts";case "iife":return ".d.ts"}}function j(r){return r==="module"}function $(r){return r?Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})])):[]}function D(r){return r.map(t=>typeof t=="string"?new RegExp(`^${w(t)}($|\\/|\\\\)`):t)}function v(r,t){return D(r.external||[]).concat($(t).map(e=>new RegExp(`^${w(e)}($|\\/|\\\\)`)))}function P(r){return D(r.noExternal||[])}var p={MAX_LABEL_LENGTH:5,colors:{cli:"183",info:"240",warn:"221",error:"203",progress:{ESM:"214",CJS:"114",IIFE:"105",DTS:"75"},default:"255"},labels:{cli:"BUNUP",info:"INFO",warn:"WARN",error:"ERROR"},formatMessage(r,t,e){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length));return `\x1B[38;5;${r}m[${t}]\x1B[0m ${s}${e}`},cli(r){let t=this.labels.cli;console.log(this.formatMessage(this.colors.cli,t,r));},info(r){let t=this.labels.info;console.log(this.formatMessage(this.colors.info,t,r));},warn(r){let t=this.labels.warn;console.warn(this.formatMessage(this.colors.warn,t,r));},error(r){let t=this.labels.error;console.error(this.formatMessage(this.colors.error,t,r));},progress(r,t){let e=String(r),s=this.colors.default;for(let[n,o]of Object.entries(this.colors.progress))if(e.includes(n)){s=o;break}console.log(this.formatMessage(s,e,t));}};function S(r,t){return `${t?`${t.replace(/-/g,"_")}_`:""}${r}`.toUpperCase()}function R(r){let t=h__default.default.join(r,"package.json");try{if(!y__default.default.existsSync(t))return null;let e=y__default.default.readFileSync(t,"utf8");return JSON.parse(e)}catch(e){return p.error(`Failed to load package.json at ${t}: ${f(e)}`),null}}async function M(r,t,e,s){let{absoluteRootDir:n,absoluteEntry:o}=q(r,t),i=await L(o),a=await U(i);return J(o,a,e,s,n)}async function L(r){let t=new Set,e=[r];for(;e.length>0;){let s=e.pop();if(!(!s||t.has(s))){t.add(s);try{let n=await y__default.default.promises.readFile(s,"utf8"),o=_(n);for(let i of o){let a=h__default.default.dirname(s),c=h__default.default.resolve(a,i),m=[c,`${c}.ts`,`${c}.tsx`,`${c}/index.ts`,`${c}/index.tsx`];for(let g of m)if(y__default.default.existsSync(g)&&g.endsWith(".ts")&&!t.has(g)){e.push(g);break}}}catch(n){p.warn(`Error processing ${s}: ${n instanceof Error?n.message:String(n)}`);}}}return t}function _(r){let t=new Set;try{let e=/(?:import|export)(?:(?:[\s\n]*(?:type[\s\n]+)?(?:\*|\{[^}]*\}|[\w$]+)[\s\n]+from[\s\n]*)|[\s\n]+)(["'`])([^'"]+)\1/g,s;for(;(s=e.exec(r))!==null;){let i=s[2];i.startsWith(".")&&t.add(i);}let n=/import\s+(["'`])([^'"]+)\1\s*;?/g;for(;(s=n.exec(r))!==null;){let i=s[2];i.startsWith(".")&&t.add(i);}let o=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;for(;(s=o.exec(r))!==null;){let i=s[2];i.startsWith(".")&&t.add(i);}}catch(e){p.warn(`Error extracting imports: ${e instanceof Error?e.message:String(e)}`);}return Array.from(t)}async function U(r){let t=new Map;return await Promise.all(Array.from(r).map(async e=>{try{let s=e.replace(/\.tsx?$/,".d.ts"),n=await y__default.default.promises.readFile(e,"utf8"),{code:o}=I__default.default.isolatedDeclaration(e,n);o&&t.set(s,o);}catch(s){p.warn(`Failed to generate declaration for ${e}: ${s instanceof Error?s.message:String(s)}`);}})),t}async function J(r,t,e,s,n){let o="\0virtual:",i=r.replace(/\.tsx?$/,".d.ts"),a=`${o}${i}`,c={name:"virtual-dts",resolveId(l,u){if(l.startsWith(o))return l;if(u?.startsWith(o)){let d=u.slice(o.length),B=h__default.default.dirname(d);if(l.startsWith(".")){let T=h__default.default.resolve(B,l);for(let F of ["",".d.ts","/index.d.ts"]){let k=`${T}${F}`;if(t.has(k))return `${o}${k}`}}}return null},load(l){if(l.startsWith(o)){let u=l.slice(o.length);return t.get(u)||null}return null}},m=R(n),g=v(s,m),E=P(s),x;try{x=await rollup.rollup({input:a,onwarn(u,d){u.code==="UNRESOLVED_IMPORT"||u.code==="CIRCULAR_DEPENDENCY"||u.code==="EMPTY_BUNDLE"||d(u);},plugins:[c,N__default.default()],external:u=>g.some(d=>d.test(u))&&!E.some(d=>d.test(u))});let{output:l}=await x.generate({format:e});if(!l[0]?.code)throw new Error("Generated bundle is empty");return l[0].code}catch(l){throw new Error(`DTS bundling failed: ${f(l)}`)}finally{x&&await x.close();}}function q(r,t){let e=h__default.default.resolve(r),s=h__default.default.resolve(e,t);if(!y__default.default.existsSync(e))throw new Error(`Root directory does not exist: ${e}`);if(!y__default.default.existsSync(s))throw new Error(`Entry file does not exist: ${s}`);if(!s.endsWith(".ts"))throw new Error(`Entry file must be a TypeScript file (.ts): ${s}`);if(h__default.default.relative(e,s).startsWith(".."))throw new Error(`Entry file must be within rootDir: ${s}`);return {absoluteRootDir:e,absoluteEntry:s}}self.onmessage=async r=>{let{name:t,rootDir:e,outDir:s,entry:n,format:o,packageType:i,options:a}=r.data;try{let c=await M(e,n.path,o,a),m=b(o,i),g=`${s}/${n.name}${m}`,E=`${e}/${g}`;await Bun.write(E,c);let x={name:t,success:!0,outputRelativePath:g};self.postMessage(x);}catch(c){let m={success:false,error:f(c)};self.postMessage(m);}};var O=class{constructor(t=navigator.hardwareConcurrency||4){this.workers=[];this.queue=[];this.busyWorkers=new Set;this.isShuttingDown=false;this.maxWorkers=t;}async process(t){if(this.isShuttingDown)throw new Error("Worker pool is shutting down");return new Promise((e,s)=>{this.queue.push({task:t,resolve:e,reject:s}),this.processQueue();})}processQueue(){if(!(this.queue.length===0||this.isShuttingDown))if(this.workers.length<this.maxWorkers){let t=new Worker(h__default.default.join(__dirname,"./dtsWorker.js"));this.workers.push(t),this.assignTaskToWorker(t);}else {let t=this.workers.find(e=>!this.busyWorkers.has(e));t&&this.assignTaskToWorker(t);}}assignTaskToWorker(t){let e=this.queue.shift();if(!e)return;let{task:s,resolve:n,reject:o}=e;this.busyWorkers.add(t);let i=()=>{this.busyWorkers.delete(t),this.isShuttingDown&&this.busyWorkers.size===0?this.terminateAllWorkers():this.processQueue();};t.onmessage=a=>{a.data.success?(p.progress(S("DTS",a.data.name),a.data.outputRelativePath),n()):(p.error(`DTS generation failed: ${a.data.error}`),o(new Error(a.data.error))),i();},t.onerror=a=>{let c=f(a);p.error(`Worker error: ${c}`),o(a),i();},t.postMessage(s);}terminateAllWorkers(){this.workers.forEach(t=>{try{t.terminate();}catch(e){p.error(`Error terminating worker: ${f(e)}`);}}),this.workers=[],this.busyWorkers.clear();}async cleanup(){if(this.isShuttingDown=true,this.busyWorkers.size===0){this.terminateAllWorkers();return}return new Promise(t=>{let e=setInterval(()=>{this.busyWorkers.size===0&&(clearInterval(e),this.terminateAllWorkers(),t());},100);setTimeout(()=>{clearInterval(e),this.terminateAllWorkers(),t();},5e3);})}};exports.DtsWorker=O;
|
package/build/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
3
3
|
type Format = 'esm' | 'cjs' | 'iife';
|
|
4
4
|
type Target = 'bun' | 'node' | 'browser';
|
|
5
5
|
type External = string[];
|
|
6
|
+
type Entry = string | Record<string, string>;
|
|
6
7
|
interface BunupOptions {
|
|
7
8
|
/**
|
|
8
9
|
* Name of the build configuration
|
|
@@ -13,7 +14,7 @@ interface BunupOptions {
|
|
|
13
14
|
* Entry point files for the build
|
|
14
15
|
* These are the files that will be processed and bundled
|
|
15
16
|
*/
|
|
16
|
-
entry:
|
|
17
|
+
entry: Entry[];
|
|
17
18
|
/**
|
|
18
19
|
* Output directory for the bundled files
|
|
19
20
|
* Defaults to 'dist' if not specified
|
package/build/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
3
3
|
type Format = 'esm' | 'cjs' | 'iife';
|
|
4
4
|
type Target = 'bun' | 'node' | 'browser';
|
|
5
5
|
type External = string[];
|
|
6
|
+
type Entry = string | Record<string, string>;
|
|
6
7
|
interface BunupOptions {
|
|
7
8
|
/**
|
|
8
9
|
* Name of the build configuration
|
|
@@ -13,7 +14,7 @@ interface BunupOptions {
|
|
|
13
14
|
* Entry point files for the build
|
|
14
15
|
* These are the files that will be processed and bundled
|
|
15
16
|
*/
|
|
16
|
-
entry:
|
|
17
|
+
entry: Entry[];
|
|
17
18
|
/**
|
|
18
19
|
* Output directory for the bundled files
|
|
19
20
|
* Defaults to 'dist' if not specified
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"tsup": "^8.0.2",
|
|
25
25
|
"typescript": "^5.4.3",
|
|
26
26
|
"vitest": "^2.0.5",
|
|
27
|
-
"bunup": "0.1.
|
|
27
|
+
"bunup": "0.1.5"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"typescript": ">=4.5.0"
|