@visulima/packem 1.0.0-alpha.30 → 1.0.0-alpha.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import"node:fs/promises";import"node:module";import"node:process";import"@visulima/colorize";import"@visulima/fs";import"@visulima/fs/error";import"@visulima/humanizer";import"@visulima/package";import"@visulima/package/package-json";import"@visulima/pail";import"@visulima/pail/processor";import"@visulima/path";import"defu";import"hookable";import{O as g}from"./shared/packem.6D80t8pb.mjs";import"./shared/packem.CxExFSHU.mjs";
1
+ var mt=Object.defineProperty;var m=(e,t)=>mt(e,"name",{value:t,configurable:!0});import{chmod as ft,stat as Oe,readdir as gt}from"node:fs/promises";import pe from"node:module";import{env as W,exit as I,versions as ht,cwd as yt}from"node:process";import{cyan as b,gray as F,bold as D,grey as vt,green as bt}from"@visulima/colorize";import{readFile as ee,writeFile as L,readFileSync as Ee,writeFileSync as Se,writeJsonSync as $t,isAccessibleSync as J,collectSync as jt,ensureDirSync as wt,emptyDir as De,walk as kt,isAccessible as xt}from"@visulima/fs";import{NotFoundError as Ot}from"@visulima/fs/error";import{formatBytes as M,duration as Et}from"@visulima/humanizer";import{findCacheDirectorySync as St,readTsConfig as Dt,findTSConfig as Nt}from"@visulima/package";import{parsePackageJson as Pt}from"@visulima/package/package-json";import{createPail as _t}from"@visulima/pail";import{MessageFormatterProcessor as Mt,ErrorProcessor as Ct,CallerProcessor as Ft}from"@visulima/pail/processor";import{resolve as g,join as j,normalize as H,extname as te,relative as _,dirname as oe,basename as q,isAbsolute as Ne,toNamespacedPath as ue}from"@visulima/path";import{defu as It}from"defu";import{createHooks as Rt}from"hookable";import{a as T,E as de}from"./shared/packem.CxExFSHU.mjs";import{pathToFileURL as Tt,fileURLToPath as At}from"node:url";import{resolvePath as Wt,resolveModuleExportNames as Jt,findStaticImports as Pe}from"mlly";import P from"magic-string";import _e from"jiti";import{rollup as Me,watch as me}from"rollup";import Ce from"@rollup/plugin-alias";import Bt from"@rollup/plugin-commonjs";import Lt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Fe}from"@rollup/plugin-node-resolve";import Ie from"@rollup/plugin-replace";import{wasm as zt}from"@rollup/plugin-wasm";import Ut from"rollup-plugin-polyfill-node";import{visualizer as Ht}from"rollup-plugin-visualizer";import{minVersion as Re}from"semver";import{glob as qt}from"glob";import Vt from"glob-parent";import Gt from"@rollup/plugin-json";import{createFilter as re,normalizePath as fe}from"@rollup/pluginutils";import Xt from"rollup-plugin-license";import{createHash as Yt}from"node:crypto";import{parse as Kt}from"@babel/parser";import{existsSync as ne}from"node:fs";import{distance as Qt}from"fastest-levenshtein";
2
2
  // -- pack CommonJS Shims --
3
3
  import __cjs_url__ from "node:url";
4
4
  import __cjs_path__ from "node:path";
@@ -6,4 +6,96 @@ import __cjs_mod__ from "node:module";
6
6
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
7
  const __dirname = __cjs_path__.dirname(__filename);
8
8
  const require = __cjs_mod__.createRequire(import.meta.url);
9
- export{g as default};
9
+ var Zt=Object.defineProperty,V=m((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"i$b");const se=/^#![^\n]*/,K=V(async e=>{await ft(e,493).catch(()=>{})},"makeExecutable"),eo=V((e,t=`#!/usr/bin/env node
10
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const s=new P(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&se.test(s.code)&&o.dir){const a=g(o.dir,r);await K(a)}}}),"shebangPlugin"),to=V(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(se,"")}}),"removeShebangPlugin"),oo=V((e,t=`
11
+ `)=>{const o=se.exec(e);return o?o+t:""},"getShebang");var ro=Object.defineProperty,no=m((e,t)=>ro(e,"name",{value:t,configurable:!0}),"p$2");const ie=no((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=j(e.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var so=Object.defineProperty,io=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"o$3");const ao=io((e,t)=>{const o=_e(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var lo=Object.defineProperty,co=m((e,t)=>lo(e,"name",{value:t,configurable:!0}),"r$9");const B=co((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var po=Object.defineProperty,uo=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"u$7");const mo=uo(async e=>{const t=await Wt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ie(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=g(e.options.rootDir,e.options.outDir,n.name),s=H(ao(n.input,e.options.rootDir)||n.input),a=s.slice(0,Math.max(0,s.length-te(s).length)),i=await ee(s),c=oo(i);e.options.emitCJS&&await L(`${r}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
+ `));let l=[];try{l=await Jt(s,{extensions:T})}catch(p){B(e,`Cannot analyze ${s} for exports:${p}`);return}const u=l.includes("default")||l.length===0;await L(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(Tt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
13
+ export default _module;`:"",...l.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
14
+ `)),await L(`${r}.d.cts`,[`export * from ${JSON.stringify(a)};`,u?`export { default } from ${JSON.stringify(a)};`:""].join(`
15
+ `)),await L(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
+ `)),c&&(await K(`${r}.cjs`),await K(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var fo=Object.defineProperty,go=m((e,t)=>fo(e,"name",{value:t,configurable:!0}),"a$b");const Q=go((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ho=Object.defineProperty,yo=m((e,t)=>ho(e,"name",{value:t,configurable:!0}),"a$a");const G=yo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var vo=Object.defineProperty,bo=m((e,t)=>vo(e,"name",{value:t,configurable:!0}),"e$2");const Z=bo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var $o=Object.defineProperty,Te=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"s$d");const jo=Te((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),a=n.get(s);if(a!==void 0)return a;const i=e(...r);return n.set(s,i),i}},"memoize"),wo=Te(e=>{const t=new Map;return o=>jo(e,o,t)},"memoizeByKey");var ko=Object.defineProperty,xo=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"m$7");const Ae=xo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(a===null||a.length<3)return null;const i=new P(n);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
17
+ module.exports.default = `+a[2]+";");let c=i.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(n);if(a===null||a.length<2)return null;const i=a[1].split(", "),c=[];let l="";for(const p of i)if(!p.includes("type"))if(p.includes("as")){const[d,h]=p.split(" as ");if(h==="default"&&(l=d,!e))continue;c.push(h+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new P(n);return u.replace(" "+l+" as default,",""),u.append(`
18
+
19
+ declare const defaultExport: {
20
+ `+(c.length>0?" ":"")+c.join(`
21
+ `)+`
22
+ } & typeof `+l+`;
23
+
24
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Oo=Object.defineProperty,Eo=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"f$8");const So=Eo((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await qt(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:Vt(a.src),src:i}))));for(const a of s)for(const i of a.src){let c;o.has(i)?c=o.get(i):(c={copied:[],dest:[],timestamp:0},o.set(i,c));const l=n.flatten?H(a.dest):j(a.dest,_(a.parent,oe(i)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let c;try{const l=await Oe(a);if(!l.isFile())return;const u=l.mtime.getTime();u>i.timestamp&&(i.timestamp=u,i.copied=[]),c=await ee(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of i.dest){if(n.copyOnce&&i.copied.includes(l))continue;const u=q(a),p=j(l,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${p}`,prefix:"plugin:copy"}),i.copied.push(l)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Do=Object.defineProperty,No=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"n$7");const ge="export default ",We=No(e=>{const t=Gt(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(ge)&&(r.code=r.code.replace(ge,"module.exports = ")),r}}},"JSONPlugin");class Po{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class _o extends Po{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const a=this.should_skip,i=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_skip,u=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=c,l)return t;if(u)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let c=0;c<i.length;c+=1){const l=i[c];he(l)&&(this.visit(l,t,s,c)||c--)}}else he(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=a,this.should_remove=i,c)return null}}return t}}function he(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(he,"isNode");function Je(e,{enter:t,leave:o}){return new _o(t,o).visit(e,null)}m(Je,"walk");var Mo=Object.defineProperty,Co=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"u$5");const Fo=Co(({attributes:e,logger:t})=>{const o=re([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const i=new P(n);return Je(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of l)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(i.overwrite(p.start-2,p.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Io=Object.defineProperty,ae=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"p$1");const Ro=ae(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),To=ae((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
25
+ ${o}
26
+ $2`)},"replaceContentWithin"),Be=ae(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:n,mode:r,packageName:s})=>Xt({thirdParty(a){const i=new Set,c=a.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:d,licenseText:h,maintainers:f,name:y,repository:v})=>{let O="## "+y+`
27
+ `;d&&(O+=`License: ${d}
28
+ `);const E=new Set;for(const x of[u,...f,...p]){const S=typeof x=="string"?x:x?.name;S&&E.add(S)}return E.size>0&&(O+=`By: ${[...E].join(", ")}
29
+ `),v&&(O+=`Repository: ${typeof v=="string"?v:v.url}
30
+ `),h&&(O+=`
31
+ `+h.trim().replaceAll(/(\r\n|\r)/g,`
32
+ `).split(`
33
+ `).map(x=>`> ${x}`).join(`
34
+ `)+`
35
+ `),d&&i.add(d),O}).join(`
36
+ ---------------------------------------
37
+
38
+ `);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const l=t(Ro(i),c,s);try{const u=Ee(e),p=To(u,n,l);if(!p){o.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+r});return}u!==p&&(Se(e,p),o.info({message:`${e} updated.`,prefix:"plugin:license:"+r}))}catch(u){o.error(u)}}}),"license");var Ao=Object.defineProperty,Wo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"i$8");const Jo=Wo(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.outDir,"graph.json");$t(o,t)},name:"packem:metafile"}),"metafilePlugin");var Bo=Object.defineProperty,Lo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"r$7");const C=Lo(e=>{const t=Yt("md5");return t.update(e),t.digest("hex")},"getHash");var zo=Object.defineProperty,Le=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"m$6");const A=Le(e=>e.handler||e,"getHandler"),w=Le((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=j("load",C(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await A(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=j("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await A(e.resolveId).call(this,o,n,r);return t.set(s,a,e.name),a},async transform(o,n){if(!e.transform)return null;const r=j("transform",C(n),C(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await A(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var Uo=Object.defineProperty,Ho=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"c$4");const qo=/\.(?:m|c)?(?:j|t)sx?$/,Vo=/^use \w+$/,Go=Ho(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const a=r.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,u)=>(u&&u.forEach(p=>{l.add(p)}),l),new Set),i=new P(n);a.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(l=>`'${l}';`).join(`
39
+ `)}
40
+ `));let c=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(c=o[r.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${c}
41
+ `)),a.size===0&&c===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=te(r);if(!qo.test(s))return null;let a=!1;const i=new P(n);if(n.startsWith("#")&&n[1]==="!"){let l=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){l=u;break}}l&&(o[r]=n.slice(0,l),i.remove(0,l+1),a=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(i.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let u=null;"directive"in l?u=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&Vo.test(l.expression.value)&&(u=l.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(i.remove(l.start,l.end),a=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Xo=Object.defineProperty,Yo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"r$6");const Ko={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Qo=Yo((e={})=>{e={...e,...Ko};const t=re(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Zo=Object.defineProperty,er=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"l$3");const X="\0__file_url__",ze=er(()=>({async load(e){if(e.startsWith(X)){const t=At(e.slice(X.length));return await ee(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${X}${e}`}}),"resolveFileUrl");var tr=Object.defineProperty,Ue=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"i$4");const or=/__filename|__dirname|require\(|require\.resolve\(/,He=`
42
+ // -- pack CommonJS Shims --
43
+ import __cjs_url__ from "node:url";
44
+ import __cjs_path__ from "node:path";
45
+ import __cjs_mod__ from "node:module";
46
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
+ const __dirname = __cjs_path__.dirname(__filename);
48
+ const require = __cjs_mod__.createRequire(import.meta.url);
49
+ `,qe=`
50
+ // -- pack CommonJS Shims Node 20.11 --
51
+ import __cjs_mod__ from "node:module";
52
+ const __filename = import.meta.filename;
53
+ const __dirname = import.meta.dirname;
54
+ const require = __cjs_mod__.createRequire(import.meta.url);
55
+ `,rr=Ue((e,t)=>{if(W.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(He)||e.includes(qe)||!or.test(e)))return null;const o=Pe(e).pop(),n=o?o.end:0,r=new P(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),nr=Ue(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=He;if(e.engines?.node){const s=Re(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=qe)}return rr(t,r)}return null}}),"cjsPlugin");var sr=Object.defineProperty,R=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"s$9");const ir=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,ar=/MIT License|MIT license|BSD license/,lr=/\n{2,}/g,cr=/\b(\w+)\$\d+\b/g,pr=/[-/\\^$*+?.()|[\]{}]/g,ur=R(e=>e.replaceAll(pr,"\\$&"),"escapeRegex"),dr=R(e=>[...new Set(e)],"unique"),mr=R(e=>e.replaceAll(ir,t=>ar.test(t)?"":t).replaceAll(lr,`
56
+
57
+ `),"cleanUnnecessaryComments"),ye=new Map;function Ve(e,t,{identifierReplacements:o},n){const r=Pe(e);for(const a in o){const i=r.find(l=>l.specifier===a&&l.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=o[a];for(const l in c){i.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${a}" for replacement`),I(1));const u=c[l],p=ur(l);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=dr(Array.from(e.matchAll(cr),a=>a[0]));if(s.length>0){const a=s.map(c=>`
58
+ - ${c}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");ye.has(i)||n.warn({message:`${t.fileName} contains confusing identifier names${a}
59
+
60
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ye.set(i,!0)}return e}m(Ve,"v$1");R(Ve,"replaceConfusingTypeNames");function Ge(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(Ge,"N");R(Ge,"removeInternal");function Xe(e,t){if(e.includes("@internal")){const o=new P(e),n=Kt(e,{plugins:["typescript"],sourceType:"module"});Je(n,{enter(r){Ge(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),I(1))}return e}m(Xe,"S");R(Xe,"stripInternalTypes");const fr=R((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Ve.call(this,o,n,e,t),o=Xe.call(this,o,n),o=mr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var gr=Object.defineProperty,Ye=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"u$3");const Ke=Ye((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const a=g(oe(n),r),i=[];if(s)for(const[c,l]of Object.entries(s)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of l){const h=[...fe(g(a,d))].map(f=>f==="*"?`$${++p}`:f==="$"?"$$":f).join("");i.push({find:u,replacement:h})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...fe(a)].map(c=>c==="$"?"$$":c).join("")}/$1`}),i},"getConfigAlias"),Qe=Ye((e,t)=>{const o=Ke(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(n)){const c=n.replace(a,i),l=await this.resolve(c,r,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var hr=Object.defineProperty,Ze=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"u$2");const yr=Ze((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const a of r){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(g(e,a))}return s},"getRootDirectories"),et=Ze((e,t,o)=>{const n=yr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,a){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const i of n){const c=j(i,r),l=await this.resolve(c,s,{skipSelf:!0,...a});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var vr=Object.defineProperty,br=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"r$5");const tt=br(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var $r=Object.defineProperty,jr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"s$8");const wr=jr(e=>{const t=q(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"i$3");const Y=xr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Or=Object.defineProperty,ve=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"c$2");const be=ve((e,t)=>{const o=new Map;return ve(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:a}=s,i=s.meta,c=Y(i);if(!a){const l=o.get(n);if(l)return l;const u=wr(n);if(u)return o.set(n,u),u}if(a){const l=r.getModuleIds();for(const u of l)r.getModuleInfo(u)&&Y(i)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!a&&e.has(n)){const l=[...e.get(n)];if(l.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return Y(d?d.meta:{})===c}return!1}))return;if(l.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=`${q(n,te(n))}-${c}`;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Er=Object.defineProperty,Sr=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"n$5");const N=Sr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Dr=Object.defineProperty,Nr=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"s$6");const Pr=process.platform==="win32",$e=Nr((e,t)=>{const o=Pr?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var _r=Object.defineProperty,$=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"p");const Mr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+ht.node.split(".")[0];if(t.pkg.engines?.node){const n=Re(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=G(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...G(o),...n])])}else t.options.rollup.esbuild.target=G(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),ot=$((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${b(_(g(),e.id))}"
61
+ Is the module installed? Note:
62
+ ↳ to inline a module into your bundle, install it to "devDependencies".
63
+ ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),je=new Map,rt=$((e,t,o)=>{const n=$(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),r=Ke(e.tsconfig,!1);return{external(s){const a=n(s);a&&(s=a);const i=Z(s),c=Q(e.options.externals,i)||Q(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||Ne(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(r){for(const{find:l}of r)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!c&&!je.has(s)&&e.logger.info({message:'Inlined implicit external "'+b(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),je.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),onLog:$((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
64
+ ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){ot(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),nt=$(async(e,t)=>{const o=ie(e,"build");let n;return e.options.rollup.resolve&&(n=w(Fe({extensions:T,...e.options.rollup.resolve}),t)),{...rt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>N(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>$e(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:be(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>N(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>$e(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:be(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[w(ze(),t),w(tt(),t),e.tsconfig&&w(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ie({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ce({customResolver:n?.resolveId,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Ut({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&We({...e.options.rollup.json}),Go(e.logger),eo(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&zt(e.options.rollup.wsam),e.options.transformer?.(Mr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ae({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Lt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&w(Bt({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&nr(e.pkg),e.options.rollup.raw&&Qo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Fo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Jo({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&So(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Be({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Ht({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Cr=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Fr=wo(Cr),st=$(async(e,t)=>{const o=ie(e,"types"),n={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=w(Fe({extensions:T,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...rt(e,o,"dts"),onwarn(i,c){ot(i,e)||i.code!=="EMPTY_BUNDLE"&&c(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>N(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:$(i=>N(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:$(i=>N(e,i,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[w(ze(),t),w(tt(),t),e.options.rollup.json&&We({...e.options.rollup.json}),n,e.tsconfig&&w(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ie({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ce({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await Fr(a)(e),e.options.cjsInterop&&e.options.emitCJS&&Ae({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&fr(e.options.rollup.patchTypes,e.logger),to(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Be({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Ir=Object.defineProperty,Rr=m((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"c$1");const Tr=Rr(async(e,t)=>{const o=await nt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await Me(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=o.output,a=new Map;for(const i of s){const{output:c}=await r.write(i),l=new Set,u=c.filter(d=>d.type==="chunk");for(const d of u){l.add(d.fileName);for(const h of d.imports)e.usedImports.add(h);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(h=>u.find(f=>f.fileName===h)),exports:d.exports,modules:Object.entries(d.modules).map(([h,f])=>({bytes:f.renderedLength,id:h})),path:d.fileName,type:"entry"})}const p=c.filter(d=>d.type==="asset");for(const d of p)a.has(d.fileName)||a.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of l)e.usedImports.delete(d)}e.buildEntries.push(...a.values())},"build");var Ar=Object.defineProperty,z=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"r$3");const Wr=z(async(e,t)=>{const o=await st(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await Me(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:z(s=>N(e,s,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:z(s=>N(e,s,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await r.write({chunkFileNames:z(s=>N(e,s,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Jr=Object.defineProperty,it=m((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"e$1");const we=it((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${b(_(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",r=>{r.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:n}),r.code==="ERROR"&&o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n})})},"watchHandler"),Br=it(async(e,t)=>{const o=await nt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const n=me(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const a of r)s+=F(`
65
+ └─ ${_(process.cwd(),a)}`);if(e.logger.info(s),we(n,"bundle",e.logger),e.options.declaration){const a=await st(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=me(a);await e.hooks.callHook("rollup:watch",e,i),we(i,"types",e.logger)}},"watch");var Lr=Object.defineProperty,zr=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"i$2");const at=zr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Ur=Object.defineProperty,Hr=m((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"a$3");let qr=class{static{m(this,"g")}static{Hr(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,n){this.#r=t,this.#e=St("visulima-packem",{cwd:t}),this.#n=o,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:J(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!J(n))return;const r=Ee(n),s=JSON.parse(r);return this.#o.set(n,s),s}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),Se(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(ue(this.#r),"");return n=n.replaceAll(":","-"),j(this.#e,this.#n,o?.replaceAll(":","-")??"",ue(n))}};var Vr=Object.defineProperty,U=m((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"l$2");const Gr=re,Xr=U((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=U(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=U(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=Gr(r,null,{resolve:e})}else n=U(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Yr=Object.defineProperty,Kr=m((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"t$4");const Qr=Kr(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var Zr=Object.defineProperty,lt=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"t$3");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"),ct=lt((e,t,o,n)=>{if(o){const a=le(o);if(a)return a}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...s]=t;return ct(r,s,o,n)},"inferExportType");var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"f$3");const ce=tn((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=le(e),s=t==="module"?"esm":"cjs";if(r&&r!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:r??s}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>r==="types"&&!o?[]:typeof s=="string"?{file:s,type:ct(r,n,s,t)}:ce(s,t,o,[...n,r]))},"extractExportFilenames");var on=Object.defineProperty,rn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"e");const nn=rn(e=>{const t=H(e).split("/");return t.map((o,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var sn=Object.defineProperty,an=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"h$1");const ln=an((e,t,o,n=".")=>{const r=[];t.sort((p,d)=>p.split("/").length-d.split("/").length);const s=ce(e.exports,e.type??"commonjs",o);if(e.bin){const p=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of p)s.push({file:d,isExecutable:!0})}e.main&&s.push({file:e.main,type:le(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&s.push({file:e.module,type:"esm"}),o===void 0&&(e.types||e.typings)&&s.push({file:e.types??e.typings});const a=e.type==="module";for(const p of s.filter(d=>!d.type)){const d=p.file.endsWith(".js");a&&d||p.file.endsWith(".mjs")?p.type="esm":(!a&&d||p.file.endsWith(".cjs"))&&(p.type="cjs")}let i=!1,c=!1,l=!1;const u=[];for(const p of s){const d=p.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),h=d.endsWith("/");if(h&&["./","/"].includes(d))continue;const f=nn(d).reduce((v,O)=>{if(v)return v;const E=new RegExp(`(?<=/|$)${O}${h?"":"\\.\\w+"}$`);return t.find(x=>E.test(x))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!f){ne(g(n,p.file))||r.push(`Could not find entrypoint for \`${p.file}\``);continue}p.type==="cjs"&&(i=!0),p.type==="esm"&&(c=!0);const y=u.find(v=>v.input===f)??u[u.push({input:f})-1];/\.d\.(?:m|c)?ts$/.test(p.file)&&(l=!0),h&&(y.outDir=d),p.isExecutable&&(y.isExecutable=!0)}return{cjs:i,dts:l,entries:u,esm:c,warnings:r}},"inferEntries");var cn=Object.defineProperty,pn=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"t$2");const un=pn((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 dn=Object.defineProperty,mn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"t$1");const fn={hooks:{"build:prepare":mn(function(e){if(e.options.entries.length>0)return;const t=j(e.options.rootDir,"src");if(!ne(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=jt(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&&(n=un(n,e.options.declaration));const r=ln(n,o,e.options.declaration,e.options.rootDir);for(const s of r.warnings)B(e,s);if(e.options.entries.push(...r.entries),e.options.emitCJS===void 0&&r.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&r.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&r.dts&&(e.options.declaration=r.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b(e.options.entries.map(s=>D(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),F([r.esm&&"esm",r.cjs&&"cjs",r.dts&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var gn=Object.defineProperty,hn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"r");const pt=hn((e,t)=>_e(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var yn=Object.defineProperty,vn=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"t");const bn=vn((e,t)=>(e==="auto"?e=fn:typeof e=="string"&&(e=pt(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var $n=Object.defineProperty,jn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"o");const wn=jn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(Array.isArray(e.options.dependencies))for(const r of e.options.dependencies)o.delete(r);for(const r of t)!Q(e.options.externals,r)&&!r.startsWith("chunks/")&&!e.options.dependencies.includes(Z(r))&&!e.options.peerDependencies.includes(Z(r))&&n.add(r);o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(r=>b(r)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(r=>b(r)).join(", ")}`)},"validateDependencies");var kn=Object.defineProperty,ut=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"i");const xn=ut((e,t)=>Qt(e,t)<=e.length/3||t.includes(e),"isSimilar"),On=ut((e,t)=>{const o=e.toLowerCase();return t.filter(n=>xn(n.toLowerCase(),o))},"findAlternatives");var En=Object.defineProperty,ke=m((e,t)=>En(e,"name",{value:t,configurable:!0}),"n");const Sn=ke((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...ce(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!ne(r)&&n.push(r.replace(`${t.rootDir}/`,""));if(n.length>0){const r=ke(i=>_(t.rootDir,g(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>r(i.path));let a="Potential missing or wrong package.json files:";for(const i of n){const c=On(i,s);a+=`
66
+ - `+b(i)+(c.length>0?vt` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}B(t,a)}},"validatePackage");var Dn=Object.defineProperty,k=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"m");const xe=k((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
+ `),e.logger.warn(`Build is done with some warnings:
68
+
69
+ ${[...e.warnings].map(o=>`- ${o}`).join(`
70
+ `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),I(1)))},"logErrors"),Nn=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),Pn=k((e,t,o,n,r,s,a,i)=>{const c=Nn(i?.config.compilerOptions?.jsx),l=It(r,n,s,{alias:{},fileCache:!0,clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...pe.builtinModules,...pe.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:W.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:i?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:W.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:k((u,p,d)=>`
71
+ # Licenses of bundled dependencies
72
+ The published ${d} artifact additionally contains code with the following licenses:
73
+ ${u.join(", ")}
74
+
75
+ # Bundled dependencies:
76
+ `+p,"dependenciesTemplate"),dtsTemplate:k((u,p,d)=>`
77
+ # Licenses of bundled types
78
+ The published ${d} artifact additionally contains code with the following licenses:
79
+ ${u.join(", ")}
80
+
81
+ # Bundled types:
82
+ `+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:de,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:W.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:W.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Xr(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:de}},rootDir:t,sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const u=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(u.has("esbuild"))l.transformerName="esbuild";else if(u.has("@swc/core"))l.transformerName="swc";else if(u.has("sucrase"))l.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+b(l.transformerName)+'" as transformer.')}return l.outDir=g(l.rootDir,l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
83
+ Because none of the third-party transpilers, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
84
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),l.dependencies=Object.keys(a.dependencies??{}),l.peerDependencies=Object.keys(a.peerDependencies??{}),l.devDependencies=Object.keys(a.devDependencies??{}),l.optionalDependencies=Object.keys(a.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),_n=k(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let n=Ne(o.input)?_(t,o.input):H(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=Qr(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${at(o)}`);if(!e.options.declaration&&o.declaration===void 0&&(o.declaration=e.options.declaration),o.input=g(e.options.rootDir,o.input),!J(o.input)){const n=new Set(await gt(oe(o.input)));let r=!1;for(const s of T)if(n.has(q(o.input)+s)){r=!0;break}if(!r)throw new Ot("Your configured entry: "+b(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Mn=k((e,t,o)=>{const n=k(s=>_(t.rootDir,g(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let i=` ${D(n(s.path))} (${["total size: "+b(M(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+b(M(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
85
+ exports: `+F(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
86
+ ${s.chunks.map(c=>{const l=t.buildEntries.find(u=>u.path===c)??{};return F(" └─ "+n(c)+D(l.bytes?" ("+M(l?.bytes)+")":""))}).join(`
87
+ `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>F(" 📦 "+n(l.id)+D(l.bytes?" ("+M(l.bytes)+")":""))).join(`
88
+ `);i+=c.length>0?`
89
+ inlined modules:
90
+ `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",c=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),i+=p&&l===o.type?`
91
+ types:
92
+ `+[u,p].map(d=>F(" └─ ")+D(n(d.path))+" (total size: "+b(M(d.bytes??0))+")").join(`
93
+ `):`
94
+ types: `+D(n(u.path))+" (total size: "+b(M(u.bytes??0))+")"}}r=!0,i+=`
95
+
96
+ `,e.raw(s.chunk?F(i):i)}return r&&e.raw("Σ Total dist size (byte size):",b(M(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
97
+ `),r},"showSizeInformation"),Cn=k(async(e,t,o,n,r,s,a,i,c)=>{const l=bn(r.preset??n.preset??"auto",t),u=Pn(e,t,o,n,r,l,s,a);i.isEnabled=u.fileCache,wt(u.outDir);const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Rt(),logger:e,mode:o,options:u,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),n.hooks&&p.hooks.addHooks(n.hooks),r.hooks&&p.hooks.addHooks(r.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===!1&&p.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");p.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),p.options.declaration||e.info("Declaration files, are disabled."),await _n(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(o==="watch"?d="Watching":o==="jit"&&(d="Stubbing"),e.info(b(`${d} ${p.options.name}`)),e.debug(`${D("Root dir:")} ${p.options.rootDir}
98
+ ${D("Entries:")}
99
+ ${p.options.entries.map(f=>` ${at(f)}`).join(`
100
+ `)}`),p.options.clean)for(const f of new Set(p.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===p.options.rootDir||p.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||c.some(y=>f.startsWith(y))||(c.push(f),e.info(`Cleaning dist directory: \`./${_(p.options.rootDir,f)}\``),await De(f));if(p.options.stub){await mo(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await Br(p,i),xe(p,!1);return}await Promise.all([Tr(p,i),p.options.declaration&&Wr(p,i)]),e.success(bt(`Build succeeded for ${p.options.name}`));for await(const f of kt(p.options.outDir)){let y=p.buildEntries.find(v=>j(p.options.outDir,v.path)===f.path);if(y||(y={chunk:!0,path:f.path},p.buildEntries.push(y)),!y.bytes){const v=await Oe(g(p.options.outDir,f.path));y.bytes=v.size}}const h=Mn(e,p,s);wn(p),Sn(s,p),await p.hooks.callHook("build:done",p),xe(p,h)},"build"),$s=k(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...a}=o,i=[new Mt,new Ct];r&&i.push(new Ft);const c=_t({logLevel:r?"debug":"informational",processors:i,scope:"packem"});c.wrapAll(),e=g(yt(),e),c.debug("Root directory:",e);const l=j(e,"package.json"),u=Pt(l);c.debug("Using package.json found at",l);let p;if(s){const d=j(e,s);await xt(d)||(c.error("tsconfig.json not found at",d),I(1)),p={config:Dt(d),path:d},c.info("Using tsconfig settings at",d)}else try{p=await Nt(e),c.debug("Using tsconfig settings found at",p.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const d=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),I(1));const h=pt(d,e);c.debug("Using packem config found at",j(e,d));const f=(Array.isArray(h)?h:[h]).filter(Boolean),y=Date.now(),v=k(()=>Et(Math.floor(Date.now()-y)),"getDuration"),O=[],E=[],x=C(u.version+JSON.stringify({...u.dependencies,...u.devDependencies,eNode:u.engines?.node})),S=new qr(e,x,c);S.cachePath&&!J(j(S.cachePath,x))&&J(S.cachePath)&&(c.info("Clearing file cache because the cache key has changed."),await De(S.cachePath));for(const dt of f)E.push(Cn(c,e,t,a,dt,u,p,S,O));await Promise.all(E),c.raw(`
101
+ ⚡️ Build`+(E.length>1?"s":"")+" run in "+v()),c.restoreAll(),I(0)}catch(d){c.error("An error occurred while building",d),I(1)}},"createBundler");export{$s as default};
@@ -100,10 +100,9 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
- cache?: boolean;
104
103
  cjsInterop?: boolean;
105
104
  clean: boolean;
106
- declaration?: boolean | "compatible" | "node16";
105
+ declaration?: boolean | "compatible" | "node16" | undefined;
107
106
  dependencies: string[];
108
107
  devDependencies: string[];
109
108
  emitCJS?: boolean;
@@ -111,6 +110,7 @@ interface BuildOptions {
111
110
  entries: BuildEntry[];
112
111
  externals: (RegExp | string)[];
113
112
  failOnWarn?: boolean;
113
+ fileCache?: boolean;
114
114
  minify: boolean;
115
115
  name: string;
116
116
  optionalDependencies: string[];
@@ -100,10 +100,9 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
- cache?: boolean;
104
103
  cjsInterop?: boolean;
105
104
  clean: boolean;
106
- declaration?: boolean | "compatible" | "node16";
105
+ declaration?: boolean | "compatible" | "node16" | undefined;
107
106
  dependencies: string[];
108
107
  devDependencies: string[];
109
108
  emitCJS?: boolean;
@@ -111,6 +110,7 @@ interface BuildOptions {
111
110
  entries: BuildEntry[];
112
111
  externals: (RegExp | string)[];
113
112
  failOnWarn?: boolean;
113
+ fileCache?: boolean;
114
114
  minify: boolean;
115
115
  name: string;
116
116
  optionalDependencies: string[];
@@ -100,10 +100,9 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
- cache?: boolean;
104
103
  cjsInterop?: boolean;
105
104
  clean: boolean;
106
- declaration?: boolean | "compatible" | "node16";
105
+ declaration?: boolean | "compatible" | "node16" | undefined;
107
106
  dependencies: string[];
108
107
  devDependencies: string[];
109
108
  emitCJS?: boolean;
@@ -111,6 +110,7 @@ interface BuildOptions {
111
110
  entries: BuildEntry[];
112
111
  externals: (RegExp | string)[];
113
112
  failOnWarn?: boolean;
113
+ fileCache?: boolean;
114
114
  minify: boolean;
115
115
  name: string;
116
116
  optionalDependencies: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "1.0.0-alpha.30",
3
+ "version": "1.0.0-alpha.32",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -1,101 +0,0 @@
1
- var dt=Object.defineProperty;var m=(e,t)=>dt(e,"name",{value:t,configurable:!0});import{chmod as mt,stat as Oe,readdir as ft}from"node:fs/promises";import ue from"node:module";import{env as A,exit as C,versions as gt,cwd as ht}from"node:process";import{cyan as b,gray as M,bold as _,grey as yt,green as vt}from"@visulima/colorize";import{readFile as te,writeFile as W,readFileSync as _e,writeFileSync as De,writeJsonSync as bt,isAccessibleSync as K,collectSync as jt,ensureDirSync as $t,emptyDir as wt,walk as kt,isAccessible as xt}from"@visulima/fs";import{NotFoundError as Et}from"@visulima/fs/error";import{formatBytes as P,duration as Ot}from"@visulima/humanizer";import{findCacheDirectorySync as _t,readTsConfig as Dt,findTSConfig as St}from"@visulima/package";import{parsePackageJson as Nt}from"@visulima/package/package-json";import{createPail as Pt}from"@visulima/pail";import{MessageFormatterProcessor as Mt,ErrorProcessor as Ct,CallerProcessor as It}from"@visulima/pail/processor";import{resolve as g,join as $,normalize as H,extname as se,relative as N,dirname as oe,basename as q,isAbsolute as Se,toNamespacedPath as de}from"@visulima/path";import{defu as Ft}from"defu";import{createHooks as Rt}from"hookable";import{a as F,E as me}from"./packem.CxExFSHU.mjs";import{pathToFileURL as At,fileURLToPath as Tt}from"node:url";import{resolvePath as Lt,resolveModuleExportNames as Wt,findStaticImports as Ne}from"mlly";import S from"magic-string";import Pe from"jiti";import{rollup as Me,watch as fe}from"rollup";import Ce from"@rollup/plugin-alias";import Bt from"@rollup/plugin-commonjs";import Jt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Ie}from"@rollup/plugin-node-resolve";import Fe from"@rollup/plugin-replace";import{wasm as zt}from"@rollup/plugin-wasm";import Ut from"rollup-plugin-polyfill-node";import{visualizer as Ht}from"rollup-plugin-visualizer";import{minVersion as Re}from"semver";import{glob as qt}from"glob";import Vt from"glob-parent";import Gt from"@rollup/plugin-json";import{createFilter as ne,normalizePath as ge}from"@rollup/pluginutils";import Xt from"rollup-plugin-license";import{createHash as Ae}from"node:crypto";import{parse as Yt}from"@babel/parser";import{existsSync as re}from"node:fs";import{distance as Kt}from"fastest-levenshtein";
2
- // -- pack CommonJS Shims --
3
- import __cjs_url__ from "node:url";
4
- import __cjs_path__ from "node:path";
5
- import __cjs_mod__ from "node:module";
6
- const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
- const __dirname = __cjs_path__.dirname(__filename);
8
- const require = __cjs_mod__.createRequire(import.meta.url);
9
- const Qt="@visulima/packem",Zt="1.0.0-alpha.29",es="A fast and modern bundler for Node.js and TypeScript.",ts=["anolilab","assets","bundle","bundler","cjs","commonjs","compiler","css","declaration","es6","esbuild","esm","exports","package.json","packem","rollup","sucrase","swc","typescript","visulima","zero config"],ss="https://www.visulima.com/docs/package/packem",os={type:"git",url:"https://github.com/visulima/packem.git",directory:"packages/packem"},ns=[{type:"github",url:"https://github.com/sponsors/prisis"},{type:"consulting",url:"https://anolilab.com/support"}],rs="MIT",is={name:"Daniel Bannert",email:"d.bannert@anolilab.de"},as=!1,ls="module",ps={".":{require:{types:"./dist/create-bundler.d.cts",default:"./dist/create-bundler.cjs"},import:{types:"./dist/create-bundler.d.mts",default:"./dist/create-bundler.mjs"}},"./config":{require:{types:"./dist/config.d.cts",default:"./dist/config.cjs"},import:{types:"./dist/config.d.mts",default:"./dist/config.mjs"}},"./transformer/esbuild":{require:{types:"./dist/rollup/plugins/esbuild/index.d.cts",default:"./dist/rollup/plugins/esbuild/index.cjs"},import:{types:"./dist/rollup/plugins/esbuild/index.d.mts",default:"./dist/rollup/plugins/esbuild/index.mjs"}},"./transformer/swc":{require:{types:"./dist/rollup/plugins/swc/index.d.cts",default:"./dist/rollup/plugins/swc/index.cjs"},import:{types:"./dist/rollup/plugins/swc/index.d.mts",default:"./dist/rollup/plugins/swc/index.mjs"}},"./transformer/sucrase":{require:{types:"./dist/rollup/plugins/sucrase/index.d.cts",default:"./dist/rollup/plugins/sucrase/index.cjs"},import:{types:"./dist/rollup/plugins/sucrase/index.d.mts",default:"./dist/rollup/plugins/sucrase/index.mjs"}},"./package.json":"./package.json"},cs="./dist/create-bundler.cjs",us="./dist/create-bundler.mjs",ds="./dist/create-bundler.d.ts",ms={packem:"./dist/cli.cjs"},fs=["dist/**","README.md","CHANGELOG.md","LICENSE.md"],gs={build:"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 NODE_ENV=development jiti ./src/cli build","build:prod":"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 NODE_ENV=production jiti ./src/cli build --minify",clean:"rimraf node_modules dist .eslintcache",dev:"pnpm run build","lint:eslint":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs","lint:eslint:fix":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix","lint:packagejson":"publint --strict","lint:prettier":"prettier --config=.prettierrc.cjs --check .","lint:prettier:fix":"prettier --config=.prettierrc.cjs --write .","lint:types":"tsc --noEmit",test:"vitest run","test:coverage":"vitest run --coverage","test:ui":"vitest --ui --coverage.enabled=true","test:watch":"vitest"},hs={"@antfu/install-pkg":"^0.3.3","@babel/parser":"^7.24.6","@rollup/plugin-alias":"^5.1.0","@rollup/plugin-commonjs":"^25.0.8","@rollup/plugin-dynamic-import-vars":"^2.1.2","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-wasm":"^6.2.2","@rollup/pluginutils":"^5.1.0","@visulima/cerebro":"^1.0.30","@visulima/colorize":"^1.4.1","@visulima/fs":"^2.1.2","@visulima/humanizer":"^1.0.3","@visulima/package":"^1.8.4","@visulima/pail":"^1.1.11","@visulima/path":"^1.0.1","@clack/prompts":"^0.7.0",defu:"6.1.4","es-module-lexer":"^1.5.3","fastest-levenshtein":"^1.0.16",glob:"^10.4.1","glob-parent":"^6.0.2",hookable:"^5.5.3","magic-string":"^0.30.10",mlly:"^1.7.0",rollup:"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-license":"^3.4.0","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-visualizer":"^5.12.0",semver:"^7.6.2"},ys={"@anolilab/eslint-config":"^15.0.3","@anolilab/prettier-config":"^5.0.14","@anolilab/semantic-release-pnpm":"^1.1.0","@anolilab/semantic-release-preset":"^8.1.0","@babel/core":"^7.24.6","@rushstack/eslint-plugin-security":"^0.8.1","@secretlint/secretlint-rule-preset-recommend":"^8.2.4","@swc/core":"^1.5.24","@swc/types":"0.1.7","@total-typescript/ts-reset":"^0.5.1","@types/estree":"^1.0.5","@types/glob":"^8.1.0","@types/glob-parent":"^5.1.3","@types/micromatch":"^4.0.7","@types/node":"18.18.14","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/semver":"^7.5.8","@vitest/coverage-v8":"^1.6.0","@vitest/ui":"^1.6.0","cross-env":"^7.0.3",esbuild:"^0.21.4",eslint:"^8.56.0","eslint-plugin-deprecation":"^2.0.0","eslint-plugin-etc":"^2.0.3","eslint-plugin-import":"npm:eslint-plugin-i@^2.29.1","eslint-plugin-mdx":"^3.1.5","eslint-plugin-vitest":"^0.4.1","eslint-plugin-vitest-globals":"^1.5.0","estree-walker":"^3.0.3",execa:"^9.1.0",jiti:"^1.21.0",prettier:"^3.2.5",react:"^18.3.1","react-dom":"^18.3.1",rimraf:"^5.0.7",secretlint:"8.2.4","semantic-release":"^23.1.1","sort-package-json":"^2.10.0",sucrase:"^3.35.0",tempy:"^3.1.0","ts-essentials":"^10.0.0",typescript:"^5.4.5",vitest:"^1.6.0"},vs={"@swc/core":"^1.5.7",esbuild:"^0.20.2 || ^0.21.3",jiti:"^1.21.0",sucrase:"^3.35.0",typescript:"^4.5 || ^5.0"},bs={"@swc/core":{optional:!0},esbuild:{optional:!0},sucrase:{optional:!0},typescript:{optional:!0}},js={node:">=18.* <=22.*"},$s={access:"public",provenance:!0},ws={"eslint-config":{plugin:{tsdoc:!1,"testing-library-react":!1,"react-usememo":!1,"react-hooks":!1,"jsx-a11y":!1,react:!1,"validate-jsx-nesting":!1,"ssr-friendly":!1},warn_on_unsupported_typescript_version:!1,info_on_disabling_jsx_react_rule:!1,info_on_disabling_prettier_conflict_rule:!1,info_on_disabling_jsonc_sort_keys_rule:!1,info_on_disabling_etc_no_deprecated:!1}},ks={name:Qt,version:Zt,description:es,keywords:ts,homepage:ss,repository:os,funding:ns,license:rs,author:is,sideEffects:as,type:ls,exports:ps,main:cs,module:us,types:ds,bin:ms,files:fs,scripts:gs,dependencies:hs,devDependencies:ys,peerDependencies:vs,peerDependenciesMeta:bs,engines:js,publishConfig:$s,anolilab:ws};var xs=Object.defineProperty,V=m((e,t)=>xs(e,"name",{value:t,configurable:!0}),"i$b");const ie=/^#![^\n]*/,Q=V(async e=>{await mt(e,493).catch(()=>{})},"makeExecutable"),Es=V((e,t=`#!/usr/bin/env node
10
- `)=>({name:"packem:shebang",renderChunk:{handler(s,n,o){if(!n.isEntry||!n.facadeModuleId||s.startsWith("#")&&s[1]==="!")return null;if(e.includes(n.name)){const r=new S(s);return r.prepend(t),{code:r.toString(),map:o.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(s,n){for(const[o,r]of Object.entries(n))if(r.type==="chunk"&&ie.test(r.code)&&s.dir){const a=g(s.dir,o);await Q(a)}}}),"shebangPlugin"),Os=V(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ie,"")}}),"removeShebangPlugin"),_s=V((e,t=`
11
- `)=>{const s=ie.exec(e);return s?s+t:""},"getShebang");var Ds=Object.defineProperty,Ss=m((e,t)=>Ds(e,"name",{value:t,configurable:!0}),"p$3");const ae=Ss((e,t)=>{let s={};if(e.pkg.name&&(s[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const o in n){if(o.startsWith("#"))continue;const r=n[o];typeof r=="string"&&(s[o]=$(e.rootDir,r))}}return s={...s,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(s,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(s,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(s),prefix:t}),s},"resolveAliases");var Ns=Object.defineProperty,Ps=m((e,t)=>Ns(e,"name",{value:t,configurable:!0}),"o$4");const Ms=Ps((e,t)=>{const s=Pe(t,{esmResolve:!0,interopDefault:!0});try{return s.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Cs=Object.defineProperty,Is=m((e,t)=>Cs(e,"name",{value:t,configurable:!0}),"r$8");const T=Is((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Fs=Object.defineProperty,Rs=m((e,t)=>Fs(e,"name",{value:t,configurable:!0}),"u$7");const As=Rs(async e=>{const t=await Lt("jiti",{url:import.meta.url}),s=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ae(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const o=g(e.options.rootDir,e.options.outDir,n.name),r=H(Ms(n.input,e.options.rootDir)||n.input),a=r.slice(0,Math.max(0,r.length-se(r).length)),i=await te(r),c=_s(i);e.options.emitCJS&&await W(`${o}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
12
- `));let l=[];try{l=await Wt(r,{extensions:F})}catch(p){T(e,`Cannot analyze ${r} for exports:${p}`);return}const u=l.includes("default")||l.length===0;await W(`${o}.mjs`,c+[`import jiti from ${JSON.stringify(At(t).href)};`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(r)})} */`,`const _module = await _jiti.import(${JSON.stringify(r)});`,u?`
13
- export default _module;`:"",...l.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
14
- `)),await W(`${o}.d.cts`,[`export * from ${JSON.stringify(a)};`,u?`export { default } from ${JSON.stringify(a)};`:""].join(`
15
- `)),await W(`${o}.d.mts`,[`export * from ${JSON.stringify(r)};`,u?`export { default } from ${JSON.stringify(r)};`:""].join(`
16
- `)),c&&(await Q(`${o}.cjs`),await Q(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ts=Object.defineProperty,Ls=m((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"a$b");const Z=Ls((e,t)=>e.some(s=>s instanceof RegExp?s.test(t):s===t),"arrayIncludes");var Ws=Object.defineProperty,Bs=m((e,t)=>Ws(e,"name",{value:t,configurable:!0}),"a$a");const G=Bs(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Js=Object.defineProperty,zs=m((e,t)=>Js(e,"name",{value:t,configurable:!0}),"e$2");const ee=zs((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Us=Object.defineProperty,Te=m((e,t)=>Us(e,"name",{value:t,configurable:!0}),"s$c");const Hs=Te((e,t,s)=>{const n=s??new Map;return(...o)=>{const r=t?typeof t=="function"?t(...o):t:JSON.stringify({args:o}),a=n.get(r);if(a!==void 0)return a;const i=e(...o);return n.set(r,i),i}},"memoize"),qs=Te(e=>{const t=new Map;return s=>Hs(e,s,t)},"memoizeByKey");var Vs=Object.defineProperty,Gs=m((e,t)=>Vs(e,"name",{value:t,configurable:!0}),"m$6");const Le=Gs(({addDefaultProperty:e=!1,logger:t,type:s})=>({name:"packem:cjs-interop",renderChunk(n,o,r){if(o.type!=="chunk"||!o.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(a===null||a.length<3)return null;const i=new S(n);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
17
- module.exports.default = `+a[2]+";");let c=i.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:i.generateMap({hires:!0})}}if(r.format==="es"&&/\.d\.(?:ts|cts)$/.test(o.fileName)){if(s!=="commonjs"&&o.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(n);if(a===null||a.length<2)return null;const i=a[1].split(", "),c=[];let l="";for(const p of i)if(!p.includes("type"))if(p.includes("as")){const[d,h]=p.split(" as ");if(h==="default"&&(l=d,!e))continue;c.push(h+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new S(n);return u.replace(" "+l+" as default,",""),u.append(`
18
-
19
- declare const defaultExport: {
20
- `+(c.length>0?" ":"")+c.join(`
21
- `)+`
22
- } & typeof `+l+`;
23
-
24
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Xs=Object.defineProperty,Ys=m((e,t)=>Xs(e,"name",{value:t,configurable:!0}),"f$9");const Ks=Ys((e,t)=>{const s=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const r=await Promise.all(o.flatMap(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await qt(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:Vt(a.src),src:i}))));for(const a of r)for(const i of a.src){let c;s.has(i)?c=s.get(i):(c={copied:[],dest:[],timestamp:0},s.set(i,c));const l=n.flatten?H(a.dest):$(a.dest,N(a.parent,oe(i)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...s].map(async([a,i])=>{let c;try{const l=await Oe(a);if(!l.isFile())return;const u=l.mtime.getTime();u>i.timestamp&&(i.timestamp=u,i.copied=[]),c=await te(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of i.dest){if(n.copyOnce&&i.copied.includes(l))continue;const u=q(a),p=$(l,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${p}`,prefix:"plugin:copy"}),i.copied.push(l)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Qs=Object.defineProperty,Zs=m((e,t)=>Qs(e,"name",{value:t,configurable:!0}),"n$7");const he="export default ",We=Zs(e=>{const t=Gt(e);return{...t,name:"packem:json",transform(s,n){const o=t.transform?.call(this,s,n);return o&&typeof o!="string"&&"code"in o&&o.code?.startsWith(he)&&(o.code=o.code.replace(he,"module.exports = ")),o}}},"JSONPlugin");class eo{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,s,n,o){t&&s&&(n!=null?t[s][n]=o:t[s]=o)}remove(t,s,n){t&&s&&(n!=null?t[s].splice(n,1):delete t[s])}}class to extends eo{static{m(this,"SyncWalker")}constructor(t,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=s}visit(t,s,n,o){if(t){if(this.enter){const a=this.should_skip,i=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,s,n,o),this.replacement&&(t=this.replacement,this.replace(s,n,o,t)),this.should_remove&&this.remove(s,n,o);const l=this.should_skip,u=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=c,l)return t;if(u)return null}let r;for(r in t){const a=t[r];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let c=0;c<i.length;c+=1){const l=i[c];ye(l)&&(this.visit(l,t,r,c)||c--)}}else ye(a)&&this.visit(a,t,r,null)}if(this.leave){const a=this.replacement,i=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,s,n,o),this.replacement&&(t=this.replacement,this.replace(s,n,o,t)),this.should_remove&&this.remove(s,n,o);const c=this.should_remove;if(this.replacement=a,this.should_remove=i,c)return null}}return t}}function ye(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ye,"isNode");function Be(e,{enter:t,leave:s}){return new to(t,s).visit(e,null)}m(Be,"walk");var so=Object.defineProperty,oo=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"u$5");const no=oo(({attributes:e,logger:t})=>{const s=ne([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,o){if(!s(o))return null;let r=null;try{r=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${o}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const i=new S(n);return Be(r,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of l)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(i.overwrite(p.start-2,p.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var ro=Object.defineProperty,le=m((e,t)=>ro(e,"name",{value:t,configurable:!0}),"p$2");const io=le(e=>{const t=[],s=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):s.push(n)}),[...s.sort(),...t.sort()]},"sortLicenses"),ao=le((e,t,s)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
25
- ${s}
26
- $2`)},"replaceContentWithin"),Je=le(({licenseFilePath:e,licenseTemplate:t,logger:s,marker:n,mode:o,packageName:r})=>Xt({thirdParty(a){const i=new Set,c=a.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:d,licenseText:h,maintainers:f,name:y,repository:v})=>{let x="## "+y+`
27
- `;d&&(x+=`License: ${d}
28
- `);const E=new Set;for(const O of[u,...f,...p]){const L=typeof O=="string"?O:O?.name;L&&E.add(L)}return E.size>0&&(x+=`By: ${[...E].join(", ")}
29
- `),v&&(x+=`Repository: ${typeof v=="string"?v:v.url}
30
- `),h&&(x+=`
31
- `+h.trim().replaceAll(/(\r\n|\r)/g,`
32
- `).split(`
33
- `).map(O=>`> ${O}`).join(`
34
- `)+`
35
- `),d&&i.add(d),x}).join(`
36
- ---------------------------------------
37
-
38
- `);if(c===""){s.info({message:"No dependencies license information found.",prefix:"plugin:license:"+o});return}const l=t(io(i),c,r);try{const u=_e(e),p=ao(u,n,l);if(!p){s.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+o});return}u!==p&&(De(e,p),s.info({message:`${e} updated.`,prefix:"plugin:license:"+o}))}catch(u){s.error(u)}}}),"license");var lo=Object.defineProperty,po=m((e,t)=>lo(e,"name",{value:t,configurable:!0}),"i$8");const co=po(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const o=this.getModuleInfo(n);if(o!=null&&!o.isExternal)for(const r of o.importedIds)t.push({source:n,target:r})}if(Array.isArray(t)&&t.length===0)return;const s=g(e.outDir,"graph.json");bt(s,t)},name:"packem:metafile"}),"metafilePlugin");var uo=Object.defineProperty,U=m((e,t)=>uo(e,"name",{value:t,configurable:!0}),"o$3");const R=U(e=>e.handler||e,"getHandler"),B=U(e=>{if(!e.includes(".pnpm"))return e;const t=e.split(".pnpm");return t.splice(0,1),$(".pnpm",t.join(""))},"optimizeFileName"),w=U((e,t)=>{const s=U(n=>{const o=Ae("md5");return o.update(n),o.digest("hex")},"getCacheVersion");return{...e,async buildEnd(n){e.buildEnd&&await R(e.buildEnd).call(this,n)},async buildStart(n){e.buildStart&&await R(e.buildStart).call(this,n)},async load(n){if(!e.load)return null;const o=$("load",B(n));if(t.has(o,e.name))return await t.get(o,e.name);const r=await R(e.load).call(this,n);return t.set(o,r,e.name),r},name:`cached(${e.name})`,async resolveId(n,o,r){if(!e.resolveId)return null;const a=$("resolveId",s(JSON.stringify(r)),o?B(o):"",B(n));if(t.has(a,e.name))return await t.get(a,e.name);const i=await R(e.resolveId).call(this,n,o,r);return t.set(a,i,e.name),i},async transform(n,o){if(!e.transform)return null;const r=$("transform",s(n),B(o));if(t.has(r,e.name))return await t.get(r,e.name);const a=await R(e.transform).call(this,n,o);return t.set(r,a,e.name),a}}},"cachingPlugin");var mo=Object.defineProperty,fo=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"c$4");const go=/\.(?:m|c)?(?:j|t)sx?$/,ho=/^use \w+$/,yo=fo(e=>{const t={},s={};return{name:"packem:preserve-directives",onLog(n,o){return o.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,o,{sourcemap:r}){const a=o.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,u)=>(u&&u.forEach(p=>{l.add(p)}),l),new Set),i=new S(n);a.size>0&&(e.debug({message:`directives for chunk "${o.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(l=>`'${l}';`).join(`
39
- `)}
40
- `));let c=null;return o.facadeModuleId&&typeof s[o.facadeModuleId]=="string"&&(c=s[o.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${o.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${c}
41
- `)),a.size===0&&c===null?null:{code:i.toString(),map:r?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,o){const r=se(o);if(!go.test(r))return null;let a=!1;const i=new S(n);if(n.startsWith("#")&&n[1]==="!"){let l=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){l=u;break}}l&&(s[o]=n.slice(0,l),i.remove(0,l+1),a=!0,e.debug({message:`shebang for module "${o}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(i.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${o}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let u=null;"directive"in l?u=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&ho.test(l.expression.value)&&(u=l.expression.value),u!=="use strict"&&u&&(t[o]||=new Set,t[o].add(u),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(i.remove(l.start,l.end),a=!0),e.debug({message:`directive "${u}" for module "${o}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[o]??[]],shebang:s[o]??null}}}:null},order:"post"}}},"preserveDirectives");var vo=Object.defineProperty,bo=m((e,t)=>vo(e,"name",{value:t,configurable:!0}),"r$6");const jo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},$o=bo((e={})=>{e={...e,...jo};const t=ne(e.include,e.exclude);return{name:"packem:raw",transform(s,n){return t(n)?{code:`export default ${JSON.stringify(s)}`,map:null}:null}}},"rawPlugin");var wo=Object.defineProperty,ko=m((e,t)=>wo(e,"name",{value:t,configurable:!0}),"l$3");const X="\0__file_url__",ze=ko(()=>({async load(e){if(e.startsWith(X)){const t=Tt(e.slice(X.length));return await te(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${X}${e}`}}),"resolveFileUrl");var xo=Object.defineProperty,Ue=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"i$4");const Eo=/__filename|__dirname|require\(|require\.resolve\(/,He=`
42
- // -- pack CommonJS Shims --
43
- import __cjs_url__ from "node:url";
44
- import __cjs_path__ from "node:path";
45
- import __cjs_mod__ from "node:module";
46
- const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
- const __dirname = __cjs_path__.dirname(__filename);
48
- const require = __cjs_mod__.createRequire(import.meta.url);
49
- `,qe=`
50
- // -- pack CommonJS Shims Node 20.11 --
51
- import __cjs_mod__ from "node:module";
52
- const __filename = import.meta.filename;
53
- const __dirname = import.meta.dirname;
54
- const require = __cjs_mod__.createRequire(import.meta.url);
55
- `,Oo=Ue((e,t)=>{if(A.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(He)||e.includes(qe)||!Eo.test(e)))return null;const s=Ne(e).pop(),n=s?s.end:0,o=new S(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),_o=Ue(e=>({name:"packem:cjs",renderChunk(t,s,n){if(n.format==="es"){let o=He;if(e.engines?.node){const r=Re(e.engines.node);r&&r.major>=20&&r.minor>=11&&(o=qe)}return Oo(t,o)}return null}}),"cjsPlugin");var Do=Object.defineProperty,I=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"s$9");const So=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,No=/MIT License|MIT license|BSD license/,Po=/\n{2,}/g,Mo=/\b(\w+)\$\d+\b/g,Co=/[-/\\^$*+?.()|[\]{}]/g,Io=I(e=>e.replaceAll(Co,"\\$&"),"escapeRegex"),Fo=I(e=>[...new Set(e)],"unique"),Ro=I(e=>e.replaceAll(So,t=>No.test(t)?"":t).replaceAll(Po,`
56
-
57
- `),"cleanUnnecessaryComments"),ve=new Map;function Ve(e,t,{identifierReplacements:s},n){const o=Ne(e);for(const a in s){const i=o.find(l=>l.specifier===a&&l.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=s[a];for(const l in c){i.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${a}" for replacement`),C(1));const u=c[l],p=Io(l);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const r=Fo(Array.from(e.matchAll(Mo),a=>a[0]));if(r.length>0){const a=r.map(c=>`
58
- - ${c}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");ve.has(i)||n.warn({message:`${t.fileName} contains confusing identifier names${a}
59
-
60
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ve.set(i,!0)}return e}m(Ve,"v$1");I(Ve,"replaceConfusingTypeNames");function Ge(e,t){if(t.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,s),!0}return!1}m(Ge,"N$1");I(Ge,"removeInternal");function Xe(e,t){if(e.includes("@internal")){const s=new S(e),n=Yt(e,{plugins:["typescript"],sourceType:"module"});Be(n,{enter(o){Ge(s,o)&&this.skip()}}),e=s.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),C(1))}return e}m(Xe,"S$1");I(Xe,"stripInternalTypes");const Ao=I((e,t)=>({name:"packem:patch-types",renderChunk(s,n){return s=Ve.call(this,s,n,e,t),s=Xe.call(this,s,n),s=Ro(s),s},resolveId(s){return s.startsWith("types/")?{external:!0,id:"../../"+(s.endsWith(".js")?s:s+".js")}:null}}),"patchTypescriptTypes");var To=Object.defineProperty,Ye=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"u$3");const Ke=Ye((e,t=!0)=>{if(!e)return null;const{config:s,path:n}=e;if(!s.compilerOptions)return null;const{baseUrl:o,paths:r}=s.compilerOptions;if(!o)return null;const a=g(oe(n),o),i=[];if(r)for(const[c,l]of Object.entries(r)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of l){const h=[...ge(g(a,d))].map(f=>f==="*"?`$${++p}`:f==="$"?"$$":f).join("");i.push({find:u,replacement:h})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...ge(a)].map(c=>c==="$"?"$$":c).join("")}/$1`}),i},"getConfigAlias"),Qe=Ye((e,t)=>{const s=Ke(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,o,r){if(!s||n.includes("\0"))return null;for(const{find:a,replacement:i}of s)if(a.test(n)){const c=n.replace(a,i),l=await this.resolve(c,o,{skipSelf:!0,...r});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var Lo=Object.defineProperty,Ze=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"u$2");const Wo=Ze((e,t)=>{if(!t)return null;const{config:s,path:n}=t;if(!s.compilerOptions)return null;const{rootDirs:o}=s.compilerOptions;if(!o)return null;const r=[];for(const a of o){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);r.push(g(e,a))}return r},"getRootDirectories"),et=Ze((e,t,s)=>{const n=Wo(e,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(o,r,a){if(n===null||n.length===0)return null;if(o.startsWith("."))for(const i of n){const c=$(i,o),l=await this.resolve(c,r,{skipSelf:!0,...a});if(l)return t.debug({message:`Resolved ${o} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var Bo=Object.defineProperty,Jo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"r$5");const tt=Jo(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,s,n){return e.test(t)&&s?await this.resolve(t.replace(/js(x?)$/,"ts$1"),s,n):null}}},"resolveTypescriptMjsCts");var zo=Object.defineProperty,Uo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"s$8");const Ho=Uo(e=>{const t=q(e).split(".");if(t.length>=2){const[s,n]=t.slice(-2),o=t[0],r=/^(\w+)-runtime$/.exec(s)?.[1];if(F.includes(n)&&r&&r.length>0)return o+"-"+r}},"getCustomModuleLayer");var qo=Object.defineProperty,Vo=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"i$3");const Y=Vo(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Go=Object.defineProperty,be=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"c$2");const je=be((e,t)=>{const s=new Map;return be(function(n,o){const r=o.getModuleInfo(n);if(!r)return;const{isEntry:a}=r,i=r.meta,c=Y(i);if(!a){const l=s.get(n);if(l)return l;const u=Ho(n);if(u)return s.set(n,u),u}if(a){const l=o.getModuleIds();for(const u of l)o.getModuleInfo(u)&&Y(i)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!a&&e.has(n)){const l=[...e.get(n)];if(l.some(([p])=>{if(t.some(d=>d.path===p)){const d=o.getModuleInfo(p);return Y(d?d.meta:{})===c}return!1}))return;if(l.every(([,p])=>p===c))return s.has(n)?s.get(n):void 0;const u=`${q(n,se(n))}-${c}`;return s.set(n,u),u}},"splitChunks")},"createSplitChunks");var Xo=Object.defineProperty,Yo=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"n$5");const D=Yo((e,t,s)=>t.isDynamicEntry?`chunks/[name].${s}`:`shared/${e.options.name}.[hash].${s}`,"getChunkFilename");var Ko=Object.defineProperty,Qo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"s$6");const Zo=process.platform==="win32",$e=Qo((e,t)=>{const s=Zo?"\\":"/";return e.name?.includes("node_modules"+s+".pnpm")?(e.name.replace("node_modules"+s+".pnpm","external")+"."+t).replace("node_modules"+s,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var en=Object.defineProperty,j=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"p$1");const tn=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let s="node"+gt.node.split(".")[0];if(t.pkg.engines?.node){const n=Re(t.pkg.engines.node);n&&(s="node"+n.major)}if(t.options.rollup.esbuild.target){const n=G(t.options.rollup.esbuild.target);n.some(o=>o.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...G(s),...n])])}else t.options.rollup.esbuild.target=G(s);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),st=j((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${b(N(g(),e.id))}"
61
- Is the module installed? Note:
62
- ↳ to inline a module into your bundle, install it to "devDependencies".
63
- ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),we=new Map,ot=j((e,t,s)=>{const n=j(r=>{for(const[a,i]of Object.entries(t))if(r.startsWith(a))return r.replace(a,i)},"findAlias"),o=Ke(e.tsconfig,!1);return{external(r){const a=n(r);a&&(r=a);const i=ee(r),c=Z(e.options.externals,i)||Z(e.options.externals,r);if(c)return!0;if(r.startsWith(".")||Se(r)||/src[/\\]/.test(r)||e.pkg.name&&r.startsWith(e.pkg.name))return!1;if(o){for(const{find:l}of o)if(l.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${l.source}`,prefix:s}),!1}return!c&&!we.has(r)&&e.logger.info({message:'Inlined implicit external "'+b(r)+'". If this is incorrect, add it to the "externals" option.',prefix:s}),we.set(r,!0),c},input:Object.fromEntries(e.options.entries.map(r=>[r.name,g(e.options.rootDir,r.input)])),onLog:j((r,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
64
- ${a.stack}`),r){case"info":{e.logger.info({message:i,prefix:s+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:s+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:s+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(r,a){st(r,e)||r.code||a(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),nt=j(async(e,t)=>{const s=ae(e,"build");let n;return e.options.rollup.resolve&&(n=w(Ie({extensions:F,...e.options.rollup.resolve}),t)),{...ot(e,s,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(o=>D(e,o,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>$e(o,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(o=>D(e,o,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>$e(o,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[w(ze(),t),w(tt(),t),e.tsconfig&&w(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Fe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ce({customResolver:n?.resolveId,...e.options.rollup.alias,entries:s}),n,e.options.rollup.polyfillNode&&Ut({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&We({...e.options.rollup.json}),yo(e.logger),Es(e.options.entries.filter(o=>o.isExecutable).map(o=>o.name).filter(Boolean)),e.options.rollup.wsam&&zt(e.options.rollup.wsam),e.options.transformer?.(tn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Le({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Jt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&w(Bt({extensions:F,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&_o(e.pkg),e.options.rollup.raw&&$o(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&no({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&co({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Ks(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Je({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Ht({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),sn=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),on=qs(sn),rt=j(async(e,t)=>{const s=ae(e,"types"),n={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},o=e.tsconfig?.config.compilerOptions;delete o?.lib;let r;e.options.rollup.resolve&&(r=w(Ie({extensions:F,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...ot(e,s,"dts"),onwarn(i,c){st(i,e)||i.code!=="EMPTY_BUNDLE"&&c(i)},output:[e.options.emitCJS&&{chunkFileNames:j(i=>D(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:j(i=>D(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:j(i=>D(e,i,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[w(ze(),t),w(tt(),t),e.options.rollup.json&&We({...e.options.rollup.json}),n,e.tsconfig&&w(et(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&w(Qe(e.tsconfig,e.logger),t),e.options.rollup.replace&&Fe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ce({customResolver:r?.resolveId,...e.options.rollup.alias,entries:s}),r,await on(a)(e),e.options.cjsInterop&&e.options.emitCJS&&Le({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Ao(e.options.rollup.patchTypes,e.logger),Os(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Je({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var nn=Object.defineProperty,rn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"c$1");const an=rn(async(e,t)=>{const s=await nt(e,t);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;const n="rollup-build.json";s.cache=t.get(n);const o=await Me(s);t.set(n,o.cache),await e.hooks.callHook("rollup:build",e,o);const r=s.output,a=new Map;for(const i of r){const{output:c}=await o.write(i),l=new Set,u=c.filter(d=>d.type==="chunk");for(const d of u){l.add(d.fileName);for(const h of d.imports)e.usedImports.add(h);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(h=>u.find(f=>f.fileName===h)),exports:d.exports,modules:Object.entries(d.modules).map(([h,f])=>({bytes:f.renderedLength,id:h})),path:d.fileName,type:"entry"})}const p=c.filter(d=>d.type==="asset");for(const d of p)a.has(d.fileName)||a.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of l)e.usedImports.delete(d)}e.buildEntries.push(...a.values())},"build");var ln=Object.defineProperty,J=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"r$3");const pn=J(async(e,t)=>{const s=await rt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,s),Object.keys(s.input).length===0)return;const n="rollup-dts.json";s.cache=t.get(n);const o=await Me(s);t.set(n,o.cache),await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:J(r=>D(e,r,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:J(r=>D(e,r,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:J(r=>D(e,r,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var cn=Object.defineProperty,it=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"e$1");const ke=it((e,t,s)=>{const n="watcher:"+t;e.on("change",(o,{event:r})=>{s.info({message:`${b(N(".",o))} was ${r}d`,prefix:n})}),e.on("restart",()=>{s.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",o=>{o.code==="END"&&s.success({message:"Rebuild "+t+" finished",prefix:n}),o.code==="ERROR"&&s.error({context:[o.error],message:"Rebuild "+t+" failed: "+o.error.message,prefix:n})})},"watchHandler"),un=it(async(e,t)=>{const s=await nt(e,t);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-watch");const n=fe(s);await e.hooks.callHook("rollup:watch",e,n);const o=[...Array.isArray(s.input)?s.input:typeof s.input=="string"?[s.input]:Object.keys(s.input??{})];let r="Starting watchers for entries:";for(const a of o)r+=M(`
65
- └─ ${N(process.cwd(),a)}`);if(e.logger.info(r),ke(n,"bundle",e.logger),e.options.declaration){const a=await rt(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=fe(a);await e.hooks.callHook("rollup:watch",e,i),ke(i,"types",e.logger)}},"watch");var dn=Object.defineProperty,mn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"i$2");const at=mn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var fn=Object.defineProperty,gn=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"a$3");class hn{static{m(this,"p")}static{gn(this,"FileCache")}#o;#e;#n;#t=!0;#s=new Map;constructor(t,s,n){this.#o=t,this.#e=_t("visulima-packem",{create:!0,cwd:t});const o=Ae("md5");o.update(s),this.#n=o.digest("hex"),this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}has(t,s){return!this.#t||this.#e===void 0?!1:K(this.getFilePath(t,s))}get(t,s){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,s);if(this.#s.has(n))return this.#s.get(n);if(!K(n))return;const o=_e(n),r=JSON.parse(o);return this.#s.set(n,r),r}set(t,s,n){if(!this.#t||this.#e===void 0||s===void 0)return;const o=this.getFilePath(t,n);typeof s=="object"&&(s=JSON.stringify(s)),De(o,s,{overwrite:!0})}getFilePath(t,s){let n=t.replaceAll(de(this.#o),"");return n=n.replaceAll(":","-"),$(this.#e,this.#n,s?.replaceAll(":","-")??"",de(n))}}var yn=Object.defineProperty,z=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"l$2");const vn=ne,bn=z((e,t)=>{const{sideEffects:s}=t;let n;if(typeof s=="boolean")n=z(()=>s,"hasSideEffects");else if(Array.isArray(s))if(s.length<=0)n=z(()=>!1,"hasSideEffects");else{const o=s.map(r=>r.includes("/")?r:`**/${r}`);n=vn(o,null,{resolve:e})}else n=z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var jn=Object.defineProperty,$n=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"t$4");const wn=$n(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var kn=Object.defineProperty,lt=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"t$3");const pe=lt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),pt=lt((e,t,s,n)=>{if(s){const a=pe(s);if(a)return a}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[o,...r]=t;return pt(o,r,s,n)},"inferExportType");var xn=Object.defineProperty,En=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"f$3");const ce=En((e,t,s,n=[])=>{if(!e)return[];if(typeof e=="string"){const o=pe(e),r=t==="module"?"esm":"cjs";if(o&&o!==r)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:o??r}]}return Object.entries(e).filter(([o])=>!o.endsWith(".json")).flatMap(([o,r])=>o==="types"&&!s?[]:typeof r=="string"?{file:r,type:pt(o,n,r,t)}:ce(r,t,s,[...n,o]))},"extractExportFilenames");var On=Object.defineProperty,_n=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"e");const Dn=_n(e=>{const t=H(e).split("/");return t.map((s,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var Sn=Object.defineProperty,Nn=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"h$1");const Pn=Nn((e,t,s,n=".")=>{const o=[];t.sort((p,d)=>p.split("/").length-d.split("/").length);const r=ce(e.exports,e.type??"commonjs",s);if(e.bin){const p=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of p)r.push({file:d,isExecutable:!0})}e.main&&r.push({file:e.main,type:pe(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,type:"esm"}),s===void 0&&(e.types||e.typings)&&r.push({file:e.types??e.typings});const a=e.type==="module";for(const p of r.filter(d=>!d.type)){const d=p.file.endsWith(".js");a&&d||p.file.endsWith(".mjs")?p.type="esm":(!a&&d||p.file.endsWith(".cjs"))&&(p.type="cjs")}let i=!1,c=!1,l=!1;const u=[];for(const p of r){const d=p.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),h=d.endsWith("/");if(h&&["./","/"].includes(d))continue;const f=Dn(d).reduce((v,x)=>{if(v)return v;const E=new RegExp(`(?<=/|$)${x}${h?"":"\\.\\w+"}$`);return t.find(O=>E.test(O))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!f){re(g(n,p.file))||o.push(`Could not find entrypoint for \`${p.file}\``);continue}p.type==="cjs"&&(i=!0),p.type==="esm"&&(c=!0);const y=u.find(v=>v.input===f)??u[u.push({input:f})-1];/\.d\.(?:m|c)?ts$/.test(p.file)&&(l=!0),h&&(y.outDir=d),p.isExecutable&&(y.isExecutable=!0)}return{cjs:i,dts:l,entries:u,esm:c,warnings:o}},"inferEntries");var Mn=Object.defineProperty,Cn=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"t$2");const In=Cn((e,t)=>{const{publishConfig:s}=e;return s&&(s.bin&&(typeof s.bin=="object"||typeof s.bin=="string")&&(e.bin=s.bin),s.type&&typeof s.type=="string"&&s.type!==""&&(e.type=s.type),s.main&&typeof s.main=="string"&&s.main!==""&&(e.main=s.main),s.module&&typeof s.module=="string"&&s.module!==""&&(e.module=s.module),t===void 0&&s.types&&typeof s.types=="string"&&s.types!==""?e.types=s.types:t===void 0&&s.typings&&typeof s.typings=="string"&&s.typings!==""&&(e.typings=s.typings),s.exports&&typeof s.exports=="object"&&(e.exports=s.exports)),e},"overwriteWithPublishConfig");var Fn=Object.defineProperty,Rn=m((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"t$1");const An={hooks:{"build:prepare":Rn(function(e){if(e.options.entries.length>0)return;const t=$(e.options.rootDir,"src");if(!re(t))throw new Error("No 'src' directory found. Please provide entries manually.");const s=jt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(s.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=In(n,e.options.declaration));const o=Pn(n,s,e.options.declaration,e.options.rootDir);for(const r of o.warnings)T(e,r);if(e.options.entries.push(...o.entries),e.options.emitCJS===void 0&&o.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&o.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&o.dts&&(e.options.declaration=o.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b(e.options.entries.map(r=>_(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([o.esm&&"esm",o.cjs&&"cjs",o.dts&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Tn=Object.defineProperty,Ln=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"r");const ct=Ln((e,t)=>Pe(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Wn=Object.defineProperty,Bn=m((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"t");const Jn=Bn((e,t)=>(e==="auto"?e=An:typeof e=="string"&&(e=ct(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var zn=Object.defineProperty,Un=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"o");const Hn=Un(e=>{const t=new Set,s=new Set(Object.keys(e.pkg.dependencies??{})),n=new Set;for(const o of e.usedImports)s.delete(o),t.add(o);if(Array.isArray(e.options.dependencies))for(const o of e.options.dependencies)s.delete(o);for(const o of t)!Z(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(ee(o))&&!e.options.peerDependencies.includes(ee(o))&&n.add(o);s.size>0&&T(e,`Potential unused dependencies found: ${[...s].map(o=>b(o)).join(", ")}`),n.size>0&&T(e,`Potential implicit dependencies found: ${[...n].map(o=>b(o)).join(", ")}`)},"validateDependencies");var qn=Object.defineProperty,ut=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"i");const Vn=ut((e,t)=>Kt(e,t)<=e.length/3||t.includes(e),"isSimilar"),Gn=ut((e,t)=>{const s=e.toLowerCase();return t.filter(n=>Vn(n.toLowerCase(),s))},"findAlternatives");var Xn=Object.defineProperty,xe=m((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"n");const Yn=xe((e,t)=>{const s=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...ce(e.exports,e.type??"commonjs",t.options.declaration).map(o=>o.file)].map(o=>o&&g(t.rootDir,o.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const o of s)o&&!o.includes("*")&&!re(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=xe(i=>N(t.rootDir,g(t.options.outDir,i)),"rPath"),r=t.buildEntries.filter(i=>!i.chunk).map(i=>o(i.path));let a="Potential missing or wrong package.json files:";for(const i of n){const c=Gn(i,r);a+=`
66
- - `+b(i)+(c.length>0?yt` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}T(t,a)}},"validatePackage");var Kn=Object.defineProperty,k=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"m");const Ee=k((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
- `),e.logger.warn(`Build is done with some warnings:
68
-
69
- ${[...e.warnings].map(s=>`- ${s}`).join(`
70
- `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),C(1)))},"logErrors"),Qn=k(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),Zn=k((e,t,s,n,o,r,a,i)=>{const c=Qn(i?.config.compilerOptions?.jsx),l=Ft(o,n,r,{alias:{},cache:!0,clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ue.builtinModules,...ue.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:A.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:i?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:A.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:k((u,p,d)=>`
71
- # Licenses of bundled dependencies
72
- The published ${d} artifact additionally contains code with the following licenses:
73
- ${u.join(", ")}
74
-
75
- # Bundled dependencies:
76
- `+p,"dependenciesTemplate"),dtsTemplate:k((u,p,d)=>`
77
- # Licenses of bundled types
78
- The published ${d} artifact additionally contains code with the following licenses:
79
- ${u.join(", ")}
80
-
81
- # Bundled types:
82
- `+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:me,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:A.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:A.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:bn(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:me}},rootDir:t,sourcemap:!1,stub:s==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const u=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(u.has("esbuild"))l.transformerName="esbuild";else if(u.has("@swc/core"))l.transformerName="swc";else if(u.has("sucrase"))l.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+b(l.transformerName)+'" as transformer.')}return l.outDir=g(l.rootDir,l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
83
- Because none of the third-party transpilers, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
84
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),l.dependencies=Object.keys(a.dependencies??{}),l.peerDependencies=Object.keys(a.peerDependencies??{}),l.devDependencies=Object.keys(a.devDependencies??{}),l.optionalDependencies=Object.keys(a.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),er=k(async(e,t)=>{e.options.entries=e.options.entries.map(s=>typeof s=="string"?{input:s}:s);for await(const s of e.options.entries){if(typeof s.name!="string"){let n=Se(s.input)?N(t,s.input):H(s.input);n.startsWith("./")&&(n=n.slice(2)),s.name=wn(n.replace(/^src\//,""))}if(!s.input)throw new Error(`Missing entry input: ${at(s)}`);if(!e.options.declaration&&s.declaration===void 0&&(s.declaration=e.options.declaration),s.input=g(e.options.rootDir,s.input),!K(s.input)){const n=new Set(await ft(oe(s.input)));let o=!1;for(const r of F)if(n.has(q(s.input)+r)){o=!0;break}if(!o)throw new Et("Your configured entry: "+b(s.input)+" does not exist.")}s.outDir=g(e.options.rootDir,s.outDir??e.options.outDir)}},"prepareEntries"),tr=k((e,t,s)=>{const n=k(r=>N(t.rootDir,g(t.options.outDir,r)),"rPath");let o=!1;for(const r of t.buildEntries.filter(a=>!a.chunk)){let a=r.bytes??0;for(const c of r.chunks??[])a+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let i=` ${_(n(r.path))} (${["total size: "+b(P(a)),r.type!=="asset"&&r.bytes&&"chunk size: "+b(P(r.bytes))].filter(Boolean).join(", ")})`;if(i+=r.exports?.length?`
85
- exports: `+M(r.exports.join(", ")):"",r.chunks?.length&&(i+=`
86
- ${r.chunks.map(c=>{const l=t.buildEntries.find(u=>u.path===c)??{};return M(" └─ "+n(c)+_(l.bytes?" ("+P(l?.bytes)+")":""))}).join(`
87
- `)}`),r.modules&&r.modules.length>0){const c=r.modules.filter(l=>l.id.includes("node_modules")).sort((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>M(" 📦 "+n(l.id)+_(l.bytes?" ("+P(l.bytes)+")":""))).join(`
88
- `);i+=c.length>0?`
89
- inlined modules:
90
- `+c:""}if(t.options.declaration&&r.type==="entry"){let c=r.path.replace(/\.js$/,".d.ts"),l="commonjs";r.path.endsWith(".cjs")?c=r.path.replace(/\.cjs$/,".d.cts"):r.path.endsWith(".mjs")&&(l="module",c=r.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),i+=p&&l===s.type?`
91
- types:
92
- `+[u,p].map(d=>M(" └─ ")+_(n(d.path))+" (total size: "+b(P(d.bytes??0))+")").join(`
93
- `):`
94
- types: `+_(n(u.path))+" (total size: "+b(P(u.bytes??0))+")"}}o=!0,i+=`
95
-
96
- `,e.raw(r.chunk?M(i):i)}return o&&e.raw("Σ Total dist size (byte size):",b(P(t.buildEntries.reduce((r,a)=>r+(a.bytes??0),0))),`
97
- `),o},"showSizeInformation"),sr=k(async(e,t,s,n,o,r,a,i,c)=>{const l=Jn(o.preset??n.preset??"auto",t),u=Zn(e,t,s,n,o,l,r,a);i.isEnabled=u.cache,$t(u.outDir);const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Rt(),logger:e,mode:s,options:u,pkg:r,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),n.hooks&&p.hooks.addHooks(n.hooks),o.hooks&&p.hooks.addHooks(o.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===!1&&p.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");p.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),p.options.declaration||e.info("Declaration files, are disabled."),await er(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(s==="watch"?d="Watching":s==="jit"&&(d="Stubbing"),e.info(b(`${d} ${p.options.name}`)),e.debug(`${_("Root dir:")} ${p.options.rootDir}
98
- ${_("Entries:")}
99
- ${p.options.entries.map(f=>` ${at(f)}`).join(`
100
- `)}`),p.options.clean)for(const f of new Set(p.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===p.options.rootDir||p.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||c.some(y=>f.startsWith(y))||(c.push(f),e.info(`Cleaning dist directory: \`./${N(p.options.rootDir,f)}\``),await wt(f));if(p.options.stub){await As(p),await p.hooks.callHook("build:done",p);return}if(s==="watch"){await un(p,i),Ee(p,!1);return}await Promise.all([an(p,i),p.options.declaration&&pn(p,i)]),e.success(vt(`Build succeeded for ${p.options.name}`));for await(const f of kt(p.options.outDir)){let y=p.buildEntries.find(v=>$(p.options.outDir,v.path)===f.path);if(y||(y={chunk:!0,path:f.path},p.buildEntries.push(y)),!y.bytes){const v=await Oe(g(p.options.outDir,f.path));y.bytes=v.size}}const h=tr(e,p,r);Hn(p),Yn(r,p),await p.hooks.callHook("build:done",p),Ee(p,h)},"build"),Jr=k(async(e,t,s={})=>{const{configPath:n,debug:o,tsconfigPath:r,...a}=s,i=[new Mt,new Ct];o&&i.push(new It);const c=Pt({logLevel:o?"debug":"informational",processors:i,scope:"packem"});c.wrapAll(),e=g(ht(),e),c.debug("Root directory:",e);const l=$(e,"package.json"),u=Nt(l);c.debug("Using package.json found at",l);let p;if(r){const d=$(e,r);await xt(d)||(c.error("tsconfig.json not found at",d),C(1)),p={config:Dt(d),path:d},c.info("Using tsconfig settings at",d)}else try{p=await St(e),c.debug("Using tsconfig settings found at",p.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const d=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),C(1));const h=ct(d,e);c.debug("Using packem config found at",$(e,d));const f=(Array.isArray(h)?h:[h]).filter(Boolean),y=Date.now(),v=k(()=>Ot(Math.floor(Date.now()-y)),"getDuration"),x=[],E=[],O=new hn(e,ks.version,c);for(const L of f)E.push(sr(c,e,t,a,L,u,p,O,x));await Promise.all(E),c.raw(`
101
- ⚡️ Build`+(E.length>1?"s":"")+" run in "+v()),c.restoreAll(),C(0)}catch(d){c.error("An error occurred while building",d),C(1)}},"createBundler");export{Jr as O,Qt as n,Zt as v};