bunup 0.1.5 → 0.1.6
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 +17 -15
- package/build/cli.mjs +17 -15
- package/build/dtsWorker.js +1 -1
- package/build/index.d.mts +47 -4
- package/build/index.d.ts +47 -4
- package/package.json +4 -4
package/build/cli.js
CHANGED
|
@@ -171,7 +171,6 @@ var DEFAULT_OPTIONS = {
|
|
|
171
171
|
};
|
|
172
172
|
function createDefaultBunBuildOptions(options, rootDir) {
|
|
173
173
|
return {
|
|
174
|
-
entrypoints: options.entry.map((e) => `${rootDir}/${e}`),
|
|
175
174
|
outdir: `${rootDir}/${options.outDir}`,
|
|
176
175
|
minify: createMinifyOptions(options),
|
|
177
176
|
target: options.target,
|
|
@@ -568,7 +567,7 @@ var DtsWorker = class {
|
|
|
568
567
|
function getEntryNameOnly(entry) {
|
|
569
568
|
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
570
569
|
}
|
|
571
|
-
function normalizeEntryToProcessableEntries(
|
|
570
|
+
function normalizeEntryToProcessableEntries(entry) {
|
|
572
571
|
const result = [];
|
|
573
572
|
const usedNames = /* @__PURE__ */ new Set();
|
|
574
573
|
function addEntry(name, path6) {
|
|
@@ -580,20 +579,20 @@ function normalizeEntryToProcessableEntries(entries) {
|
|
|
580
579
|
usedNames.add(name);
|
|
581
580
|
}
|
|
582
581
|
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
const name = getEntryNameOnly(
|
|
586
|
-
addEntry(name,
|
|
587
|
-
} else {
|
|
588
|
-
Object.entries(entry).forEach(([name, path6]) => {
|
|
589
|
-
addEntry(name, path6);
|
|
590
|
-
});
|
|
582
|
+
if (Array.isArray(entry)) {
|
|
583
|
+
for (const item of entry) {
|
|
584
|
+
const name = getEntryNameOnly(item);
|
|
585
|
+
addEntry(name, item);
|
|
591
586
|
}
|
|
587
|
+
} else {
|
|
588
|
+
Object.entries(entry).forEach(([name, path6]) => {
|
|
589
|
+
addEntry(name, path6);
|
|
590
|
+
});
|
|
592
591
|
}
|
|
593
592
|
return result;
|
|
594
593
|
}
|
|
595
|
-
function getEntryNamingFormat(extension) {
|
|
596
|
-
return `[dir]
|
|
594
|
+
function getEntryNamingFormat(name, extension) {
|
|
595
|
+
return `[dir]/${name}${extension}`;
|
|
597
596
|
}
|
|
598
597
|
|
|
599
598
|
// src/plugins/external.ts
|
|
@@ -654,10 +653,11 @@ async function build(options, rootDir) {
|
|
|
654
653
|
}
|
|
655
654
|
return true;
|
|
656
655
|
});
|
|
656
|
+
const dtsEntry = options.dts === true ? processableEntries : normalizeEntryToProcessableEntries(options.dts.entry);
|
|
657
657
|
const dtsWorker = new DtsWorker();
|
|
658
658
|
try {
|
|
659
659
|
const dtsPromises = formatsToProcess.flatMap(
|
|
660
|
-
(fmt) =>
|
|
660
|
+
(fmt) => dtsEntry.map(
|
|
661
661
|
(entry) => generateDtsForEntry(
|
|
662
662
|
options,
|
|
663
663
|
rootDir,
|
|
@@ -700,7 +700,7 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
700
700
|
...defaultBunBuildOptions,
|
|
701
701
|
entrypoints: [`${rootDir}/${entry.path}`],
|
|
702
702
|
format: fmt,
|
|
703
|
-
naming: { entry: getEntryNamingFormat(extension) },
|
|
703
|
+
naming: { entry: getEntryNamingFormat(entry.name, extension) },
|
|
704
704
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
705
705
|
plugins
|
|
706
706
|
});
|
|
@@ -802,7 +802,9 @@ function parseCliOptions(argv) {
|
|
|
802
802
|
if (!cliOptions.entry) {
|
|
803
803
|
cliOptions.entry = [];
|
|
804
804
|
}
|
|
805
|
-
cliOptions.entry
|
|
805
|
+
if (Array.isArray(cliOptions.entry)) {
|
|
806
|
+
cliOptions.entry.push(arg);
|
|
807
|
+
}
|
|
806
808
|
}
|
|
807
809
|
}
|
|
808
810
|
return cliOptions;
|
package/build/cli.mjs
CHANGED
|
@@ -161,7 +161,6 @@ var DEFAULT_OPTIONS = {
|
|
|
161
161
|
};
|
|
162
162
|
function createDefaultBunBuildOptions(options, rootDir) {
|
|
163
163
|
return {
|
|
164
|
-
entrypoints: options.entry.map((e) => `${rootDir}/${e}`),
|
|
165
164
|
outdir: `${rootDir}/${options.outDir}`,
|
|
166
165
|
minify: createMinifyOptions(options),
|
|
167
166
|
target: options.target,
|
|
@@ -558,7 +557,7 @@ var DtsWorker = class {
|
|
|
558
557
|
function getEntryNameOnly(entry) {
|
|
559
558
|
return entry.split("/").pop()?.split(".").slice(0, -1).join(".") || "";
|
|
560
559
|
}
|
|
561
|
-
function normalizeEntryToProcessableEntries(
|
|
560
|
+
function normalizeEntryToProcessableEntries(entry) {
|
|
562
561
|
const result = [];
|
|
563
562
|
const usedNames = /* @__PURE__ */ new Set();
|
|
564
563
|
function addEntry(name, path6) {
|
|
@@ -570,20 +569,20 @@ function normalizeEntryToProcessableEntries(entries) {
|
|
|
570
569
|
usedNames.add(name);
|
|
571
570
|
}
|
|
572
571
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
const name = getEntryNameOnly(
|
|
576
|
-
addEntry(name,
|
|
577
|
-
} else {
|
|
578
|
-
Object.entries(entry).forEach(([name, path6]) => {
|
|
579
|
-
addEntry(name, path6);
|
|
580
|
-
});
|
|
572
|
+
if (Array.isArray(entry)) {
|
|
573
|
+
for (const item of entry) {
|
|
574
|
+
const name = getEntryNameOnly(item);
|
|
575
|
+
addEntry(name, item);
|
|
581
576
|
}
|
|
577
|
+
} else {
|
|
578
|
+
Object.entries(entry).forEach(([name, path6]) => {
|
|
579
|
+
addEntry(name, path6);
|
|
580
|
+
});
|
|
582
581
|
}
|
|
583
582
|
return result;
|
|
584
583
|
}
|
|
585
|
-
function getEntryNamingFormat(extension) {
|
|
586
|
-
return `[dir]
|
|
584
|
+
function getEntryNamingFormat(name, extension) {
|
|
585
|
+
return `[dir]/${name}${extension}`;
|
|
587
586
|
}
|
|
588
587
|
|
|
589
588
|
// src/plugins/external.ts
|
|
@@ -644,10 +643,11 @@ async function build(options, rootDir) {
|
|
|
644
643
|
}
|
|
645
644
|
return true;
|
|
646
645
|
});
|
|
646
|
+
const dtsEntry = options.dts === true ? processableEntries : normalizeEntryToProcessableEntries(options.dts.entry);
|
|
647
647
|
const dtsWorker = new DtsWorker();
|
|
648
648
|
try {
|
|
649
649
|
const dtsPromises = formatsToProcess.flatMap(
|
|
650
|
-
(fmt) =>
|
|
650
|
+
(fmt) => dtsEntry.map(
|
|
651
651
|
(entry) => generateDtsForEntry(
|
|
652
652
|
options,
|
|
653
653
|
rootDir,
|
|
@@ -690,7 +690,7 @@ async function buildEntry(options, rootDir, entry, fmt, packageType, plugins) {
|
|
|
690
690
|
...defaultBunBuildOptions,
|
|
691
691
|
entrypoints: [`${rootDir}/${entry.path}`],
|
|
692
692
|
format: fmt,
|
|
693
|
-
naming: { entry: getEntryNamingFormat(extension) },
|
|
693
|
+
naming: { entry: getEntryNamingFormat(entry.name, extension) },
|
|
694
694
|
splitting: getResolvedSplitting(options.splitting, fmt),
|
|
695
695
|
plugins
|
|
696
696
|
});
|
|
@@ -792,7 +792,9 @@ function parseCliOptions(argv) {
|
|
|
792
792
|
if (!cliOptions.entry) {
|
|
793
793
|
cliOptions.entry = [];
|
|
794
794
|
}
|
|
795
|
-
cliOptions.entry
|
|
795
|
+
if (Array.isArray(cliOptions.entry)) {
|
|
796
|
+
cliOptions.entry.push(arg);
|
|
797
|
+
}
|
|
796
798
|
}
|
|
797
799
|
}
|
|
798
800
|
return cliOptions;
|
package/build/dtsWorker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 D(r){return r?Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})])):[]}function $(r){return r.map(t=>typeof t=="string"?new RegExp(`^${w(t)}($|\\/|\\\\)`):t)}function v(r,t){return $(r.external||[]).concat(D(t).map(e=>new RegExp(`^${w(e)}($|\\/|\\\\)`)))}function P(r){return $(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 o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length));return `\x1B[38;5;${r}m[${t}]\x1B[0m ${o}${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),o=this.colors.default;for(let[n,s]of Object.entries(this.colors.progress))if(e.includes(n)){o=s;break}console.log(this.formatMessage(o,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 O(r,t,e,o){let{absoluteRootDir:n,absoluteEntry:s}=q(r,t),i=await L(s),a=await U(i);return J(s,a,e,o,n)}async function L(r){let t=new Set,e=[r];for(;e.length>0;){let o=e.pop();if(!(!o||t.has(o))){t.add(o);try{let n=await y__default.default.promises.readFile(o,"utf8"),s=_(n);for(let i of s){let a=h__default.default.dirname(o),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 ${o}: ${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,o;for(;(o=e.exec(r))!==null;){let i=o[2];i.startsWith(".")&&t.add(i);}let n=/import\s+(["'`])([^'"]+)\1\s*;?/g;for(;(o=n.exec(r))!==null;){let i=o[2];i.startsWith(".")&&t.add(i);}let s=/import\s*\(\s*(["'`])([^'"]+)\1\s*\)/g;for(;(o=s.exec(r))!==null;){let i=o[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 o=e.replace(/\.tsx?$/,".d.ts"),n=await y__default.default.promises.readFile(e,"utf8"),{code:s}=I__default.default.isolatedDeclaration(e,n);s&&t.set(o,s);}catch(o){p.warn(`Failed to generate declaration for ${e}: ${o instanceof Error?o.message:String(o)}`);}})),t}async function J(r,t,e,o,n){let s="\0virtual:",i=r.replace(/\.tsx?$/,".d.ts"),a=`${s}${i}`,c={name:"virtual-dts",resolveId(l,u){if(l.startsWith(s))return l;if(u?.startsWith(s)){let d=u.slice(s.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 `${s}${k}`}}}return null},load(l){if(l.startsWith(s)){let u=l.slice(s.length);return t.get(u)||null}return null}},m=R(n),g=v(o,m),E=P(o),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),o=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(o))throw new Error(`Entry file does not exist: ${o}`);if(!o.endsWith(".ts"))throw new Error(`Entry file must be a TypeScript file (.ts): ${o}`);if(h__default.default.relative(e,o).startsWith(".."))throw new Error(`Entry file must be within rootDir: ${o}`);return {absoluteRootDir:e,absoluteEntry:o}}self.onmessage=async r=>{let{name:t,rootDir:e,outDir:o,entry:n,format:s,packageType:i,options:a}=r.data;try{let c=await O(e,n.path,s,a),m=b(s,i),g=`${o}/${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 M=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,o)=>{this.queue.push({task:t,resolve:e,reject:o}),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:o,resolve:n,reject:s}=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}`),s(new Error(a.data.error))),i();},t.onerror=a=>{let c=f(a);p.error(`Worker error: ${c}`),s(a),i();},t.postMessage(o);}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=M;
|
package/build/index.d.mts
CHANGED
|
@@ -3,7 +3,32 @@ 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
|
+
type Entry = string[] | Record<string, string>;
|
|
7
|
+
type DtsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Entry point files for TypeScript declaration file generation
|
|
10
|
+
*
|
|
11
|
+
* This can be:
|
|
12
|
+
* - An array of file paths
|
|
13
|
+
* - An object where keys are output names and values are input file paths
|
|
14
|
+
*
|
|
15
|
+
* The key names are used for the generated declaration files.
|
|
16
|
+
* For example, {custom: './src/index.ts'} will generate custom.d.ts
|
|
17
|
+
*
|
|
18
|
+
* If not specified, the main entry points will be used for declaration file generation.
|
|
19
|
+
*
|
|
20
|
+
* If a string path is provided in an array, the file name (without extension)
|
|
21
|
+
* will be used as the name for the output declaration file.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Using string paths in an array
|
|
25
|
+
* entry: ['./src/index.ts'] // Generates index.d.ts
|
|
26
|
+
*
|
|
27
|
+
* // Using named outputs as an object
|
|
28
|
+
* entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
29
|
+
*/
|
|
30
|
+
entry: Entry;
|
|
31
|
+
};
|
|
7
32
|
interface BunupOptions {
|
|
8
33
|
/**
|
|
9
34
|
* Name of the build configuration
|
|
@@ -12,9 +37,25 @@ interface BunupOptions {
|
|
|
12
37
|
name?: string;
|
|
13
38
|
/**
|
|
14
39
|
* Entry point files for the build
|
|
15
|
-
*
|
|
40
|
+
*
|
|
41
|
+
* This can be:
|
|
42
|
+
* - An array of file paths
|
|
43
|
+
* - An object where keys are output names and values are input file paths
|
|
44
|
+
*
|
|
45
|
+
* The key names are used for the generated output files.
|
|
46
|
+
* For example, {custom: './src/index.ts'} will generate custom.js
|
|
47
|
+
*
|
|
48
|
+
* If a string path is provided in an array, the file name (without extension)
|
|
49
|
+
* will be used as the name for the output file.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Using string paths in an array
|
|
53
|
+
* entry: ['./src/index.ts'] // Generates index.js
|
|
54
|
+
*
|
|
55
|
+
* // Using named outputs as an object
|
|
56
|
+
* entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.js and utils.js
|
|
16
57
|
*/
|
|
17
|
-
entry: Entry
|
|
58
|
+
entry: Entry;
|
|
18
59
|
/**
|
|
19
60
|
* Output directory for the bundled files
|
|
20
61
|
* Defaults to 'dist' if not specified
|
|
@@ -57,8 +98,10 @@ interface BunupOptions {
|
|
|
57
98
|
watch?: boolean;
|
|
58
99
|
/**
|
|
59
100
|
* Whether to generate TypeScript declaration files (.d.ts)
|
|
101
|
+
* When set to true, generates declaration files for all entry points
|
|
102
|
+
* Can also be configured with DtsOptions for more control
|
|
60
103
|
*/
|
|
61
|
-
dts?: boolean;
|
|
104
|
+
dts?: boolean | DtsOptions;
|
|
62
105
|
/**
|
|
63
106
|
* External packages that should not be bundled
|
|
64
107
|
* Useful for dependencies that should be kept as external imports
|
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,32 @@ 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
|
+
type Entry = string[] | Record<string, string>;
|
|
7
|
+
type DtsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Entry point files for TypeScript declaration file generation
|
|
10
|
+
*
|
|
11
|
+
* This can be:
|
|
12
|
+
* - An array of file paths
|
|
13
|
+
* - An object where keys are output names and values are input file paths
|
|
14
|
+
*
|
|
15
|
+
* The key names are used for the generated declaration files.
|
|
16
|
+
* For example, {custom: './src/index.ts'} will generate custom.d.ts
|
|
17
|
+
*
|
|
18
|
+
* If not specified, the main entry points will be used for declaration file generation.
|
|
19
|
+
*
|
|
20
|
+
* If a string path is provided in an array, the file name (without extension)
|
|
21
|
+
* will be used as the name for the output declaration file.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Using string paths in an array
|
|
25
|
+
* entry: ['./src/index.ts'] // Generates index.d.ts
|
|
26
|
+
*
|
|
27
|
+
* // Using named outputs as an object
|
|
28
|
+
* entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
|
|
29
|
+
*/
|
|
30
|
+
entry: Entry;
|
|
31
|
+
};
|
|
7
32
|
interface BunupOptions {
|
|
8
33
|
/**
|
|
9
34
|
* Name of the build configuration
|
|
@@ -12,9 +37,25 @@ interface BunupOptions {
|
|
|
12
37
|
name?: string;
|
|
13
38
|
/**
|
|
14
39
|
* Entry point files for the build
|
|
15
|
-
*
|
|
40
|
+
*
|
|
41
|
+
* This can be:
|
|
42
|
+
* - An array of file paths
|
|
43
|
+
* - An object where keys are output names and values are input file paths
|
|
44
|
+
*
|
|
45
|
+
* The key names are used for the generated output files.
|
|
46
|
+
* For example, {custom: './src/index.ts'} will generate custom.js
|
|
47
|
+
*
|
|
48
|
+
* If a string path is provided in an array, the file name (without extension)
|
|
49
|
+
* will be used as the name for the output file.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Using string paths in an array
|
|
53
|
+
* entry: ['./src/index.ts'] // Generates index.js
|
|
54
|
+
*
|
|
55
|
+
* // Using named outputs as an object
|
|
56
|
+
* entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.js and utils.js
|
|
16
57
|
*/
|
|
17
|
-
entry: Entry
|
|
58
|
+
entry: Entry;
|
|
18
59
|
/**
|
|
19
60
|
* Output directory for the bundled files
|
|
20
61
|
* Defaults to 'dist' if not specified
|
|
@@ -57,8 +98,10 @@ interface BunupOptions {
|
|
|
57
98
|
watch?: boolean;
|
|
58
99
|
/**
|
|
59
100
|
* Whether to generate TypeScript declaration files (.d.ts)
|
|
101
|
+
* When set to true, generates declaration files for all entry points
|
|
102
|
+
* Can also be configured with DtsOptions for more control
|
|
60
103
|
*/
|
|
61
|
-
dts?: boolean;
|
|
104
|
+
dts?: boolean | DtsOptions;
|
|
62
105
|
/**
|
|
63
106
|
* External packages that should not be bundled
|
|
64
107
|
* Useful for dependencies that should be kept as external imports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"@types/bun": "^1.2.5",
|
|
19
19
|
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
20
20
|
"bumpp": "^10.1.0",
|
|
21
|
+
"bunup": "^0.1.5",
|
|
21
22
|
"eslint": "^8.57.0",
|
|
22
23
|
"husky": "^9.1.6",
|
|
23
24
|
"prettier": "^3.2.5",
|
|
24
25
|
"tsup": "^8.0.2",
|
|
25
26
|
"typescript": "^5.4.3",
|
|
26
|
-
"vitest": "^2.0.5"
|
|
27
|
-
"bunup": "0.1.5"
|
|
27
|
+
"vitest": "^2.0.5"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"typescript": ">=4.5.0"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsup",
|
|
63
63
|
"dev": "tsup --watch",
|
|
64
|
-
"test-build": "
|
|
64
|
+
"test-build": "pnpm -C tests build",
|
|
65
65
|
"test": "vitest run",
|
|
66
66
|
"tsc": "tsc --noEmit",
|
|
67
67
|
"lint": "eslint src --fix",
|