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