bunup 0.1.6 → 0.1.9

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 +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 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;
1
+ var C=require("node:module");var v=Object.create;var{getPrototypeOf:b,defineProperty:n,getOwnPropertyNames:u,getOwnPropertyDescriptor:E}=Object,h=Object.prototype.hasOwnProperty;var w=(r,e,s)=>{s=r!=null?v(b(r)):{};let o=e||!r||!r.__esModule?n(s,"default",{value:r,enumerable:!0}):s;for(let t of u(r))if(!h.call(o,t))n(o,t,{get:()=>r[t],enumerable:!0});return o},g=new WeakMap,y=(r)=>{var e=g.get(r),s;if(e)return e;if(e=n({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")u(r).map((o)=>!h.call(e,o)&&n(e,o,{get:()=>r[o],enumerable:!(s=E(r,o))||s.enumerable}));return g.set(r,e),e};var D=(r,e)=>{for(var s in e)n(r,s,{get:e[s],enumerable:!0,configurable:!0,set:(o)=>e[s]=()=>o})};var M={};D(M,{DtsWorker:()=>d});module.exports=y(M);var m=require("node:os"),f=w(require("node:path")),k=require("node:worker_threads");var c=(r)=>{if(r instanceof Error)return r.message;return String(r)};var a={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,e,s){let o=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-e.length));return`\x1B[38;5;${r}m[${e}]\x1B[0m ${o}${s}`},cli(r){let e=this.labels.cli;console.log(this.formatMessage(this.colors.cli,e,r))},info(r){let e=this.labels.info;console.log(this.formatMessage(this.colors.info,e,r))},warn(r){let e=this.labels.warn;console.warn(this.formatMessage(this.colors.warn,e,r))},error(r){let e=this.labels.error;console.error(this.formatMessage(this.colors.error,e,r))},progress(r,e){let s=String(r),o=this.colors.default;for(let[t,l]of Object.entries(this.colors.progress))if(s.includes(t)){o=l;break}console.log(this.formatMessage(o,s,e))}};function p(r,e){return`${e?`${e.replace(/-/g,"_")}_`:""}${r}`.toUpperCase()}var __dirname="/home/runner/work/bunup/bunup/src/dts";class d{workers=[];queue=[];maxWorkers;busyWorkers=new Set;isShuttingDown=!1;constructor(r=m.cpus().length||4){this.maxWorkers=r}async process(r){if(this.isShuttingDown)throw new Error("Worker pool is shutting down");return new Promise((e,s)=>{this.queue.push({task:r,resolve:e,reject:s}),this.processQueue()})}processQueue(){if(this.queue.length===0||this.isShuttingDown)return;if(this.workers.length<this.maxWorkers){let r=new k.Worker(f.default.join(__dirname,"./dtsWorker.js"));this.workers.push(r),this.assignTaskToWorker(r)}else{let r=this.workers.find((e)=>!this.busyWorkers.has(e));if(r)this.assignTaskToWorker(r)}}assignTaskToWorker(r){let e=this.queue.shift();if(!e)return;let{task:s,resolve:o,reject:t}=e;this.busyWorkers.add(r);let l=()=>{if(this.busyWorkers.delete(r),this.isShuttingDown&&this.busyWorkers.size===0)this.terminateAllWorkers();else this.processQueue()};r.on("message",(i)=>{if(i.success)a.progress(p("DTS",i.name),i.outputRelativePath),o();else a.error(`DTS generation failed: ${i.error}`),t(new Error(i.error));l()}),r.on("error",(i)=>{let W=c(i);a.error(`Worker error: ${W}`),t(i),l()}),r.postMessage(s)}terminateAllWorkers(){this.workers.forEach((r)=>{try{r.terminate()}catch(e){a.error(`Error terminating worker: ${c(e)}`)}}),this.workers=[],this.busyWorkers.clear()}async cleanup(){if(this.isShuttingDown=!0,this.busyWorkers.size===0){this.terminateAllWorkers();return}return new Promise((r)=>{let e=setInterval(()=>{if(this.busyWorkers.size===0)clearInterval(e),this.terminateAllWorkers(),r()},100);setTimeout(()=>{clearInterval(e),this.terminateAllWorkers(),r()},5000)})}}
package/build/index.d.mts CHANGED
@@ -1,132 +1,146 @@
1
- type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
1
+ type WithOptional<
2
+ T,
3
+ K extends keyof T
4
+ > = Omit<T, K> & Partial<Pick<T, K>>;
2
5
 
3
- type Format = 'esm' | 'cjs' | 'iife';
4
- type Target = 'bun' | 'node' | 'browser';
6
+ type Format = "esm" | "cjs" | "iife";
7
+ type Target = "bun" | "node" | "browser";
5
8
  type External = string[];
6
9
  type Entry = string[] | Record<string, string>;
7
10
  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;
11
+ /**
12
+ * Entry point files for TypeScript declaration file generation
13
+ *
14
+ * This can be:
15
+ * - An array of file paths
16
+ * - An object where keys are output names and values are input file paths
17
+ *
18
+ * The key names are used for the generated declaration files.
19
+ * For example, {custom: './src/index.ts'} will generate custom.d.ts
20
+ *
21
+ * If not specified, the main entry points will be used for declaration file generation.
22
+ *
23
+ * If a string path is provided in an array, the file name (without extension)
24
+ * will be used as the name for the output declaration file.
25
+ *
26
+ * @example
27
+ * // Using string paths in an array
28
+ * entry: ['./src/index.ts'] // Generates index.d.ts
29
+ *
30
+ * // Using named outputs as an object
31
+ * entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
32
+ */
33
+ entry: Entry
34
+ /**
35
+ * Path to a preferred tsconfig.json file to use for declaration generation
36
+ *
37
+ * If not specified, the tsconfig.json in the project root will be used.
38
+ * This option allows you to use a different TypeScript configuration
39
+ * specifically for declaration file generation.
40
+ *
41
+ * @example
42
+ * preferredTsconfigPath: './tsconfig.build.json'
43
+ */
44
+ preferredTsconfigPath?: string
31
45
  };
32
46
  interface BunupOptions {
33
- /**
34
- * Name of the build configuration
35
- * Used for logging and identification purposes
36
- */
37
- name?: string;
38
- /**
39
- * Entry point files for the build
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
57
- */
58
- entry: Entry;
59
- /**
60
- * Output directory for the bundled files
61
- * Defaults to 'dist' if not specified
62
- */
63
- outDir: string;
64
- /**
65
- * Output formats for the bundle
66
- * Can include 'esm', 'cjs', and/or 'iife'
67
- * Defaults to ['esm'] if not specified
68
- */
69
- format: Format[];
70
- /**
71
- * Whether to enable all minification options
72
- * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
73
- */
74
- minify?: boolean;
75
- /**
76
- * Whether to enable code splitting
77
- * Defaults to true for ESM format, false for CJS format
78
- */
79
- splitting?: boolean;
80
- /**
81
- * Whether to minify whitespace in the output
82
- * Removes unnecessary whitespace to reduce file size
83
- */
84
- minifyWhitespace?: boolean;
85
- /**
86
- * Whether to minify identifiers in the output
87
- * Renames variables and functions to shorter names
88
- */
89
- minifyIdentifiers?: boolean;
90
- /**
91
- * Whether to minify syntax in the output
92
- * Optimizes code structure for smaller file size
93
- */
94
- minifySyntax?: boolean;
95
- /**
96
- * Whether to watch for file changes and rebuild automatically
97
- */
98
- watch?: boolean;
99
- /**
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
103
- */
104
- dts?: boolean | DtsOptions;
105
- /**
106
- * External packages that should not be bundled
107
- * Useful for dependencies that should be kept as external imports
108
- */
109
- external?: External;
110
- /**
111
- * Packages that should be bundled even if they are in external
112
- * Useful for dependencies that should be included in the bundle
113
- */
114
- noExternal?: External;
115
- /**
116
- * The target environment for the bundle
117
- * Can be 'browser', 'bun', 'node', etc.
118
- * Defaults to 'node' if not specified
119
- */
120
- target?: Target;
121
- /**
122
- * Whether to clean the output directory before building
123
- * When true, removes all files in the outDir before starting a new build
124
- * Defaults to true if not specified
125
- */
126
- clean?: boolean;
47
+ /**
48
+ * Name of the build configuration
49
+ * Used for logging and identification purposes
50
+ */
51
+ name?: string;
52
+ /**
53
+ * Entry point files for the build
54
+ *
55
+ * This can be:
56
+ * - An array of file paths
57
+ * - An object where keys are output names and values are input file paths
58
+ *
59
+ * The key names are used for the generated output files.
60
+ * For example, {custom: './src/index.ts'} will generate custom.js
61
+ *
62
+ * If a string path is provided in an array, the file name (without extension)
63
+ * will be used as the name for the output file.
64
+ *
65
+ * @example
66
+ * // Using string paths in an array
67
+ * entry: ['./src/index.ts'] // Generates index.js
68
+ *
69
+ * // Using named outputs as an object
70
+ * entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.js and utils.js
71
+ */
72
+ entry: Entry;
73
+ /**
74
+ * Output directory for the bundled files
75
+ * Defaults to 'dist' if not specified
76
+ */
77
+ outDir: string;
78
+ /**
79
+ * Output formats for the bundle
80
+ * Can include 'esm', 'cjs', and/or 'iife'
81
+ * Defaults to ['esm'] if not specified
82
+ */
83
+ format: Format[];
84
+ /**
85
+ * Whether to enable all minification options
86
+ * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
87
+ */
88
+ minify?: boolean;
89
+ /**
90
+ * Whether to enable code splitting
91
+ * Defaults to true for ESM format, false for CJS format
92
+ */
93
+ splitting?: boolean;
94
+ /**
95
+ * Whether to minify whitespace in the output
96
+ * Removes unnecessary whitespace to reduce file size
97
+ */
98
+ minifyWhitespace?: boolean;
99
+ /**
100
+ * Whether to minify identifiers in the output
101
+ * Renames variables and functions to shorter names
102
+ */
103
+ minifyIdentifiers?: boolean;
104
+ /**
105
+ * Whether to minify syntax in the output
106
+ * Optimizes code structure for smaller file size
107
+ */
108
+ minifySyntax?: boolean;
109
+ /**
110
+ * Whether to watch for file changes and rebuild automatically
111
+ */
112
+ watch?: boolean;
113
+ /**
114
+ * Whether to generate TypeScript declaration files (.d.ts)
115
+ * When set to true, generates declaration files for all entry points
116
+ * Can also be configured with DtsOptions for more control
117
+ */
118
+ dts?: boolean | DtsOptions;
119
+ /**
120
+ * External packages that should not be bundled
121
+ * Useful for dependencies that should be kept as external imports
122
+ */
123
+ external?: External;
124
+ /**
125
+ * Packages that should be bundled even if they are in external
126
+ * Useful for dependencies that should be included in the bundle
127
+ */
128
+ noExternal?: External;
129
+ /**
130
+ * The target environment for the bundle
131
+ * Can be 'browser', 'bun', 'node', etc.
132
+ * Defaults to 'node' if not specified
133
+ */
134
+ target?: Target;
135
+ /**
136
+ * Whether to clean the output directory before building
137
+ * When true, removes all files in the outDir before starting a new build
138
+ * Defaults to true if not specified
139
+ */
140
+ clean?: boolean;
127
141
  }
128
142
 
129
- type DefineConfigOption = WithOptional<BunupOptions, 'outDir' | 'format'>;
143
+ type DefineConfigOption = WithOptional<BunupOptions, "outDir" | "format">;
130
144
  type DefineConfigOptions = DefineConfigOption | DefineConfigOption[];
131
145
  declare function defineConfig(options: DefineConfigOptions): DefineConfigOptions;
132
146
 
package/build/index.d.ts CHANGED
@@ -1,132 +1,146 @@
1
- type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
1
+ type WithOptional<
2
+ T,
3
+ K extends keyof T
4
+ > = Omit<T, K> & Partial<Pick<T, K>>;
2
5
 
3
- type Format = 'esm' | 'cjs' | 'iife';
4
- type Target = 'bun' | 'node' | 'browser';
6
+ type Format = "esm" | "cjs" | "iife";
7
+ type Target = "bun" | "node" | "browser";
5
8
  type External = string[];
6
9
  type Entry = string[] | Record<string, string>;
7
10
  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;
11
+ /**
12
+ * Entry point files for TypeScript declaration file generation
13
+ *
14
+ * This can be:
15
+ * - An array of file paths
16
+ * - An object where keys are output names and values are input file paths
17
+ *
18
+ * The key names are used for the generated declaration files.
19
+ * For example, {custom: './src/index.ts'} will generate custom.d.ts
20
+ *
21
+ * If not specified, the main entry points will be used for declaration file generation.
22
+ *
23
+ * If a string path is provided in an array, the file name (without extension)
24
+ * will be used as the name for the output declaration file.
25
+ *
26
+ * @example
27
+ * // Using string paths in an array
28
+ * entry: ['./src/index.ts'] // Generates index.d.ts
29
+ *
30
+ * // Using named outputs as an object
31
+ * entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
32
+ */
33
+ entry: Entry
34
+ /**
35
+ * Path to a preferred tsconfig.json file to use for declaration generation
36
+ *
37
+ * If not specified, the tsconfig.json in the project root will be used.
38
+ * This option allows you to use a different TypeScript configuration
39
+ * specifically for declaration file generation.
40
+ *
41
+ * @example
42
+ * preferredTsconfigPath: './tsconfig.build.json'
43
+ */
44
+ preferredTsconfigPath?: string
31
45
  };
32
46
  interface BunupOptions {
33
- /**
34
- * Name of the build configuration
35
- * Used for logging and identification purposes
36
- */
37
- name?: string;
38
- /**
39
- * Entry point files for the build
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
57
- */
58
- entry: Entry;
59
- /**
60
- * Output directory for the bundled files
61
- * Defaults to 'dist' if not specified
62
- */
63
- outDir: string;
64
- /**
65
- * Output formats for the bundle
66
- * Can include 'esm', 'cjs', and/or 'iife'
67
- * Defaults to ['esm'] if not specified
68
- */
69
- format: Format[];
70
- /**
71
- * Whether to enable all minification options
72
- * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
73
- */
74
- minify?: boolean;
75
- /**
76
- * Whether to enable code splitting
77
- * Defaults to true for ESM format, false for CJS format
78
- */
79
- splitting?: boolean;
80
- /**
81
- * Whether to minify whitespace in the output
82
- * Removes unnecessary whitespace to reduce file size
83
- */
84
- minifyWhitespace?: boolean;
85
- /**
86
- * Whether to minify identifiers in the output
87
- * Renames variables and functions to shorter names
88
- */
89
- minifyIdentifiers?: boolean;
90
- /**
91
- * Whether to minify syntax in the output
92
- * Optimizes code structure for smaller file size
93
- */
94
- minifySyntax?: boolean;
95
- /**
96
- * Whether to watch for file changes and rebuild automatically
97
- */
98
- watch?: boolean;
99
- /**
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
103
- */
104
- dts?: boolean | DtsOptions;
105
- /**
106
- * External packages that should not be bundled
107
- * Useful for dependencies that should be kept as external imports
108
- */
109
- external?: External;
110
- /**
111
- * Packages that should be bundled even if they are in external
112
- * Useful for dependencies that should be included in the bundle
113
- */
114
- noExternal?: External;
115
- /**
116
- * The target environment for the bundle
117
- * Can be 'browser', 'bun', 'node', etc.
118
- * Defaults to 'node' if not specified
119
- */
120
- target?: Target;
121
- /**
122
- * Whether to clean the output directory before building
123
- * When true, removes all files in the outDir before starting a new build
124
- * Defaults to true if not specified
125
- */
126
- clean?: boolean;
47
+ /**
48
+ * Name of the build configuration
49
+ * Used for logging and identification purposes
50
+ */
51
+ name?: string;
52
+ /**
53
+ * Entry point files for the build
54
+ *
55
+ * This can be:
56
+ * - An array of file paths
57
+ * - An object where keys are output names and values are input file paths
58
+ *
59
+ * The key names are used for the generated output files.
60
+ * For example, {custom: './src/index.ts'} will generate custom.js
61
+ *
62
+ * If a string path is provided in an array, the file name (without extension)
63
+ * will be used as the name for the output file.
64
+ *
65
+ * @example
66
+ * // Using string paths in an array
67
+ * entry: ['./src/index.ts'] // Generates index.js
68
+ *
69
+ * // Using named outputs as an object
70
+ * entry: { myModule: './src/index.ts', utils: './src/utility-functions.ts' } // Generates myModule.js and utils.js
71
+ */
72
+ entry: Entry;
73
+ /**
74
+ * Output directory for the bundled files
75
+ * Defaults to 'dist' if not specified
76
+ */
77
+ outDir: string;
78
+ /**
79
+ * Output formats for the bundle
80
+ * Can include 'esm', 'cjs', and/or 'iife'
81
+ * Defaults to ['esm'] if not specified
82
+ */
83
+ format: Format[];
84
+ /**
85
+ * Whether to enable all minification options
86
+ * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
87
+ */
88
+ minify?: boolean;
89
+ /**
90
+ * Whether to enable code splitting
91
+ * Defaults to true for ESM format, false for CJS format
92
+ */
93
+ splitting?: boolean;
94
+ /**
95
+ * Whether to minify whitespace in the output
96
+ * Removes unnecessary whitespace to reduce file size
97
+ */
98
+ minifyWhitespace?: boolean;
99
+ /**
100
+ * Whether to minify identifiers in the output
101
+ * Renames variables and functions to shorter names
102
+ */
103
+ minifyIdentifiers?: boolean;
104
+ /**
105
+ * Whether to minify syntax in the output
106
+ * Optimizes code structure for smaller file size
107
+ */
108
+ minifySyntax?: boolean;
109
+ /**
110
+ * Whether to watch for file changes and rebuild automatically
111
+ */
112
+ watch?: boolean;
113
+ /**
114
+ * Whether to generate TypeScript declaration files (.d.ts)
115
+ * When set to true, generates declaration files for all entry points
116
+ * Can also be configured with DtsOptions for more control
117
+ */
118
+ dts?: boolean | DtsOptions;
119
+ /**
120
+ * External packages that should not be bundled
121
+ * Useful for dependencies that should be kept as external imports
122
+ */
123
+ external?: External;
124
+ /**
125
+ * Packages that should be bundled even if they are in external
126
+ * Useful for dependencies that should be included in the bundle
127
+ */
128
+ noExternal?: External;
129
+ /**
130
+ * The target environment for the bundle
131
+ * Can be 'browser', 'bun', 'node', etc.
132
+ * Defaults to 'node' if not specified
133
+ */
134
+ target?: Target;
135
+ /**
136
+ * Whether to clean the output directory before building
137
+ * When true, removes all files in the outDir before starting a new build
138
+ * Defaults to true if not specified
139
+ */
140
+ clean?: boolean;
127
141
  }
128
142
 
129
- type DefineConfigOption = WithOptional<BunupOptions, 'outDir' | 'format'>;
143
+ type DefineConfigOption = WithOptional<BunupOptions, "outDir" | "format">;
130
144
  type DefineConfigOptions = DefineConfigOption | DefineConfigOption[];
131
145
  declare function defineConfig(options: DefineConfigOptions): DefineConfigOptions;
132
146
 
package/build/index.js CHANGED
@@ -1,8 +1 @@
1
- 'use strict';
2
-
3
- // src/define-config.ts
4
- function defineConfig(options) {
5
- return options;
6
- }
7
-
8
- exports.defineConfig = defineConfig;
1
+ var D=require("node:module");var{defineProperty:e,getOwnPropertyNames:r,getOwnPropertyDescriptor:O}=Object,g=Object.prototype.hasOwnProperty;var f=new WeakMap,C=(i)=>{var n=f.get(i),o;if(n)return n;if(n=e({},"__esModule",{value:!0}),i&&typeof i==="object"||typeof i==="function")r(i).map((t)=>!g.call(n,t)&&e(n,t,{get:()=>i[t],enumerable:!(o=O(i,t))||o.enumerable}));return f.set(i,n),n};var u=(i,n)=>{for(var o in n)e(i,o,{get:n[o],enumerable:!0,configurable:!0,set:(t)=>n[o]=()=>t})};var m={};u(m,{defineConfig:()=>p});module.exports=C(m);function p(i){return i}
package/build/index.mjs CHANGED
@@ -1,6 +1 @@
1
- // src/define-config.ts
2
- function defineConfig(options) {
3
- return options;
4
- }
5
-
6
- export { defineConfig };
1
+ function n(i){return i}export{n as defineConfig};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunup",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
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,11 +18,10 @@
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
+ "bunup": "^0.1.6",
22
22
  "eslint": "^8.57.0",
23
23
  "husky": "^9.1.6",
24
24
  "prettier": "^3.2.5",
25
- "tsup": "^8.0.2",
26
25
  "typescript": "^5.4.3",
27
26
  "vitest": "^2.0.5"
28
27
  },
@@ -59,8 +58,8 @@
59
58
  "rollup-plugin-dts": "^6.1.1"
60
59
  },
61
60
  "scripts": {
62
- "build": "tsup",
63
- "dev": "tsup --watch",
61
+ "build": "bunup",
62
+ "dev": "bunup --watch",
64
63
  "test-build": "pnpm -C tests build",
65
64
  "test": "vitest run",
66
65
  "tsc": "tsc --noEmit",