@visulima/packem 1.0.4 → 1.0.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/CHANGELOG.md +10 -0
- package/dist/cli.mjs +2 -2
- package/dist/create-bundler.cjs +1 -1
- package/dist/create-bundler.mjs +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/packem [1.0.5](https://github.com/visulima/packem/compare/@visulima/packem@1.0.4...@visulima/packem@1.0.5) (2024-09-29)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* fixed wrong entries finding if declaration are off, updated rollup to v4.22.5 and oxc-parser to 0.30.5 ([17e0ff5](https://github.com/visulima/packem/commit/17e0ff52bc6bc192387254dee26e8e9f0eeeaae0))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* updated dev dependencies ([cfbb2be](https://github.com/visulima/packem/commit/cfbb2beda943dccd4a1c9bce6d8ba15271096d29))
|
|
10
|
+
|
|
1
11
|
## @visulima/packem [1.0.4](https://github.com/visulima/packem/compare/@visulima/packem@1.0.3...@visulima/packem@1.0.4) (2024-09-26)
|
|
2
12
|
|
|
3
13
|
### Bug Fixes
|
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
|
5
5
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
7
7
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
8
|
-
const Zo="@visulima/packem",er="1.0.
|
|
8
|
+
const Zo="@visulima/packem",er="1.0.4",Ce=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".jsx"],C="production",Q="development",_e=new Set(["react-server","react-native","edge-light"]),pe=new Set([Q,C,..._e]),V=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,tr="packem_chunks",or="packem_shared",H=/\.(?:m|c)?(?:j|t)sx?$/;var rr=Object.defineProperty,nr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$g");const De=nr((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ir=Object.defineProperty,sr=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"a$f");const X=sr(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"a$e");const xt=lr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var cr=Object.defineProperty,Et=m((e,t)=>cr(e,"name",{value:t,configurable:!0}),"s$g");const pr=Et((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),ur=Et(e=>{const t=new Map;return o=>pr(e,o,t)},"memoizeByKey");var dr=Object.defineProperty,Z=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"r$f");const mr=Z(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ce(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of Io(t.id))yield o;break}}},"exportName"),fr=Z(function*(e){if(e.declaration)for(const t of mr(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),gr=Z(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),yr=Z(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),hr=Z(function*(e,t){ce(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*gr(r);break}case"ExportDefaultDeclaration":{yield*yr();break}case"ExportNamedDeclaration":{yield*fr(r);break}}},"parseExports");var vr=Object.defineProperty,ee=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"n$9");const Dt=ee(async function(e,t,o){const r=await e.resolve(t,o.id);if(ce(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ce(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),br=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);r&&(yield*Te(e,r))},"gatherBarrelReExports"),wr=ee(async function*(e,t,o){const r=await Dt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Te(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),$r=ee(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Te=ee(async function*(e,t){for(const o of hr(e,t))o.from==="self"?yield*$r(t,o):o.type==="barrel"?yield*br(e,o,t):yield*wr(e,o,t)},"gatherExports");var jr=Object.defineProperty,kr=m((e,t)=>jr(e,"name",{value:t,configurable:!0}),"r$e");const xr=kr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Te(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Er=Object.defineProperty,Dr=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"r$d");const Sr=Dr((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Or=Object.defineProperty,Nr=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"a$d");const St=Nr(e=>{const t=Sr(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new F(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
|
|
9
9
|
?`),""),n.append(`
|
|
10
10
|
|
|
11
11
|
export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Pr=Object.defineProperty,Ue=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"i$b");const Ot=Ue(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:Ue(async(r,n,i)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new F(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
@@ -69,7 +69,7 @@ ${s.chunks.map(c=>{const d=t.buildEntries.find(p=>p.path===c)??{};return I("
|
|
|
69
69
|
└─ `)+N(o(a.path))+" (total size: "+k(T(a.bytes??0))+")");s+=`
|
|
70
70
|
|
|
71
71
|
`,e.raw(s)}return r&&e.raw("Σ Total dist size (byte size):",k(T(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
|
|
72
|
-
`),r},"showSizeInformation"),ji=de((e,t)=>{const o=bi(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],y=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&y.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d}};r.push(re(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ki=de(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(ji(e,t)),e.logger.success(uo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of yo(b(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>b(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await ut($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),$i(e.logger,e)},"build");var xi=Object.defineProperty,Ei=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"r$5");const j=Ei((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Di=Object.defineProperty,Xt=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"t$4");const me=Xt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Xt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=me(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Oe(n,i,o,r)},"inferExportType");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"y$1");const Ni=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",..._e,...pe]),Me=Oi((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=me(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Oe(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")return[];const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Ni.has(l)?{subKey:l}:{},type:Oe(l,r,t,c)}):i=[...i,...Me({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Pi=Object.defineProperty,be=m((e,t)=>Pi(e,"name",{value:t,configurable:!0}),"c$3");const Ci=be((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===Q?Q:t,"getEnvironment"),ne=be((e,t,o,r,n,i,s)=>{const a=Ci(n,i.environment);let l="node";for(const p of _e)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(ft(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");pe.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let ot=!1;const rt=be(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),_i=be((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Me(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=me(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:me(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(rt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),ot=!0);const h=[],w=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(w.test(v)||pe.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)ne(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let y=t.find(h=>g.test(h));if(pe.has(a.subKey)&&y===void 0){const h=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>h.test(w))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&rt(o);const f=le(y.replace(J,""));S(f+".cts")&&S(f+".mts")?(ne(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),ne(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):ne(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var Ti=Object.defineProperty,Ii=m((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"o$3");const Mi=Ii((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Ai=Object.defineProperty,Ri=m((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"t$3");const Fi={hooks:{"build:prepare":Ri(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=Mi(r,e.options.declaration));const n=_i(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?N(i.fileAlias)+" => "+N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Ji=Object.defineProperty,Bi=m((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"t$2");const Li=Bi(async(e,t)=>{if(e==="auto")e=Fi;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Wi=Object.defineProperty,Vi=m((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"j");const zi=Vi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Ie(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Fo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Y(s),c=_n(l);let d=[];try{d=await Jo(s,{extensions:Ce})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(z(i),await Le("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";A(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((y,f)=>"import plugin"+f+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
72
|
+
`),r},"showSizeInformation"),ji=de((e,t)=>{const o=bi(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],y=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&y.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d}};r.push(re(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ki=de(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(ji(e,t)),e.logger.success(uo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of yo(b(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>b(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await ut($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),$i(e.logger,e)},"build");var xi=Object.defineProperty,Ei=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"r$5");const j=Ei((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Di=Object.defineProperty,Xt=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"t$4");const me=Xt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Xt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=me(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Oe(n,i,o,r)},"inferExportType");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"y$1");const Ni=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",..._e,...pe]),Me=Oi((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=me(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Oe(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Ni.has(l)?{subKey:l}:{},type:Oe(l,r,t,c)}):i=[...i,...Me({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Pi=Object.defineProperty,be=m((e,t)=>Pi(e,"name",{value:t,configurable:!0}),"c$3");const Ci=be((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===Q?Q:t,"getEnvironment"),ne=be((e,t,o,r,n,i,s)=>{const a=Ci(n,i.environment);let l="node";for(const p of _e)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(ft(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");pe.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let ot=!1;const rt=be(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),_i=be((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Me(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=me(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:me(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(rt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),ot=!0);const h=[],w=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(w.test(v)||pe.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)ne(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let y=t.find(h=>g.test(h));if(pe.has(a.subKey)&&y===void 0){const h=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>h.test(w))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&rt(o);const f=le(y.replace(J,""));S(f+".cts")&&S(f+".mts")?(ne(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),ne(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):ne(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var Ti=Object.defineProperty,Ii=m((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"o$3");const Mi=Ii((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Ai=Object.defineProperty,Ri=m((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"t$3");const Fi={hooks:{"build:prepare":Ri(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=Mi(r,e.options.declaration));const n=_i(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?N(i.fileAlias)+" => "+N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Ji=Object.defineProperty,Bi=m((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"t$2");const Li=Bi(async(e,t)=>{if(e==="auto")e=Fi;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Wi=Object.defineProperty,Vi=m((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"j");const zi=Vi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Ie(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Fo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Y(s),c=_n(l);let d=[];try{d=await Jo(s,{extensions:Ce})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(z(i),await Le("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";A(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((y,f)=>"import plugin"+f+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
73
73
|
export default _module;`:"",...d.filter(y=>y!=="default").map(y=>`export const ${y} = _module.${y};`)].join(`
|
|
74
74
|
`)),e.options.declaration&&A(`${i}.d.mts`,'export * from "'+g+`";
|
|
75
75
|
`+(p?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const u=O(z(i),await Le("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";A(`${i}.cjs`,c+['const { createJiti } = require("'+u+'");',...o.map((y,f)=>"const plugin"+f+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+s+'")'].join(`
|
package/dist/create-bundler.cjs
CHANGED
|
@@ -62,7 +62,7 @@ ${s.chunks.map(c=>{const d=t.buildEntries.find(p=>p.path===c)??{};return j.gray(
|
|
|
62
62
|
└─ `)+j.bold(o(a.path))+" (total size: "+j.cyan(P.formatBytes(a.bytes??0))+")");s+=`
|
|
63
63
|
|
|
64
64
|
`,e.raw(s)}return n&&e.raw("Σ Total dist size (byte size):",j.cyan(P.formatBytes(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
|
|
65
|
-
`),n},"showSizeInformation"),Cr=oe((e,t)=>{const o=Nr(e.options.entries,"environment","runtime"),n=[];for(const[r,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(r!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":j.cyan(r)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":j.cyan(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),r!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";r!=="undefined"&&(c+=r+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),r==="development"?d=!1:r==="production"&&(d=!0);const p=[],u=[],y=[],h=[];for(const g of a)g.cjs&&g.esm?p.push(g):g.cjs?y.push(g):g.esm?u.push(g):g.declaration&&h.push(g);if(p.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(u.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(y.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:y,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(l.options.declaration&&h.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:d}};n.push(H(g,t,c))}}return n.filter(Boolean)},"prepareRollupConfig"),Rr=oe(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(Cr(e,t)),e.logger.success(j.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of $.walk(f.join(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(r=>f.join(e.options.rootDir,e.options.outDir,r.path)===o.path);if(n||(n={chunk:!0,path:o.path},e.buildEntries.push(n)),!n.bytes){const r=await ie.stat(f.resolve(e.options.rootDir,e.options.outDir,o.path));n.bytes=r.size}}return await e.hooks.callHook("build:done",e),Pr(e.logger,e)},"build");var Tr=Object.defineProperty,Ar=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"r$4");const k=Ar((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ir=Object.defineProperty,wt=m((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$4");const ne=wt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ye=wt((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const s=ne(n);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...i]=t;return ye(r,i,o,n)},"inferExportType");var Mr=Object.defineProperty,Fr=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"y$1");const Jr=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...w.RUNTIME_EXPORT_CONVENTIONS,...w.SPECIAL_EXPORT_CONVENTIONS]),je=Fr((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ne(e);if(r&&r!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of r)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:ye(s,n,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")return[];const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Jr.has(l)?{subKey:l}:{},type:ye(l,n,t,c)}):i=[...i,...je({[d]:c},t,o,[...n,l])]}return i}return[]},"extractExportFilenames");var Lr=Object.defineProperty,le=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"c$3");const qr=le((e,t)=>e.key==="exports"&&e.subKey===w.PRODUCTION_ENV?w.PRODUCTION_ENV:e.key==="exports"&&e.subKey===w.DEVELOPMENT_ENV?w.DEVELOPMENT_ENV:t,"getEnvironment"),Y=le((e,t,o,n,r,i,s)=>{const a=qr(r,i.environment);let l="node";for(const p of w.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+p+".")||r.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&r.exportKey&&c.exportKey.add(r.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=n),r.isExecutable?(c.executable=!0,c.declaration=!1,r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0));const d=r.file.replace(f.extname(r.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");w.SPECIAL_EXPORT_CONVENTIONS.has(r.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let Ie=!1;const Me=le(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Br=le((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const i=je(e.exports,r,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ne(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&i.push({file:e.main,key:"main",type:ne(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Me(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ie||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ie=!0);const v=[],E=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const b of t)(E.test(b)||w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&x.test(b))&&v.push(b);if(v.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const b of v)Y(s,b,c,l,a,o,!0);continue}const y=new RegExp(p+d+u);let h=t.find(v=>y.test(v));if(w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&h===void 0){const v=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(E=>v.test(E))}if(h===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&$.isAccessibleSync(h)&&Me(o);const g=f.toNamespacedPath(h.replace(w.ENDING_RE,""));$.isAccessibleSync(g+".cts")&&$.isAccessibleSync(g+".mts")?(Y(s,g+".cts",c,l,{...a,type:"cjs"},o,!1),Y(s,g+".mts",c,l,{...a,type:"esm"},o,!1)):Y(s,h,c,l,a,o,!1)}return{entries:s,warnings:n}},"inferEntries");var Wr=Object.defineProperty,Ur=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"o$2");const Vr=Ur((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var zr=Object.defineProperty,Gr=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"t$3");const Kr={hooks:{"build:prepare":Gr(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!V.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=Vr(n,e.options.declaration));const r=Br(n,o,e);for(const i of r.warnings)k(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j.cyan(e.options.entries.map(i=>i.fileAlias?j.bold(i.fileAlias)+" => "+j.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):j.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),j.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Xr=Object.defineProperty,Hr=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"t$2");const Yr=Hr(async(e,t)=>{if(e==="auto")e=Kr;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Qr=Object.defineProperty,Zr=m((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"j");const ei=Zr(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...be(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((r,i)=>{if(Array.isArray(r)){const[s,...a]=r;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(r),"plugin"+i}).join(",")+"]":"[]");for(const r of e.options.entries){const i=f.resolve(e.options.rootDir,e.options.outDir,r.name),s=L.fileURLToPath(e.jiti.esmResolve(r.input,{try:!0})??r.input),a=s.replace(w.ENDING_RE,""),l=$.readFileSync(s),c=Bn(l);let d=[];try{d=await L.resolveModuleExportNames(s,{extensions:w.DEFAULT_EXTENSIONS})}catch(u){k(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=f.relative(f.dirname(i),await L.resolvePath("jiti",{conditions:["node","import"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("create-bundler.cjs",document.baseURI).href})),y=a+".d.mts";$.writeFileSync(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((h,g)=>"import plugin"+g+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+y+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
65
|
+
`),n},"showSizeInformation"),Cr=oe((e,t)=>{const o=Nr(e.options.entries,"environment","runtime"),n=[];for(const[r,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(r!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":j.cyan(r)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":j.cyan(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),r!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";r!=="undefined"&&(c+=r+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),r==="development"?d=!1:r==="production"&&(d=!0);const p=[],u=[],y=[],h=[];for(const g of a)g.cjs&&g.esm?p.push(g):g.cjs?y.push(g):g.esm?u.push(g):g.declaration&&h.push(g);if(p.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(u.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(y.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:y,minify:d}};if(e.options.dtsOnly||n.push(fe(g,t,c)),e.options.declaration){const v=g.options.entries.filter(E=>E.declaration);v.length>0&&n.push(H({...g,options:{...g.options,entries:v}},t,c))}}if(l.options.declaration&&h.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:d}};n.push(H(g,t,c))}}return n.filter(Boolean)},"prepareRollupConfig"),Rr=oe(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(Cr(e,t)),e.logger.success(j.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of $.walk(f.join(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(r=>f.join(e.options.rootDir,e.options.outDir,r.path)===o.path);if(n||(n={chunk:!0,path:o.path},e.buildEntries.push(n)),!n.bytes){const r=await ie.stat(f.resolve(e.options.rootDir,e.options.outDir,o.path));n.bytes=r.size}}return await e.hooks.callHook("build:done",e),Pr(e.logger,e)},"build");var Tr=Object.defineProperty,Ar=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"r$4");const k=Ar((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ir=Object.defineProperty,wt=m((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$4");const ne=wt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ye=wt((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const s=ne(n);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...i]=t;return ye(r,i,o,n)},"inferExportType");var Mr=Object.defineProperty,Fr=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"y$1");const Jr=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...w.RUNTIME_EXPORT_CONVENTIONS,...w.SPECIAL_EXPORT_CONVENTIONS]),je=Fr((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ne(e);if(r&&r!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of r)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:ye(s,n,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Jr.has(l)?{subKey:l}:{},type:ye(l,n,t,c)}):i=[...i,...je({[d]:c},t,o,[...n,l])]}return i}return[]},"extractExportFilenames");var Lr=Object.defineProperty,le=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"c$3");const qr=le((e,t)=>e.key==="exports"&&e.subKey===w.PRODUCTION_ENV?w.PRODUCTION_ENV:e.key==="exports"&&e.subKey===w.DEVELOPMENT_ENV?w.DEVELOPMENT_ENV:t,"getEnvironment"),Y=le((e,t,o,n,r,i,s)=>{const a=qr(r,i.environment);let l="node";for(const p of w.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+p+".")||r.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&r.exportKey&&c.exportKey.add(r.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=n),r.isExecutable?(c.executable=!0,c.declaration=!1,r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),r.type==="cjs"?c.cjs=!0:r.type==="esm"&&(c.esm=!0));const d=r.file.replace(f.extname(r.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");w.SPECIAL_EXPORT_CONVENTIONS.has(r.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let Ie=!1;const Me=le(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Br=le((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const i=je(e.exports,r,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ne(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&i.push({file:e.main,key:"main",type:ne(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Me(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ie||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ie=!0);const v=[],E=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const b of t)(E.test(b)||w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&x.test(b))&&v.push(b);if(v.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const b of v)Y(s,b,c,l,a,o,!0);continue}const y=new RegExp(p+d+u);let h=t.find(v=>y.test(v));if(w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&h===void 0){const v=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(E=>v.test(E))}if(h===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&$.isAccessibleSync(h)&&Me(o);const g=f.toNamespacedPath(h.replace(w.ENDING_RE,""));$.isAccessibleSync(g+".cts")&&$.isAccessibleSync(g+".mts")?(Y(s,g+".cts",c,l,{...a,type:"cjs"},o,!1),Y(s,g+".mts",c,l,{...a,type:"esm"},o,!1)):Y(s,h,c,l,a,o,!1)}return{entries:s,warnings:n}},"inferEntries");var Wr=Object.defineProperty,Ur=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"o$2");const Vr=Ur((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var zr=Object.defineProperty,Gr=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"t$3");const Kr={hooks:{"build:prepare":Gr(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!V.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(n.publishConfig),n=Vr(n,e.options.declaration));const r=Br(n,o,e);for(const i of r.warnings)k(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j.cyan(e.options.entries.map(i=>i.fileAlias?j.bold(i.fileAlias)+" => "+j.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):j.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),j.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Xr=Object.defineProperty,Hr=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"t$2");const Yr=Hr(async(e,t)=>{if(e==="auto")e=Kr;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Qr=Object.defineProperty,Zr=m((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"j");const ei=Zr(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...be(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((r,i)=>{if(Array.isArray(r)){const[s,...a]=r;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(r),"plugin"+i}).join(",")+"]":"[]");for(const r of e.options.entries){const i=f.resolve(e.options.rootDir,e.options.outDir,r.name),s=L.fileURLToPath(e.jiti.esmResolve(r.input,{try:!0})??r.input),a=s.replace(w.ENDING_RE,""),l=$.readFileSync(s),c=Bn(l);let d=[];try{d=await L.resolveModuleExportNames(s,{extensions:w.DEFAULT_EXTENSIONS})}catch(u){k(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=f.relative(f.dirname(i),await L.resolvePath("jiti",{conditions:["node","import"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("create-bundler.cjs",document.baseURI).href})),y=a+".d.mts";$.writeFileSync(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((h,g)=>"import plugin"+g+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+n+");","",'/** @type {import("'+y+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
66
66
|
export default _module;`:"",...d.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
|
|
67
67
|
`)),e.options.declaration&&$.writeFileSync(`${i}.d.mts`,'export * from "'+y+`";
|
|
68
68
|
`+(p?'export { default } from "'+y+'";':""))}if(e.options.emitCJS){const u=f.relative(f.dirname(i),await L.resolvePath("jiti",{conditions:["node","require"],url:typeof document>"u"?require("url").pathToFileURL(__filename).href:J&&J.tagName.toUpperCase()==="SCRIPT"&&J.src||new URL("create-bundler.cjs",document.baseURI).href})),y=a+".d.cts";$.writeFileSync(`${i}.cjs`,c+['const { createJiti } = require("'+u+'");',...o.map((h,g)=>"const plugin"+g+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+n+");","",'/** @type {import("'+y+'")} */','module.exports = jiti("'+s+'")'].join(`
|
package/dist/create-bundler.mjs
CHANGED
|
@@ -68,7 +68,7 @@ ${s.chunks.map(c=>{const d=t.buildEntries.find(p=>p.path===c)??{};return A("
|
|
|
68
68
|
└─ `)+D(o(a.path))+" (total size: "+k(C(a.bytes??0))+")");s+=`
|
|
69
69
|
|
|
70
70
|
`,e.raw(s)}return r&&e.raw("Σ Total dist size (byte size):",k(C(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
|
|
71
|
-
`),r},"showSizeInformation"),si=ae((e,t)=>{const o=ri(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],h=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&h.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(l.options.declaration&&h.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:d}};r.push(ee(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ai=ae(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(si(e,t)),e.logger.success(Zt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of ro(w(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>w(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await tt($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),ii(e.logger,e)},"build");var li=Object.defineProperty,ci=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"r$4");const j=ci((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var pi=Object.defineProperty,Lt=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"t$4");const le=Lt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),we=Lt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=le(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return we(n,i,o,r)},"inferExportType");var ui=Object.defineProperty,di=m((e,t)=>ui(e,"name",{value:t,configurable:!0}),"y$1");const mi=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...dt,...ne]),Oe=di((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=le(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:we(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")return[];const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...mi.has(l)?{subKey:l}:{},type:we(l,r,t,c)}):i=[...i,...Oe({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var fi=Object.defineProperty,me=m((e,t)=>fi(e,"name",{value:t,configurable:!0}),"c$3");const gi=me((e,t)=>e.key==="exports"&&e.subKey===q?q:e.key==="exports"&&e.subKey===_e?_e:t,"getEnvironment"),te=me((e,t,o,r,n,i,s)=>{const a=gi(n,i.environment);let l="node";for(const p of dt)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(nt(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");ne.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let Ve=!1;const qe=me(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),hi=me((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Oe(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=le(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:le(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(qe(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ve||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ve=!0);const y=[],b=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(b.test(v)||ne.has(a.subKey)&&x.test(v))&&y.push(v);if(y.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of y)te(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let h=t.find(y=>g.test(y));if(ne.has(a.subKey)&&h===void 0){const y=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(b=>y.test(b))}if(h===void 0){P($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&P(h)&&qe(o);const f=re(h.replace(F,""));P(f+".cts")&&P(f+".mts")?(te(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),te(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):te(s,h,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var yi=Object.defineProperty,vi=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"o$2");const bi=vi((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var wi=Object.defineProperty,$i=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"t$3");const ji={hooks:{"build:prepare":$i(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!et(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=no(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=bi(r,e.options.declaration));const n=hi(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?D(i.fileAlias)+" => "+D(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):D(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),A([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var ki=Object.defineProperty,xi=m((e,t)=>ki(e,"name",{value:t,configurable:!0}),"t$2");const Ei=xi(async(e,t)=>{if(e==="auto")e=ji;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"j");const Di=Oi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Se(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Do(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(F,""),l=G(s),c=hn(l);let d=[];try{d=await Po(s,{extensions:xe})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(W(i),await Ae("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";R(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((h,f)=>"import plugin"+f+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
71
|
+
`),r},"showSizeInformation"),si=ae((e,t)=>{const o=ri(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],h=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&h.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(ye(f,t,c)),e.options.declaration){const y=f.options.entries.filter(b=>b.declaration);y.length>0&&r.push(ee({...f,options:{...f.options,entries:y}},t,c))}}if(l.options.declaration&&h.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:h,minify:d}};r.push(ee(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ai=ae(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(si(e,t)),e.logger.success(Zt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of ro(w(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>w(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await tt($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),ii(e.logger,e)},"build");var li=Object.defineProperty,ci=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"r$4");const j=ci((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var pi=Object.defineProperty,Lt=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"t$4");const le=Lt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),we=Lt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=le(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return we(n,i,o,r)},"inferExportType");var ui=Object.defineProperty,di=m((e,t)=>ui(e,"name",{value:t,configurable:!0}),"y$1");const mi=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...dt,...ne]),Oe=di((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=le(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:we(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...mi.has(l)?{subKey:l}:{},type:we(l,r,t,c)}):i=[...i,...Oe({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var fi=Object.defineProperty,me=m((e,t)=>fi(e,"name",{value:t,configurable:!0}),"c$3");const gi=me((e,t)=>e.key==="exports"&&e.subKey===q?q:e.key==="exports"&&e.subKey===_e?_e:t,"getEnvironment"),te=me((e,t,o,r,n,i,s)=>{const a=gi(n,i.environment);let l="node";for(const p of dt)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(nt(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");ne.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let Ve=!1;const qe=me(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),hi=me((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Oe(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=le(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:le(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(qe(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){Ve||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ve=!0);const y=[],b=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(b.test(v)||ne.has(a.subKey)&&x.test(v))&&y.push(v);if(y.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of y)te(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let h=t.find(y=>g.test(y));if(ne.has(a.subKey)&&h===void 0){const y=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);h=t.find(b=>y.test(b))}if(h===void 0){P($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(h.endsWith(".ts")||h.endsWith(".cts")||h.endsWith(".mts"))&&P(h)&&qe(o);const f=re(h.replace(F,""));P(f+".cts")&&P(f+".mts")?(te(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),te(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):te(s,h,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var yi=Object.defineProperty,vi=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"o$2");const bi=vi((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var wi=Object.defineProperty,$i=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"t$3");const ji={hooks:{"build:prepare":$i(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!et(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=no(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=bi(r,e.options.declaration));const n=hi(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?D(i.fileAlias)+" => "+D(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):D(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),A([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var ki=Object.defineProperty,xi=m((e,t)=>ki(e,"name",{value:t,configurable:!0}),"t$2");const Ei=xi(async(e,t)=>{if(e==="auto")e=ji;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"j");const Di=Oi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Se(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Do(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(F,""),l=G(s),c=hn(l);let d=[];try{d=await Po(s,{extensions:xe})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(W(i),await Ae("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";R(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((h,f)=>"import plugin"+f+' from "'+h+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
72
72
|
export default _module;`:"",...d.filter(h=>h!=="default").map(h=>`export const ${h} = _module.${h};`)].join(`
|
|
73
73
|
`)),e.options.declaration&&R(`${i}.d.mts`,'export * from "'+g+`";
|
|
74
74
|
`+(p?'export { default } from "'+g+'";':""))}if(e.options.emitCJS){const u=O(W(i),await Ae("jiti",{conditions:["node","require"],url:import.meta.url})),g=a+".d.cts";R(`${i}.cjs`,c+['const { createJiti } = require("'+u+'");',...o.map((h,f)=>"const plugin"+f+" = require("+JSON.stringify(h)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+g+'")} */','module.exports = jiti("'+s+'")'].join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/packem",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A fast and modern bundler for Node.js and TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -194,15 +194,15 @@
|
|
|
194
194
|
"@rollup/plugin-replace": "6.0.1",
|
|
195
195
|
"@rollup/plugin-wasm": "6.2.2",
|
|
196
196
|
"@rollup/pluginutils": "5.1.2",
|
|
197
|
-
"@visulima/cerebro": "1.1.
|
|
197
|
+
"@visulima/cerebro": "1.1.22",
|
|
198
198
|
"@visulima/colorize": "1.4.10",
|
|
199
|
-
"@visulima/find-cache-dir": "1.0.
|
|
200
|
-
"@visulima/fs": "2.
|
|
199
|
+
"@visulima/find-cache-dir": "1.0.12",
|
|
200
|
+
"@visulima/fs": "2.2.0",
|
|
201
201
|
"@visulima/humanizer": "1.0.12",
|
|
202
|
-
"@visulima/package": "3.1.
|
|
202
|
+
"@visulima/package": "3.1.2",
|
|
203
203
|
"@visulima/pail": "2.1.9",
|
|
204
204
|
"@visulima/path": "1.0.9",
|
|
205
|
-
"@visulima/tsconfig": "1.0.
|
|
205
|
+
"@visulima/tsconfig": "1.0.14",
|
|
206
206
|
"defu": "6.1.4",
|
|
207
207
|
"es-module-lexer": "1.5.4",
|
|
208
208
|
"fastest-levenshtein": "1.0.16",
|
|
@@ -212,8 +212,8 @@
|
|
|
212
212
|
"jiti": "2.0.0",
|
|
213
213
|
"magic-string": "0.30.11",
|
|
214
214
|
"mlly": "1.7.1",
|
|
215
|
-
"oxc-parser": "0.30.
|
|
216
|
-
"rollup": "4.22.
|
|
215
|
+
"oxc-parser": "0.30.5",
|
|
216
|
+
"rollup": "4.22.5",
|
|
217
217
|
"rollup-plugin-dts": "6.1.1",
|
|
218
218
|
"rollup-plugin-license": "3.5.3",
|
|
219
219
|
"rollup-plugin-polyfill-node": "0.13.0",
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"@types/glob-parent": "^5.1.3",
|
|
242
242
|
"@types/is-glob": "^4.0.4",
|
|
243
243
|
"@types/node": "18.19.50",
|
|
244
|
-
"@types/react": "^18.3.
|
|
244
|
+
"@types/react": "^18.3.10",
|
|
245
245
|
"@types/react-dom": "^18.3.0",
|
|
246
246
|
"@types/semver": "^7.5.8",
|
|
247
247
|
"@vitest/coverage-v8": "^2.1.1",
|
|
@@ -259,13 +259,13 @@
|
|
|
259
259
|
"eslint-plugin-vitest-globals": "^1.5.0",
|
|
260
260
|
"estree-walker": "^3.0.3",
|
|
261
261
|
"execa": "^9.4.0",
|
|
262
|
-
"oxc-transform": "^0.30.
|
|
262
|
+
"oxc-transform": "^0.30.5",
|
|
263
263
|
"prettier": "^3.3.3",
|
|
264
264
|
"react": "^18.3.1",
|
|
265
265
|
"react-dom": "^18.3.1",
|
|
266
266
|
"rimraf": "^6.0.1",
|
|
267
267
|
"secretlint": "8.2.4",
|
|
268
|
-
"semantic-release": "^24.1.
|
|
268
|
+
"semantic-release": "^24.1.2",
|
|
269
269
|
"sort-package-json": "^2.10.1",
|
|
270
270
|
"sucrase": "^3.35.0",
|
|
271
271
|
"tempy": "^3.1.0",
|