bunup 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Arshad Yaseen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Bunup
2
+
3
+ # bunup
@@ -0,0 +1,3 @@
1
+ var c=n=>n instanceof Error?n.message:String(n),O=(n,t)=>{let e=c(n),s=t?`[${t}] `:"";console.error(`\x1B[31m[ERROR]\x1B[0m ${s}${e}`),process.env.NODE_ENV!=="production"&&n instanceof Error&&n.stack&&console.error("\x1B[2m"+n.stack.split(`
2
+ `).slice(1).join(`
3
+ `)+"\x1B[0m");};function b(n){console.log(`\x1B[32m[INFO]\x1B[0m ${n}`);}function m(n){console.warn(`\x1B[33m[WARN]\x1B[0m ${n}`);}function p(n){console.error(`\x1B[31m[ERROR]\x1B[0m ${n}`);}var l={entry:["src/index.ts"],format:["esm"],outdir:"dist",minify:false,minifyIdentifiers:false,minifySyntax:false,minifyWhitespace:false,watch:false,dts:false,external:[]},$=(n,t)=>({entrypoints:n.entry.map(e=>`${t}/${e}`),outdir:`${t}/${n.outdir}`,format:n.format[0],minify:d(n),external:n.external||["node_modules/*"]});function d(n){return {whitespace:n.minifyWhitespace!==void 0?n.minifyWhitespace:n.minify??false,identifiers:n.minifyIdentifiers!==void 0?n.minifyIdentifiers:n.minify??false,syntax:n.minifySyntax!==void 0?n.minifySyntax:n.minify??false}}function I(n){return n}var y=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"],g=["bunup.config"];async function D(n){let t=[],e=new Set;async function s(o){if(e.has(o))return;e.add(o);for(let x of g)for(let a of y){let r=`${o}/${x}${a}`;try{if(await Bun.file(r).exists()){let i;if(a===".json"||a===".jsonc"){let f=await Bun.file(r).text();i=JSON.parse(f);}else {let f=await import(r);i=f.default||f,i||(m(`No default export found in ${r}`),i={});}t.unshift({options:{...l,...i},rootDir:o});}}catch(i){p(`Failed to load config from ${r}: ${c(i)}`);}}let u=o.split("/").slice(0,-1).join("/")||"/";u!==o&&await s(u);}return await s(n),t}export{b as a,p as b,l as c,$ as d,O as e,I as f,D as g};
package/build/cli.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bun
2
+ 'use strict';function u(t){console.log(`\x1B[32m[INFO]\x1B[0m ${t}`);}function x(t){console.warn(`\x1B[33m[WARN]\x1B[0m ${t}`);}function l(t){console.error(`\x1B[31m[ERROR]\x1B[0m ${t}`);}var m={entry:["src/index.ts"],format:["esm"],outdir:"dist",minify:false,minifyIdentifiers:false,minifySyntax:false,minifyWhitespace:false,watch:false,dts:false,external:[]},O=(t,n)=>({entrypoints:t.entry.map(e=>`${n}/${e}`),outdir:`${n}/${t.outdir}`,format:t.format[0],minify:$(t),external:t.external||["node_modules/*"]});function $(t){return {whitespace:t.minifyWhitespace!==void 0?t.minifyWhitespace:t.minify??false,identifiers:t.minifyIdentifiers!==void 0?t.minifyIdentifiers:t.minify??false,syntax:t.minifySyntax!==void 0?t.minifySyntax:t.minify??false}}async function d(t,n,e=false){let i=O(t,n);if(e)u(`Watching ${n}...`),Bun.spawn(["bun","build",...i.entrypoints||[],"--outdir",i.outdir||"","--watch"],{stdout:"inherit",stderr:"inherit"});else {for(let o of t.format){let r=await Bun.build({...i,format:o});r.success||(l("Build failed:"),r.logs.forEach(s=>console.error(s)),process.exit(1));}t.dts&&(u("Generating .d.ts files..."),await Bun.spawn(["tsc","--emitDeclarationOnly","--outDir",`${n}/${t.outdir}`]).exited),u(`Built to ${t.outdir}`);}}var E={f:"format",o:"outdir",m:"minify",w:"watch",d:"dts",e:"external",mw:"minifyWhitespace",mi:"minifyIdentifiers",ms:"minifySyntax"},T={format:(t,n)=>{n.format=t.split(",");},outdir:(t,n)=>{n.outdir=t;},minify:(t,n)=>{n.minify=!!t;},watch:(t,n)=>{n.watch=!!t;},dts:(t,n)=>{n.dts=!!t;},external:(t,n)=>{n.external=t.split(",");},minifyWhitespace:(t,n)=>{n.minifyWhitespace=!!t;},minifyIdentifiers:(t,n)=>{n.minifyIdentifiers=!!t;},minifySyntax:(t,n)=>{n.minifySyntax=!!t;}};function h(t){let n={entry:[]};for(let e=0;e<t.length;e++){let i=t[e];if(i.startsWith("--")||i.startsWith("-")){let o=i.startsWith("-")&&!i.startsWith("--"),r=o?i.slice(1):i.slice(2),s=o?E[r]:r,c=T[s];if(!c){l(`Unknown option: ${r}`);continue}let f=t[e+1],a=f&&!f.startsWith("-")?f:true;c(a,n),typeof a=="string"&&e++;}else n.entry.push(i);}return n}var g=t=>t instanceof Error?t.message:String(t),B=(t,n)=>{let e=g(t),i="";console.error(`\x1B[31m[ERROR]\x1B[0m ${i}${e}`),process.env.NODE_ENV!=="production"&&t instanceof Error&&t.stack&&console.error("\x1B[2m"+t.stack.split(`
3
+ `).slice(1).join(`
4
+ `)+"\x1B[0m");};var W=[".ts",".js",".mjs",".cjs",".mts",".cts",".json",".jsonc"],j=["bunup.config"];async function b(t){let n=[],e=new Set;async function i(o){if(e.has(o))return;e.add(o);for(let s of j)for(let c of W){let f=`${o}/${s}${c}`;try{if(await Bun.file(f).exists()){let a;if(c===".json"||c===".jsonc"){let p=await Bun.file(f).text();a=JSON.parse(p);}else {let p=await import(f);a=p.default||p,a||(x(`No default export found in ${f}`),a={});}n.unshift({options:{...m,...a},rootDir:o});}}catch(a){l(`Failed to load config from ${f}: ${g(a)}`);}}let r=o.split("/").slice(0,-1).join("/")||"/";r!==o&&await i(r);}return await i(t),n}function y(t,...n){if(!n.length)return t;let e={...t};for(let i of n)if(!(!i||typeof i!="object")){for(let o in i)if(Object.prototype.hasOwnProperty.call(i,o)){let r=e[o],s=i[o];if(s&&typeof s=="object"&&!Array.isArray(s)&&r&&typeof r=="object"&&!Array.isArray(r))e[o]=y(r,s);else if(Array.isArray(s)){let c=Array.isArray(r)?r:[],f=[...c];for(let a of s)c.some(p=>JSON.stringify(p)===JSON.stringify(a))||f.push(a);e[o]=f;}else e[o]=s;}}return e}async function w(t=Bun.argv.slice(2)){let n=h(t),e=await b(process.cwd());if(u(`Running bunup with Bun v${Bun.version}`),e.length===0)await d(y(m,n),process.cwd(),n.watch);else for(let{options:i,rootDir:o}of e){let r=y(m,n,i);console.log(r),await d(r,o,r.watch);}}typeof Bun>"u"&&(console.error(`Bunup requires Bun to run.
5
+ To install Bun, visit https://bun.sh/docs/installation`),process.exit(1));w().catch(t=>{B(t),process.exit(1);});
package/build/cli.mjs ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+ import {e,g,a,b as b$1,d,c}from'./chunk-4DGR6V7O.mjs';async function y(t,i,n=false){let e=d(t,i);if(n)a(`Watching ${i}...`),Bun.spawn(["bun","build",...e.entrypoints||[],"--outdir",e.outdir||"","--watch"],{stdout:"inherit",stderr:"inherit"});else {for(let r of t.format){let o=await Bun.build({...e,format:r});o.success||(b$1("Build failed:"),o.logs.forEach(s=>console.error(s)),process.exit(1));}t.dts&&(a("Generating .d.ts files..."),await Bun.spawn(["tsc","--emitDeclarationOnly","--outDir",`${i}/${t.outdir}`]).exited),a(`Built to ${t.outdir}`);}}var w={f:"format",o:"outdir",m:"minify",w:"watch",d:"dts",e:"external",mw:"minifyWhitespace",mi:"minifyIdentifiers",ms:"minifySyntax"},x={format:(t,i)=>{i.format=t.split(",");},outdir:(t,i)=>{i.outdir=t;},minify:(t,i)=>{i.minify=!!t;},watch:(t,i)=>{i.watch=!!t;},dts:(t,i)=>{i.dts=!!t;},external:(t,i)=>{i.external=t.split(",");},minifyWhitespace:(t,i)=>{i.minifyWhitespace=!!t;},minifyIdentifiers:(t,i)=>{i.minifyIdentifiers=!!t;},minifySyntax:(t,i)=>{i.minifySyntax=!!t;}};function O(t){let i={entry:[]};for(let n=0;n<t.length;n++){let e=t[n];if(e.startsWith("--")||e.startsWith("-")){let r=e.startsWith("-")&&!e.startsWith("--"),o=r?e.slice(1):e.slice(2),s=r?w[o]:o,c=x[s];if(!c){b$1(`Unknown option: ${o}`);continue}let a=t[n+1],f=a&&!a.startsWith("-")?a:true;c(f,i),typeof f=="string"&&n++;}else i.entry.push(e);}return i}function u(t,...i){if(!i.length)return t;let n={...t};for(let e of i)if(!(!e||typeof e!="object")){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let o=n[r],s=e[r];if(s&&typeof s=="object"&&!Array.isArray(s)&&o&&typeof o=="object"&&!Array.isArray(o))n[r]=u(o,s);else if(Array.isArray(s)){let c=Array.isArray(o)?o:[],a=[...c];for(let f of s)c.some(B=>JSON.stringify(B)===JSON.stringify(f))||a.push(f);n[r]=a;}else n[r]=s;}}return n}async function b(t=Bun.argv.slice(2)){let i=O(t),n=await g(process.cwd());if(a(`Running bunup with Bun v${Bun.version}`),n.length===0)await y(u(c,i),process.cwd(),i.watch);else for(let{options:e,rootDir:r}of n){let o=u(c,i,e);console.log(o),await y(o,r,o.watch);}}typeof Bun>"u"&&(console.error(`Bunup requires Bun to run.
3
+ To install Bun, visit https://bun.sh/docs/installation`),process.exit(1));b().catch(t=>{e(t),process.exit(1);});
@@ -0,0 +1,17 @@
1
+ type Format = 'esm' | 'cjs' | 'iife';
2
+ interface BunupOptions {
3
+ entry: string[];
4
+ format: Format[];
5
+ outdir: string;
6
+ minify?: boolean;
7
+ minifyWhitespace?: boolean;
8
+ minifyIdentifiers?: boolean;
9
+ minifySyntax?: boolean;
10
+ watch?: boolean;
11
+ dts?: boolean;
12
+ external?: string[];
13
+ }
14
+
15
+ declare function defineConfig(options: BunupOptions): BunupOptions;
16
+
17
+ export { defineConfig };
@@ -0,0 +1,17 @@
1
+ type Format = 'esm' | 'cjs' | 'iife';
2
+ interface BunupOptions {
3
+ entry: string[];
4
+ format: Format[];
5
+ outdir: string;
6
+ minify?: boolean;
7
+ minifyWhitespace?: boolean;
8
+ minifyIdentifiers?: boolean;
9
+ minifySyntax?: boolean;
10
+ watch?: boolean;
11
+ dts?: boolean;
12
+ external?: string[];
13
+ }
14
+
15
+ declare function defineConfig(options: BunupOptions): BunupOptions;
16
+
17
+ export { defineConfig };
package/build/index.js ADDED
@@ -0,0 +1 @@
1
+ 'use strict';function t(n){return n}exports.defineConfig=t;
@@ -0,0 +1 @@
1
+ export{f as defineConfig}from'./chunk-4DGR6V7O.mjs';
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "bunup",
3
+ "version": "0.1.0",
4
+ "description": "A extremely fast, zero-config bundler for TypeScript & JavaScript, powered by Bun.",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "module": "./build/index.mjs",
8
+ "files": [
9
+ "build"
10
+ ],
11
+ "bin": {
12
+ "bunup": "build/cli.js"
13
+ },
14
+ "devDependencies": {
15
+ "@commitlint/cli": "^19.5.0",
16
+ "@commitlint/config-conventional": "^19.5.0",
17
+ "@ianvs/prettier-plugin-sort-imports": "^4.2.1",
18
+ "@types/bun": "^1.2.5",
19
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
20
+ "bumpp": "^10.1.0",
21
+ "eslint": "^8.57.0",
22
+ "husky": "^9.1.6",
23
+ "prettier": "^3.2.5",
24
+ "tsup": "^8.0.2",
25
+ "typescript": "^5.4.3",
26
+ "vitest": "^2.0.5",
27
+ "bunup": "0.1.0"
28
+ },
29
+ "keywords": [
30
+ "bun",
31
+ "bunup",
32
+ "bun-bundler"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/arshad-yaseen/bunup.git"
37
+ },
38
+ "maintainers": [
39
+ {
40
+ "name": "Arshad Yaseen",
41
+ "email": "m@arshadyaseen.com",
42
+ "url": "https://arshadyaseen.com"
43
+ }
44
+ ],
45
+ "license": "MIT",
46
+ "author": "Arshad Yaseen <m@arshadyaseen.com> (https://arshadyaseen.com)",
47
+ "scripts": {
48
+ "build": "tsup",
49
+ "dev": "bunup --watch",
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
52
+ "tsc": "tsc --noEmit",
53
+ "lint": "eslint . --ext .ts,.tsx --fix",
54
+ "validate": "pnpm build && pnpm format && pnpm tsc && pnpm lint",
55
+ "format": "prettier --write ."
56
+ }
57
+ }