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