@visulima/packem 2.0.0-alpha.29 → 2.0.0-alpha.30

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.
@@ -0,0 +1,3 @@
1
+ var m=Object.defineProperty;var l=(e,r)=>m(e,"name",{value:r,configurable:!0});import{createRequire as f}from"node:module";const d=f(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{transpileDeclaration:y,formatDiagnostics:v,sys:n}=d("typescript");var _=Object.defineProperty,b=l((e,r)=>_(e,"name",{value:r,configurable:!0}),"p"),j=Object.defineProperty,N=b((e,r)=>j(e,"name",{value:r,configurable:!0}),"l"),T=Object.defineProperty,t=N((e,r)=>T(e,"name",{value:r,configurable:!0}),"s");const C=t(e=>{const r=e.split(`
2
+ `);return r.at(-1)?.startsWith("//# sourceMappingURL=")?r.slice(0,-1).join(`
3
+ `):e},"stripMapUrl"),h=t(async(e,r,u,o)=>{const a={declarationMap:u,...o?.compilerOptions};let{diagnostics:c,outputText:s,sourceMapText:i}=y(r,{fileName:e,reportDiagnostics:!0,...o,compilerOptions:a});a.declarationMap&&(s=C(s));const g=c?.length?[v(c,{getCanonicalFileName:t(p=>n.useCaseSensitiveFileNames?p:p.toLowerCase(),"getCanonicalFileName"),getCurrentDirectory:t(()=>n.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:t(()=>n.newLine,"getNewLine")})]:[];return i&&(i=JSON.parse(i).mappings),{errors:g,map:i,sourceText:s}},"isolatedDeclarationsTypescriptTransformer");export{h as v};
@@ -0,0 +1 @@
1
+ var R=Object.defineProperty;var y=(r,e)=>R(r,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{createFilter as M}from"@rollup/pluginutils";import{findPackageJson as S}from"@visulima/package/package-json";import{dirname as a}from"@visulima/path";const F=w(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{ResolverFactory:k}=F("oxc-resolver");var O=Object.defineProperty,q=y((r,e)=>O(r,"name",{value:e,configurable:!0}),"y"),T=Object.defineProperty,A=q((r,e)=>T(r,"name",{value:e,configurable:!0}),"g"),B=Object.defineProperty,u=A((r,e)=>B(r,"name",{value:e,configurable:!0}),"a");let x;const J=new Map,G=u((r,e,_,m)=>{const{ignoreSideEffectsForRoot:h,...i}=r;let c=x;return c||(c=x=new k({...i,roots:[...i.roots??[],e],tsconfig:m?{configFile:m,references:"auto"}:void 0})),{name:"oxc-resolve",resolveId:{async handler(p,l,{isEntry:j}){const v=j||!l?a(p):a(l),{error:g,path:o}=await c.async(v,p);if(g){_.debug(g,{context:[{basedir:e,extensions:i.extensions,id:o}]});return}let f=u(t=>!1,"hasModuleSideEffects");try{const{packageJson:t,path:E}=await S(a(o),{cache:J}),b=a(E);if(!h||e!==b){const n=t.sideEffects;if(typeof n=="boolean")f=u(()=>n,"hasModuleSideEffects");else if(Array.isArray(n)){const P=n.map(d=>d.includes("/")?d:`**/${d}`);f=M(P,void 0,{resolve:b})}}}catch(t){console.debug(t.message,{context:[{basedir:v,caller:"Resolver",error:t,extensions:i.extensions,id:o}]})}const s=await this.resolve(o,l,{skipSelf:!0});if(s)return s.external?!1:s.id!==o?s:{id:o,meta:s.meta,moduleSideEffects:f(o)}},order:"post"}}},"oxcResolvePlugin");export{G as z};
@@ -1,6 +1,6 @@
1
- var D=Object.defineProperty;var u=(t,e)=>D(t,"name",{value:e,configurable:!0});import{createRequire as E}from"node:module";import{parse as F}from"@babel/parser";import{findStaticImports as Z}from"mlly";import{isAbsolute as z,join as B,dirname as G,resolve as N}from"@visulima/path";import{isRelative as H}from"@visulima/path/utils";const U=E(import.meta.url);const Fe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=U("magic-string");var J=Object.defineProperty,m=u((t,e)=>J(t,"name",{value:e,configurable:!0}),"u$1"),K=Object.defineProperty,h=m((t,e)=>K(t,"name",{value:e,configurable:!0}),"n"),Q=Object.defineProperty,x=h((t,e)=>Q(t,"name",{value:e,configurable:!0}),"i");let I=class{static{u(this,"y")}static{m(this,"_")}static{h(this,"WalkerBase")}static{x(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:x(()=>this.should_skip=!0,"skip"),remove:x(()=>this.should_remove=!0,"remove"),replace:x(e=>this.replacement=e,"replace")}}replace(e,s,r,n){e&&s&&(r!=null?e[s][r]=n:e[s]=n)}remove(e,s,r){e&&s&&(r!=null?e[s].splice(r,1):delete e[s])}};var V=Object.defineProperty,g=h((t,e)=>V(t,"name",{value:e,configurable:!0}),"c$1");let X=class extends I{static{u(this,"A")}static{m(this,"x")}static{h(this,"SyncWalker")}static{g(this,"SyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:g(()=>this.should_skip=!0,"skip"),remove:g(()=>this.should_remove=!0,"remove"),replace:g(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];y(a)&&(this.visit(a,e,c,l)||l--)}}else y(i)&&this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function y(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u(y,"d$2");m(y,"f");h(y,"n");g(y,"isNode");var Y=Object.defineProperty,b=h((t,e)=>Y(t,"name",{value:e,configurable:!0}),"c");let ee=class extends I{static{u(this,"P")}static{m(this,"j")}static{h(this,"AsyncWalker")}static{b(this,"AsyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:b(()=>this.should_skip=!0,"skip"),remove:b(()=>this.should_remove=!0,"remove"),replace:b(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}async visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];$(a)&&(await this.visit(a,e,c,l)||l--)}}else $(i)&&await this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function $(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u($,"f$2");m($,"d");h($,"a$1");b($,"isNode");var te=Object.defineProperty,C=h((t,e)=>te(t,"name",{value:e,configurable:!0}),"a");function j(t,{enter:e,leave:s}){return new X(e,s).visit(t,null)}u(j,"k$1");m(j,"A");h(j,"walk");C(j,"walk");async function P(t,{enter:e,leave:s}){return await new ee(e,s).visit(t,null)}u(P,"w$3");m(P,"O");h(P,"asyncWalk");C(P,"asyncWalk");var se=Object.defineProperty,A=u((t,e)=>se(t,"name",{value:e,configurable:!0}),"l$1"),re=Object.defineProperty,T=A((t,e)=>re(t,"name",{value:e,configurable:!0}),"l"),ie=Object.defineProperty,d=T((t,e)=>ie(t,"name",{value:e,configurable:!0}),"r");const ne=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,oe=/MIT License|MIT license|BSD license/,le=/\n{2,}/g,ae=/\b(\w+)\$\d+\b/g,ce=/[-/\\^$*+?.()|[\]{}]/g,ue=d(t=>t.replaceAll(ce,String.raw`\$&`),"escapeRegex"),pe=d(t=>[...new Set(t)],"unique"),he=d(t=>t.replaceAll(ne,e=>oe.test(e)?"":e).replaceAll(le,`
1
+ var D=Object.defineProperty;var u=(t,e)=>D(t,"name",{value:e,configurable:!0});import{createRequire as E}from"node:module";import{parse as F}from"@babel/parser";import{findStaticImports as Z}from"mlly";import{isAbsolute as z,join as B,dirname as G,resolve as N}from"@visulima/path";import{isRelative as H}from"@visulima/path/utils";const U=E(import.meta.url),Fe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const L=U("magic-string");var J=Object.defineProperty,m=u((t,e)=>J(t,"name",{value:e,configurable:!0}),"u$1"),K=Object.defineProperty,h=m((t,e)=>K(t,"name",{value:e,configurable:!0}),"n"),Q=Object.defineProperty,x=h((t,e)=>Q(t,"name",{value:e,configurable:!0}),"i");let I=class{static{u(this,"y")}static{m(this,"_")}static{h(this,"WalkerBase")}static{x(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:x(()=>this.should_skip=!0,"skip"),remove:x(()=>this.should_remove=!0,"remove"),replace:x(e=>this.replacement=e,"replace")}}replace(e,s,r,n){e&&s&&(r!=null?e[s][r]=n:e[s]=n)}remove(e,s,r){e&&s&&(r!=null?e[s].splice(r,1):delete e[s])}};var V=Object.defineProperty,g=h((t,e)=>V(t,"name",{value:e,configurable:!0}),"c$1");let X=class extends I{static{u(this,"A")}static{m(this,"x")}static{h(this,"SyncWalker")}static{g(this,"SyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:g(()=>this.should_skip=!0,"skip"),remove:g(()=>this.should_remove=!0,"remove"),replace:g(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];b(a)&&(this.visit(a,e,c,l)||l--)}}else b(i)&&this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function b(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u(b,"d$2");m(b,"f");h(b,"n");g(b,"isNode");var Y=Object.defineProperty,y=h((t,e)=>Y(t,"name",{value:e,configurable:!0}),"c");let ee=class extends I{static{u(this,"P")}static{m(this,"j")}static{h(this,"AsyncWalker")}static{y(this,"AsyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:y(()=>this.should_skip=!0,"skip"),remove:y(()=>this.should_remove=!0,"remove"),replace:y(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}async visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];$(a)&&(await this.visit(a,e,c,l)||l--)}}else $(i)&&await this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function $(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u($,"f$2");m($,"d");h($,"a$1");y($,"isNode");var te=Object.defineProperty,C=h((t,e)=>te(t,"name",{value:e,configurable:!0}),"a");function j(t,{enter:e,leave:s}){return new X(e,s).visit(t,null)}u(j,"k$1");m(j,"A");h(j,"walk");C(j,"walk");async function P(t,{enter:e,leave:s}){return await new ee(e,s).visit(t,null)}u(P,"w$3");m(P,"O");h(P,"asyncWalk");C(P,"asyncWalk");var se=Object.defineProperty,A=u((t,e)=>se(t,"name",{value:e,configurable:!0}),"l$1"),re=Object.defineProperty,T=A((t,e)=>re(t,"name",{value:e,configurable:!0}),"l"),ie=Object.defineProperty,d=T((t,e)=>ie(t,"name",{value:e,configurable:!0}),"r");const ne=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,oe=/MIT License|MIT license|BSD license/,le=/\n{2,}/g,ae=/\b(\w+)\$\d+\b/g,ce=/[-/\\^$*+?.()|[\]{}]/g,ue=d(t=>t.replaceAll(ce,String.raw`\$&`),"escapeRegex"),pe=d(t=>[...new Set(t)],"unique"),he=d(t=>t.replaceAll(ne,e=>oe.test(e)?"":e).replaceAll(le,`
2
2
 
3
3
  `),"cleanUnnecessaryComments"),R=new Map;function w(t,e,{identifierReplacements:s},r){const n=Z(t);for(const i in s){const o=n.find(a=>a.specifier===i&&a.imports.includes("{"));if(!o){this.warn(`${e.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=s[i];for(const a in l){if(!o.imports.includes(a))throw new Error(`${e.fileName} does not import "${a}" from "${i}" for replacement`);const p=l[a],v=ue(a);p.includes(".")&&(t=t.replace(new RegExp(`\\b\\w+\\b as ${v},?\\s?`),"")),t=t.replaceAll(new RegExp(`\\b${v}\\b`,"g"),p)}}const c=pe(Array.from(t.matchAll(ae),i=>i[0]));if(c.length>0){const i=c.map(l=>`
4
4
  - ${l}`).join(""),o=e.fileName.replace(/\.[^/.]+$/,"");R.has(o)||r.warn({message:`${e.fileName} contains confusing identifier names${i}
5
5
 
6
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),R.set(o,!0)}return t}u(w,"f$1");A(w,"g");T(w,"I");d(w,"replaceConfusingTypeNames");const fe=d((t,e)=>{if(e.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=t.original[e.end]===","?e.end+1:e.end;return t.remove(e.leadingComments[0].start,s),!0}return!1},"removeInternal");function O(t,e){if(t.includes("@internal")){const s=new L(t),r=F(t,{plugins:["typescript"],sourceType:"module"});if(j(r,{enter(n){fe(s,n)&&this.skip()}}),t=s.toString(),t.includes("@internal"))throw new Error(`${e.fileName} has unhandled @internal declarations`)}return t}u(O,"u");A(O,"h");T(O,"S");d(O,"stripInternalTypes");const Qe=d((t,e)=>({name:"packem:patch-types",renderChunk(s,r){return s=w.call(this,s,r,t,e),s=O.call(this,s,r),s=he(s),s}}),"patchTypescriptTypes");var me=Object.defineProperty,de=u((t,e)=>me(t,"name",{value:e,configurable:!0}),"d$1"),ve=Object.defineProperty,ge=de((t,e)=>ve(t,"name",{value:e,configurable:!0}),"d"),be=Object.defineProperty,f=ge((t,e)=>be(t,"name",{value:e,configurable:!0}),"o");const ye=42,$e=f(t=>{let e=!1;for(let s=0;s<t.length;s++)if(t.codePointAt(s)===ye){if(e)return!1;e=!0}return!0},"hasZeroOrOneAsteriskCharacter"),_e=f(t=>{const e=t.indexOf("*");return e===-1?void 0:{prefix:t.slice(0,e),suffix:t.slice(e+1)}},"tryParsePattern"),ke=f(({prefix:t,suffix:e},s)=>s.length>=t.length+e.length&&s.startsWith(t)&&s.endsWith(e),"isPatternMatch"),xe=f((t,e,s)=>{let r,n=-1;for(const c of t){const i=e(c);ke(i,s)&&i.prefix.length>n&&(n=i.prefix.length,r=c)}return r},"findBestPatternMatch"),je=f((t,e)=>{const s=[];for(const r of t){if(!$e(r))continue;const n=_e(r);if(n)s.push(n);else if(r===e)return r}return xe(s,r=>r,e)},"matchPatternOrExact"),we=f((t,e)=>e.substring(t.prefix.length,e.length-t.suffix.length),"matchedText"),Oe=f(({prefix:t,suffix:e})=>`${t}*${e}`,"patternText"),Pe=f((t,e,s)=>{let r=G(e.path);e.config.compilerOptions?.baseUrl&&(r=N(t,e.config.compilerOptions.baseUrl)),s?.debug({message:`Resolved baseUrl to ${r}`,prefix:"plugin:resolve-tsconfig-paths"});const n=e.config.compilerOptions?.paths??{};return Object.keys(n).length===0&&s?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:n,resolvedBaseUrl:r}},"getTsconfigPaths"),Ve=f((t,e,s,r)=>{const{paths:n,resolvedBaseUrl:c}=Pe(t,e,s),i=Object.keys(n);return{name:"plugin:resolve-tsconfig-paths",async resolveId(o,l,a){if(i.length===0)return;if(o.includes("\0")){s.debug({message:`Skipping resolution of ${o} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(o.includes("node_modules")){s.debug({message:`Skipping request as it is inside node_modules ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!r.resolveAbsolutePath&&z(o)){s.debug({message:`Skipping request as it is an absolute path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(H(o)){s.debug({message:`Skipping request as it is a relative path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=je(i,o);if(!p){s.debug({message:`moduleName did not match any paths pattern ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const v=typeof p=="string"?void 0:we(p,o),q=typeof p=="string"?p:Oe(p);for await(const W of n[q]){const _=v?W.replace("*",v):W;if(_.endsWith(".d.ts")||_.endsWith(".d.cts")||_.endsWith(".d.mts"))continue;const S=B(c,_);try{const k=await this.resolve(S,l,{skipSelf:!0,...a});if(k)return k}catch(k){s.debug({context:[k],message:`Failed to resolve ${S} from ${o}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}},"resolveTsconfigPathsPlugin");var Ae=Object.defineProperty,Te=u((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"f"),We=Object.defineProperty,Se=Te((t,e)=>We(t,"name",{value:e,configurable:!0}),"c"),Re=Object.defineProperty,M=Se((t,e)=>Re(t,"name",{value:e,configurable:!0}),"u");const Be=M((t,e)=>{if(!e)return;const{config:s,path:r}=e;if(!s.compilerOptions)return;const{rootDirs:n}=s.compilerOptions;if(!n)return;const c=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);c.push(N(t,i))}return c},"getRootDirectories"),Xe=M((t,e,s)=>{const r=Be(t,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,c,i){if(!(r===void 0||r.length===0)&&n.startsWith("."))for(const o of r){const l=B(o,n),a=await this.resolve(l,c,{skipSelf:!0,...i});if(a)return e.debug({message:`Resolved ${n} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}}}},"resolveTsconfigRootDirectories");var Ne=Object.defineProperty,Ie=u((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"t"),Ce=Object.defineProperty,Me=Ie((t,e)=>Ce(t,"name",{value:e,configurable:!0}),"t"),qe=Object.defineProperty,De=Me((t,e)=>qe(t,"name",{value:e,configurable:!0}),"r");const Ye=De(()=>{const t=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(e,s,r){if(t.test(e)&&s)return await this.resolve(e.replace(/js(x?)$/,"ts$1"),s,r)}}},"resolveTypescriptMjsCts");export{Qe as B,Xe as D,Ve as N,Ye as i,j as k};
6
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),R.set(o,!0)}return t}u(w,"f$1");A(w,"g");T(w,"I");d(w,"replaceConfusingTypeNames");const fe=d((t,e)=>{if(e.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=t.original[e.end]===","?e.end+1:e.end;return t.remove(e.leadingComments[0].start,s),!0}return!1},"removeInternal");function O(t,e){if(t.includes("@internal")){const s=new L(t),r=F(t,{plugins:["typescript"],sourceType:"module"});if(j(r,{enter(n){fe(s,n)&&this.skip()}}),t=s.toString(),t.includes("@internal"))throw new Error(`${e.fileName} has unhandled @internal declarations`)}return t}u(O,"u");A(O,"h");T(O,"S");d(O,"stripInternalTypes");const Qe=d((t,e)=>({name:"packem:patch-types",renderChunk(s,r){return s=w.call(this,s,r,t,e),s=O.call(this,s,r),s=he(s),s}}),"patchTypescriptTypes");var me=Object.defineProperty,de=u((t,e)=>me(t,"name",{value:e,configurable:!0}),"d$1"),ve=Object.defineProperty,ge=de((t,e)=>ve(t,"name",{value:e,configurable:!0}),"d"),ye=Object.defineProperty,f=ge((t,e)=>ye(t,"name",{value:e,configurable:!0}),"o");const be=42,$e=f(t=>{let e=!1;for(let s=0;s<t.length;s++)if(t.codePointAt(s)===be){if(e)return!1;e=!0}return!0},"hasZeroOrOneAsteriskCharacter"),_e=f(t=>{const e=t.indexOf("*");return e===-1?void 0:{prefix:t.slice(0,e),suffix:t.slice(e+1)}},"tryParsePattern"),ke=f(({prefix:t,suffix:e},s)=>s.length>=t.length+e.length&&s.startsWith(t)&&s.endsWith(e),"isPatternMatch"),xe=f((t,e,s)=>{let r,n=-1;for(const c of t){const i=e(c);ke(i,s)&&i.prefix.length>n&&(n=i.prefix.length,r=c)}return r},"findBestPatternMatch"),je=f((t,e)=>{const s=[];for(const r of t){if(!$e(r))continue;const n=_e(r);if(n)s.push(n);else if(r===e)return r}return xe(s,r=>r,e)},"matchPatternOrExact"),we=f((t,e)=>e.substring(t.prefix.length,e.length-t.suffix.length),"matchedText"),Oe=f(({prefix:t,suffix:e})=>`${t}*${e}`,"patternText"),Pe=f((t,e,s)=>{let r=G(e.path);e.config.compilerOptions?.baseUrl&&(r=N(t,e.config.compilerOptions.baseUrl)),s?.debug({message:`Resolved baseUrl to ${r}`,prefix:"plugin:resolve-tsconfig-paths"});const n=e.config.compilerOptions?.paths??{};return Object.keys(n).length===0&&s?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:n,resolvedBaseUrl:r}},"getTsconfigPaths"),Ve=f((t,e,s,r)=>{const{paths:n,resolvedBaseUrl:c}=Pe(t,e,s),i=Object.keys(n);return{name:"plugin:resolve-tsconfig-paths",async resolveId(o,l,a){if(i.length===0)return;if(o.includes("\0")){s.debug({message:`Skipping resolution of ${o} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(o.includes("node_modules")){s.debug({message:`Skipping request as it is inside node_modules ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!r.resolveAbsolutePath&&z(o)){s.debug({message:`Skipping request as it is an absolute path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(H(o)){s.debug({message:`Skipping request as it is a relative path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=je(i,o);if(!p){s.debug({message:`moduleName did not match any paths pattern ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const v=typeof p=="string"?void 0:we(p,o),q=typeof p=="string"?p:Oe(p);for await(const W of n[q]){const _=v?W.replace("*",v):W;if(_.endsWith(".d.ts")||_.endsWith(".d.cts")||_.endsWith(".d.mts"))continue;const S=B(c,_);try{const k=await this.resolve(S,l,{skipSelf:!0,...a});if(k)return k}catch(k){s.debug({context:[k],message:`Failed to resolve ${S} from ${o}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}},"resolveTsconfigPathsPlugin");var Ae=Object.defineProperty,Te=u((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"f"),We=Object.defineProperty,Se=Te((t,e)=>We(t,"name",{value:e,configurable:!0}),"c"),Re=Object.defineProperty,M=Se((t,e)=>Re(t,"name",{value:e,configurable:!0}),"u");const Be=M((t,e)=>{if(!e)return;const{config:s,path:r}=e;if(!s.compilerOptions)return;const{rootDirs:n}=s.compilerOptions;if(!n)return;const c=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);c.push(N(t,i))}return c},"getRootDirectories"),Xe=M((t,e,s)=>{const r=Be(t,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,c,i){if(!(r===void 0||r.length===0)&&n.startsWith("."))for(const o of r){const l=B(o,n),a=await this.resolve(l,c,{skipSelf:!0,...i});if(a)return e.debug({message:`Resolved ${n} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}}}},"resolveTsconfigRootDirectories");var Ne=Object.defineProperty,Ie=u((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"t"),Ce=Object.defineProperty,Me=Ie((t,e)=>Ce(t,"name",{value:e,configurable:!0}),"t"),qe=Object.defineProperty,De=Me((t,e)=>qe(t,"name",{value:e,configurable:!0}),"r");const Ye=De(()=>{const t=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(e,s,r){if(t.test(e)&&s)return await this.resolve(e.replace(/js(x?)$/,"ts$1"),s,r)}}},"resolveTypescriptMjsCts");export{Qe as B,Xe as D,Ve as N,Ye as i,j as k};
@@ -1 +1 @@
1
- import{z as f}from"../../../packem_shared/esbuildPlugin-BrFhdKJk-BzTGlVjw.js";export{f as default};
1
+ import{z as f}from"../../../packem_shared/esbuildPlugin-BrFhdKJk-C8Y7RuGP.js";export{f as default};
@@ -1 +1 @@
1
- import{sucrasePlugin as r}from"../../../packem_shared/default-BM-KR0tJ.js";export{r as default};
1
+ import{sucrasePlugin as r}from"../../../packem_shared/default-Bi3Aj6a9.js";export{r as default};
@@ -1 +1 @@
1
- import{v as f}from"../../../packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-CAV3IRk9.js";export{f as default};
1
+ import{v as f}from"../../../packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-BCM0B079.js";export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "2.0.0-alpha.29",
3
+ "version": "2.0.0-alpha.30",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -171,7 +171,7 @@
171
171
  "@visulima/fs": "3.1.8",
172
172
  "@visulima/humanizer": "1.2.2",
173
173
  "@visulima/package": "4.0.0",
174
- "@visulima/packem-rollup": "1.0.0-alpha.22",
174
+ "@visulima/packem-rollup": "1.0.0-alpha.23",
175
175
  "@visulima/packem-share": "1.0.0-alpha.13",
176
176
  "@visulima/pail": "2.1.28",
177
177
  "@visulima/path": "1.4.0",
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var o=(e,r)=>l(e,"name",{value:r,configurable:!0});import{createRequire as f}from"node:module";import{createFilter as m}from"@rollup/pluginutils";import{f as d}from"./index-CUp9WuCG.js";const p=f(import.meta.url);const O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transform:b}=p("sucrase");var _=Object.defineProperty,g=o((e,r)=>_(e,"name",{value:r,configurable:!0}),"n"),v=Object.defineProperty,j=g((e,r)=>v(e,"name",{value:r,configurable:!0}),"a"),P=Object.defineProperty,y=j((e,r)=>P(e,"name",{value:r,configurable:!0}),"n");const n=y(({exclude:e,include:r,...t})=>{const c=m(r,e??d);return{name:"packem:sucrase",async transform(a,s){if(!c(s))return;const{code:i,sourceMap:u}=b(a,{...t,filePath:s,sourceMapOptions:{compiledFilename:s}});return{code:i,map:u}}}},"sucraseTransformPlugin");n.NAME="sucrase";const x=n;export{x as sucrasePlugin};
@@ -1,3 +0,0 @@
1
- var k=Object.defineProperty;var v=(e,r)=>k(e,"name",{value:r,configurable:!0});import{createRequire as M}from"node:module";import{createFilter as P}from"@rollup/pluginutils";import{a as A}from"./index-CUp9WuCG.js";import{extname as $,join as q}from"@visulima/path";import{findCacheDirSync as T}from"@visulima/find-cache-dir";import{readFileSync as S}from"@visulima/fs";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
- const require = __cjs_mod__.createRequire(import.meta.url);
3
- const _=M(import.meta.url);const ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transform:w,formatMessages:E,build:R}=_("esbuild"),h=_("rs-module-lexer"),W={...h,default:h};var B=Object.defineProperty,C=v((e,r)=>B(e,"name",{value:r,configurable:!0}),"h"),F=Object.defineProperty,f=C((e,r)=>F(e,"name",{value:r,configurable:!0}),"u"),I=Object.defineProperty,N=f((e,r)=>I(e,"name",{value:r,configurable:!0}),"n$1");const j=N(async(e,r)=>{r.length>0&&(await E(r,{color:!0,kind:"warning"})).forEach(a=>e.warn(a))},"warn");var L=Object.defineProperty,D=f((e,r)=>L(e,"name",{value:r,configurable:!0}),"t");const G=D(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),H=D(({sourceMap:e=!0,...r})=>async function(a,n,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=G(i.format),c=await w(a,{format:t,loader:"js",sourcemap:e,...r});if(await j(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var U=Object.defineProperty,z=f((e,r)=>U(e,"name",{value:r,configurable:!0}),"n");const y=z(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:J}=W,K=z(async e=>{const r=T("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await R({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",async setup(n){n.onResolve({filter:/.*/},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await n.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),n.onLoad({filter:/.*/,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,u=S(t),{output:g}=await J({input:[{code:u,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${y(t)}'`:`module.exports = require('${y(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const a=new Map;for(const n of e.include)a.set(n,{file:q(r,`${n}.js`)});return{cacheDir:r,optimized:a}},"optimizeDeps");var Q=Object.defineProperty,V=f((e,r)=>Q(e,"name",{value:r,configurable:!0}),"g");const X=V(({exclude:e,include:r,loaders:a,logger:n,optimizeDeps:i,sourceMap:t,...c})=>{const u=A;if(a!==void 0)for(let[o,s]of Object.entries(a)){const p=o.startsWith(".")?o:`.${o}`;typeof s=="string"?u[p]=s:s||delete u[p]}const g=Object.keys(u),x=new RegExp(`\\.(${g.map(o=>o.slice(1)).join("|")})$`),O=P(r??x,e);let l,b=process.cwd();return{async buildStart(){!i||l||(l=await K({cwd:b,sourceMap:t??!1,...i}),n.debug("optimized %O",l.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:H({...c,sourceMap:t}),async resolveId(o){if(l?.optimized.has(o)){const s=l.optimized.get(o);if(s)return n.debug("resolved %s to %s",o,s.file),s.file}},async transform(o,s){if(!O(s)||l?.optimized.has(s))return;const p=$(s),d=u[p];if(n.debug("transforming %s with %s loader",s,d),!d)return;const m=await w(o,{format:["base64","binary","dataurl","text","json"].includes(d)?"esm":void 0,loader:d,sourcefile:s.replace(/\.[cm]ts/,".ts"),sourcemap:t,...c});if(await j(this,m.warnings),m.code)return{code:m.code,map:m.map||void 0}}}},"esbuildTransformer");X.NAME="esbuild";export{X as z};
@@ -1,3 +0,0 @@
1
- var m=Object.defineProperty;var l=(e,r)=>m(e,"name",{value:r,configurable:!0});import{createRequire as f}from"node:module";const d=f(import.meta.url);const O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transpileDeclaration:y,formatDiagnostics:_,sys:o}=d("typescript");var b=Object.defineProperty,v=l((e,r)=>b(e,"name",{value:r,configurable:!0}),"p"),j=Object.defineProperty,N=v((e,r)=>j(e,"name",{value:r,configurable:!0}),"l"),T=Object.defineProperty,t=N((e,r)=>T(e,"name",{value:r,configurable:!0}),"s");const C=t(e=>{const r=e.split(`
2
- `);return r.at(-1)?.startsWith("//# sourceMappingURL=")?r.slice(0,-1).join(`
3
- `):e},"stripMapUrl"),h=t(async(e,r,u,n)=>{const a={declarationMap:u,...n?.compilerOptions};let{diagnostics:c,outputText:i,sourceMapText:s}=y(r,{fileName:e,reportDiagnostics:!0,...n,compilerOptions:a});a.declarationMap&&(i=C(i));const g=c?.length?[_(c,{getCanonicalFileName:t(p=>o.useCaseSensitiveFileNames?p:p.toLowerCase(),"getCanonicalFileName"),getCurrentDirectory:t(()=>o.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:t(()=>o.newLine,"getNewLine")})]:[];return s&&(s=JSON.parse(s).mappings),{errors:g,map:s,sourceText:i}},"isolatedDeclarationsTypescriptTransformer");export{h as v};
@@ -1 +0,0 @@
1
- var R=Object.defineProperty;var y=(r,e)=>R(r,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{createFilter as M}from"@rollup/pluginutils";import{findPackageJson as S}from"@visulima/package/package-json";import{dirname as a}from"@visulima/path";const F=w(import.meta.url);const N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{ResolverFactory:k}=F("oxc-resolver");var O=Object.defineProperty,q=y((r,e)=>O(r,"name",{value:e,configurable:!0}),"y"),T=Object.defineProperty,A=q((r,e)=>T(r,"name",{value:e,configurable:!0}),"g"),B=Object.defineProperty,u=A((r,e)=>B(r,"name",{value:e,configurable:!0}),"a");let x;const J=new Map,G=u((r,e,_,p)=>{const{ignoreSideEffectsForRoot:h,...i}=r;let c=x;return c||(c=x=new k({...i,roots:[...i.roots??[],e],tsconfig:p?{configFile:p,references:"auto"}:void 0})),{name:"oxc-resolve",resolveId:{async handler(m,l,{isEntry:j}){const g=j||!l?a(m):a(l),{error:v,path:o}=await c.async(g,m);if(v){_.debug(v,{context:[{basedir:e,extensions:i.extensions,id:o}]});return}let f=u(t=>!1,"hasModuleSideEffects");try{const{packageJson:t,path:E}=await S(a(o),{cache:J}),b=a(E);if(!h||e!==b){const n=t.sideEffects;if(typeof n=="boolean")f=u(()=>n,"hasModuleSideEffects");else if(Array.isArray(n)){const P=n.map(d=>d.includes("/")?d:`**/${d}`);f=M(P,void 0,{resolve:b})}}}catch(t){console.debug(t.message,{context:[{basedir:g,caller:"Resolver",error:t,extensions:i.extensions,id:o}]})}const s=await this.resolve(o,l,{skipSelf:!0});if(s)return s.external?!1:s.id!==o?s:{id:o,meta:s.meta,moduleSideEffects:f(o)}},order:"post"}}},"oxcResolvePlugin");export{G as z};