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