@visulima/packem 1.0.0-alpha.86 → 1.0.0-alpha.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cli.cjs +7 -5
- package/dist/cli.mjs +8 -6
- package/dist/create-bundler.cjs +47 -47
- package/dist/create-bundler.mjs +43 -43
- package/package.json +10 -6
package/dist/create-bundler.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new R(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&
|
|
3
|
-
`)=>{const o=
|
|
4
|
-
`));let c=[];try{c=await V.resolveModuleExportNames(s,{extensions:
|
|
1
|
+
"use strict";var ft=Object.defineProperty;var m=(e,t)=>ft(e,"name",{value:t,configurable:!0});const ne=require("node:fs/promises"),mt=require("node:module"),se=require("node:process"),v=require("@visulima/colorize"),$=require("@visulima/fs"),P=require("@visulima/humanizer"),gt=require("@visulima/package/package-json"),f=require("@visulima/path"),ge=require("@visulima/tsconfig"),ht=require("defu"),yt=require("hookable"),A=require("rollup"),x=require("./shared/constants-lwnJ_PjR.cjs"),Pe=require("node:url"),V=require("mlly"),vt=require("magic-string"),bt=require("jiti"),ie=require("node:fs"),$t=require("@rollup/plugin-alias"),wt=require("@rollup/plugin-commonjs"),jt=require("@rollup/plugin-dynamic-import-vars"),Ce=require("@rollup/plugin-node-resolve"),xt=require("@rollup/plugin-replace"),kt=require("@rollup/plugin-wasm"),Et=require("rollup-plugin-polyfill-node"),St=require("rollup-plugin-visualizer"),Re=require("semver"),Ot=require("node:assert/strict"),D=require("@rollup/pluginutils"),Nt=require("glob-parent"),Ie=require("tinyglobby"),_t=require("oxc-parser"),Dt=require("@rollup/plugin-json"),Pt=require("rollup-plugin-license"),Ct=require("node:crypto"),Rt=require("@babel/parser"),It=require("@visulima/find-cache-dir"),Ft=require("@visulima/fs/error"),Mt=require("@visulima/path/utils"),Tt=require("is-glob"),At=require("fastest-levenshtein");var he=typeof document<"u"?document.currentScript:null;const O=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ye=O(mt),R=O(vt),Fe=O(bt),Me=O($t),Jt=O(wt),Lt=O(jt),Te=O(xt),qt=O(Et),H=O(Ot),Bt=O(Nt),Wt=O(Dt),Ut=O(Pt),ve=O(Tt);var zt=Object.defineProperty,X=m((e,t)=>zt(e,"name",{value:t,configurable:!0}),"i$c");const ae=/^#![^\n]*/,oe=X(async e=>{await ne.chmod(e,493).catch(()=>{})},"makeExecutable"),Vt=X((e,t=`#!/usr/bin/env node
|
|
2
|
+
`)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new R(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&ae.test(s.code)&&o.dir){const i=f.resolve(o.dir,n);await oe(i)}}}),"shebangPlugin"),Ht=X(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ae,"")}}),"removeShebangPlugin"),Gt=X((e,t=`
|
|
3
|
+
`)=>{const o=ae.exec(e);return o?o+t:""},"getShebang");var Xt=Object.defineProperty,Kt=m((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"p$2");const le=Kt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const s=r[n];typeof s=="string"&&(o[n]=f.join(e.options.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(r=>[r.find,r.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 Yt=Object.defineProperty,Qt=m((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"o$4");const Zt=Qt((e,t)=>{const o=Fe(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var eo=Object.defineProperty,to=m((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$9");const J=to((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var oo=Object.defineProperty,ro=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$d");const no=ro(async e=>{const t=await V.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:he&&he.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...le(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=f.resolve(e.options.rootDir,e.options.outDir,r.name),s=f.normalize(Zt(r.input,e.options.rootDir)||r.input),i=s.slice(0,Math.max(0,s.length-f.extname(s).length)),a=await $.readFile(s),l=Gt(a);e.options.emitCJS&&await $.writeFile(`${n}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
|
|
4
|
+
`));let c=[];try{c=await V.resolveModuleExportNames(s,{extensions:x.DEFAULT_EXTENSIONS})}catch(d){J(e,`Cannot analyze ${s} for exports: ${d.toString()}`);return}const u=c.includes("default")||c.length===0;await $.writeFile(`${n}.mjs`,l+[`import jiti from ${JSON.stringify(Pe.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
|
|
5
5
|
export default _module;`:"",...c.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
|
|
6
|
-
`)),await
|
|
7
|
-
`)),await
|
|
8
|
-
`)),l&&(await te(`${n}.cjs`),await te(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=f((e,t)=>so(e,"name",{value:t,configurable:!0}),"r$8");const Ae=io((e,t)=>Me(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var ao=Object.defineProperty,lo=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$9");const le=lo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var co=Object.defineProperty,Le=f((e,t)=>co(e,"name",{value:t,configurable:!0}),"e$3");const X=Le(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Je=Le((e,t,o,r)=>{if(r){const i=X(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...s]=t;return Je(n,s,o,r)},"inferExportType");var po=Object.defineProperty,uo=f((e,t)=>po(e,"name",{value:t,configurable:!0}),"i$8");const fo=new Set(["import","require","node","node-addons","default","types","deno","browser",...w.SPECIAL_EXPORT_CONVENTIONS]),ce=uo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=X(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>o===!1&&n==="types"?[]:typeof s=="string"?{file:s,key:"exports",...fo.has(n)?{subKey:n}:{},type:Je(n,r,t,s)}:ce(s,t,o,[...r,n]))},"extractExportFilenames");var mo=Object.defineProperty,K=f((e,t)=>mo(e,"name",{value:t,configurable:!0}),"a$c");const go=K((e,t)=>e.key==="exports"&&e.subKey===w.PRODUCTION_ENV?w.PRODUCTION_ENV:e.key==="exports"&&e.subKey===w.DEVELOPMENT_ENV?w.DEVELOPMENT_ENV:t,"getEnvironment"),B=K((e,t,o,r,n,s)=>{const i=go(n,s.environment);let a=e.find(c=>c.input===t&&c.environment===i);if(a===void 0&&(a=e[e.push({input:t})-1]),o&&(a.outDir=r),n.isExecutable)a.executable=!0,a.declaration=!1,n.type==="cjs"&&(a.cjs=!0),n.type==="esm"&&(a.esm=!0);else{/\.d\.[mc]?ts$/.test(n.file)&&s.options.declaration!==!1&&(a.declaration=s.options.declaration),n.type==="cjs"&&(a.cjs=!0),n.type==="esm"&&(a.esm=!0);for(const c of w.RUNTIME_EXPORT_CONVENTIONS)if(n.file.includes("."+c+".")){a.runtime=c;break}}a.runtime===void 0&&(a.runtime="node"),a.environment=i;const l=n.file.replace(m.extname(n.file),"").replace(new RegExp(`^./${s.options.outDir.replace(/^\.\//,"")}/`),"");w.SPECIAL_EXPORT_CONVENTIONS.has(n.subKey)&&!t.includes(l)&&(a.fileAlias=l)},"createOrUpdateEntry");let ve=!1;const be=K(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),ho=K((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const s=ce(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=X(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&s.push({file:e.main,key:"main",type:X(e.main)??n}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(be(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const a of s){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",p=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){ve||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),ve=!0);const x=[],j=new RegExp(d+u.replace("*","(.*)")+p),$=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+p);for(const E of t)(j.test(E)||w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&$.test(E))&&x.push(E);if(x.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const E of x)B(i,E,c,l,a,o);continue}const g=new RegExp(d+u+p);let v=t.find(x=>g.test(x));if(w.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&v===void 0){const x=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1")+p);v=t.find(j=>x.test(j))}if(v===void 0){b.isAccessibleSync(m.resolve(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(v.endsWith(".ts")||v.endsWith(".cts")||v.endsWith(".mts"))&&b.isAccessibleSync(v)&&be(o);const h=v.replace(w.ENDING_RE,"");b.isAccessibleSync(h+".cts")&&b.isAccessibleSync(h+".mts")?(B(i,h+".cts",c,l,{...a,type:"cjs"},o),B(i,h+".mts",c,l,{...a,type:"esm"},o)):B(i,v,c,l,a,o)}return{entries:i,warnings:r}},"inferEntries");var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"o$3");const bo=vo((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 $o=Object.defineProperty,wo=f((e,t)=>$o(e,"name",{value:t,configurable:!0}),"t$7");const jo={hooks:{"build:prepare":wo(function(e){if(e.options.entries.length>0)return;const t=m.join(e.options.rootDir,e.options.sourceDir);if(!se.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=b.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(le(r.publishConfig)),r=bo(r,e.options.declaration));const n=ho(r,o,e);for(const s of n.warnings)L(e,s);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",y.cyan(e.options.entries.map(s=>y.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),y.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var xo=Object.defineProperty,ko=f((e,t)=>xo(e,"name",{value:t,configurable:!0}),"n$9");const Eo=ko((e,t)=>{if(e==="auto")e=jo;else{if(e==="none")return{};typeof e=="string"&&(e=Ae(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var So=Object.defineProperty,Oo=f((e,t)=>So(e,"name",{value:t,configurable:!0}),"a$b");const oe=Oo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Do=Object.defineProperty,_o=f((e,t)=>Do(e,"name",{value:t,configurable:!0}),"a$a");const F=_o(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var No=Object.defineProperty,Po=f((e,t)=>No(e,"name",{value:t,configurable:!0}),"a$9");const qe=Po((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Co=Object.defineProperty,Be=f((e,t)=>Co(e,"name",{value:t,configurable:!0}),"s$b");const Ro=Be((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const a=e(...n);return r.set(s,a),a}},"memoize"),Io=Be(e=>{const t=new Map;return o=>Ro(e,o,t)},"memoizeByKey");var Mo=Object.defineProperty,J=f((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"r$5");const To=J(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;H(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of N.extractAssignedNames(t.id))yield o;break}}},"exportName"),Fo=J(function*(e){if(e.declaration)for(const t of To(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),Ao=J(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),Lo=J(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Jo=J(function*(e,t){H(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*Ao(r);break}case"ExportDefaultDeclaration":{yield*Lo();break}case"ExportNamedDeclaration":{yield*Fo(r);break}}},"parseExports");var qo=Object.defineProperty,q=f((e,t)=>qo(e,"name",{value:t,configurable:!0}),"n$6");const We=q(async function(e,t,o){const r=await e.resolve(t,o.id);if(H(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return H(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),Bo=q(async function*(e,t,o){const r=await We(e,t.source,o);r&&(yield*pe(e,r))},"gatherBarrelReExports"),Wo=q(async function*(e,t,o){const r=await We(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of pe(e,r)){const i=n.get(s.exportedName);i&&(yield{...s,exportedName:i.exportedName})}},"gatherNamedReExports"),Uo=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),pe=q(async function*(e,t){for(const o of Jo(e,t))o.from==="self"?yield*Uo(t,o):o.type==="barrel"?yield*Bo(e,o,t):yield*Wo(e,o,t)},"gatherExports");var zo=Object.defineProperty,Vo=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$5");const Ho=Vo(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of pe(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Xo=Object.defineProperty,Go=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"m$6");const Ue=Go(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,s){if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const a=new R(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
6
|
+
`)),await $.writeFile(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
7
|
+
`)),await $.writeFile(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
8
|
+
`)),l&&(await oe(`${n}.cjs`),await oe(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"r$8");const Ae=io((e,t)=>Fe(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$9");const ce=lo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var co=Object.defineProperty,Je=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"e$2");const G=Je(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Le=Je((e,t,o,r)=>{if(r){const i=G(r);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...s]=t;return Le(n,s,o,r)},"inferExportType");var po=Object.defineProperty,uo=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"i$8");const fo=new Set(["import","require","node","node-addons","default","types","deno","browser",...x.SPECIAL_EXPORT_CONVENTIONS]),pe=uo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=G(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>o===!1&&n==="types"?[]:typeof s=="string"?{file:s,key:"exports",...fo.has(n)?{subKey:n}:{},type:Le(n,r,t,s)}:pe(s,t,o,[...r,n]))},"extractExportFilenames");var mo=Object.defineProperty,K=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"a$d");const go=K((e,t)=>e.key==="exports"&&e.subKey===x.PRODUCTION_ENV?x.PRODUCTION_ENV:e.key==="exports"&&e.subKey===x.DEVELOPMENT_ENV?x.DEVELOPMENT_ENV:t,"getEnvironment"),B=K((e,t,o,r,n,s)=>{const i=go(n,s.environment);let a=e.find(c=>c.input===t&&c.environment===i);if(a===void 0&&(a=e[e.push({input:t})-1]),o&&(a.outDir=r),n.isExecutable)a.executable=!0,a.declaration=!1,n.type==="cjs"&&(a.cjs=!0),n.type==="esm"&&(a.esm=!0);else{/\.d\.[mc]?ts$/.test(n.file)&&s.options.declaration!==!1&&(a.declaration=s.options.declaration),n.type==="cjs"&&(a.cjs=!0),n.type==="esm"&&(a.esm=!0);for(const c of x.RUNTIME_EXPORT_CONVENTIONS)if(n.file.includes("."+c+".")){a.runtime=c;break}}a.runtime===void 0&&(a.runtime="node"),a.environment=i;const l=n.file.replace(f.extname(n.file),"").replace(new RegExp(`^./${s.options.outDir.replace(/^\.\//,"")}/`),"");x.SPECIAL_EXPORT_CONVENTIONS.has(n.subKey)&&!t.includes(l)&&(a.fileAlias=l)},"createOrUpdateEntry");let be=!1;const $e=K(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),ho=K((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const s=pe(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=G(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&s.push({file:e.main,key:"main",type:G(e.main)??n}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&($e(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),s.push({file:e.types??e.typings,key:"types"}));const i=[];for(const a of s){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",p=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){be||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),be=!0);const b=[],w=new RegExp(d+u.replace("*","(.*)")+p),j=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+p);for(const E of t)(w.test(E)||x.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&j.test(E))&&b.push(E);if(b.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const E of b)B(i,E,c,l,a,o);continue}const g=new RegExp(d+u+p);let y=t.find(b=>g.test(b));if(x.SPECIAL_EXPORT_CONVENTIONS.has(a.subKey)&&y===void 0){const b=new RegExp(d+u.replace(/(.*)\.[^.]*$/,"$1")+p);y=t.find(w=>b.test(w))}if(y===void 0){$.isAccessibleSync(f.resolve(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&$.isAccessibleSync(y)&&$e(o);const h=y.replace(x.ENDING_RE,"");$.isAccessibleSync(h+".cts")&&$.isAccessibleSync(h+".mts")?(B(i,h+".cts",c,l,{...a,type:"cjs"},o),B(i,h+".mts",c,l,{...a,type:"esm"},o)):B(i,y,c,l,a,o)}return{entries:i,warnings:r}},"inferEntries");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"o$3");const bo=vo((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 $o=Object.defineProperty,wo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"t$7");const jo={hooks:{"build:prepare":wo(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,e.options.sourceDir);if(!ie.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=$.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(ce(r.publishConfig)),r=bo(r,e.options.declaration));const n=ho(r,o,e);for(const s of n.warnings)J(e,s);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v.cyan(e.options.entries.map(s=>v.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),v.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var xo=Object.defineProperty,ko=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"n$9");const Eo=ko((e,t)=>{if(e==="auto")e=jo;else{if(e==="none")return{};typeof e=="string"&&(e=Ae(e,t))}return typeof e=="function"&&(e=e()),e},"resolvePreset");var So=Object.defineProperty,Oo=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"a$c");const re=Oo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var No=Object.defineProperty,_o=m((e,t)=>No(e,"name",{value:t,configurable:!0}),"a$b");const T=_o(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var Do=Object.defineProperty,Po=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"a$a");const qe=Po((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Co=Object.defineProperty,Be=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"s$c");const Ro=Be((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const a=e(...n);return r.set(s,a),a}},"memoize"),Io=Be(e=>{const t=new Map;return o=>Ro(e,o,t)},"memoizeByKey");var Fo=Object.defineProperty,L=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$5");const Mo=L(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;H(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of D.extractAssignedNames(t.id))yield o;break}}},"exportName"),To=L(function*(e){if(e.declaration)for(const t of Mo(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),Ao=L(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),Jo=L(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),Lo=L(function*(e,t){H(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*Ao(r);break}case"ExportDefaultDeclaration":{yield*Jo();break}case"ExportNamedDeclaration":{yield*To(r);break}}},"parseExports");var qo=Object.defineProperty,q=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"n$6");const We=q(async function(e,t,o){const r=await e.resolve(t,o.id);if(H(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return H(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),Bo=q(async function*(e,t,o){const r=await We(e,t.source,o);r&&(yield*ue(e,r))},"gatherBarrelReExports"),Wo=q(async function*(e,t,o){const r=await We(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(s=>[s.importedName,s]));for await(const s of ue(e,r)){const i=n.get(s.exportedName);i&&(yield{...s,exportedName:i.exportedName})}},"gatherNamedReExports"),Uo=q(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ue=q(async function*(e,t){for(const o of Lo(e,t))o.from==="self"?yield*Uo(t,o):o.type==="barrel"?yield*Bo(e,o,t):yield*Wo(e,o,t)},"gatherExports");var zo=Object.defineProperty,Vo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$5");const Ho=Vo(({preserveChunkSignature:e=!1}={})=>({moduleParsed:{async handler(t){if(t.isEntry)for await(const o of ue(this,t))o.id!==t.id&&this.emitFile({id:o.id,name:o.exportedName,preserveSignature:e,type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var Go=Object.defineProperty,Xo=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"m$7");const Ue=Xo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,s){if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const a=new R(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
9
9
|
module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const a=i[1].split(", "),l=[];let c="";for(const d of a)if(!d.includes("type"))if(d.includes("as")){const[p,g]=d.split(" as ");if(g==="default"&&(c=p,!e))continue;l.push(g+": typeof "+p+";")}else l.push(d+": typeof "+d+";");const u=new R(r);return u.replace(" "+c+" as default,",""),u.append(`
|
|
10
10
|
|
|
11
11
|
declare const defaultExport: {
|
|
@@ -13,7 +13,7 @@ declare const defaultExport: {
|
|
|
13
13
|
`)+`
|
|
14
14
|
}`+(c?" & typeof "+c:"")+`;
|
|
15
15
|
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ko=Object.defineProperty,Yo=
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ko=Object.defineProperty,Yo=m((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"u$8");const Qo=Yo((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Ie.glob(T(i.src),{ignore:T(i.exclude).filter(Boolean)}).then(a=>({dest:i.dest??"",parent:Bt(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await ne.stat(i);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),l=await $.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const u=f.basename(i),d=f.join(c,u);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:d,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(p){t.error({context:[p],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Zo=Object.defineProperty,Y=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$5");const er=/\Wrequire(?:\.resolve)?\(/,tr=Y((e,t)=>{if(se.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,n=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),er.test(e)&&(n=!0),!o&&!r&&!n)return null;const s=V.findStaticImports(e).pop(),i=s?s.end:0,a=new R(e);return a.appendRight(i,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),or=Y((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
17
17
|
`),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
18
18
|
`),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
19
19
|
`),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
@@ -23,77 +23,77 @@ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to en
|
|
|
23
23
|
`),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
24
24
|
`),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
25
25
|
`),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
26
|
-
`),r},"generateCJSShimNode20_11"),nr=Y((e,t)=>{const o=
|
|
26
|
+
`),r},"generateCJSShimNode20_11"),nr=Y((e,t)=>{const o=D.createFilter(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,n,s){if(s.format==="es"&&o(n.fileName)){let i=or;if(e.engines?.node){const a=Re.minVersion(e.engines.node);a&&a.major>=20&&a.minor>=11&&(i=rr)}return tr(r,i)}return null}}},"esmShimCjsSyntaxPlugin");var sr=Object.defineProperty,ir=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"n$4");const ar=ir(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$a");const pr=cr((...e)=>{if(e.length===0)return"";if(e.length===1)return f.dirname(e[0]);e=e.map(n=>f.toNamespacedPath(n));const[t,...o]=e;let r=t.split("/");for(const n of o){const s=n.split("/",r.length);let i=0;for(const a of s)if(a===r[i])i+=1;else{r=r.slice(0,i);break}r=r.slice(0,i)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var ur=Object.defineProperty,Q=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"m$5");const dr=Q((e,t,o,r={})=>{const n=D.createFilter(r.include,r.exclude),s={},i=Q((c,u)=>{s[c.replace(/\..?[jt]s$/,"")]=u},"addOutput");async function a(c,u){if(!n(u))return;const{errors:d,sourceText:p}=await e(u,c);if(d.length>0){if(r.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}i(u,p);let g;try{g=JSON.parse((await _t.parseAsync(c,{sourceFilename:u})).program)}catch{return}const y=g.body.filter(h=>h.type!=="ImportDeclaration"?!1:h.importKind==="type"?!0:(h.specifiers||[]).every(b=>b.type==="ImportSpecifier"&&b.importKind==="type"));for await(const h of y)this.resolve(h.source.value,u).then(async b=>{if(!b)return;const w=b.id;if(n(w)&&!s[w.replace(x.ENDING_RE,"")])try{const j=await $.readFile(w);await a.call(this,j,w)}catch{}}).catch(b=>{console.log(b)})}m(a,"g"),Q(a,"transform");const l=o==="module"?"es":"cjs";return{name:"packem:isolated-declarations",renderStart(c,{input:u}){const d=pr(...Array.isArray(u)?u:Object.values(u));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const p=c.entryFileNames.replace(/\.(.)?[jt]s$/,(g,y)=>`.d.${y||""}ts`);for(const[g,y]of Object.entries(s)){(t===!0||t==="compatible")&&c.format===l&&this.emitFile({fileName:p.replace("[name]",f.relative(d,g)).replace(l==="cjs"?".cts":".mts",".ts"),source:y,type:"asset"});const h=y.includes("from '")?"'":'"';this.emitFile({fileName:p.replace("[name]",f.relative(d,g)),source:y.replaceAll(/from\s+['"]([^'"]+)['"]/g,(b,w)=>`from ${h}${w.replace(x.ENDING_RE,"")}${c.format==="cjs"?".cts":".mts"}${h}`),type:"asset"})}},transform:a}},"isolatedDeclarationsPlugin");var fr=Object.defineProperty,mr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"n$3");const we="export default ",ze=mr(e=>{const t=Wt(e);return{...t,name:"packem:json",transform(o,r){const n=t.transform?.call(this,o,r);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(we)&&(n.code=n.code.replace(we,"module.exports = ")),n}}},"JSONPlugin");class gr{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,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class hr extends gr{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(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];je(c)&&(this.visit(c,t,s,l)||l--)}}else je(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=a,l)return null}}return t}}function je(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(je,"isNode");function Ve(e,{enter:t,leave:o}){return new hr(t,o).visit(e,null)}m(Ve,"walk");var yr=Object.defineProperty,vr=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"u$7");const br=vr(({attributes:e,logger:t})=>{const o=D.createFilter([/\.[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(r,n){if(!o(n))return null;let s=null;try{s=this.parse(r,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(l),null}let i=!1;const a=new R(r);return Ve(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const d of u.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(a.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var $r=Object.defineProperty,de=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"g$4");const wr=de(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),jr=de((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
|
|
27
27
|
${o}
|
|
28
|
-
$2`)},"replaceContentWithin"),He=
|
|
29
|
-
`;g&&(
|
|
30
|
-
`);const E=new Set;for(const _ of[d,...h,...p]){const
|
|
31
|
-
`),
|
|
32
|
-
`),
|
|
33
|
-
`+
|
|
28
|
+
$2`)},"replaceContentWithin"),He=de(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:s,packageName:i})=>Ut({thirdParty(a){const l=new Set,c=a.sort(({name:d},{name:p})=>(d||0)>(p||0)?1:(p||0)>(d||0)?-1:0).map(({author:d,contributors:p,license:g,licenseText:y,maintainers:h,name:b,repository:w})=>{let j="## "+b+`
|
|
29
|
+
`;g&&(j+=`License: ${g}
|
|
30
|
+
`);const E=new Set;for(const _ of[d,...h,...p]){const me=typeof _=="string"?_:_?.name;me&&E.add(me)}return E.size>0&&(j+=`By: ${[...E].join(", ")}
|
|
31
|
+
`),w&&(j+=`Repository: ${typeof w=="string"?w:w.url}
|
|
32
|
+
`),y&&(j+=`
|
|
33
|
+
`+y.trim().replaceAll(/\r\n|\r/g,`
|
|
34
34
|
`).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
|
|
35
35
|
`).map(_=>_?`> ${_}`:">").join(`
|
|
36
36
|
`)+`
|
|
37
|
-
`),g&&l.add(g)
|
|
37
|
+
`),g&&l.add(g),j}).join(`
|
|
38
38
|
---------------------------------------
|
|
39
39
|
|
|
40
|
-
`);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(
|
|
41
|
-
`+e}return null},order:"post"}}),"prependDirectivePlugin");var
|
|
40
|
+
`);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const u=o(wr(l),c,i);try{const d=$.readFileSync(t),p=jr(d,n,u);if(!p){r.error({message:`Could not find the license marker: <!-- ${n} --> in ${t}`,prefix:"plugin:license:"+s});return}d!==p&&($.writeFileSync(t,p),r.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(d){r.error(d)}}}),"license");var xr=Object.defineProperty,kr=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"i$5");const Er=kr(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const s of n.importedIds)t.push({source:r,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.rootDir,e.outDir,"graph.json");$.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Sr=Object.defineProperty,Or=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"r$3");const I=Or(e=>{const t=Ct.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Nr=Object.defineProperty,Ge=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"d$4");const M=Ge(e=>e.handler||e,"getHandler"),N=Ge((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await M(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await M(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const n=f.join(o,e.name),s=f.join("load",I(r));if(t.has(s,n))return await t.get(s,n);const i=await M(e.load).call(this,r);return t.set(s,i,n),i},name:`cached(${e.name})`,async resolveId(r,n,s){if(!e.resolveId)return null;const i=f.join(o,e.name),a=f.join("resolveId",I(r),n?I(n):"",I(JSON.stringify(s)));if(t.has(a,i))return await t.get(a,i);const l=await M(e.resolveId).call(this,r,n,s);return t.set(a,l,i),l},async transform(r,n){if(!e.transform)return null;const s=f.join(o,e.name),i=f.join("transform",I(n),I(r));if(t.has(i,s))return await t.get(i,s);const a=await M(e.transform).call(this,r,n);return t.set(i,a,s),a}}),"cachingPlugin");var _r=Object.defineProperty,Dr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"n$2");const Pr=Dr(()=>({name:"prependDirective",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const r=o.meta.preserveDirectives.directives[0];if(r)return`'${r.value}';
|
|
41
|
+
`+e}return null},order:"post"}}),"prependDirectivePlugin");var Cr=Object.defineProperty,Rr=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"c$6");const Ir=Rr(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const n={},s={},i=D.createFilter(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const u=l.moduleIds.map(g=>n[g]?n[g]:null).reduce((g,y)=>(y&&y.forEach(h=>{g.add(h)}),g),new Set),d=new R(a);u.size>0&&(r.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${[...u].map(g=>`'${g}';`).join(`
|
|
42
42
|
`)}
|
|
43
43
|
`));let p=null;return l.facadeModuleId&&typeof s[l.facadeModuleId]=="string"&&(p=s[l.facadeModuleId]),p&&(r.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${p}
|
|
44
|
-
`)),u.size===0&&p===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!i(l))return null;let c=!1;const u=new R(a);if(a.startsWith("#")&&a[1]==="!"){let p=0;for(let g=2,
|
|
44
|
+
`)),u.size===0&&p===null?null:{code:d.toString(),map:c?d.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!i(l))return null;let c=!1;const u=new R(a);if(a.startsWith("#")&&a[1]==="!"){let p=0;for(let g=2,y=a.length;g<y;g++){const h=a.codePointAt(g);if(h===10||h===13||h===8232||h===8233){p=g;break}}p&&(s[l]=a.slice(0,p),u.remove(0,p+1),c=!0,r.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(u.toString(),{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),r.warn(p),null}if(d.type!=="Program")return null;for(const p of d.body.filter(Boolean)){if(p.type!=="ExpressionStatement")break;let g=null;"directive"in p?g=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&e.test(p.expression.value)&&(g=p.expression.value),g!=="use strict"&&g&&(n[l]||=new Set,n[l].add(g),"start"in p&&typeof p.start=="number"&&"end"in p&&typeof p.end=="number"&&(u.remove(p.start,p.end),c=!0),r.debug({message:`directive "${g}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:u.toString(),map:u.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[l]??[]],shebang:s[l]??null}}}:null}}},"preserveDirectives");var Fr=Object.defineProperty,Mr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"t$3");const Tr=Mr(e=>{const t=D.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Ar=Object.defineProperty,Jr=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"l$5");const Z="\0__file_url__",Xe=Jr(()=>({async load(e){if(e.startsWith(Z)){const t=Pe.fileURLToPath(e.slice(Z.length));return await $.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${Z}${e}`}}),"resolveFileUrl");var Lr=Object.defineProperty,F=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$2");const qr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Br=/MIT License|MIT license|BSD license/,Wr=/\n{2,}/g,Ur=/\b(\w+)\$\d+\b/g,zr=/[-/\\^$*+?.()|[\]{}]/g,Vr=F(e=>e.replaceAll(zr,"\\$&"),"escapeRegex"),Hr=F(e=>[...new Set(e)],"unique"),Gr=F(e=>e.replaceAll(qr,t=>Br.test(t)?"":t).replaceAll(Wr,`
|
|
45
45
|
|
|
46
|
-
`),"cleanUnnecessaryComments"),xe=new Map;function Ke(e,t,{identifierReplacements:o},r){const n=V.findStaticImports(e);for(const i in o){const a=n.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const u=l[c],d=
|
|
46
|
+
`),"cleanUnnecessaryComments"),xe=new Map;function Ke(e,t,{identifierReplacements:o},r){const n=V.findStaticImports(e);for(const i in o){const a=n.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const u=l[c],d=Vr(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),u)}}const s=Hr(Array.from(e.matchAll(Ur),i=>i[0]));if(s.length>0){const i=s.map(l=>`
|
|
47
47
|
- ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");xe.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
48
48
|
|
|
49
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),xe.set(a,!0)}return e}
|
|
49
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),xe.set(a,!0)}return e}m(Ke,"I$1");F(Ke,"replaceConfusingTypeNames");const Xr=F((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},"removeInternal");function Ye(e,t){if(e.includes("@internal")){const o=new R(e),r=Rt.parse(e,{plugins:["typescript"],sourceType:"module"});if(Ve(r,{enter(n){Xr(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Ye,"S$1");F(Ye,"stripInternalTypes");const Kr=F((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Ke.call(this,o,r,e,t),o=Ye.call(this,o,r),o=Gr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Yr=Object.defineProperty,Qe=m((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"m$4");const Ze=Qe((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=f.resolve(f.dirname(r),n),a=[];if(s)for(const[l,c]of Object.entries(s)){let u;l==="@"||l==="~"||l==="#"?u=new RegExp(`^${l}/(.+)$`):u=new RegExp(`^${[...l].map(p=>p==="*"?"(.+)":p.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const p of c){const g=[...D.normalizePath(f.resolve(i,p))].map(y=>y==="*"?"$"+(++d+""):y==="$"?"$$":y).join("");a.push({find:u,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...D.normalizePath(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),et=Qe((e,t)=>{const o=Ze(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(r)){const l=r.replace(i,a),c=await this.resolve(l,n,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Qr=Object.defineProperty,tt=m((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"u$4");const Zr=tt((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];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}.`);s.push(f.resolve(e,i))}return s},"getRootDirectories"),ot=tt((e,t,o)=>{const r=Zr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=f.join(a,n),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"r$1");const rt=tn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var on=Object.defineProperty,rn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"s$6");const nn=rn(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(x.DEFAULT_EXTENSIONS.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var sn=Object.defineProperty,an=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"i$2");const ee=an(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ln=Object.defineProperty,ke=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"c$4");const cn=ke((e,t)=>{const o=new Map;return ke(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,a=s.meta,l=ee(a);if(!i){const c=o.get(r);if(c)return c;const u=nn(r);if(u)return o.set(r,u),u}if(i){const c=n.getModuleIds();for(const u of c)n.getModuleInfo(u)&&ee(a)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([r,l]))}if(l&&!i&&e.has(r)){const c=[...e.get(r)];if(c.some(([d])=>{if(t.some(p=>p.path===d)){const p=n.getModuleInfo(d);return ee(p?p.meta:{})===l}return!1}))return;if(c.every(([,d])=>d===l))return o.has(r)?o.get(r):void 0;const u=f.basename(r,f.extname(r))+"-"+l;return o.set(r,u),u}},"splitChunks")},"createSplitChunks");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"n");const C=un((e,t)=>e.isDynamicEntry?`chunks/[name].${t}`:`shared/${e.name}-[hash].${t}`,"getChunkFilename");var dn=Object.defineProperty,fn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"s$4");const mn=process.platform==="win32",Ee=fn((e,t)=>{const o=mn?"\\":"/";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 gn=Object.defineProperty,k=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"l$4");const hn=k((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"+se.versions.node.split(".")[0];if(t.pkg.engines?.node){const r=Re.minVersion(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=T(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...T(o),...r])])}else t.options.rollup.esbuild.target=T(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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}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"),nt=k((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v.cyan(f.relative(f.resolve(),e.id))}"
|
|
50
50
|
Is the module installed? Note:
|
|
51
51
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
52
|
-
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Se=new Map,
|
|
53
|
-
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){
|
|
54
|
-
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack")
|
|
52
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Se=new Map,st=k((e,t,o)=>{const r=k(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=Ze(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=qe(s);if(re(e.options.externals,a)||re(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||f.isAbsolute(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name)||l?.imports?.[s]!==void 0)return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return Se.has(s)||e.logger.info({message:'Inlined implicit external "'+v.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Se.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,f.resolve(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:k((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
53
|
+
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){nt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),it=k(async(e,t)=>{const o=le(e,"build");let r;e.options.rollup.resolve&&(r=N(Ce.nodeResolve({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:cn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...st(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:k(s=>C(s,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:k(s=>Ee(s,"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,...n},e.options.emitESM&&{chunkFileNames:k(s=>C(s,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:k(s=>Ee(s,"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,...n}].filter(Boolean),plugins:[N(Xe(),t),N(rt(),t),e.tsconfig&&N(ot(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&N(et(e.tsconfig,e.logger),t),e.options.rollup.replace&&Te({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Me({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&qt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ze({...e.options.rollup.json}),Ho(),e.options.rollup.wsam&&kt.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&dr(e.options.isolatedDeclarationTransformer,e.options.declaration,e.pkg.type,e.options.rollup.isolatedDeclarations),e.options.transformer?.(hn(e.options.transformerName,e)),Ir({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),Vt(e.options.entries.filter(s=>s.executable).map(s=>s.name).filter(Boolean)),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&ar(),e.options.rollup.dynamicVars&&Lt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&N(Jt({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.shim),e.options.rollup.raw&&Tr(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&br({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Er({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Qo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&He({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",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}),Pr(),e.options.rollup.visualizer&&St.visualizer({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"),yn=k(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"),vn=Io(yn),at=k(async(e,t)=>{const o=le(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=N(Ce.nodeResolve({...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...st(e,o,"dts"),onwarn(a,l){nt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:k(a=>C(a,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:k(a=>C(a,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:k(a=>C(a,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[N(Xe(),t),N(rt(),t),e.options.rollup.json&&ze({...e.options.rollup.json}),r,e.tsconfig&&N(ot(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&N(et(e.tsconfig,e.logger),t),e.options.rollup.replace&&Te({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Me({customResolver:s,...e.options.rollup.alias,entries:o}),s,await vn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Kr(e.options.rollup.patchTypes,e.logger),Ht(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&He({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"c$3");const te=$n(async(e,t,o)=>{const r=await it(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;const n="rollup-build.json";r.cache=t.get(n,o);const s=await A.rollup(r);t.set(n,s.cache,o),await e.hooks.callHook("rollup:build",e,s);const i=new Map;for(const a of r.output){const{output:l}=await s.write(a),c=new Set,u=l.filter(p=>p.type==="chunk");for(const p of u){c.add(p.fileName);for(const g of p.imports)e.usedImports.add(g);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(g=>u.find(y=>y.fileName===g)),exports:p.exports,modules:Object.entries(p.modules).map(([g,y])=>({bytes:y.renderedLength,id:g})),path:p.fileName,type:"entry"})}const d=l.filter(p=>p.type==="asset");for(const p of d)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var wn=Object.defineProperty,W=m((e,t)=>wn(e,"name",{value:t,configurable:!0}),"a$5");const U=W(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await at(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;const n="rollup-dts.json";r.cache=t.get(n,o);const s=await A.rollup(r);t.set(n,s.cache,o),await e.hooks.callHook("rollup:dts:build",e,s),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await s.write({chunkFileNames:W(i=>C(i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await s.write({chunkFileNames:W(i=>C(i,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await s.write({chunkFileNames:W(i=>C(i,"d.cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var jn=Object.defineProperty,fe=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"i$1");const xn=fe(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
|
|
54
|
+
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),kn=fe(e=>`
|
|
55
55
|
${e.replaceAll(/^\n|\n$/g,"")}
|
|
56
|
-
`,"normalizeCodeFrame"),
|
|
57
|
-
file: ${
|
|
58
|
-
`+
|
|
59
|
-
${t}`)},"enhanceRollupError");var
|
|
60
|
-
└─ ${
|
|
61
|
-
- `+
|
|
56
|
+
`,"normalizeCodeFrame"),lt=fe(e=>{const t=xn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
|
|
57
|
+
file: ${v.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
|
|
58
|
+
`+v.yellow(kn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
|
|
59
|
+
${t}`)},"enhanceRollupError");var En=Object.defineProperty,ct=m((e,t)=>En(e,"name",{value:t,configurable:!0}),"l$3");const Oe=ct((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${v.cyan(f.relative(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",async n=>{switch(n.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:r});break}case"BUNDLE_START":{o.info({message:v.cyan("build started..."),prefix:r});break}case"BUNDLE_END":{await n.result.close(),o.info({message:v.cyan(`built in ${n.duration+""}ms.`),prefix:r});break}case"ERROR":{lt(n.error),o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r});break}}})},"watchHandler"),Sn=ct(async(e,t)=>{const o=await it(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[f.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const r=A.watch(o);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of n)s+=v.gray(`
|
|
60
|
+
└─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(s),Oe(r,"bundle",e.logger),e.options.declaration){const i=await at(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const a=A.watch(i);await e.hooks.callHook("rollup:watch",e,a),Oe(a,"types",e.logger)}},"watch");var On=Object.defineProperty,Nn=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"a$3");class _n{static{m(this,"p")}static{Nn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;#s;constructor(t,o,r){this.#r=t,this.#e=It.findCacheDirSync("@visulima/packem",{cwd:t}),this.#n=o,this.#s=r,this.#e===void 0?r.debug("Could not create cache directory."):r.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:$.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!$.isAccessibleSync(r))return;const n=$.readFileSync(r);try{const s=JSON.parse(n);return this.#o.set(r,s),s}catch{this.#s.warn(`Could not parse cache file: ${r}, deleting the broken cache file.`),this.#o.delete(r),ie.rmSync(r,{force:!0});return}}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),$.writeFileSync(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(f.toNamespacedPath(this.#r),"");return r=r.replaceAll(":","-"),f.join(this.#e,this.#n,o?.replaceAll(":","-")??"",f.toNamespacedPath(r))}}var Dn=Object.defineProperty,z=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"l$2");const Pn=D.createFilter,Cn=z((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=z(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Pn(n,null,{resolve:e})}else r=z(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Rn=Object.defineProperty,In=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"y");const Fn=In((e,t,o)=>e.reduce((r,n)=>{const s=n[t],i=n[o];return r[s]||(r[s]={}),r[s][i]||(r[s][i]=[]),r[s][i].push(n),r},{}),"groupByKeys");var Mn=Object.defineProperty,pt=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"e");const Ne=pt(async(e,t)=>{if(typeof e.name!="string"){let o=f.isAbsolute(e.input)?f.relative(t.options.rootDir,e.input):f.normalize(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(x.ENDING_RE,"")}if(!e.input)throw new Error(`Missing entry input: ${ce(e)}`);Mt.isRelative(e.input)&&(e.input=f.resolve(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),t.options.emitCJS!==void 0&&e.cjs===void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&e.esm===void 0&&(e.esm=t.options.emitESM),e.outDir=f.resolve(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Tn=pt(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:ve(t)}:{...t,isGlob:ve(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,n=Ie.globSync([r.input],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**"],onlyFiles:!0});if(n.length===0)throw new Ft.NotFoundError("No files found in the glob pattern: "+v.cyan(f.join(e.options.rootDir,r.input)));for(const s of n)e.options.entries.push({...r,input:f.resolve(e.options.rootDir,s)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for await(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await Ne(t,e);for await(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Ne(t,e)},"prepareEntries");var An=Object.defineProperty,Jn=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"a$2");const Ln=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,qn=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),_e=Jn(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ln.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(qn.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=f.resolve(o);if(!$.isAccessibleSync(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Bn=Object.defineProperty,Wn=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"o");const Un=Wn(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),r=new Set;for(const n of e.usedImports)o.delete(n),t.add(n);if(e.pkg?.dependencies)for(const n of Object.keys(e.pkg?.dependencies))o.delete(n);for(const n of t){const s=qe(n);!re(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[s]===void 0&&e.pkg?.peerDependencies?.[s]===void 0&&r.add(n)}o.size>0&&J(e,`Potential unused dependencies found: ${[...o].map(n=>v.cyan(n)).join(", ")}`),r.size>0&&J(e,`Potential implicit dependencies found: ${[...r].map(n=>v.cyan(n)).join(", ")}`)},"validateDependencies");var zn=Object.defineProperty,ut=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i");const Vn=ut((e,t)=>At.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Hn=ut((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Vn(r.toLowerCase(),o))},"findAlternatives");var Gn=Object.defineProperty,De=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s");const Xn=De((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:"",...pe(e.exports,e.type==="module"?"esm":"cjs",t.options.declaration).map(n=>n.file)].map(n=>n&&f.resolve(t.options.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!ie.existsSync(n)&&r.push(n.replace(`${t.options.rootDir}/`,""));if(r.length>0){const n=De(a=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>n(a.path));let i="Potential missing or wrong package.json files:";for(const a of r){const l=Hn(a,s);i+=`
|
|
61
|
+
- `+v.cyan(a)+(l.length>0?v.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}J(t,i)}},"validatePackage");var Kn=Object.defineProperty,S=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"g");const dt=S((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
62
62
|
`),e.logger.warn(`Build is done with some warnings:
|
|
63
63
|
|
|
64
64
|
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
65
|
-
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),
|
|
65
|
+
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),Yn=S(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"),Qn=S((e,t,o,r,n,s,i,a,l,c)=>{const u=Yn(c?.config.compilerOptions?.jsx),d=ht.defu(i,s,a,{alias:{},cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ye.builtinModules,...ye.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,minify:r===x.PRODUCTION_ENV,name:(l.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:c?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,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:u,jsxDev:c?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:c?.config.compilerOptions?.jsxFactory,jsxFragment:c?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:c?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:c?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:c?.config},isolatedDeclarations:{exclude:x.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:S((p,g,y)=>`
|
|
66
66
|
# Licenses of bundled dependencies
|
|
67
|
-
The published ${
|
|
67
|
+
The published ${y} artifact additionally contains code with the following licenses:
|
|
68
68
|
`+(p.length>0?`${p.join(", ")}
|
|
69
69
|
|
|
70
70
|
`:`
|
|
71
71
|
`)+`# Bundled dependencies:
|
|
72
|
-
`+g,"dependenciesTemplate"),dtsTemplate:S((p,g,
|
|
72
|
+
`+g,"dependenciesTemplate"),dtsTemplate:S((p,g,y)=>`
|
|
73
73
|
# Licenses of bundled types
|
|
74
|
-
The published ${
|
|
74
|
+
The published ${y} artifact additionally contains code with the following licenses:
|
|
75
75
|
`+(p.length>0?`${p.join(", ")}
|
|
76
76
|
|
|
77
77
|
`:`
|
|
78
78
|
`)+`# Bundled types:
|
|
79
|
-
`+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:
|
|
80
|
-
exports: `+
|
|
81
|
-
${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return
|
|
82
|
-
`)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>
|
|
79
|
+
`+g,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:x.EXCLUDE_REGEXP,include:[/\.(?:m|c)?(?:j|t)sx?$/]},preserveDynamicImports:!0,raw:{exclude:x.EXCLUDE_REGEXP,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,extensions:x.DEFAULT_EXTENSIONS,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:c?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:r===x.PRODUCTION_ENV,...c?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(c.config.compilerOptions.jsx)?{jsxFragmentPragma:c.config.compilerOptions.jsxFragmentFactory,jsxImportSource:c.config.compilerOptions.jsxImportSource,jsxPragma:c.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...c.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...c?.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:c?.config.compilerOptions?.experimentalDecorators,syntax:c?"typescript":"ecmascript",[c?"tsx":"jsx"]:!0},target:c?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:c?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:c?.config.compilerOptions?.experimentalDecorators,react:{development:r!==x.PRODUCTION_ENV,pragma:c?.config.compilerOptions?.jsxFactory,pragmaFrag:c?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:c?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:c?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Cn(t,l),preset:"recommended",propertyReadSideEffects:!0},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:x.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!d.transformerName){const p=new Map([...Object.entries(l.dependencies??{}),...Object.entries(l.devDependencies??{})]);let g="0.0.0";if(p.has("esbuild"))d.transformerName="esbuild",g=p.get("esbuild");else if(p.has("@swc/core"))d.transformerName="swc",g=p.get("@swc/core");else if(p.has("sucrase"))d.transformerName="sucrase",g=p.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+v.cyan("rollup ")+A.VERSION),e.info({message:"Using "+v.cyan(d.transformerName)+" "+g,prefix:"transformer"})}return d.rollup.resolve&&d.rollup.resolve.preferBuiltins===!0&&(d.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),l.dependencies&&d.externals.push(...Object.keys(l.dependencies)),l.peerDependencies&&d.externals.push(...Object.keys(l.peerDependencies)),l.optionalDependencies&&d.externals.push(...Object.keys(l.optionalDependencies)),_e(d.alias),d.rollup.alias&&d.rollup.alias.entries&&_e(d.rollup.alias.entries),d},"generateOptions"),Zn=S((e,t,o)=>{const r=S(s=>f.relative(t.options.rootDir,f.resolve(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const l of s.chunks??[])i+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let a=` ${v.bold(r(s.path))} (${["total size: "+v.cyan(P.formatBytes(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+v.cyan(P.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
|
|
80
|
+
exports: `+v.gray(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
|
|
81
|
+
${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return v.gray(" └─ "+r(l)+v.bold(c.bytes?" ("+P.formatBytes(c?.bytes)+")":""))}).join(`
|
|
82
|
+
`)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>v.gray(" 📦 "+r(c.id)+v.bold(c.bytes?" ("+P.formatBytes(c.bytes)+")":""))).join(`
|
|
83
83
|
`);a+=l.length>0?`
|
|
84
84
|
inlined modules:
|
|
85
85
|
`+l:""}if(t.options.declaration&&s.type==="entry"){let l=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?l=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",l=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(d=>d.path.endsWith(l));if(u){let d;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),d=t.buildEntries.find(p=>p.path.endsWith(l))),a+=d&&c===o.type?`
|
|
86
86
|
types:
|
|
87
|
-
`+[u,d].map(p=>
|
|
87
|
+
`+[u,d].map(p=>v.gray(" └─ ")+v.bold(r(p.path))+" (total size: "+v.cyan(P.formatBytes(p.bytes??0))+")").join(`
|
|
88
88
|
`):`
|
|
89
|
-
types: `+
|
|
89
|
+
types: `+v.bold(r(u.path))+" (total size: "+v.cyan(P.formatBytes(u.bytes??0))+")"}}n=!0,a+=`
|
|
90
90
|
|
|
91
|
-
`,e.raw(s.chunk?
|
|
92
|
-
`),n},"showSizeInformation"),
|
|
91
|
+
`,e.raw(s.chunk?v.gray(a):a)}return n&&e.raw("Σ Total dist size (byte size):",v.cyan(P.formatBytes(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
|
|
92
|
+
`),n},"showSizeInformation"),es=S(async(e,t,o,r,n,s,i,a,l)=>{const c=Eo(i.preset??s.preset??"auto",t),u=Qn(e,t,o,r,n,s,i,c,a,l);$.ensureDirSync(f.join(u.rootDir,u.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:yt.createHooks(),logger:e,mode:o,options:u,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};return c.hooks&&d.hooks.addHooks(c.hooks),s.hooks&&d.hooks.addHooks(s.hooks),i.hooks&&d.hooks.addHooks(i.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d},"createContext"),ts=S(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${f.relative(e.options.rootDir,o)}\``),await $.emptyDir(o))},"cleanDistributionDirectories"),os=S((e,t)=>{const o=Fn(e.options.entries,"environment","runtime"),r=[];for(const[n,s]of Object.entries(o))for(const[i,a]of Object.entries(s)){const l={...e};(n!=="undefined"||i!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":v.cyan(n)+" environment"+(i==="undefined"?"":" with "))+(i==="undefined"?"":v.cyan(i)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),i==="edge-light"&&(l.options.rollup.replace.values.EdgeRuntime=JSON.stringify("edge-runtime"))):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),i!=="undefined"&&(c+=i+"/");let u=!1;l.options.minify!==void 0&&(u=l.options.minify),n==="development"?u=!1:n==="production"&&(u=!0);const d=[],p=[],g=[],y=[];for(const h of a)h.cjs&&h.esm?d.push(h):h.cjs?g.push(h):h.esm?p.push(h):h.declaration&&y.push(h);if(d.length>0){const h={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:d,minify:u}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(p.length>0){const h={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:p,minify:u}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(g.length>0){const h={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:u}};r.push(te(h,t,c));const b=h.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(U({...h,options:{...h.options,entries:b}},t,c))}if(l.options.declaration&&y.length>0){const h={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:u}};r.push(U(h,t,c))}}return r},"prepareRollupConfig"),rs=S(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const r=t.dependencies?.typescript!==void 0||t.devDependencies?.typescript!==void 0;if(e.options.declaration&&e.tsconfig===void 0&&r)throw new Error("Cannot build declaration files without a tsconfig.json");r?e.options.declaration===!1&&e.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(e.options.declaration=!1,e.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),e.options.declaration&&e.logger.info("Using typescript version: "+v.cyan(t.devDependencies?.typescript??t.dependencies?.typescript??"unknown")),e.options.declaration&&(t.dependencies?.typescript||t.devDependencies?.typescript)&&!e.tsconfig?.config.compilerOptions?.isolatedModules&&e.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
93
93
|
Because none of the third-party transpiler, 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.
|
|
94
|
-
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.`),await Promise.all(
|
|
95
|
-
${
|
|
96
|
-
${
|
|
97
|
-
`)}`),await
|
|
94
|
+
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.`),await Promise.all(os(e,o)),e.logger.success(v.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of $.walk(f.join(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(a=>f.join(e.options.rootDir,e.options.outDir,a.path)===s.path);if(i||(i={chunk:!0,path:s.path},e.buildEntries.push(i)),!i.bytes){const a=await ne.stat(f.resolve(e.options.rootDir,e.options.outDir,s.path));i.bytes=a.size}}const n=Zn(e.logger,e,t);Un(e),Xn(t,e),await e.hooks.callHook("build:done",e),dt(e,n)},"build"),ns=S(async(e,t,o,r,n={})=>{const{configPath:s,debug:i,tsconfigPath:a,...l}=n;r.wrapAll(),e=f.resolve(se.cwd(),e),r.debug("Root directory:",e);const c=f.join(e,"package.json");if(!$.isAccessibleSync(c))throw new Error("package.json not found at "+c);const u=gt.parsePackageJson(c);r.debug("Using package.json found at",c);let d;if(a){const p=f.join(e,a);if(!await $.isAccessible(p))throw new Error("tsconfig.json not found at "+p);d={config:ge.readTsConfig(p),path:p},r.info("Using tsconfig settings at",p)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{d=await ge.findTsConfig(e),r.debug("Using tsconfig settings found at",d.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}try{let p=s??"";if(!p){const E=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const _ of E)if($.isAccessibleSync(f.join(e,_))){p="./"+_;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(p))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let g=Ae(p,e);typeof g=="function"&&(g=g(o,t)),r.debug("Using packem config found at",f.join(e,p));const y=Date.now(),h=S(()=>P.duration(Math.floor(Date.now()-y)),"getDuration"),b=I(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),w=new _n(e,b,r);w.cachePath&&!$.isAccessibleSync(f.join(w.cachePath,b))&&$.isAccessibleSync(w.cachePath)&&(r.info("Clearing file cache because the cache key has changed."),await $.emptyDir(w.cachePath));const j=await es(r,e,t,o,i??!1,l,g,u,d);if(w.isEnabled=j.options.fileCache,await Tn(j),j.logger.info(v.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+j.options.name)),j.logger.debug(`${v.bold("Root dir:")} ${j.options.rootDir}
|
|
95
|
+
${v.bold("Entries:")}
|
|
96
|
+
${j.options.entries.map(E=>` ${ce(E)}`).join(`
|
|
97
|
+
`)}`),await ts(j),j.options.stub){await no(j),await j.hooks.callHook("build:done",j);return}if(t==="watch"){if(j.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Sn(j,w),dt(j,!1);return}await rs(j,u,w),r.raw(`
|
|
98
98
|
⚡️ Build run in `+h()),r.restoreAll()}catch(p){throw r.raw(`
|
|
99
|
-
`),
|
|
99
|
+
`),lt(p),p}},"createBundler");module.exports=ns;
|