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