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