@visulima/packem 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +163 -0
- package/README.md +16 -3
- package/dist/cli.cjs +7 -1
- package/dist/cli.mjs +15 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +5 -2
- package/dist/config.d.mts +5 -2
- package/dist/config.d.ts +5 -2
- package/dist/config.mjs +9 -1
- package/dist/create-bundler.cjs +93 -1
- package/dist/create-bundler.d.cts +4 -1
- package/dist/create-bundler.d.mts +4 -1
- package/dist/create-bundler.d.ts +4 -1
- package/dist/create-bundler.mjs +101 -1
- package/dist/rollup/plugins/esbuild/index.cjs +1 -0
- package/dist/rollup/plugins/esbuild/index.d.cts +9 -0
- package/dist/rollup/plugins/esbuild/index.d.mts +9 -0
- package/dist/rollup/plugins/esbuild/index.d.ts +9 -0
- package/dist/rollup/plugins/esbuild/index.mjs +9 -0
- package/dist/rollup/plugins/sucrase/index.cjs +1 -0
- package/dist/rollup/plugins/sucrase/index.d.cts +8 -0
- package/dist/rollup/plugins/sucrase/index.d.mts +8 -0
- package/dist/rollup/plugins/sucrase/index.d.ts +8 -0
- package/dist/rollup/plugins/sucrase/index.mjs +9 -0
- package/dist/rollup/plugins/swc/index.cjs +1 -0
- package/dist/rollup/plugins/swc/index.d.cts +7 -0
- package/dist/rollup/plugins/swc/index.d.mts +7 -0
- package/dist/rollup/plugins/swc/index.d.ts +7 -0
- package/dist/rollup/plugins/swc/index.mjs +9 -0
- package/dist/shared/packem.BAcY88If.mjs +9 -0
- package/dist/shared/packem.BK03IQfP.d.ts +176 -0
- package/dist/shared/packem.BchP_OVQ.d.mts +176 -0
- package/dist/shared/{packem.eS2oNfLM.d.ts → packem.C44tLE3n.d.cts} +1 -193
- package/dist/shared/{packem.eS2oNfLM.d.cts → packem.C44tLE3n.d.mts} +1 -193
- package/dist/shared/{packem.eS2oNfLM.d.mts → packem.C44tLE3n.d.ts} +1 -193
- package/dist/shared/packem.CGAPjagQ.d.cts +176 -0
- package/dist/shared/packem.CKW9adaV.cjs +1 -0
- package/dist/shared/packem.CxExFSHU.mjs +9 -0
- package/dist/shared/packem.D09xRBAa.d.cts +25 -0
- package/dist/shared/packem.D09xRBAa.d.mts +25 -0
- package/dist/shared/packem.D09xRBAa.d.ts +25 -0
- package/dist/shared/packem.DvWhOdt5.d.cts +10 -0
- package/dist/shared/packem.DvWhOdt5.d.mts +10 -0
- package/dist/shared/packem.DvWhOdt5.d.ts +10 -0
- package/package.json +57 -17
- package/dist/chunks/index.cjs +0 -1
- package/dist/chunks/index.mjs +0 -1
- package/dist/chunks/index2.cjs +0 -1
- package/dist/chunks/index2.mjs +0 -9
- package/dist/chunks/sucrase.cjs +0 -1
- package/dist/chunks/sucrase.mjs +0 -1
- package/dist/shared/packem.BF9udlBc.mjs +0 -91
- package/dist/shared/packem.Bdmp1hC5.mjs +0 -1
- package/dist/shared/packem.e4bzQy8N.cjs +0 -91
package/dist/chunks/index2.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var O=Object.defineProperty;var g=(e,r)=>O(e,"name",{value:r,configurable:!0});import{existsSync as k,statSync as M}from"node:fs";import{createFilter as $}from"@rollup/pluginutils";import{join as P,resolve as R,dirname as S,extname as W}from"@visulima/path";import{formatMessages as A,transform as b,build as C}from"esbuild";import{E as F,a as L}from"../shared/packem.BF9udlBc.mjs";import{x as D}from"../shared/packem.Bdmp1hC5.mjs";import{readFile as I}from"node:fs/promises";import{findCacheDirectory as U}from"@visulima/package";import{init as X,parse as q}from"es-module-lexer";
|
|
2
|
-
// -- pack CommonJS Shims --
|
|
3
|
-
import __cjs_url__ from "node:url";
|
|
4
|
-
import __cjs_path__ from "node:path";
|
|
5
|
-
import __cjs_mod__ from "node:module";
|
|
6
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
8
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
9
|
-
var G=Object.defineProperty,T=g((e,r)=>G(e,"name",{value:r,configurable:!0}),"t$1");const _=T(async(e,r)=>{r.length>0&&(await A(r,{color:!0,kind:"warning"})).forEach(l=>e.warn(l))},"warn");var B=Object.defineProperty,z=g((e,r)=>B(e,"name",{value:r,configurable:!0}),"t");const H=z(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),J=z(({sourceMap:e=!0,...r})=>async function(l,s,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const n=H(i.format),c=await b(l,{format:n,loader:"js",sourcemap:e,...r});if(await _(this,c.warnings),c.code)return{code:c.code,map:c.map||null}}return null},"getRenderChunk");var K=Object.defineProperty,x=g((e,r)=>K(e,"name",{value:r,configurable:!0}),"o");const E=x(e=>e.replaceAll("\\","/"),"slash"),N=x(async e=>{const r=await U("packem/optimize_deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await X,await C({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",async setup(s){s.onResolve({filter:/.*/},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(i.pluginData?.__resolving_dep_path__)return null;if(e.include.includes(i.path)){const n=await s.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return n.errors.length>0||n.warnings.length>0?n:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:n.path,resolveDir:i.resolveDir}}}return null}),s.onLoad({filter:/.*/,namespace:"optimize-deps"},async i=>{const{absolute:n,resolveDir:c}=i.pluginData,p=await I(n,"utf8"),[,f]=q(p);return{contents:f.length>0?`export * from '${E(n)}'`:`module.exports = require('${E(n)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins||[]]});const l=new Map;for(const s of e.include)l.set(s,{file:P(r,`${s}.js`)});return{cacheDir:r,optimized:l}},"optimizeDeps");var Q=Object.defineProperty,V=g((e,r)=>Q(e,"name",{value:r,configurable:!0}),"E");const Y=V(({exclude:e,include:r,loaders:l,logger:s,optimizeDeps:i,sourceMap:n=!0,...c})=>{const p=L;if(l)for(let[t,a]of Object.entries(l))t=t.startsWith(".")?t:`.${t}`,typeof a=="string"?p[t]=a:a||delete p[t];const f=Object.keys(p),j=new RegExp(`\\.(${f.map(t=>t.slice(1)).join("|")})$`),v=$(r||j,e||F);let u,y=process.cwd();const h=new Map;return{async buildStart(){!i||u||(u=await N({cwd:y,sourceMap:n,...i}),s.debug("optimized %O",u.optimized))},name:"esbuild",options({context:t}){return t&&(y=t),null},renderChunk:J({...c,sourceMap:n}),async resolveId(t,a,{isEntry:w}){if(!a||w||!v(t)||t.startsWith("\0"))return null;if(u?.optimized.has(t)){const o=u.optimized.get(t);if(o)return s.debug("resolved %s to %s",t,o.file),o.file}const m=h.get(t);if(m!==void 0)return m;if(a&&t.startsWith(".")){const o=R(a?S(a):process.cwd(),t);let d=D(f,o);if(d||!d&&k(o)&&M(o).isDirectory()&&(d=D(f,o,!0),d))return h.set(t,d),d}return h.set(t,null),null},async transform(t,a){if(!v(a)||u?.optimized.has(a))return null;const w=W(a),m=p[w];if(!m)return null;const o=await b(t,{format:["base64","binary","dataurl","text","json"].includes(m)?"esm":void 0,loader:m,sourcefile:a.replace(/\.[cm]ts/,".ts"),sourcemap:n,...c});return await _(this,o.warnings),o.code?{code:o.code,map:o.map||null}:null}}},"default");export{Y as default};
|
package/dist/chunks/sucrase.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var a=(n,s)=>v(n,"name",{value:s,configurable:!0});const d=require("node:fs"),y=require("@rollup/pluginutils"),f=require("@visulima/path"),q=require("sucrase"),p=require("../shared/packem.e4bzQy8N.cjs"),E=require("../shared/packem.CEXB7aOL.cjs");var P=Object.defineProperty,x=a((n,s)=>P(n,"name",{value:s,configurable:!0}),"c");const h=x(({exclude:n,extensions:s=p.DEFAULT_EXTENSIONS,include:g,...m})=>{const l=y.createFilter(g,n??p.EXCLUDE_REGEXP),u=new Map;return{async resolveId(e,r,{isEntry:o}){if(!r||o||!l(e)||e.startsWith("\0"))return null;const c=u.get(e);if(c!==void 0)return c;if(r&&e.startsWith(".")){const i=f.resolve(r?f.dirname(r):process.cwd(),e);let t=E.x(s,i);if(t||!t&&d.existsSync(i)&&d.statSync(i).isDirectory()&&(t=E.x(s,i,!0),t))return u.set(e,t),t}return u.set(e,null),null},async transform(e,r){if(!l(r))return null;const{code:o,sourceMap:c}=q.transform(e,{...m,filePath:r,sourceMapOptions:{compiledFilename:r}});return{code:o,map:c}}}},"sucrasePlugin");exports.sucrasePlugin=h;
|
package/dist/chunks/sucrase.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var u=(s,e)=>d(s,"name",{value:e,configurable:!0});import{existsSync as E,statSync as y}from"node:fs";import{createFilter as v}from"@rollup/pluginutils";import{resolve as g,dirname as x}from"@visulima/path";import{transform as P}from"sucrase";import{E as D,D as S}from"../shared/packem.BF9udlBc.mjs";import{x as m}from"../shared/packem.Bdmp1hC5.mjs";var h=Object.defineProperty,F=u((s,e)=>h(s,"name",{value:e,configurable:!0}),"c");const M=F(({exclude:s,extensions:e=S,include:f,...p})=>{const l=v(f,s??D),a=new Map;return{async resolveId(r,t,{isEntry:c}){if(!t||c||!l(r)||r.startsWith("\0"))return null;const n=a.get(r);if(n!==void 0)return n;if(t&&r.startsWith(".")){const i=g(t?x(t):process.cwd(),r);let o=m(e,i);if(o||!o&&E(i)&&y(i).isDirectory()&&(o=m(e,i,!0),o))return a.set(r,o),o}return a.set(r,null),null},async transform(r,t){if(!l(t))return null;const{code:c,sourceMap:n}=P(r,{...p,filePath:t,sourceMapOptions:{compiledFilename:t}});return{code:c,map:n}}}},"sucrasePlugin");export{M as sucrasePlugin};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
var nt=Object.defineProperty;var f=(e,t)=>nt(e,"name",{value:t,configurable:!0});import{chmod as st,stat as pe}from"node:fs/promises";import ce from"node:module";import{exit as R,env as W,versions as it,cwd as at}from"node:process";import{cyan as j,gray as P,bold as E,grey as lt,green as pt}from"@visulima/colorize";import{readFile as X,writeFile as J,readFileSync as ct,writeFileSync as ut,writeJsonSync as mt,collectSync as dt,ensureDirSync as ft,emptyDir as gt,walk as ht,isAccessible as yt}from"@visulima/fs";import{formatBytes as M}from"@visulima/humanizer";import{readTsConfig as vt,findTSConfig as bt,findPackageJson as $t}from"@visulima/package";import{createPail as jt}from"@visulima/pail";import{MessageFormatterProcessor as wt,ErrorProcessor as kt,CallerProcessor as xt}from"@visulima/pail/processor";import{resolve as h,join as C,normalize as z,extname as G,relative as D,dirname as ue,basename as U,isAbsolute as me}from"@visulima/path";import{defu as Ot}from"defu";import{createHooks as Et}from"hookable";import{minVersion as de}from"semver";import{DEFAULTS as Dt,nodeResolve as H}from"@rollup/plugin-node-resolve";import{pathToFileURL as _t,fileURLToPath as St}from"node:url";import{resolvePath as Nt,resolveModuleExportNames as Pt,findStaticImports as fe}from"mlly";import _ from"magic-string";import ge from"jiti";import{watch as he,rollup as ye}from"rollup";import ve from"@rollup/plugin-alias";import Mt from"@rollup/plugin-commonjs";import Ft from"@rollup/plugin-dynamic-import-vars";import be from"@rollup/plugin-replace";import{wasm as It}from"@rollup/plugin-wasm";import{dts as Rt}from"rollup-plugin-dts";import Ct from"rollup-plugin-polyfill-node";import{visualizer as Tt}from"rollup-plugin-visualizer";import{glob as At}from"glob";import Wt from"glob-parent";import Bt from"@rollup/plugin-json";import{createFilter as Y,normalizePath as $e}from"@rollup/pluginutils";import Lt from"rollup-plugin-license";import{parse as Jt}from"@babel/parser";import{existsSync as Z}from"node:fs";import{distance as zt}from"fastest-levenshtein";const Ut=[...Dt.extensions,".cjs"],S=[...Ut,".ts",".cts",".mts",".tsx",".jsx"],Ht={".aac":"file",".cjs":"js",".css":"file",".cts":"ts",".eot":"file",".flac":"file",".gif":"file",".jpeg":"file",".jpg":"file",".js":"js",".json":"json",".jsx":"jsx",".mjs":"js",".mp3":"file",".mp4":"file",".mts":"ts",".ogg":"file",".otf":"file",".png":"file",".svg":"file",".ts":"ts",".tsx":"tsx",".ttf":"file",".wav":"file",".webm":"file",".webp":"file",".woff":"file",".woff2":"file"},K=/node_modules/;var qt=Object.defineProperty,q=f((e,t)=>qt(e,"name",{value:t,configurable:!0}),"i$8");const Q=/^#![^\n]*/,ee=q(async e=>{await st(e,493).catch(()=>{})},"makeExecutable"),Vt=q((e,t=`#!/usr/bin/env node
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(r,n,o){if(!n.isEntry||!n.facadeModuleId||r.startsWith("#")&&r[1]==="!")return null;if(e.includes(n.name)){const i=new _(r);return i.prepend(t),{code:i.toString(),map:o.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(r,n){for(const[o,i]of Object.entries(n))if(i.type==="chunk"&&Q.test(i.code)&&r.dir){const s=h(r.dir,o);await ee(s)}}}),"shebangPlugin"),Xt=q(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Q,"")}}),"removeShebangPlugin"),Gt=q((e,t=`
|
|
3
|
-
`)=>{const r=Q.exec(e);return r?r+t:""},"getShebang");var Yt=Object.defineProperty,Zt=f((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"p$2");const te=Zt((e,t)=>{let r={};if(e.pkg.name&&(r[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const o in n){if(o.startsWith("#"))continue;const i=n[o];typeof i=="string"&&(r[o]=C(e.rootDir,i))}}return r={...r,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(r,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(r,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(r),prefix:t}),r},"resolveAliases");var Kt=Object.defineProperty,Qt=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"o$4");const eo=Qt((e,t)=>{const r=ge(t,{esmResolve:!0,interopDefault:!0});try{return r.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 to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"r$6");const B=oo((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var ro=Object.defineProperty,no=f((e,t)=>ro(e,"name",{value:t,configurable:!0}),"u$8");const so=no(async e=>{const t=await Nt("jiti",{url:import.meta.url}),r=JSON.stringify({...e.options.stubOptions.jiti,alias:{...te(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const o=h(e.options.rootDir,e.options.outDir,n.name),i=z(eo(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-G(i).length)),c=await X(i),u=Gt(c);e.options.emitCJS&&await J(`${o}.cjs`,u+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
|
|
4
|
-
`));let p=[];try{p=await Pt(i,{extensions:S})}catch(a){B(e,`Cannot analyze ${i} for exports:${a}`);return}const l=p.includes("default")||p.length===0;await J(`${o}.mjs`,u+[`import jiti from ${JSON.stringify(_t(t).href)};`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,l?`
|
|
5
|
-
export default _module;`:"",...p.filter(a=>a!=="default").map(a=>`export const ${a} = _module.${a};`)].join(`
|
|
6
|
-
`)),await J(`${o}.d.cts`,[`export * from ${JSON.stringify(s)};`,l?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
7
|
-
`)),await J(`${o}.d.mts`,[`export * from ${JSON.stringify(i)};`,l?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
8
|
-
`)),u&&(await ee(`${o}.cjs`),await ee(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var io=Object.defineProperty,ao=f((e,t)=>io(e,"name",{value:t,configurable:!0}),"a$a");const oe=ao((e,t)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),"arrayIncludes");var lo=Object.defineProperty,po=f((e,t)=>lo(e,"name",{value:t,configurable:!0}),"e$2");const re=po((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var co=Object.defineProperty,uo=f((e,t)=>co(e,"name",{value:t,configurable:!0}),"m$4");const je=uo(({addDefaultProperty:e=!1,logger:t,type:r})=>({name:"packem:cjs-interop",renderChunk(n,o,i){if(o.type!=="chunk"||!o.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const c=new _(n);c.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),c.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&c.append(`
|
|
9
|
-
module.exports.default = `+s[2]+";");let u=c.toString();return u=u.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:u,map:c.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(o.fileName)){if(r!=="commonjs"&&o.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(n);if(s===null||s.length<2)return null;const c=s[1].split(", "),u=[];let p;for(const a of c)if(!a.includes("type"))if(a.includes("as")){const[d,$]=a.split(" as ");if($==="default"&&(p=d,!e))continue;u.push($+": typeof "+d+";")}else u.push(a+": typeof "+a+";");const l=new _(n);return l.replace(" "+p+" as default,",""),l.append(`
|
|
10
|
-
|
|
11
|
-
declare const defaultExport: {
|
|
12
|
-
`+(u.length>0?" ":"")+u.join(`
|
|
13
|
-
`)+`
|
|
14
|
-
} & typeof `+p+`;
|
|
15
|
-
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:l.toString(),map:l.generateMap({hires:!0})}}return null}}),"cjsInterop");var mo=Object.defineProperty,fo=f((e,t)=>mo(e,"name",{value:t,configurable:!0}),"u$7");const go=fo((e,t)=>{const r=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const i=await Promise.all(o.flatMap(s=>Array.isArray(s.src)?s.src.map(c=>({...s,src:c})):s).map(async s=>await At(s.src,{ignore:s.exclude}).then(c=>({dest:s.dest??"",parent:Wt(s.src),src:c}))));for(const s of i)for(const c of s.src){let u;r.has(c)?u=r.get(c):(u={copied:[],dest:[],timestamp:0},r.set(c,u));const p=n.flatten?z(s.dest):C(s.dest,D(s.parent,ue(c)));u.dest.includes(p)||u.dest.push(p),this.addWatchFile(c)}t.info({message:"Copying files...",prefix:"copy"}),await Promise.all([...r].map(async([s,c])=>{let u;try{const p=await pe(s);if(!p.isFile())return;const l=p.mtime.getTime();l>c.timestamp&&(c.timestamp=l,c.copied=[]),u=await X(s,{buffer:!0})}catch(p){t.error({context:[p],message:`error reading file ${s}`,prefix:"copy"});return}for(const p of c.dest){if(n.copyOnce&&c.copied.includes(p))continue;const l=U(s),a=C(p,l);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:a,source:u,type:"asset"}),t.debug({message:`copied ${s} → ${a}`,prefix:"copy"}),c.copied.push(p)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${a}`,prefix:"copy"})}}}))},name:"packem:copy"}},"copyPlugin");var ho=Object.defineProperty,yo=f((e,t)=>ho(e,"name",{value:t,configurable:!0}),"n$8");const we="export default ",ke=yo(e=>{const t=Bt(e);return{...t,name:"packem:json",transform(r,n){const o=t.transform?.call(this,r,n);return o&&typeof o!="string"&&"code"in o&&o.code?.startsWith(we)&&(o.code=o.code.replace(we,"module.exports = ")),o}}},"JSONPlugin");class vo{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,r,n,o){t&&r&&(n!=null?t[r][n]=o:t[r]=o)}remove(t,r,n){t&&r&&(n!=null?t[r].splice(n,1):delete t[r])}}class bo extends vo{static{f(this,"SyncWalker")}constructor(t,r){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(n=>this.replacement=n,"replace")},this.enter=t,this.leave=r}visit(t,r,n,o){if(t){if(this.enter){const s=this.should_skip,c=this.should_remove,u=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,r,n,o),this.replacement&&(t=this.replacement,this.replace(r,n,o,t)),this.should_remove&&this.remove(r,n,o);const p=this.should_skip,l=this.should_remove;if(this.should_skip=s,this.should_remove=c,this.replacement=u,p)return t;if(l)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const c=s;for(let u=0;u<c.length;u+=1){const p=c[u];xe(p)&&(this.visit(p,t,i,u)||u--)}}else xe(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,c=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,r,n,o),this.replacement&&(t=this.replacement,this.replace(r,n,o,t)),this.should_remove&&this.remove(r,n,o);const u=this.should_remove;if(this.replacement=s,this.should_remove=c,u)return null}}return t}}function xe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(xe,"isNode");function Oe(e,{enter:t,leave:r}){return new bo(t,r).visit(e,null)}f(Oe,"walk");var $o=Object.defineProperty,jo=f((e,t)=>$o(e,"name",{value:t,configurable:!0}),"u$6");const wo=jo(({attributes:e,logger:t})=>{const r=Y([/\.[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,o){if(!r(o))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${o}" and remove the jsx attribute.`}),t.warn(u),null}let s=!1;const c=new _(n);return Oe(i,{enter(u){if(u.type==="CallExpression"&&u.callee.type==="Identifier"&&u.callee.name==="jsx"){const p=u.arguments.filter(l=>l.type==="ObjectExpression"&&Array.isArray(l.properties));for(const l of p)for(const a of l.properties)a.type==="Property"&&a.key.type==="Literal"&&a.value.type==="Literal"&&e.includes(a.key.value)&&(c.overwrite(a.start-2,a.end,""),s=!0)}}}),s?{code:c.toString(),map:c.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var ko=Object.defineProperty,ne=f((e,t)=>ko(e,"name",{value:t,configurable:!0}),"p$1");const xo=ne(e=>{const t=[],r=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):r.push(n)}),[...r.sort(),...t.sort()]},"sortLicenses"),Oo=ne((e,t,r)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
|
|
17
|
-
${r}
|
|
18
|
-
$2`)},"replaceContentWithin"),Ee=ne(({licenseFilePath:e,licenseTemplate:t,logger:r,marker:n,mode:o,packageName:i})=>Lt({thirdParty(s){const c=new Set,u=s.sort(({name:l},{name:a})=>l>a?1:a>l?-1:0).map(({author:l,contributors:a,license:d,licenseText:$,maintainers:w,name:x,repository:m})=>{let g=`## ${x}
|
|
19
|
-
`;d&&(g+=`License: ${d}
|
|
20
|
-
`);const y=new Set;for(const v of[l,...w,...a]){const b=typeof v=="string"?v:v?.name;b&&y.add(b)}return y.size>0&&(g+=`By: ${[...y].join(", ")}
|
|
21
|
-
`),m&&(g+=`Repository: ${typeof m=="string"?m:m.url}
|
|
22
|
-
`),$&&(g+=`
|
|
23
|
-
`+$.trim().replaceAll(/(\r\n|\r)/g,`
|
|
24
|
-
`).split(`
|
|
25
|
-
`).map(v=>`> ${v}`).join(`
|
|
26
|
-
`)+`
|
|
27
|
-
`),d&&c.add(d),g}).join(`
|
|
28
|
-
---------------------------------------
|
|
29
|
-
|
|
30
|
-
`),p=t(xo(c),u,i);try{const l=ct(e),a=Oo(l,n,p);if(!a){r.error(`Could not find the license marker: <!-- ${n} --> in ${e}`);return}l!==a&&(ut(e,a),r.info({message:`${e} updated.`,prefix:`license:${o}`}))}catch(l){r.error(l)}}}),"license");var Eo=Object.defineProperty,Do=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"i$5");const _o=Do(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const o=this.getModuleInfo(n);if(o!=null&&!o.isExternal)for(const i of o.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const r=h(e.outDir,"graph.json");mt(r,t)},name:"packem:metafile"}),"metafilePlugin");var So=Object.defineProperty,No=f((e,t)=>So(e,"name",{value:t,configurable:!0}),"c$4");const Po=/\.(?:m|c)?(?:j|t)sx?$/,Mo=/^use \w+$/,Fo=No(e=>{const t={},r={};return{name:"packem:preserve-directives",onLog(n,o){return o.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,o,{sourcemap:i}){const s=o.moduleIds.map(p=>t[p]?t[p]:null).reduce((p,l)=>(l&&l.forEach(a=>{p.add(a)}),p),new Set),c=new _(n);s.size>0&&(e.debug({message:`directives for chunk "${o.fileName}" are preserved.`,prefix:"preserve-directives"}),c.prepend(`${[...s].map(p=>`'${p}';`).join(`
|
|
31
|
-
`)}
|
|
32
|
-
`));let u=null;return o.facadeModuleId&&typeof r[o.facadeModuleId]=="string"&&(u=r[o.facadeModuleId]),u&&(e.debug({message:`shebang for chunk "${o.fileName}" is preserved.`,prefix:"preserve-directives"}),c.prepend(`${u}
|
|
33
|
-
`)),s.size===0&&u===null?null:{code:c.toString(),map:i?c.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,o){const i=G(o);if(!Po.test(i))return null;let s=!1;const c=new _(n);if(n.startsWith("#")&&n[1]==="!"){let p=0;for(let l=2,a=n.length;l<a;l++){const d=n.codePointAt(l);if(d===10||d===13||d===8232||d===8233){p=l;break}}p&&(r[o]=n.slice(0,p),c.remove(0,p+1),s=!0,e.debug({message:`shebang for module "${o}" is preserved.`,prefix:"preserve-directives"}))}let u=null;try{u=this.parse(c.toString(),{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${o}" and extract the directives.`}),e.warn(p),null}if(u.type!=="Program")return null;for(const p of u.body.filter(Boolean)){if(p.type!=="ExpressionStatement")break;let l=null;"directive"in p?l=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&Mo.test(p.expression.value)&&(l=p.expression.value),l!=="use strict"&&l&&(t[o]||=new Set,t[o].add(l),"start"in p&&typeof p.start=="number"&&"end"in p&&typeof p.end=="number"&&(c.remove(p.start,p.end),s=!0),e.debug({message:`directive "${l}" for module "${o}" is preserved.`,prefix:"preserve-directives"}))}return s?{code:c.toString(),map:c.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[o]??[]],shebang:r[o]??null}}}:null},order:"post"}}},"preserveDirectives");var Io=Object.defineProperty,Ro=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"r$4");const Co={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},To=Ro((e={})=>{e={...e,...Co};const t=Y(e.include,e.exclude);return{name:"packem:raw",transform(r,n){return t(n)?{code:`export default ${JSON.stringify(r)}`,map:null}:null}}},"rawPlugin");var Ao=Object.defineProperty,Wo=f((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"l$3");const se="\0__file_url__",De=Wo(()=>({async load(e){if(e.startsWith(se)){const t=St(e.slice(se.length));return await X(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${se}${e}`}}),"resolveFileUrl");var Bo=Object.defineProperty,_e=f((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"m$2");const Lo=/__filename|__dirname|require\(|require\.resolve\(/,Se=`
|
|
34
|
-
// -- pack CommonJS Shims --
|
|
35
|
-
import __cjs_url__ from "node:url";
|
|
36
|
-
import __cjs_path__ from "node:path";
|
|
37
|
-
import __cjs_mod__ from "node:module";
|
|
38
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,Ne=`
|
|
42
|
-
// -- pack CommonJS Shims Node 20.11 --
|
|
43
|
-
import __cjs_mod__ from "node:module";
|
|
44
|
-
const __filename = import.meta.filename;
|
|
45
|
-
const __dirname = import.meta.dirname;
|
|
46
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
-
`,Jo=_e((e,t)=>{if(e.includes(Se)||e.includes(Ne)||!Lo.test(e))return null;const r=fe(e).pop(),n=r?r.end:0,o=new _(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),zo=_e(e=>({name:"packem:cjs",renderChunk(t,r,n){if(n.format==="es"){let o=Se;if(e.engines?.node){const i=de(e.engines.node);i&&i.major>=20&&i.minor>=11&&(o=Ne)}return Jo(t,o)}return null}}),"cjsPlugin");var Uo=Object.defineProperty,F=f((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"s$a");const Ho=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,qo=/MIT License|MIT license|BSD license/,Vo=/\n{2,}/g,Xo=/\b(\w+)\$\d+\b/g,Go=/[-/\\^$*+?.()|[\]{}]/g,Yo=F(e=>e.replaceAll(Go,"\\$&"),"escapeRegex"),Zo=F(e=>[...new Set(e)],"unique"),Ko=F(e=>e.replaceAll(Ho,t=>qo.test(t)?"":t).replaceAll(Vo,`
|
|
48
|
-
|
|
49
|
-
`),"cleanUnnecessaryComments"),Pe=new Map;function Me(e,t,{identifierReplacements:r},n){const o=fe(e);for(const s in r){const c=o.find(p=>p.specifier===s&&p.imports.includes("{"));if(!c){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const u=r[s];for(const p in u){c.imports.includes(p)||(this.warn(`${t.fileName} does not import "${p}" from "${s}" for replacement`),R(1));const l=u[p],a=Yo(p);l.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${a},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${a}\\b`,"g"),l)}}const i=Zo(Array.from(e.matchAll(Xo),s=>s[0]));if(i.length>0){const s=i.map(u=>`
|
|
50
|
-
- ${u}`).join(""),c=t.fileName.replace(/\.[^/.]+$/,"");Pe.has(c)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
|
|
51
|
-
|
|
52
|
-
To replace these, add them to the "patchTypes -> identifierReplacements" option in your packem config.`,prefix:"patch-types"}),Pe.set(c,!0)}return e}f(Me,"v$2"),F(Me,"replaceConfusingTypeNames");function Fe(e,t){if(t.leadingComments?.some(r=>r.type==="CommentBlock"&&r.value.includes("@internal"))){const r=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,r),!0}return!1}f(Fe,"N$1"),F(Fe,"removeInternal");function Ie(e,t){if(e.includes("@internal")){const r=new _(e),n=Jt(e,{plugins:["typescript"],sourceType:"module"});Oe(n,{enter(o){Fe(r,o)&&this.skip()}}),e=r.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),R(1))}return e}f(Ie,"S$1"),F(Ie,"stripInternalTypes");const Qo=F((e,t)=>({name:"packem:patch-types",renderChunk(r,n){return r=Me.call(this,r,n,e,t),r=Ie.call(this,r,n),r=Ko(r),r},resolveId(r){return r.startsWith("types/")?{external:!0,id:"../../"+(r.endsWith(".js")?r:r+".js")}:null}}),"patchTypescriptTypes");var er=Object.defineProperty,Re=f((e,t)=>er(e,"name",{value:t,configurable:!0}),"u$3");const Ce=Re((e,t=!0)=>{if(!e)return null;const{config:r,path:n}=e;if(!r.compilerOptions)return null;const{baseUrl:o,paths:i}=r.compilerOptions;if(!o)return null;const s=h(ue(n),o),c=[];if(i)for(const[u,p]of Object.entries(i)){const l=new RegExp(`^${[...u].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let a=0;for(const d of p){const $=[...$e(h(s,d))].map(w=>w==="*"?`$${++a}`:w==="$"?"$$":w).join("");c.push({find:l,replacement:$})}}return t&&c.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...$e(s)].map(u=>u==="$"?"$$":u).join("")}/$1`}),c},"getConfigAlias"),Te=Re((e,t)=>{const r=Ce(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,o,i){if(!r||n.includes("\0"))return null;for(const{find:s,replacement:c}of r)if(s.test(n)){const u=n.replace(s,c),p=await this.resolve(u,o,{skipSelf:!0,...i});if(p)return t.debug({message:`Resolved ${n} to ${p.id} using paths from tsconfig.json.`,prefix:"resolve-tsconfig-paths"}),p.id}return null}}},"resolveTsconfigPaths");var tr=Object.defineProperty,Ae=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"u$2");const or=Ae((e,t)=>{if(!t)return null;const{config:r,path:n}=t;if(!r.compilerOptions)return null;const{rootDirs:o}=r.compilerOptions;if(!o)return null;const i=[];for(const s of o){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(h(e,s))}return i},"getRootDirectories"),We=Ae((e,t,r)=>{const n=or(e,r);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(o,i,s){if(n===null||n.length===0)return null;if(o.startsWith("."))for(const c of n){const u=C(c,o),p=await this.resolve(u,i,{skipSelf:!0,...s});if(p)return t.debug({message:`Resolved ${o} to ${p.id} using rootDirs from tsconfig.json.`,prefix:"resolve-tsconfig-root-dirs"}),p.id}return null}}},"resolveTsconfigRootDirectories");var rr=Object.defineProperty,nr=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"r$3");const Be=nr(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,r,n){return e.test(t)&&r?await this.resolve(t.replace(/js(x?)$/,"ts$1"),r,n):null}}},"resolveTypescriptMjsCts");var sr=Object.defineProperty,ir=f((e,t)=>sr(e,"name",{value:t,configurable:!0}),"s$9");const ar=ir(e=>{const t=U(e).split(".");if(t.length>=2){const[r,n]=t.slice(-2),o=t[0],i=/^(\w+)-runtime$/.exec(r)?.[1];if(S.includes(n)&&i&&i.length>0)return o+"-"+i}},"getCustomModuleLayer");var lr=Object.defineProperty,pr=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$2");const ie=pr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var cr=Object.defineProperty,Le=f((e,t)=>cr(e,"name",{value:t,configurable:!0}),"c$2");const Je=Le((e,t)=>{const r=new Map;return Le(function(n,o){const i=o.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,c=i.meta,u=ie(c);if(!s){const p=r.get(n);if(p)return p;const l=ar(n);if(l)return r.set(n,l),l}if(s){const p=o.getModuleIds();for(const l of p)o.getModuleInfo(l)&&ie(c)===u&&(e.has(l)||e.set(l,new Set),e.get(l).add([n,u]))}if(u&&!s&&e.has(n)){const p=[...e.get(n)];if(p.some(([a])=>{if(console.log(a),t.some(d=>d.path===a)){const d=o.getModuleInfo(a);return ie(d?d.meta:{})===u}return!1}))return;if(p.every(([,a])=>a===u))return r.has(n)?r.get(n):void 0;const l=`${U(n,G(n))}-${u}`;return r.set(n,l),l}},"splitChunks")},"createSplitChunks");var ur=Object.defineProperty,mr=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"n$6");const N=mr((e,t,r)=>t.isDynamicEntry?`chunks/[name].${r}`:`shared/${e.options.name}.[hash].${r}`,"getChunkFilename");var dr=Object.defineProperty,fr=f((e,t)=>dr(e,"name",{value:t,configurable:!0}),"s$7");const gr=process.platform==="win32",ze=fr((e,t)=>{const r=gr?"\\":"/";return e.name?.includes("node_modules"+r+".pnpm")?(e.name.replace("node_modules"+r+".pnpm","external")+"."+t).replace("node_modules"+r,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var hr=Object.defineProperty,k=f((e,t)=>hr(e,"name",{value:t,configurable:!0}),"e$1");const yr=k(async e=>(await import("../chunks/index.mjs").then(t=>t.default))(e),"lazyImportSwc"),vr=k(async e=>(await import("../chunks/index2.mjs").then(t=>t.default))(e),"lazyImportEsbuild"),br=k(async e=>(await import("../chunks/sucrase.mjs").then(t=>t.sucrasePlugin))(e),"lazyImportSucrase"),Ue=k((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${j(D(h(),e.id))}"
|
|
53
|
-
Is the module installed? Note:
|
|
54
|
-
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
55
|
-
↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),He=new Map,qe=k((e,t)=>{const r=k(o=>{for(const[i,s]of Object.entries(t))if(o.startsWith(i))return o.replace(i,s)},"findAlias"),n=Ce(e.tsconfig,!1);return{external(o){const i=r(o);i&&(o=i);const s=re(o),c=oe(e.options.externals,s)||oe(e.options.externals,o);if(c)return!0;if(o.startsWith(".")||me(o)||/src[/\\]/.test(o)||e.pkg.name&&o.startsWith(e.pkg.name))return!1;if(n){for(const{find:u}of n)if(u.test(o))return e.logger.debug(`Resolved alias ${o} to ${u.source}`),!1}return!c&&He.has(o)&&e.logger.info('Inlined implicit external "'+j(o)+'". If this is incorrect, add it to the "externals" option.'),He.set(o,!0),c},input:Object.fromEntries(e.options.entries.map(o=>[o.name,h(e.options.rootDir,o.input)])),onwarn(o,i){Ue(o,e)||o.code||i(o)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ve=k(async e=>{const t=te(e,"build");return{...qe(e,t),output:[e.options.emitCJS&&{chunkFileNames:k(r=>N(e,r,"cjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:k(r=>ze(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{constBindings:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:k(r=>N(e,r,"mjs"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:k(r=>ze(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{constBindings:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[De(),Be(),e.tsconfig&&We(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Te(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:H({extensions:S,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&H({extensions:S,...e.options.rollup.resolve}),e.options.rollup.polyfillNode&&Ct({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ke({...e.options.rollup.json}),Fo(e.logger),Vt(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&It(e.options.rollup.wsam),e.options.rollup.esbuild&&e.options.transformer==="esbuild"&&await vr({sourceMap:e.options.sourcemap,...e.options.rollup.esbuild,logger:e.logger}),e.options.rollup.sucrase&&e.options.transformer==="sucrase"&&await br(e.options.rollup.sucrase),e.options.rollup.swc&&e.options.transformer==="swc"&&await yr({...e.options.rollup.swc,jsc:{...W.NODE_ENV==="production"?{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:e.options.sourcemap}}:{},...e.options.rollup.swc.jsc},sourceMaps:e.options.sourcemap}),e.options.cjsInterop&&e.options.emitCJS&&je({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ft(),e.options.rollup.commonjs&&Mt({extensions:S,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&zo(e.pkg),e.options.rollup.raw&&To(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&wo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&_o({outDir:h(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&go(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.template=="function"&&Ee({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.template,logger:e.logger,marker:e.options.rollup.license.marker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Tt({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"),Xe=k(e=>{const t=te(e,"types"),r={load(o){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(o)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;return delete n?.lib,{...qe(e,t),onwarn(o,i){Ue(o,e)||o.code!=="EMPTY_BUNDLE"&&i(o)},output:[e.options.emitCJS&&{chunkFileNames:k(o=>N(e,o,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:k(o=>N(e,o,"d.mts"),"chunkFileNames"),dir:h(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:k(o=>N(e,o,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[De(),Be(),e.options.rollup.json&&ke({...e.options.rollup.json}),r,e.tsconfig&&We(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Te(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:H({extensions:S,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&H({extensions:S,...e.options.rollup.resolve}),Rt({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}),e.options.cjsInterop&&e.options.emitCJS&&je({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Qo(e.options.rollup.patchTypes,e.logger),Xt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ee({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.marker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var $r=Object.defineProperty,T=f((e,t)=>$r(e,"name",{value:t,configurable:!0}),"p");const Ge=T((e,t,r)=>{const n="watcher:"+t;e.on("change",(o,{event:i})=>{r.info({message:`${j(D(".",o))} was ${i}d`,prefix:n})}),e.on("restart",()=>{r.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",o=>{o.code==="END"&&r.success({message:"Rebuild "+t+" finished",prefix:n}),o.code==="ERROR"&&r.error({context:[o.error],message:"Rebuild "+t+" failed: "+o.error.message,prefix:n})})},"watchHandler"),jr=T(async e=>{const t=await Ve(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=he(t);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(t.input)?t.input:typeof t.input=="string"?[t.input]:Object.keys(t.input??{})];let o="Starting watchers for entries:";for(const i of n)o+=P(`
|
|
56
|
-
└─ ${D(process.cwd(),i)}`);if(e.logger.info(o),Ge(r,"bundle",e.logger),e.options.declaration){const i=Xe(e);await e.hooks.callHook("rollup:dts:options",e,i);const s=he(i);await e.hooks.callHook("rollup:watch",e,s),Ge(s,"types",e.logger)}},"watch"),wr=T(async e=>{const t=await Ve(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=await ye(t);await e.hooks.callHook("rollup:build",e,r);const n=t.output,o=new Map;for(const i of n){const{output:s}=await r.write(i),c=new Set,u=s.filter(l=>l.type==="chunk");for(const l of u){c.add(l.fileName);for(const a of l.imports)e.usedImports.add(a);l.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(l.code,"utf8"),chunks:l.imports.filter(a=>u.find(d=>d.fileName===a)),exports:l.exports,modules:Object.entries(l.modules).map(([a,d])=>({bytes:d.renderedLength,id:a})),path:l.fileName,type:"entry"})}const p=s.filter(l=>l.type==="asset");for(const l of p)o.has(l.fileName)||o.set(l.fileName,{bytes:Buffer.byteLength(l.source,"utf8"),path:l.fileName,type:"asset"});for(const l of c)e.usedImports.delete(l)}if(e.buildEntries.push(...o.values()),e.options.declaration){const i=Xe(e);if(await e.hooks.callHook("rollup:dts:options",e,i),Object.keys(i.input).length===0)return;const s=await ye(i);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:T(c=>N(e,c,"d.cts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await s.write({chunkFileNames:T(c=>N(e,c,"d.mts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration===!0&&await s.write({chunkFileNames:T(c=>N(e,c,"d.ts"),"chunkFileNames"),dir:h(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"})}await e.hooks.callHook("rollup:dts:done",e)},"build");var kr=Object.defineProperty,xr=f((e,t)=>kr(e,"name",{value:t,configurable:!0}),"a$3");const Or=xr(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Er=Object.defineProperty,Dr=f((e,t)=>Er(e,"name",{value:t,configurable:!0}),"i$1");const Ye=Dr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var _r=Object.defineProperty,V=f((e,t)=>_r(e,"name",{value:t,configurable:!0}),"l$2");const Sr=Y,Nr=V((e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=V(()=>r,"hasSideEffects");else if(Array.isArray(r))if(r.length<=0)n=V(()=>!1,"hasSideEffects");else{const o=r.map(i=>i.includes("/")?i:`**/${i}`);n=Sr(o,null,{resolve:e})}else n=V(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Pr=Object.defineProperty,Mr=f((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"t$3");const Fr=Mr(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var Ir=Object.defineProperty,Ze=f((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"t$2");const ae=Ze(e=>{if(e.endsWith(".d.ts")||e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"cjs"},"inferExportTypeFromFileName"),Ke=Ze((e,t,r,n)=>{if(r){const s=ae(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[o,...i]=t;return Ke(o,i,r,n)},"inferExportType");var Rr=Object.defineProperty,Cr=f((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"s$4");const le=Cr((e,t,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ae(e),o=t==="module"?"esm":"cjs";if(n&&n!==o)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:n??o}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,o])=>typeof o=="string"?{file:o,type:Ke(n,r,o,t)}:le(o,t,[...r,n]))},"extractExportFilenames");var Tr=Object.defineProperty,Ar=f((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"e");const Wr=Ar(e=>{const t=z(e).split("/");return t.map((r,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var Br=Object.defineProperty,Lr=f((e,t)=>Br(e,"name",{value:t,configurable:!0}),"E");const Jr=Lr((e,t,r=".")=>{const n=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const o=le(e.exports,e.type||"commonjs");if(e.bin){const l=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const a of l)o.push({file:a,isExecutable:!0})}e.main&&o.push({file:e.main,type:ae(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&o.push({file:e.module,type:"esm"}),(e.types||e.typings)&&o.push({file:e.types||e.typings});const i=e.type==="module";for(const l of o.filter(a=>!a.type)){const a=l.file.endsWith(".js");i&&a||l.file.endsWith(".mjs")?l.type="esm":(!i&&a||l.file.endsWith(".cjs"))&&(l.type="cjs")}let s=!1,c=!1,u=!1;const p=[];for(const l of o){const a=l.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),d=a.endsWith("/");if(d&&["./","/"].includes(a))continue;const $=Wr(a).reduce((x,m)=>{if(x)return x;const g=new RegExp(`(?<=/|$)${m}${d?"":"\\.\\w+"}$`);return t.find(y=>g.test(y))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!$){Z(h(r,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}l.type==="cjs"&&(s=!0),l.type==="esm"&&(c=!0);const w=p.find(x=>x.input===$)??p[p.push({input:$})-1];/\.d\.(?:m|c)?ts$/.test(l.file)&&(u=!0),d&&(w.outDir=a),l.isExecutable&&(w.isExecutable=!0)}return{cjs:s,dts:u,entries:p,esm:c,warnings:n}},"inferEntries");var zr=Object.defineProperty,Ur=f((e,t)=>zr(e,"name",{value:t,configurable:!0}),"o$1");const Hr=Ur(e=>{const{publishConfig:t}=e;return t&&(t.bin&&(typeof t.bin=="object"||typeof t.bin=="string")&&(e.bin=t.bin),t.type&&typeof t.type=="string"&&t.type!==""&&(e.type=t.type),t.main&&typeof t.main=="string"&&t.main!==""&&(e.main=t.main),t.module&&typeof t.module=="string"&&t.module!==""&&(e.module=t.module),t.types&&typeof t.types=="string"&&t.types!==""?e.types=t.types:t.typings&&typeof t.typings=="string"&&t.typings!==""&&(e.typings=t.typings),t.exports&&typeof t.exports=="object"&&(e.exports=t.exports)),e},"overwriteWithPublishConfig");var qr=Object.defineProperty,Vr=f((e,t)=>qr(e,"name",{value:t,configurable:!0}),"n$3");const Xr={hooks:{"build:prepare":Vr(function(e){if(!e.pkg||e.options.entries.length>0)return;const t=C(e.options.rootDir,"src");if(!Z(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=dt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(r.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=Hr(n));const o=Jr(n,r,e.options.rootDir);for(const i of o.warnings)B(e,i);if(e.options.entries.push(...o.entries),o.cjs&&(e.options.emitCJS=!0),o.esm&&(e.options.emitESM=!0),o.dts&&(e.options.declaration=o.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",j(e.options.entries.map(i=>E(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),P([o.esm&&"esm",o.cjs&&"cjs",o.dts&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Gr=Object.defineProperty,Yr=f((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"n$2");const Qe=Yr((e,t,r)=>{const n=ge(t,{esmResolve:!0,interopDefault:!0});try{return n(e)}catch(o){if(o.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:o});return r}},"tryRequire");var Zr=Object.defineProperty,Kr=f((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"t");const Qr=Kr((e,t)=>(e==="auto"?e=Xr:typeof e=="string"&&(e=Qe(e,t,{})),typeof e=="function"&&(e=e()),e),"resolvePreset");var en=Object.defineProperty,tn=f((e,t)=>en(e,"name",{value:t,configurable:!0}),"o");const on=tn(e=>{const t=new Set,r=new Set(Object.keys(e.pkg.dependencies||{})),n=new Set;for(const o of e.usedImports)r.delete(o),t.add(o);if(Array.isArray(e.options.dependencies))for(const o of e.options.dependencies)r.delete(o);for(const o of t)!oe(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(re(o))&&!e.options.peerDependencies.includes(re(o))&&n.add(o);r.size>0&&B(e,`Potential unused dependencies found: ${[...r].map(o=>j(o)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(o=>j(o)).join(", ")}`)},"validateDependencies");var rn=Object.defineProperty,et=f((e,t)=>rn(e,"name",{value:t,configurable:!0}),"i");const nn=et((e,t)=>zt(e,t)<=e.length/3||t.includes(e),"isSimilar"),sn=et((e,t)=>{const r=e.toLowerCase();return t.filter(n=>nn(n.toLowerCase(),r))},"findAlternatives");var an=Object.defineProperty,tt=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"n");const ln=tt((e,t)=>{if(!e)return;const r=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin||{}),e.main,e.module,e.types,e.typings,...le(e.exports,e.type??"commonjs").map(o=>o.file)].map(o=>o&&h(t.rootDir,o.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const o of r)o&&!o.includes("*")&&!Z(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=tt(c=>D(t.rootDir,h(t.options.outDir,c)),"rPath"),i=t.buildEntries.filter(c=>!c.chunk).map(c=>o(c.path));let s="Potential missing or wrong package.json files:";for(const c of n){const u=sn(c,i);s+=`
|
|
57
|
-
- `+j(c)+(u.length>0?lt` (did you mean ${u.map(p=>`"${p}"`).join(", ")}?)`:"")}B(t,s)}},"validatePackage");var pn=Object.defineProperty,I=f((e,t)=>pn(e,"name",{value:t,configurable:!0}),"b");const ot=I((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
58
|
-
`),e.logger.warn(`Build is done with some warnings:
|
|
59
|
-
|
|
60
|
-
${[...e.warnings].map(r=>`- ${r}`).join(`
|
|
61
|
-
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),R(1)))},"logErrors"),cn=I(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"),rt=I(async(e,t,r,n,o,i,s,c)=>{const u=Qr(o.preset??i.packem?.preset??n.preset??"auto",t);let p=`node${it.node.split(".")[0]}`;if(i.engines?.node){const m=de(i.engines.node);m&&(p=`node${m.major}`)}const l=cn(s?.config.compilerOptions?.jsx),a=Ot(o,i.packem,n,u,{alias:{},clean:!0,declaration:!1,dependencies:[],devDependencies:[],entries:[],externals:[...ce.builtinModules,...ce.builtinModules.map(m=>`node:${m}`)],failOnWarn:!0,name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:s?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},emitCJS:!1,emitESM:!0,esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:l,jsxDev:s?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:s?.config.compilerOptions?.jsxFactory,jsxFragment:s?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:s?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minify:W.NODE_ENV==="production",minifyWhitespace:W.NODE_ENV==="production",sourcesContent:!1,target:s?.config.compilerOptions?.target,tsconfigRaw:s?.config},json:{preferConst:!0},license:{dtsTemplate:I((m,g,y)=>`
|
|
62
|
-
# Licenses of bundled types
|
|
63
|
-
The published ${y} artifact additionally contains code with the following licenses:
|
|
64
|
-
${m.join(", ")}
|
|
65
|
-
|
|
66
|
-
# Bundled types:
|
|
67
|
-
`+g,"dtsTemplate"),template:I((m,g,y)=>`
|
|
68
|
-
# Licenses of bundled dependencies
|
|
69
|
-
The published ${y} artifact additionally contains code with the following licenses:
|
|
70
|
-
${m.join(", ")}
|
|
71
|
-
|
|
72
|
-
# Bundled dependencies:
|
|
73
|
-
`+g,"template")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:K,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:s?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:W.NODE_ENV==="production",...s?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(s.config.compilerOptions.jsx)?{jsxFragmentPragma:s.config.compilerOptions.jsxFragmentFactory,jsxImportSource:s.config.compilerOptions.jsxImportSource,jsxPragma:s.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx",...s.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...s?.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:s?.config.compilerOptions?.experimentalDecorators,dynamicImport:!0,syntax:s?"typescript":"ecmascript",[s?"tsx":"jsx"]:!0},target:s?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:s?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:!0,react:{development:W.NODE_ENV!=="production",pragma:s?.config.compilerOptions?.jsxFactory,pragmaFrag:s?.config.compilerOptions?.jsxFragmentFactory,runtime:l,throwIfNamespace:!0,useBuiltins:!0}}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Nr(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:K}},rootDir:t,sourcemap:!1,stub:r==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},target:p,transformer:void 0});if(a.transformer!=="esbuild"&&a.transformer!=="swc"&&a.transformer!=="sucrase"){const m=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(m.has("esbuild"))e.info("Found "+j("esbuild")+" in your package.json."),a.transformer="esbuild";else if(m.has("@swc/core"))e.info("Found "+j("@swc/core")+" in your package.json."),a.transformer="swc";else if(m.has("sucrase"))e.info("Found "+j("sucrase")+" in your package.json."),a.transformer="sucrase";else throw new Error(a.transformer?`Unknown transformer ${JSON.stringify(a.transformer)}`:"Missing transformer name in options.")}if(a.emitESM===!1&&a.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(a.outDir=h(a.rootDir,a.outDir),ft(a.outDir),a.transformer==="esbuild"&&a.rollup.esbuild){if(s?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(e.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(" ")),s.config.compilerOptions.target="es5",a.rollup.esbuild.target="es5"),a.rollup.esbuild.jsx==="preserve"){let m="Packem does not support 'preserve' jsx option. Please use 'transform' or 'automatic' instead.";throw s?.config.compilerOptions?.jsx&&(m="Packem does not support '"+s.config.compilerOptions.jsx+"' jsx option. Please change it to 'react' or 'react-jsx' or 'react-jsxdev' instead."),new Error(m)}if(a.rollup.esbuild.target){const m=Or(a.rollup.esbuild.target);m.some(g=>g.startsWith("node"))||(a.rollup.esbuild.target=[a.target,...m])}else a.rollup.esbuild.target=[a.target];s?.config.compilerOptions?.target==="es5"&&(a.rollup.esbuild.keepNames=!1,e.debug("Disabling keepNames because target is set to es5"))}e.info('Using "'+j(a.transformer)+'" as transformer.'),a.rollup.resolve&&a.rollup.resolve.preferBuiltins===!0&&(a.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),s?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
74
|
-
Because none of the third-party transpilers, 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.
|
|
75
|
-
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.`);const d={buildEntries:[],dependencyGraphMap:new Map,hooks:Et(),logger:e,mode:r,options:a,pkg:i,rootDir:t,tsconfig:s,usedImports:new Set,warnings:new Set};if(u.hooks&&d.hooks.addHooks(u.hooks),n.hooks&&d.hooks.addHooks(n.hooks),o.hooks&&d.hooks.addHooks(o.hooks),await d.hooks.callHook("build:prepare",d),a.declaration&&s===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");for(const m of d.options.entries){if(typeof m.name!="string"){let g=me(m.input)?D(t,m.input):z(m.input);g.startsWith("./")&&(g=g.slice(2)),m.name=Fr(g.replace(/^src\//,""))}if(!m.input)throw new Error(`Missing entry input: ${Ye(m)}`);a.declaration!==void 0&&m.declaration===void 0&&(m.declaration=a.declaration),m.input=h(a.rootDir,m.input),m.outDir=h(a.rootDir,m.outDir??a.outDir)}a.dependencies=Object.keys(i.dependencies??{}),a.peerDependencies=Object.keys(i.peerDependencies??{}),a.devDependencies=Object.keys(i.devDependencies??{}),a.optionalDependencies=Object.keys(i.optionalDependencies??{}),a.externals.push(...a.dependencies,...a.peerDependencies,...a.optionalDependencies),await d.hooks.callHook("build:before",d);let $="Building";if(r==="watch"?$="Watching":r==="jit"&&($="Stubbing"),e.info(j(`${$} ${a.name}`)),e.debug(`${E("Root dir:")} ${a.rootDir}
|
|
76
|
-
${E("Entries:")}
|
|
77
|
-
${d.options.entries.map(m=>` ${Ye(m)}`).join(`
|
|
78
|
-
`)}`),a.clean)for(const m of new Set(d.options.entries.map(g=>g.outDir).filter(Boolean).sort()))m!==a.rootDir&&(c.push(m),e.info(`Cleaning dist directory: \`./${D(a.rootDir,m)}\``),await gt(m));if(a.stub){await so(d),await d.hooks.callHook("build:done",d);return}if(r==="watch"){await jr(d),ot(d,!1);return}await wr(d),e.success(pt(`Build succeeded for ${a.name}`));for await(const m of ht(a.outDir)){let g=d.buildEntries.find(y=>C(d.options.outDir,y.path)===m.path);if(g||(g={chunk:!0,path:m.path},d.buildEntries.push(g)),!g.bytes){const y=await pe(h(a.outDir,m.path));g.bytes=y.size}}const w=I(m=>D(d.rootDir,h(a.outDir,m)),"rPath");let x=!1;for(const m of d.buildEntries.filter(g=>!g.chunk)){let g=m.bytes??0;for(const v of m.chunks??[])g+=d.buildEntries.find(b=>b.path===v)?.bytes??0;let y=` ${E(w(m.path))} (${["total size: "+j(M(g)),m.type!=="asset"&&m.bytes&&"chunk size: "+j(M(m.bytes))].filter(Boolean).join(", ")})`;if(y+=m.exports?.length?`
|
|
79
|
-
exports: `+P(m.exports.join(", ")):"",m.chunks?.length&&(y+=`
|
|
80
|
-
${m.chunks.map(v=>{const b=d.buildEntries.find(O=>O.path===v)??{};return P(" └─ "+w(v)+E(b.bytes?" ("+M(b?.bytes)+")":""))}).join(`
|
|
81
|
-
`)}`),m.modules&&m.modules.length>0){const v=m.modules.filter(b=>b.id.includes("node_modules")).sort((b,O)=>(O.bytes||0)-(b.bytes||0)).map(b=>P(" 📦 "+w(b.id)+E(b.bytes?" ("+M(b.bytes)+")":""))).join(`
|
|
82
|
-
`);y+=v.length>0?`
|
|
83
|
-
inlined modules:
|
|
84
|
-
`+v:""}if(d.options.declaration&&m.type==="entry"){let v=m.path.replace(/\.js$/,".d.ts"),b="commonjs";m.path.endsWith(".cjs")?v=m.path.replace(/\.cjs$/,".d.cts"):m.path.endsWith(".mjs")&&(b="module",v=m.path.replace(/\.mjs$/,".d.mts"));const O=d.buildEntries.find(A=>A.path.endsWith(v));if(O){let A;(d.options.declaration===!0||d.options.declaration==="compatible")&&!v.includes(".d.ts")&&(v=v.replace(b==="commonjs"?".d.c":".d.m",".d."),A=d.buildEntries.find(L=>L.path.endsWith(v))),y+=A&&b===i.type?`
|
|
85
|
-
types:
|
|
86
|
-
`+[O,A].map(L=>P(" └─ ")+E(w(L.path))+" (total size: "+j(M(L.bytes??0))+")").join(`
|
|
87
|
-
`):`
|
|
88
|
-
types: `+E(w(O.path))+" (total size: "+j(M(O.bytes??0))+")"}}x=!0,y+=`
|
|
89
|
-
|
|
90
|
-
`,e.raw(m.chunk?P(y):y)}x&&e.raw("Σ Total dist size (byte size):",j(M(d.buildEntries.reduce((m,g)=>m+(g.bytes??0),0))),`
|
|
91
|
-
`),on(d),ln(i,d),await d.hooks.callHook("build:done",d),ot(d,x)},"build"),un=I(async(e,t,r={})=>{const{configPath:n,debug:o,tsconfigPath:i,...s}=r,c=[new wt,new kt];o&&c.push(new xt);const u=jt({logLevel:o?"debug":"informational",processors:c,scope:"packem"});u.wrapAll(),e=h(at(),e);let p;if(i)await yt(i)||(u.error("tsconfig.json not found at",i),R(1)),p={config:vt(i),path:i},u.debug("Using tsconfig.json found at",i);else try{p=await bt(e),u.debug("Using "+U(p.path)+" found at",p.path)}catch{u.info("No tsconfig.json or jsconfig.json found.")}try{const{packageJson:l,path:a}=await $t(e);u.debug("Using package.json found at",a);const d=Qe(n??"./packem.config",e,[]),$=(Array.isArray(d)?d:[d]).filter(Boolean);if($.length===0)await rt(u,e,t,s,{},l,p,[]);else{const w=[];for(const x of $)await rt(u,e,t,s,x,l,p,w)}u.restoreAll(),R(0)}catch(l){u.error("An error occurred while building",l),R(1)}},"createBundler");export{S as D,K as E,Ht as a,un as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var c=Object.defineProperty;var t=(r,e)=>c(r,"name",{value:e,configurable:!0});import{existsSync as f}from"node:fs";import{join as l}from"@visulima/path";var a=Object.defineProperty,m=t((r,e)=>a(r,"name",{value:e,configurable:!0}),"o");const p=m((r,e,i=!1)=>{const s=e.replace(/\.[jt]sx?$/,"");for(const o of r){const n=i?l(e,`index${o}`):`${s}${o}`;if(f(n))return n}return null},"resolveFile");export{p as x};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";var Ke=Object.create;var U=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var f=(e,t)=>U(e,"name",{value:t,configurable:!0});var rt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!ot.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=Qe(t,o))||n.enumerable});return e};var H=(e,t,r)=>(r=e!=null?Ke(tt(e)):{},rt(t||!e||!e.__esModule?U(r,"default",{value:e,enumerable:!0}):r,e));const V=require("node:fs/promises"),nt=require("node:module"),E=require("node:process"),h=require("@visulima/colorize"),x=require("@visulima/fs"),F=require("@visulima/humanizer"),X=require("@visulima/package"),st=require("@visulima/pail"),G=require("@visulima/pail/processor"),g=require("@visulima/path"),it=require("defu"),at=require("hookable"),le=require("semver"),T=require("@rollup/plugin-node-resolve"),ce=require("node:url"),B=require("mlly"),lt=require("magic-string"),ct=require("jiti"),W=require("rollup"),pt=require("@rollup/plugin-alias"),ut=require("@rollup/plugin-commonjs"),dt=require("@rollup/plugin-dynamic-import-vars"),mt=require("@rollup/plugin-replace"),ft=require("@rollup/plugin-wasm"),gt=require("rollup-plugin-dts"),ht=require("rollup-plugin-polyfill-node"),yt=require("rollup-plugin-visualizer"),vt=require("glob"),bt=require("glob-parent"),jt=require("@rollup/plugin-json"),A=require("@rollup/pluginutils"),$t=require("rollup-plugin-license"),wt=require("@babel/parser"),Y=require("node:fs"),xt=require("fastest-levenshtein");var pe=typeof document<"u"?document.currentScript:null;function O(e){return e&&typeof e=="object"&&"default"in e?e.default:e}f(O,"_interopDefaultCompat");const ue=O(nt),S=O(lt),de=O(ct),me=O(pt),kt=O(ut),Et=O(dt),fe=O(mt),_t=O(ht),Ot=O(bt),Dt=O(jt),St=O($t),Nt=[...T.DEFAULTS.extensions,".cjs"],N=[...Nt,".ts",".cts",".mts",".tsx",".jsx"],Pt={".aac":"file",".cjs":"js",".css":"file",".cts":"ts",".eot":"file",".flac":"file",".gif":"file",".jpeg":"file",".jpg":"file",".js":"js",".json":"json",".jsx":"jsx",".mjs":"js",".mp3":"file",".mp4":"file",".mts":"ts",".ogg":"file",".otf":"file",".png":"file",".svg":"file",".ts":"ts",".tsx":"tsx",".ttf":"file",".wav":"file",".webm":"file",".webp":"file",".woff":"file",".woff2":"file"},Z=/node_modules/;var Ft=Object.defineProperty,J=f((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"i$8");const K=/^#![^\n]*/,Q=J(async e=>{await V.chmod(e,493).catch(()=>{})},"makeExecutable"),Mt=J((e,t=`#!/usr/bin/env node
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(r,n,o){if(!n.isEntry||!n.facadeModuleId||r.startsWith("#")&&r[1]==="!")return null;if(e.includes(n.name)){const i=new S(r);return i.prepend(t),{code:i.toString(),map:o.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(r,n){for(const[o,i]of Object.entries(n))if(i.type==="chunk"&&K.test(i.code)&&r.dir){const s=g.resolve(r.dir,o);await Q(s)}}}),"shebangPlugin"),Rt=J(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(K,"")}}),"removeShebangPlugin"),It=J((e,t=`
|
|
3
|
-
`)=>{const r=K.exec(e);return r?r+t:""},"getShebang");var Ct=Object.defineProperty,Tt=f((e,t)=>Ct(e,"name",{value:t,configurable:!0}),"p$2");const ee=Tt((e,t)=>{let r={};if(e.pkg.name&&(r[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const o in n){if(o.startsWith("#"))continue;const i=n[o];typeof i=="string"&&(r[o]=g.join(e.rootDir,i))}}return r={...r,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(r,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(r,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(r),prefix:t}),r},"resolveAliases");var At=Object.defineProperty,qt=f((e,t)=>At(e,"name",{value:t,configurable:!0}),"o$4");const Lt=qt((e,t)=>{const r=de(t,{esmResolve:!0,interopDefault:!0});try{return r.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 Bt=Object.defineProperty,Wt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"r$6");const q=Wt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Jt=Object.defineProperty,zt=f((e,t)=>Jt(e,"name",{value:t,configurable:!0}),"u$8");const Ut=zt(async e=>{const t=await B.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:pe&&pe.src||new URL("shared/packem.e4bzQy8N.cjs",document.baseURI).href}),r=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ee(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const o=g.resolve(e.options.rootDir,e.options.outDir,n.name),i=g.normalize(Lt(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-g.extname(i).length)),p=await x.readFile(i),u=It(p);e.options.emitCJS&&await x.writeFile(`${o}.cjs`,u+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
|
|
4
|
-
`));let c=[];try{c=await B.resolveModuleExportNames(i,{extensions:N})}catch(a){q(e,`Cannot analyze ${i} for exports:${a}`);return}const l=c.includes("default")||c.length===0;await x.writeFile(`${o}.mjs`,u+[`import jiti from ${JSON.stringify(ce.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,l?`
|
|
5
|
-
export default _module;`:"",...c.filter(a=>a!=="default").map(a=>`export const ${a} = _module.${a};`)].join(`
|
|
6
|
-
`)),await x.writeFile(`${o}.d.cts`,[`export * from ${JSON.stringify(s)};`,l?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
7
|
-
`)),await x.writeFile(`${o}.d.mts`,[`export * from ${JSON.stringify(i)};`,l?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
8
|
-
`)),u&&(await Q(`${o}.cjs`),await Q(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ht=Object.defineProperty,Vt=f((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"a$a");const te=Vt((e,t)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),"arrayIncludes");var Xt=Object.defineProperty,Gt=f((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"e$2");const oe=Gt((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Yt=Object.defineProperty,Zt=f((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"m$4");const ge=Zt(({addDefaultProperty:e=!1,logger:t,type:r})=>({name:"packem:cjs-interop",renderChunk(n,o,i){if(o.type!=="chunk"||!o.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const p=new S(n);p.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),p.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&p.append(`
|
|
9
|
-
module.exports.default = `+s[2]+";");let u=p.toString();return u=u.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:u,map:p.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(o.fileName)){if(r!=="commonjs"&&o.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(n);if(s===null||s.length<2)return null;const p=s[1].split(", "),u=[];let c;for(const a of p)if(!a.includes("type"))if(a.includes("as")){const[m,$]=a.split(" as ");if($==="default"&&(c=m,!e))continue;u.push($+": typeof "+m+";")}else u.push(a+": typeof "+a+";");const l=new S(n);return l.replace(" "+c+" as default,",""),l.append(`
|
|
10
|
-
|
|
11
|
-
declare const defaultExport: {
|
|
12
|
-
`+(u.length>0?" ":"")+u.join(`
|
|
13
|
-
`)+`
|
|
14
|
-
} & typeof `+c+`;
|
|
15
|
-
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:l.toString(),map:l.generateMap({hires:!0})}}return null}}),"cjsInterop");var Kt=Object.defineProperty,Qt=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"u$7");const eo=Qt((e,t)=>{const r=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const i=await Promise.all(o.flatMap(s=>Array.isArray(s.src)?s.src.map(p=>({...s,src:p})):s).map(async s=>await vt.glob(s.src,{ignore:s.exclude}).then(p=>({dest:s.dest??"",parent:Ot(s.src),src:p}))));for(const s of i)for(const p of s.src){let u;r.has(p)?u=r.get(p):(u={copied:[],dest:[],timestamp:0},r.set(p,u));const c=n.flatten?g.normalize(s.dest):g.join(s.dest,g.relative(s.parent,g.dirname(p)));u.dest.includes(c)||u.dest.push(c),this.addWatchFile(p)}t.info({message:"Copying files...",prefix:"copy"}),await Promise.all([...r].map(async([s,p])=>{let u;try{const c=await V.stat(s);if(!c.isFile())return;const l=c.mtime.getTime();l>p.timestamp&&(p.timestamp=l,p.copied=[]),u=await x.readFile(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"copy"});return}for(const c of p.dest){if(n.copyOnce&&p.copied.includes(c))continue;const l=g.basename(s),a=g.join(c,l);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:a,source:u,type:"asset"}),t.debug({message:`copied ${s} → ${a}`,prefix:"copy"}),p.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${s} → ${a}`,prefix:"copy"})}}}))},name:"packem:copy"}},"copyPlugin");var to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"n$8");const he="export default ",ye=oo(e=>{const t=Dt(e);return{...t,name:"packem:json",transform(r,n){const o=t.transform?.call(this,r,n);return o&&typeof o!="string"&&"code"in o&&o.code?.startsWith(he)&&(o.code=o.code.replace(he,"module.exports = ")),o}}},"JSONPlugin");class ro{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,r,n,o){t&&r&&(n!=null?t[r][n]=o:t[r]=o)}remove(t,r,n){t&&r&&(n!=null?t[r].splice(n,1):delete t[r])}}class no extends ro{static{f(this,"SyncWalker")}constructor(t,r){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(n=>this.replacement=n,"replace")},this.enter=t,this.leave=r}visit(t,r,n,o){if(t){if(this.enter){const s=this.should_skip,p=this.should_remove,u=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,r,n,o),this.replacement&&(t=this.replacement,this.replace(r,n,o,t)),this.should_remove&&this.remove(r,n,o);const c=this.should_skip,l=this.should_remove;if(this.should_skip=s,this.should_remove=p,this.replacement=u,c)return t;if(l)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const p=s;for(let u=0;u<p.length;u+=1){const c=p[u];ve(c)&&(this.visit(c,t,i,u)||u--)}}else ve(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,p=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,r,n,o),this.replacement&&(t=this.replacement,this.replace(r,n,o,t)),this.should_remove&&this.remove(r,n,o);const u=this.should_remove;if(this.replacement=s,this.should_remove=p,u)return null}}return t}}function ve(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(ve,"isNode");function be(e,{enter:t,leave:r}){return new no(t,r).visit(e,null)}f(be,"walk");var so=Object.defineProperty,io=f((e,t)=>so(e,"name",{value:t,configurable:!0}),"u$6");const ao=io(({attributes:e,logger:t})=>{const r=A.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,o){if(!r(o))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${o}" and remove the jsx attribute.`}),t.warn(u),null}let s=!1;const p=new S(n);return be(i,{enter(u){if(u.type==="CallExpression"&&u.callee.type==="Identifier"&&u.callee.name==="jsx"){const c=u.arguments.filter(l=>l.type==="ObjectExpression"&&Array.isArray(l.properties));for(const l of c)for(const a of l.properties)a.type==="Property"&&a.key.type==="Literal"&&a.value.type==="Literal"&&e.includes(a.key.value)&&(p.overwrite(a.start-2,a.end,""),s=!0)}}}),s?{code:p.toString(),map:p.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var lo=Object.defineProperty,re=f((e,t)=>lo(e,"name",{value:t,configurable:!0}),"p$1");const co=re(e=>{const t=[],r=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):r.push(n)}),[...r.sort(),...t.sort()]},"sortLicenses"),po=re((e,t,r)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
|
|
17
|
-
${r}
|
|
18
|
-
$2`)},"replaceContentWithin"),je=re(({licenseFilePath:e,licenseTemplate:t,logger:r,marker:n,mode:o,packageName:i})=>St({thirdParty(s){const p=new Set,u=s.sort(({name:l},{name:a})=>l>a?1:a>l?-1:0).map(({author:l,contributors:a,license:m,licenseText:$,maintainers:w,name:_,repository:d})=>{let y=`## ${_}
|
|
19
|
-
`;m&&(y+=`License: ${m}
|
|
20
|
-
`);const v=new Set;for(const b of[l,...w,...a]){const j=typeof b=="string"?b:b?.name;j&&v.add(j)}return v.size>0&&(y+=`By: ${[...v].join(", ")}
|
|
21
|
-
`),d&&(y+=`Repository: ${typeof d=="string"?d:d.url}
|
|
22
|
-
`),$&&(y+=`
|
|
23
|
-
`+$.trim().replaceAll(/(\r\n|\r)/g,`
|
|
24
|
-
`).split(`
|
|
25
|
-
`).map(b=>`> ${b}`).join(`
|
|
26
|
-
`)+`
|
|
27
|
-
`),m&&p.add(m),y}).join(`
|
|
28
|
-
---------------------------------------
|
|
29
|
-
|
|
30
|
-
`),c=t(co(p),u,i);try{const l=x.readFileSync(e),a=po(l,n,c);if(!a){r.error(`Could not find the license marker: <!-- ${n} --> in ${e}`);return}l!==a&&(x.writeFileSync(e,a),r.info({message:`${e} updated.`,prefix:`license:${o}`}))}catch(l){r.error(l)}}}),"license");var uo=Object.defineProperty,mo=f((e,t)=>uo(e,"name",{value:t,configurable:!0}),"i$5");const fo=mo(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const o=this.getModuleInfo(n);if(o!=null&&!o.isExternal)for(const i of o.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const r=g.resolve(e.outDir,"graph.json");x.writeJsonSync(r,t)},name:"packem:metafile"}),"metafilePlugin");var go=Object.defineProperty,ho=f((e,t)=>go(e,"name",{value:t,configurable:!0}),"c$4");const yo=/\.(?:m|c)?(?:j|t)sx?$/,vo=/^use \w+$/,bo=ho(e=>{const t={},r={};return{name:"packem:preserve-directives",onLog(n,o){return o.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,o,{sourcemap:i}){const s=o.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,l)=>(l&&l.forEach(a=>{c.add(a)}),c),new Set),p=new S(n);s.size>0&&(e.debug({message:`directives for chunk "${o.fileName}" are preserved.`,prefix:"preserve-directives"}),p.prepend(`${[...s].map(c=>`'${c}';`).join(`
|
|
31
|
-
`)}
|
|
32
|
-
`));let u=null;return o.facadeModuleId&&typeof r[o.facadeModuleId]=="string"&&(u=r[o.facadeModuleId]),u&&(e.debug({message:`shebang for chunk "${o.fileName}" is preserved.`,prefix:"preserve-directives"}),p.prepend(`${u}
|
|
33
|
-
`)),s.size===0&&u===null?null:{code:p.toString(),map:i?p.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,o){const i=g.extname(o);if(!yo.test(i))return null;let s=!1;const p=new S(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let l=2,a=n.length;l<a;l++){const m=n.codePointAt(l);if(m===10||m===13||m===8232||m===8233){c=l;break}}c&&(r[o]=n.slice(0,c),p.remove(0,c+1),s=!0,e.debug({message:`shebang for module "${o}" is preserved.`,prefix:"preserve-directives"}))}let u=null;try{u=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${o}" and extract the directives.`}),e.warn(c),null}if(u.type!=="Program")return null;for(const c of u.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let l=null;"directive"in c?l=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&vo.test(c.expression.value)&&(l=c.expression.value),l!=="use strict"&&l&&(t[o]||=new Set,t[o].add(l),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(p.remove(c.start,c.end),s=!0),e.debug({message:`directive "${l}" for module "${o}" is preserved.`,prefix:"preserve-directives"}))}return s?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[o]??[]],shebang:r[o]??null}}}:null},order:"post"}}},"preserveDirectives");var jo=Object.defineProperty,$o=f((e,t)=>jo(e,"name",{value:t,configurable:!0}),"r$4");const wo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},xo=$o((e={})=>{e={...e,...wo};const t=A.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(r,n){return t(n)?{code:`export default ${JSON.stringify(r)}`,map:null}:null}}},"rawPlugin");var ko=Object.defineProperty,Eo=f((e,t)=>ko(e,"name",{value:t,configurable:!0}),"l$3");const ne="\0__file_url__",$e=Eo(()=>({async load(e){if(e.startsWith(ne)){const t=ce.fileURLToPath(e.slice(ne.length));return await x.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${ne}${e}`}}),"resolveFileUrl");var _o=Object.defineProperty,we=f((e,t)=>_o(e,"name",{value:t,configurable:!0}),"m$2");const Oo=/__filename|__dirname|require\(|require\.resolve\(/,xe=`
|
|
34
|
-
// -- pack CommonJS Shims --
|
|
35
|
-
import __cjs_url__ from "node:url";
|
|
36
|
-
import __cjs_path__ from "node:path";
|
|
37
|
-
import __cjs_mod__ from "node:module";
|
|
38
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,ke=`
|
|
42
|
-
// -- pack CommonJS Shims Node 20.11 --
|
|
43
|
-
import __cjs_mod__ from "node:module";
|
|
44
|
-
const __filename = import.meta.filename;
|
|
45
|
-
const __dirname = import.meta.dirname;
|
|
46
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
-
`,Do=we((e,t)=>{if(e.includes(xe)||e.includes(ke)||!Oo.test(e))return null;const r=B.findStaticImports(e).pop(),n=r?r.end:0,o=new S(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),So=we(e=>({name:"packem:cjs",renderChunk(t,r,n){if(n.format==="es"){let o=xe;if(e.engines?.node){const i=le.minVersion(e.engines.node);i&&i.major>=20&&i.minor>=11&&(o=ke)}return Do(t,o)}return null}}),"cjsPlugin");var No=Object.defineProperty,M=f((e,t)=>No(e,"name",{value:t,configurable:!0}),"s$a");const Po=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Fo=/MIT License|MIT license|BSD license/,Mo=/\n{2,}/g,Ro=/\b(\w+)\$\d+\b/g,Io=/[-/\\^$*+?.()|[\]{}]/g,Co=M(e=>e.replaceAll(Io,"\\$&"),"escapeRegex"),To=M(e=>[...new Set(e)],"unique"),Ao=M(e=>e.replaceAll(Po,t=>Fo.test(t)?"":t).replaceAll(Mo,`
|
|
48
|
-
|
|
49
|
-
`),"cleanUnnecessaryComments"),Ee=new Map;function _e(e,t,{identifierReplacements:r},n){const o=B.findStaticImports(e);for(const s in r){const p=o.find(c=>c.specifier===s&&c.imports.includes("{"));if(!p){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const u=r[s];for(const c in u){p.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${s}" for replacement`),E.exit(1));const l=u[c],a=Co(c);l.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${a},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${a}\\b`,"g"),l)}}const i=To(Array.from(e.matchAll(Ro),s=>s[0]));if(i.length>0){const s=i.map(u=>`
|
|
50
|
-
- ${u}`).join(""),p=t.fileName.replace(/\.[^/.]+$/,"");Ee.has(p)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
|
|
51
|
-
|
|
52
|
-
To replace these, add them to the "patchTypes -> identifierReplacements" option in your packem config.`,prefix:"patch-types"}),Ee.set(p,!0)}return e}f(_e,"v$2"),M(_e,"replaceConfusingTypeNames");function Oe(e,t){if(t.leadingComments?.some(r=>r.type==="CommentBlock"&&r.value.includes("@internal"))){const r=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,r),!0}return!1}f(Oe,"N$1"),M(Oe,"removeInternal");function De(e,t){if(e.includes("@internal")){const r=new S(e),n=wt.parse(e,{plugins:["typescript"],sourceType:"module"});be(n,{enter(o){Oe(r,o)&&this.skip()}}),e=r.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),E.exit(1))}return e}f(De,"S$1"),M(De,"stripInternalTypes");const qo=M((e,t)=>({name:"packem:patch-types",renderChunk(r,n){return r=_e.call(this,r,n,e,t),r=De.call(this,r,n),r=Ao(r),r},resolveId(r){return r.startsWith("types/")?{external:!0,id:"../../"+(r.endsWith(".js")?r:r+".js")}:null}}),"patchTypescriptTypes");var Lo=Object.defineProperty,Se=f((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"u$3");const Ne=Se((e,t=!0)=>{if(!e)return null;const{config:r,path:n}=e;if(!r.compilerOptions)return null;const{baseUrl:o,paths:i}=r.compilerOptions;if(!o)return null;const s=g.resolve(g.dirname(n),o),p=[];if(i)for(const[u,c]of Object.entries(i)){const l=new RegExp(`^${[...u].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let a=0;for(const m of c){const $=[...A.normalizePath(g.resolve(s,m))].map(w=>w==="*"?`$${++a}`:w==="$"?"$$":w).join("");p.push({find:l,replacement:$})}}return t&&p.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...A.normalizePath(s)].map(u=>u==="$"?"$$":u).join("")}/$1`}),p},"getConfigAlias"),Pe=Se((e,t)=>{const r=Ne(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,o,i){if(!r||n.includes("\0"))return null;for(const{find:s,replacement:p}of r)if(s.test(n)){const u=n.replace(s,p),c=await this.resolve(u,o,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Bo=Object.defineProperty,Fe=f((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"u$2");const Wo=Fe((e,t)=>{if(!t)return null;const{config:r,path:n}=t;if(!r.compilerOptions)return null;const{rootDirs:o}=r.compilerOptions;if(!o)return null;const i=[];for(const s of o){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(g.resolve(e,s))}return i},"getRootDirectories"),Me=Fe((e,t,r)=>{const n=Wo(e,r);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(o,i,s){if(n===null||n.length===0)return null;if(o.startsWith("."))for(const p of n){const u=g.join(p,o),c=await this.resolve(u,i,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${o} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var Jo=Object.defineProperty,zo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"r$3");const Re=zo(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,r,n){return e.test(t)&&r?await this.resolve(t.replace(/js(x?)$/,"ts$1"),r,n):null}}},"resolveTypescriptMjsCts");var Uo=Object.defineProperty,Ho=f((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"s$9");const Vo=Ho(e=>{const t=g.basename(e).split(".");if(t.length>=2){const[r,n]=t.slice(-2),o=t[0],i=/^(\w+)-runtime$/.exec(r)?.[1];if(N.includes(n)&&i&&i.length>0)return o+"-"+i}},"getCustomModuleLayer");var Xo=Object.defineProperty,Go=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"i$2");const se=Go(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Yo=Object.defineProperty,Ie=f((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"c$2");const Ce=Ie((e,t)=>{const r=new Map;return Ie(function(n,o){const i=o.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,p=i.meta,u=se(p);if(!s){const c=r.get(n);if(c)return c;const l=Vo(n);if(l)return r.set(n,l),l}if(s){const c=o.getModuleIds();for(const l of c)o.getModuleInfo(l)&&se(p)===u&&(e.has(l)||e.set(l,new Set),e.get(l).add([n,u]))}if(u&&!s&&e.has(n)){const c=[...e.get(n)];if(c.some(([a])=>{if(console.log(a),t.some(m=>m.path===a)){const m=o.getModuleInfo(a);return se(m?m.meta:{})===u}return!1}))return;if(c.every(([,a])=>a===u))return r.has(n)?r.get(n):void 0;const l=`${g.basename(n,g.extname(n))}-${u}`;return r.set(n,l),l}},"splitChunks")},"createSplitChunks");var Zo=Object.defineProperty,Ko=f((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"n$6");const P=Ko((e,t,r)=>t.isDynamicEntry?`chunks/[name].${r}`:`shared/${e.options.name}.[hash].${r}`,"getChunkFilename");var Qo=Object.defineProperty,er=f((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"s$7");const tr=process.platform==="win32",Te=er((e,t)=>{const r=tr?"\\":"/";return e.name?.includes("node_modules"+r+".pnpm")?(e.name.replace("node_modules"+r+".pnpm","external")+"."+t).replace("node_modules"+r,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var or=Object.defineProperty,k=f((e,t)=>or(e,"name",{value:t,configurable:!0}),"e$1");const rr=k(async e=>(await import("../chunks/index.cjs").then(t=>t.default))(e),"lazyImportSwc"),nr=k(async e=>(await import("../chunks/index2.cjs").then(t=>t.default))(e),"lazyImportEsbuild"),sr=k(async e=>(await import("../chunks/sucrase.cjs").then(t=>t.sucrasePlugin))(e),"lazyImportSucrase"),Ae=k((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${h.cyan(g.relative(g.resolve(),e.id))}"
|
|
53
|
-
Is the module installed? Note:
|
|
54
|
-
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
55
|
-
↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),qe=new Map,Le=k((e,t)=>{const r=k(o=>{for(const[i,s]of Object.entries(t))if(o.startsWith(i))return o.replace(i,s)},"findAlias"),n=Ne(e.tsconfig,!1);return{external(o){const i=r(o);i&&(o=i);const s=oe(o),p=te(e.options.externals,s)||te(e.options.externals,o);if(p)return!0;if(o.startsWith(".")||g.isAbsolute(o)||/src[/\\]/.test(o)||e.pkg.name&&o.startsWith(e.pkg.name))return!1;if(n){for(const{find:u}of n)if(u.test(o))return e.logger.debug(`Resolved alias ${o} to ${u.source}`),!1}return!p&&qe.has(o)&&e.logger.info('Inlined implicit external "'+h.cyan(o)+'". If this is incorrect, add it to the "externals" option.'),qe.set(o,!0),p},input:Object.fromEntries(e.options.entries.map(o=>[o.name,g.resolve(e.options.rootDir,o.input)])),onwarn(o,i){Ae(o,e)||o.code||i(o)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Be=k(async e=>{const t=ee(e,"build");return{...Le(e,t),output:[e.options.emitCJS&&{chunkFileNames:k(r=>P(e,r,"cjs"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:k(r=>Te(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{constBindings:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:k(r=>P(e,r,"mjs"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:k(r=>Te(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{constBindings:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ce(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[$e(),Re(),e.tsconfig&&Me(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Pe(e.tsconfig,e.logger),e.options.rollup.replace&&fe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&me({customResolver:T.nodeResolve({extensions:N,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&T.nodeResolve({extensions:N,...e.options.rollup.resolve}),e.options.rollup.polyfillNode&&_t({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ye({...e.options.rollup.json}),bo(e.logger),Mt(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&ft.wasm(e.options.rollup.wsam),e.options.rollup.esbuild&&e.options.transformer==="esbuild"&&await nr({sourceMap:e.options.sourcemap,...e.options.rollup.esbuild,logger:e.logger}),e.options.rollup.sucrase&&e.options.transformer==="sucrase"&&await sr(e.options.rollup.sucrase),e.options.rollup.swc&&e.options.transformer==="swc"&&await rr({...e.options.rollup.swc,jsc:{...E.env.NODE_ENV==="production"?{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:e.options.sourcemap}}:{},...e.options.rollup.swc.jsc},sourceMaps:e.options.sourcemap}),e.options.cjsInterop&&e.options.emitCJS&&ge({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Et(),e.options.rollup.commonjs&&kt({extensions:N,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&So(e.pkg),e.options.rollup.raw&&xo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&ao({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&fo({outDir:g.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&eo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.template=="function"&&je({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.template,logger:e.logger,marker:e.options.rollup.license.marker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&yt.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),We=k(e=>{const t=ee(e,"types"),r={load(o){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(o)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;return delete n?.lib,{...Le(e,t),onwarn(o,i){Ae(o,e)||o.code!=="EMPTY_BUNDLE"&&i(o)},output:[e.options.emitCJS&&{chunkFileNames:k(o=>P(e,o,"d.cts"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:k(o=>P(e,o,"d.mts"),"chunkFileNames"),dir:g.resolve(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:k(o=>P(e,o,"d.ts"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[$e(),Re(),e.options.rollup.json&&ye({...e.options.rollup.json}),r,e.tsconfig&&Me(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Pe(e.tsconfig,e.logger),e.options.rollup.replace&&fe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&me({customResolver:T.nodeResolve({extensions:N,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&T.nodeResolve({extensions:N,...e.options.rollup.resolve}),gt.dts({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}),e.options.cjsInterop&&e.options.emitCJS&&ge({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&qo(e.options.rollup.patchTypes,e.logger),Rt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&je({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.marker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var ir=Object.defineProperty,I=f((e,t)=>ir(e,"name",{value:t,configurable:!0}),"p");const Je=I((e,t,r)=>{const n="watcher:"+t;e.on("change",(o,{event:i})=>{r.info({message:`${h.cyan(g.relative(".",o))} was ${i}d`,prefix:n})}),e.on("restart",()=>{r.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",o=>{o.code==="END"&&r.success({message:"Rebuild "+t+" finished",prefix:n}),o.code==="ERROR"&&r.error({context:[o.error],message:"Rebuild "+t+" failed: "+o.error.message,prefix:n})})},"watchHandler"),ar=I(async e=>{const t=await Be(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=W.watch(t);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(t.input)?t.input:typeof t.input=="string"?[t.input]:Object.keys(t.input??{})];let o="Starting watchers for entries:";for(const i of n)o+=h.gray(`
|
|
56
|
-
└─ ${g.relative(process.cwd(),i)}`);if(e.logger.info(o),Je(r,"bundle",e.logger),e.options.declaration){const i=We(e);await e.hooks.callHook("rollup:dts:options",e,i);const s=W.watch(i);await e.hooks.callHook("rollup:watch",e,s),Je(s,"types",e.logger)}},"watch"),lr=I(async e=>{const t=await Be(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=await W.rollup(t);await e.hooks.callHook("rollup:build",e,r);const n=t.output,o=new Map;for(const i of n){const{output:s}=await r.write(i),p=new Set,u=s.filter(l=>l.type==="chunk");for(const l of u){p.add(l.fileName);for(const a of l.imports)e.usedImports.add(a);l.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(l.code,"utf8"),chunks:l.imports.filter(a=>u.find(m=>m.fileName===a)),exports:l.exports,modules:Object.entries(l.modules).map(([a,m])=>({bytes:m.renderedLength,id:a})),path:l.fileName,type:"entry"})}const c=s.filter(l=>l.type==="asset");for(const l of c)o.has(l.fileName)||o.set(l.fileName,{bytes:Buffer.byteLength(l.source,"utf8"),path:l.fileName,type:"asset"});for(const l of p)e.usedImports.delete(l)}if(e.buildEntries.push(...o.values()),e.options.declaration){const i=We(e);if(await e.hooks.callHook("rollup:dts:options",e,i),Object.keys(i.input).length===0)return;const s=await W.rollup(i);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:I(p=>P(e,p,"d.cts"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await s.write({chunkFileNames:I(p=>P(e,p,"d.mts"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration===!0&&await s.write({chunkFileNames:I(p=>P(e,p,"d.ts"),"chunkFileNames"),dir:g.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"})}await e.hooks.callHook("rollup:dts:done",e)},"build");var cr=Object.defineProperty,pr=f((e,t)=>cr(e,"name",{value:t,configurable:!0}),"a$3");const ur=pr(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var dr=Object.defineProperty,mr=f((e,t)=>dr(e,"name",{value:t,configurable:!0}),"i$1");const ze=mr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var fr=Object.defineProperty,z=f((e,t)=>fr(e,"name",{value:t,configurable:!0}),"l$2");const gr=A.createFilter,hr=z((e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=z(()=>r,"hasSideEffects");else if(Array.isArray(r))if(r.length<=0)n=z(()=>!1,"hasSideEffects");else{const o=r.map(i=>i.includes("/")?i:`**/${i}`);n=gr(o,null,{resolve:e})}else n=z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var yr=Object.defineProperty,vr=f((e,t)=>yr(e,"name",{value:t,configurable:!0}),"t$3");const br=vr(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var jr=Object.defineProperty,Ue=f((e,t)=>jr(e,"name",{value:t,configurable:!0}),"t$2");const ie=Ue(e=>{if(e.endsWith(".d.ts")||e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"cjs"},"inferExportTypeFromFileName"),He=Ue((e,t,r,n)=>{if(r){const s=ie(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[o,...i]=t;return He(o,i,r,n)},"inferExportType");var $r=Object.defineProperty,wr=f((e,t)=>$r(e,"name",{value:t,configurable:!0}),"s$4");const ae=wr((e,t,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ie(e),o=t==="module"?"esm":"cjs";if(n&&n!==o)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:n??o}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,o])=>typeof o=="string"?{file:o,type:He(n,r,o,t)}:ae(o,t,[...r,n]))},"extractExportFilenames");var xr=Object.defineProperty,kr=f((e,t)=>xr(e,"name",{value:t,configurable:!0}),"e");const Er=kr(e=>{const t=g.normalize(e).split("/");return t.map((r,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var _r=Object.defineProperty,Or=f((e,t)=>_r(e,"name",{value:t,configurable:!0}),"E");const Dr=Or((e,t,r=".")=>{const n=[];t.sort((l,a)=>l.split("/").length-a.split("/").length);const o=ae(e.exports,e.type||"commonjs");if(e.bin){const l=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const a of l)o.push({file:a,isExecutable:!0})}e.main&&o.push({file:e.main,type:ie(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&o.push({file:e.module,type:"esm"}),(e.types||e.typings)&&o.push({file:e.types||e.typings});const i=e.type==="module";for(const l of o.filter(a=>!a.type)){const a=l.file.endsWith(".js");i&&a||l.file.endsWith(".mjs")?l.type="esm":(!i&&a||l.file.endsWith(".cjs"))&&(l.type="cjs")}let s=!1,p=!1,u=!1;const c=[];for(const l of o){const a=l.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),m=a.endsWith("/");if(m&&["./","/"].includes(a))continue;const $=Er(a).reduce((_,d)=>{if(_)return _;const y=new RegExp(`(?<=/|$)${d}${m?"":"\\.\\w+"}$`);return t.find(v=>y.test(v))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!$){Y.existsSync(g.resolve(r,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}l.type==="cjs"&&(s=!0),l.type==="esm"&&(p=!0);const w=c.find(_=>_.input===$)??c[c.push({input:$})-1];/\.d\.(?:m|c)?ts$/.test(l.file)&&(u=!0),m&&(w.outDir=a),l.isExecutable&&(w.isExecutable=!0)}return{cjs:s,dts:u,entries:c,esm:p,warnings:n}},"inferEntries");var Sr=Object.defineProperty,Nr=f((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"o$1");const Pr=Nr(e=>{const{publishConfig:t}=e;return t&&(t.bin&&(typeof t.bin=="object"||typeof t.bin=="string")&&(e.bin=t.bin),t.type&&typeof t.type=="string"&&t.type!==""&&(e.type=t.type),t.main&&typeof t.main=="string"&&t.main!==""&&(e.main=t.main),t.module&&typeof t.module=="string"&&t.module!==""&&(e.module=t.module),t.types&&typeof t.types=="string"&&t.types!==""?e.types=t.types:t.typings&&typeof t.typings=="string"&&t.typings!==""&&(e.typings=t.typings),t.exports&&typeof t.exports=="object"&&(e.exports=t.exports)),e},"overwriteWithPublishConfig");var Fr=Object.defineProperty,Mr=f((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"n$3");const Rr={hooks:{"build:prepare":Mr(function(e){if(!e.pkg||e.options.entries.length>0)return;const t=g.join(e.options.rootDir,"src");if(!Y.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=x.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(r.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=Pr(n));const o=Dr(n,r,e.options.rootDir);for(const i of o.warnings)q(e,i);if(e.options.entries.push(...o.entries),o.cjs&&(e.options.emitCJS=!0),o.esm&&(e.options.emitESM=!0),o.dts&&(e.options.declaration=o.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h.cyan(e.options.entries.map(i=>h.bold(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),h.gray([o.esm&&"esm",o.cjs&&"cjs",o.dts&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Ir=Object.defineProperty,Cr=f((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"n$2");const Ve=Cr((e,t,r)=>{const n=de(t,{esmResolve:!0,interopDefault:!0});try{return n(e)}catch(o){if(o.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:o});return r}},"tryRequire");var Tr=Object.defineProperty,Ar=f((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"t");const qr=Ar((e,t)=>(e==="auto"?e=Rr:typeof e=="string"&&(e=Ve(e,t,{})),typeof e=="function"&&(e=e()),e),"resolvePreset");var Lr=Object.defineProperty,Br=f((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"o");const Wr=Br(e=>{const t=new Set,r=new Set(Object.keys(e.pkg.dependencies||{})),n=new Set;for(const o of e.usedImports)r.delete(o),t.add(o);if(Array.isArray(e.options.dependencies))for(const o of e.options.dependencies)r.delete(o);for(const o of t)!te(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(oe(o))&&!e.options.peerDependencies.includes(oe(o))&&n.add(o);r.size>0&&q(e,`Potential unused dependencies found: ${[...r].map(o=>h.cyan(o)).join(", ")}`),n.size>0&&q(e,`Potential implicit dependencies found: ${[...n].map(o=>h.cyan(o)).join(", ")}`)},"validateDependencies");var Jr=Object.defineProperty,Xe=f((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"i");const zr=Xe((e,t)=>xt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Ur=Xe((e,t)=>{const r=e.toLowerCase();return t.filter(n=>zr(n.toLowerCase(),r))},"findAlternatives");var Hr=Object.defineProperty,Ge=f((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"n");const Vr=Ge((e,t)=>{if(!e)return;const r=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin||{}),e.main,e.module,e.types,e.typings,...ae(e.exports,e.type??"commonjs").map(o=>o.file)].map(o=>o&&g.resolve(t.rootDir,o.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const o of r)o&&!o.includes("*")&&!Y.existsSync(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=Ge(p=>g.relative(t.rootDir,g.resolve(t.options.outDir,p)),"rPath"),i=t.buildEntries.filter(p=>!p.chunk).map(p=>o(p.path));let s="Potential missing or wrong package.json files:";for(const p of n){const u=Ur(p,i);s+=`
|
|
57
|
-
- `+h.cyan(p)+(u.length>0?h.grey` (did you mean ${u.map(c=>`"${c}"`).join(", ")}?)`:"")}q(t,s)}},"validatePackage");var Xr=Object.defineProperty,R=f((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"b");const Ye=R((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
58
|
-
`),e.logger.warn(`Build is done with some warnings:
|
|
59
|
-
|
|
60
|
-
${[...e.warnings].map(r=>`- ${r}`).join(`
|
|
61
|
-
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),E.exit(1)))},"logErrors"),Gr=R(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"),Ze=R(async(e,t,r,n,o,i,s,p)=>{const u=qr(o.preset??i.packem?.preset??n.preset??"auto",t);let c=`node${E.versions.node.split(".")[0]}`;if(i.engines?.node){const d=le.minVersion(i.engines.node);d&&(c=`node${d.major}`)}const l=Gr(s?.config.compilerOptions?.jsx),a=it.defu(o,i.packem,n,u,{alias:{},clean:!0,declaration:!1,dependencies:[],devDependencies:[],entries:[],externals:[...ue.builtinModules,...ue.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:s?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},emitCJS:!1,emitESM:!0,esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:l,jsxDev:s?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:s?.config.compilerOptions?.jsxFactory,jsxFragment:s?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:s?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minify:E.env.NODE_ENV==="production",minifyWhitespace:E.env.NODE_ENV==="production",sourcesContent:!1,target:s?.config.compilerOptions?.target,tsconfigRaw:s?.config},json:{preferConst:!0},license:{dtsTemplate:R((d,y,v)=>`
|
|
62
|
-
# Licenses of bundled types
|
|
63
|
-
The published ${v} artifact additionally contains code with the following licenses:
|
|
64
|
-
${d.join(", ")}
|
|
65
|
-
|
|
66
|
-
# Bundled types:
|
|
67
|
-
`+y,"dtsTemplate"),template:R((d,y,v)=>`
|
|
68
|
-
# Licenses of bundled dependencies
|
|
69
|
-
The published ${v} artifact additionally contains code with the following licenses:
|
|
70
|
-
${d.join(", ")}
|
|
71
|
-
|
|
72
|
-
# Bundled dependencies:
|
|
73
|
-
`+y,"template")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:Z,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:s?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:E.env.NODE_ENV==="production",...s?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(s.config.compilerOptions.jsx)?{jsxFragmentPragma:s.config.compilerOptions.jsxFragmentFactory,jsxImportSource:s.config.compilerOptions.jsxImportSource,jsxPragma:s.config.compilerOptions.jsxFactory,jsxRuntime:l,transforms:["typescript","jsx",...s.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...s?.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:s?.config.compilerOptions?.experimentalDecorators,dynamicImport:!0,syntax:s?"typescript":"ecmascript",[s?"tsx":"jsx"]:!0},target:s?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:s?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:!0,react:{development:E.env.NODE_ENV!=="production",pragma:s?.config.compilerOptions?.jsxFactory,pragmaFrag:s?.config.compilerOptions?.jsxFragmentFactory,runtime:l,throwIfNamespace:!0,useBuiltins:!0}}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:hr(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:Z}},rootDir:t,sourcemap:!1,stub:r==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},target:c,transformer:void 0});if(a.transformer!=="esbuild"&&a.transformer!=="swc"&&a.transformer!=="sucrase"){const d=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(d.has("esbuild"))e.info("Found "+h.cyan("esbuild")+" in your package.json."),a.transformer="esbuild";else if(d.has("@swc/core"))e.info("Found "+h.cyan("@swc/core")+" in your package.json."),a.transformer="swc";else if(d.has("sucrase"))e.info("Found "+h.cyan("sucrase")+" in your package.json."),a.transformer="sucrase";else throw new Error(a.transformer?`Unknown transformer ${JSON.stringify(a.transformer)}`:"Missing transformer name in options.")}if(a.emitESM===!1&&a.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(a.outDir=g.resolve(a.rootDir,a.outDir),x.ensureDirSync(a.outDir),a.transformer==="esbuild"&&a.rollup.esbuild){if(s?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(e.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(" ")),s.config.compilerOptions.target="es5",a.rollup.esbuild.target="es5"),a.rollup.esbuild.jsx==="preserve"){let d="Packem does not support 'preserve' jsx option. Please use 'transform' or 'automatic' instead.";throw s?.config.compilerOptions?.jsx&&(d="Packem does not support '"+s.config.compilerOptions.jsx+"' jsx option. Please change it to 'react' or 'react-jsx' or 'react-jsxdev' instead."),new Error(d)}if(a.rollup.esbuild.target){const d=ur(a.rollup.esbuild.target);d.some(y=>y.startsWith("node"))||(a.rollup.esbuild.target=[a.target,...d])}else a.rollup.esbuild.target=[a.target];s?.config.compilerOptions?.target==="es5"&&(a.rollup.esbuild.keepNames=!1,e.debug("Disabling keepNames because target is set to es5"))}e.info('Using "'+h.cyan(a.transformer)+'" as transformer.'),a.rollup.resolve&&a.rollup.resolve.preferBuiltins===!0&&(a.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),s?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
74
|
-
Because none of the third-party transpilers, 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.
|
|
75
|
-
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.`);const m={buildEntries:[],dependencyGraphMap:new Map,hooks:at.createHooks(),logger:e,mode:r,options:a,pkg:i,rootDir:t,tsconfig:s,usedImports:new Set,warnings:new Set};if(u.hooks&&m.hooks.addHooks(u.hooks),n.hooks&&m.hooks.addHooks(n.hooks),o.hooks&&m.hooks.addHooks(o.hooks),await m.hooks.callHook("build:prepare",m),a.declaration&&s===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");for(const d of m.options.entries){if(typeof d.name!="string"){let y=g.isAbsolute(d.input)?g.relative(t,d.input):g.normalize(d.input);y.startsWith("./")&&(y=y.slice(2)),d.name=br(y.replace(/^src\//,""))}if(!d.input)throw new Error(`Missing entry input: ${ze(d)}`);a.declaration!==void 0&&d.declaration===void 0&&(d.declaration=a.declaration),d.input=g.resolve(a.rootDir,d.input),d.outDir=g.resolve(a.rootDir,d.outDir??a.outDir)}a.dependencies=Object.keys(i.dependencies??{}),a.peerDependencies=Object.keys(i.peerDependencies??{}),a.devDependencies=Object.keys(i.devDependencies??{}),a.optionalDependencies=Object.keys(i.optionalDependencies??{}),a.externals.push(...a.dependencies,...a.peerDependencies,...a.optionalDependencies),await m.hooks.callHook("build:before",m);let $="Building";if(r==="watch"?$="Watching":r==="jit"&&($="Stubbing"),e.info(h.cyan(`${$} ${a.name}`)),e.debug(`${h.bold("Root dir:")} ${a.rootDir}
|
|
76
|
-
${h.bold("Entries:")}
|
|
77
|
-
${m.options.entries.map(d=>` ${ze(d)}`).join(`
|
|
78
|
-
`)}`),a.clean)for(const d of new Set(m.options.entries.map(y=>y.outDir).filter(Boolean).sort()))d!==a.rootDir&&(p.push(d),e.info(`Cleaning dist directory: \`./${g.relative(a.rootDir,d)}\``),await x.emptyDir(d));if(a.stub){await Ut(m),await m.hooks.callHook("build:done",m);return}if(r==="watch"){await ar(m),Ye(m,!1);return}await lr(m),e.success(h.green(`Build succeeded for ${a.name}`));for await(const d of x.walk(a.outDir)){let y=m.buildEntries.find(v=>g.join(m.options.outDir,v.path)===d.path);if(y||(y={chunk:!0,path:d.path},m.buildEntries.push(y)),!y.bytes){const v=await V.stat(g.resolve(a.outDir,d.path));y.bytes=v.size}}const w=R(d=>g.relative(m.rootDir,g.resolve(a.outDir,d)),"rPath");let _=!1;for(const d of m.buildEntries.filter(y=>!y.chunk)){let y=d.bytes??0;for(const b of d.chunks??[])y+=m.buildEntries.find(j=>j.path===b)?.bytes??0;let v=` ${h.bold(w(d.path))} (${["total size: "+h.cyan(F.formatBytes(y)),d.type!=="asset"&&d.bytes&&"chunk size: "+h.cyan(F.formatBytes(d.bytes))].filter(Boolean).join(", ")})`;if(v+=d.exports?.length?`
|
|
79
|
-
exports: `+h.gray(d.exports.join(", ")):"",d.chunks?.length&&(v+=`
|
|
80
|
-
${d.chunks.map(b=>{const j=m.buildEntries.find(D=>D.path===b)??{};return h.gray(" └─ "+w(b)+h.bold(j.bytes?" ("+F.formatBytes(j?.bytes)+")":""))}).join(`
|
|
81
|
-
`)}`),d.modules&&d.modules.length>0){const b=d.modules.filter(j=>j.id.includes("node_modules")).sort((j,D)=>(D.bytes||0)-(j.bytes||0)).map(j=>h.gray(" 📦 "+w(j.id)+h.bold(j.bytes?" ("+F.formatBytes(j.bytes)+")":""))).join(`
|
|
82
|
-
`);v+=b.length>0?`
|
|
83
|
-
inlined modules:
|
|
84
|
-
`+b:""}if(m.options.declaration&&d.type==="entry"){let b=d.path.replace(/\.js$/,".d.ts"),j="commonjs";d.path.endsWith(".cjs")?b=d.path.replace(/\.cjs$/,".d.cts"):d.path.endsWith(".mjs")&&(j="module",b=d.path.replace(/\.mjs$/,".d.mts"));const D=m.buildEntries.find(C=>C.path.endsWith(b));if(D){let C;(m.options.declaration===!0||m.options.declaration==="compatible")&&!b.includes(".d.ts")&&(b=b.replace(j==="commonjs"?".d.c":".d.m",".d."),C=m.buildEntries.find(L=>L.path.endsWith(b))),v+=C&&j===i.type?`
|
|
85
|
-
types:
|
|
86
|
-
`+[D,C].map(L=>h.gray(" └─ ")+h.bold(w(L.path))+" (total size: "+h.cyan(F.formatBytes(L.bytes??0))+")").join(`
|
|
87
|
-
`):`
|
|
88
|
-
types: `+h.bold(w(D.path))+" (total size: "+h.cyan(F.formatBytes(D.bytes??0))+")"}}_=!0,v+=`
|
|
89
|
-
|
|
90
|
-
`,e.raw(d.chunk?h.gray(v):v)}_&&e.raw("Σ Total dist size (byte size):",h.cyan(F.formatBytes(m.buildEntries.reduce((d,y)=>d+(y.bytes??0),0))),`
|
|
91
|
-
`),Wr(m),Vr(i,m),await m.hooks.callHook("build:done",m),Ye(m,_)},"build"),Yr=R(async(e,t,r={})=>{const{configPath:n,debug:o,tsconfigPath:i,...s}=r,p=[new G.MessageFormatterProcessor,new G.ErrorProcessor];o&&p.push(new G.CallerProcessor);const u=st.createPail({logLevel:o?"debug":"informational",processors:p,scope:"packem"});u.wrapAll(),e=g.resolve(E.cwd(),e);let c;if(i)await x.isAccessible(i)||(u.error("tsconfig.json not found at",i),E.exit(1)),c={config:X.readTsConfig(i),path:i},u.debug("Using tsconfig.json found at",i);else try{c=await X.findTSConfig(e),u.debug("Using "+g.basename(c.path)+" found at",c.path)}catch{u.info("No tsconfig.json or jsconfig.json found.")}try{const{packageJson:l,path:a}=await X.findPackageJson(e);u.debug("Using package.json found at",a);const m=Ve(n??"./packem.config",e,[]),$=(Array.isArray(m)?m:[m]).filter(Boolean);if($.length===0)await Ze(u,e,t,s,{},l,c,[]);else{const w=[];for(const _ of $)await Ze(u,e,t,s,_,l,c,w)}u.restoreAll(),E.exit(0)}catch(l){u.error("An error occurred while building",l),E.exit(1)}},"createBundler");exports.DEFAULT_EXTENSIONS=N,exports.DEFAULT_LOADERS=Pt,exports.EXCLUDE_REGEXP=Z,exports.ye=Yr;
|