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