@visulima/packem 1.0.0-alpha.32 → 1.0.0-alpha.34
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 +16 -0
- package/README.md +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/create-bundler.cjs +48 -48
- package/dist/create-bundler.d.cts +1 -1
- package/dist/create-bundler.d.mts +1 -1
- package/dist/create-bundler.d.ts +1 -1
- package/dist/create-bundler.mjs +47 -47
- package/dist/rollup/plugins/esbuild/index.cjs +1 -1
- package/dist/rollup/plugins/esbuild/index.mjs +1 -1
- package/dist/rollup/plugins/sucrase/index.cjs +1 -1
- package/dist/rollup/plugins/sucrase/index.mjs +1 -1
- package/dist/rollup/plugins/swc/index.cjs +1 -1
- package/dist/rollup/plugins/swc/index.mjs +1 -1
- package/dist/shared/{packem.Dy_OANKe.d.mts → packem.C3jV3VSZ.d.mts} +9 -1
- package/dist/shared/{packem.mQ9P5mkv.d.cts → packem.CAFlfc60.d.cts} +9 -1
- package/dist/shared/{packem.D8hh_gRz.d.ts → packem.DyKwVld7.d.ts} +9 -1
- package/dist/shared/packem.HRXF255z.mjs +9 -0
- package/dist/shared/packem.NVRVuzg1.cjs +1 -0
- package/package.json +12 -45
- package/dist/shared/packem.CKW9adaV.cjs +0 -1
- package/dist/shared/packem.CxExFSHU.mjs +0 -9
package/dist/create-bundler.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(
|
|
3
|
-
`)=>{const
|
|
4
|
-
`));let
|
|
5
|
-
export default _module;`:"",...
|
|
6
|
-
`)),await v.writeFile(`${
|
|
7
|
-
`)),await v.writeFile(`${
|
|
8
|
-
`)),
|
|
9
|
-
module.exports.default = `+a[2]+";");let
|
|
1
|
+
"use strict";var ot=Object.defineProperty;var f=(e,t)=>ot(e,"name",{value:t,configurable:!0});const J=require("node:fs/promises"),nt=require("node:module"),j=require("node:process"),g=require("@visulima/colorize"),v=require("@visulima/fs"),rt=require("@visulima/fs/error"),D=require("@visulima/humanizer"),G=require("@visulima/package"),st=require("@visulima/package/package-json"),it=require("@visulima/pail"),U=require("@visulima/pail/processor"),m=require("@visulima/path"),at=require("defu"),lt=require("hookable"),O=require("./shared/packem.NVRVuzg1.cjs"),be=require("node:url"),W=require("mlly"),ct=require("magic-string"),pt=require("jiti"),Z=require("node:fs"),B=require("rollup"),ut=require("@rollup/plugin-alias"),dt=require("@rollup/plugin-commonjs"),mt=require("@rollup/plugin-dynamic-import-vars"),$e=require("@rollup/plugin-node-resolve"),ft=require("@rollup/plugin-replace"),gt=require("@rollup/plugin-wasm"),ht=require("rollup-plugin-polyfill-node"),yt=require("rollup-plugin-visualizer"),je=require("semver"),vt=require("glob"),bt=require("glob-parent"),$t=require("@rollup/plugin-json"),T=require("@rollup/pluginutils"),jt=require("rollup-plugin-license"),wt=require("node:crypto"),kt=require("@babel/parser"),xt=require("fastest-levenshtein");var se=typeof document<"u"?document.currentScript:null;const x=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ie=x(nt),P=x(ct),we=x(pt),ke=x(ut),Et=x(dt),Ot=x(mt),xe=x(ft),St=x(ht),_t=x(bt),Dt=x($t),Nt=x(jt);var Pt=Object.defineProperty,z=f((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"i$b");const ee=/^#![^\n]*/,K=z(async e=>{await J.chmod(e,493).catch(()=>{})},"makeExecutable"),Ft=z((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 P(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"&&ee.test(s.code)&&o.dir){const a=m.resolve(o.dir,n);await K(a)}}}),"shebangPlugin"),Mt=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ee,"")}}),"removeShebangPlugin"),Ct=z((e,t=`
|
|
3
|
+
`)=>{const o=ee.exec(e);return o?o+t:""},"getShebang");var It=Object.defineProperty,Rt=f((e,t)=>It(e,"name",{value:t,configurable:!0}),"p$3");const te=Rt((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]=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(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 Tt=Object.defineProperty,At=f((e,t)=>Tt(e,"name",{value:t,configurable:!0}),"o$3");const qt=At((e,t)=>{const o=we(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 Lt=Object.defineProperty,Wt=f((e,t)=>Lt(e,"name",{value:t,configurable:!0}),"r$8");const A=Wt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Bt=Object.defineProperty,Jt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"u$7");const zt=Jt(async e=>{const t=await W.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.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 r of e.options.entries){const n=m.resolve(e.options.rootDir,e.options.outDir,r.name),s=m.normalize(qt(r.input,e.options.rootDir)||r.input),a=s.slice(0,Math.max(0,s.length-m.extname(s).length)),i=await v.readFile(s),l=Ct(i);e.options.emitCJS&&await v.writeFile(`${n}.cjs`,l+[`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(p){A(e,`Cannot analyze ${s} for exports:${p}`);return}const u=c.includes("default")||c.length===0;await v.writeFile(`${n}.mjs`,l+[`import jiti from ${JSON.stringify(be.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
|
|
5
|
+
export default _module;`:"",...c.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
|
|
6
|
+
`)),await v.writeFile(`${n}.d.cts`,[`export * from ${JSON.stringify(a)};`,u?`export { default } from ${JSON.stringify(a)};`:""].join(`
|
|
7
|
+
`)),await v.writeFile(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
8
|
+
`)),l&&(await K(`${n}.cjs`),await K(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ut=Object.defineProperty,Ht=f((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"r$7");const Ee=Ht((e,t)=>we(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Vt=Object.defineProperty,Oe=f((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"t$4");const oe=Oe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Se=Oe((e,t,o,r)=>{if(o){const a=oe(o);if(a)return a}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 Se(n,s,o,r)},"inferExportType");var Xt=Object.defineProperty,Gt=f((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"o$2");const ne=Gt((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=oe(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",subKey:n,type:Se(n,r,s,t)}:ne(s,t,o,[...r,n]))},"extractExportFilenames");var Kt=Object.defineProperty,_e=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"d$4");const ae=_e((e,t,o,r,n,s,a)=>{const i=e.find(l=>l.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.file.includes(".min.")&&(i.minify=!0),n.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(n.file)&&!a&&(i.declaration=a),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const l of O.RUNTIME_EXPORT_CONVENTIONS)if(n.file.includes(l)){i.runtime=l;break}n.key==="exports"&&n.subKey==="production"?i.environment="production":n.key==="exports"&&n.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),le=/(?:\.d\.[mc]?ts|\.\w+)$/,Yt=_e((e,t,o)=>{const r=[];t.sort((i,l)=>i.split("/").length-l.split("/").length);const n=ne(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const l of i)n.push({file:l,isExecutable:!0,key:"bin"})}e.main&&n.push({file:e.main,key:"main",type:oe(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&n.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of n.filter(l=>!l.type)){const l=i.file.endsWith(".js");s&&l||i.file.endsWith(".mjs")?i.type="esm":(!s&&l||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of n){const l=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace("./"+o.options.outDir,o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const y=[],h=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const b of t)h.test(b)&&y.push(b.replace(le,""));if(y.length===0){r.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const b of y)ae(a,b,c,l,i,e,o.options.declaration);continue}const p=new RegExp("(?<=/|$)"+u+(c?"":"\\.\\w+")),d=t.find(y=>p.test(y))?.replace(le,"");if(!d){Z.existsSync(m.resolve(o.options.rootDir,i.file))||r.push(`Could not find entrypoint for \`${i.file}\``);continue}ae(a,d,c,l,i,e,o.options.declaration)}return{entries:a,warnings:r}},"inferEntries");var Qt=Object.defineProperty,Zt=f((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"t$3");const eo=Zt((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 to=Object.defineProperty,oo=f((e,t)=>to(e,"name",{value:t,configurable:!0}),"n$8");const no={hooks:{"build:prepare":oo(function(e){if(e.options.entries.length>0)return;const t=m.join(e.options.rootDir,"src");if(!Z.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=v.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=eo(r,e.options.declaration));const n=Yt(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:",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 ro=Object.defineProperty,so=f((e,t)=>ro(e,"name",{value:t,configurable:!0}),"t$2");const io=so((e,t)=>(e==="auto"?e=no:typeof e=="string"&&(e=Ee(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var ao=Object.defineProperty,lo=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$a");const Y=lo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var co=Object.defineProperty,po=f((e,t)=>co(e,"name",{value:t,configurable:!0}),"a$9");const H=po(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var uo=Object.defineProperty,mo=f((e,t)=>uo(e,"name",{value:t,configurable:!0}),"e$1");const Q=mo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var fo=Object.defineProperty,De=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"s$a");const go=De((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=r.get(s);if(a!==void 0)return a;const i=e(...n);return r.set(s,i),i}},"memoize"),ho=De(e=>{const t=new Map;return o=>go(e,o,t)},"memoizeByKey");var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"m$5");const Ne=vo(({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 a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(a===null||a.length<3)return null;const i=new P(r);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
|
|
9
|
+
module.exports.default = `+a[2]+";");let l=i.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:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(r);if(a===null||a.length<2)return null;const i=a[1].split(", "),l=[];let c="";for(const p of i)if(!p.includes("type"))if(p.includes("as")){const[d,y]=p.split(" as ");if(y==="default"&&(c=d,!e))continue;l.push(y+": typeof "+d+";")}else l.push(p+": typeof "+p+";");const u=new P(r);return u.replace(" "+c+" as default,",""),u.append(`
|
|
10
10
|
|
|
11
11
|
declare const defaultExport: {
|
|
12
|
-
`+(
|
|
12
|
+
`+(l.length>0?" ":"")+l.join(`
|
|
13
13
|
`)+`
|
|
14
|
-
} & typeof `+
|
|
14
|
+
} & typeof `+c+`;
|
|
15
15
|
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+
|
|
17
|
-
${
|
|
18
|
-
$2`)},"replaceContentWithin"),
|
|
19
|
-
`;d&&(
|
|
20
|
-
`);const
|
|
21
|
-
`)
|
|
22
|
-
`),y&&(
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var bo=Object.defineProperty,$o=f((e,t)=>bo(e,"name",{value:t,configurable:!0}),"f$7");const jo=$o((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(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await vt.glob(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:_t(a.src),src:i}))));for(const a of s)for(const i of a.src){let l;o.has(i)?l=o.get(i):(l={copied:[],dest:[],timestamp:0},o.set(i,l));const c=r.flatten?m.normalize(a.dest):m.join(a.dest,m.relative(a.parent,m.dirname(i)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let l;try{const c=await J.stat(a);if(!c.isFile())return;const u=c.mtime.getTime();u>i.timestamp&&(i.timestamp=u,i.copied=[]),l=await v.readFile(a,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const c of i.dest){if(r.copyOnce&&i.copied.includes(c))continue;const u=m.basename(a),p=m.join(c,u);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${a} → ${p}`,prefix:"plugin:copy"}),i.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${a} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var wo=Object.defineProperty,ko=f((e,t)=>wo(e,"name",{value:t,configurable:!0}),"n$4");const ce="export default ",Pe=ko(e=>{const t=Dt(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(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class xo{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,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 Eo extends xo{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(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const a=this.should_skip,i=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,u=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=l,c)return t;if(u)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let l=0;l<i.length;l+=1){const c=i[l];pe(c)&&(this.visit(c,t,s,l)||l--)}}else pe(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=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=a,this.should_remove=i,l)return null}}return t}}function pe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(pe,"isNode");function Fe(e,{enter:t,leave:o}){return new Eo(t,o).visit(e,null)}f(Fe,"walk");var Oo=Object.defineProperty,So=f((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"u$5");const _o=So(({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(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 a=!1;const i=new P(r);return Fe(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(i.overwrite(p.start-2,p.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Do=Object.defineProperty,re=f((e,t)=>Do(e,"name",{value:t,configurable:!0}),"p$1");const No=re(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Po=re((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
|
|
17
|
+
${o}
|
|
18
|
+
$2`)},"replaceContentWithin"),Me=re(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Nt({thirdParty(a){const i=new Set,l=a.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:d,licenseText:y,maintainers:h,name:b,repository:E})=>{let F="## "+b+`
|
|
19
|
+
`;d&&(F+=`License: ${d}
|
|
20
|
+
`);const M=new Set;for(const S of[u,...h,...p]){const _=typeof S=="string"?S:S?.name;_&&M.add(_)}return M.size>0&&(F+=`By: ${[...M].join(", ")}
|
|
21
|
+
`),E&&(F+=`Repository: ${typeof E=="string"?E:E.url}
|
|
22
|
+
`),y&&(F+=`
|
|
23
23
|
`+y.trim().replaceAll(/(\r\n|\r)/g,`
|
|
24
24
|
`).split(`
|
|
25
|
-
`).map(
|
|
25
|
+
`).map(S=>`> ${S}`).join(`
|
|
26
26
|
`)+`
|
|
27
|
-
`),d&&i.add(d),
|
|
27
|
+
`),d&&i.add(d),F}).join(`
|
|
28
28
|
---------------------------------------
|
|
29
29
|
|
|
30
|
-
`);if(
|
|
30
|
+
`);if(l===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const c=t(No(i),l,s);try{const u=v.readFileSync(e),p=Po(u,r,c);if(!p){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}u!==p&&(v.writeFileSync(e,p),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(u){o.error(u)}}}),"license");var Fo=Object.defineProperty,Mo=f((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"i$7");const Co=Mo(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=m.resolve(e.rootDir,e.outDir,"graph.json");v.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var Io=Object.defineProperty,Ro=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"r$5");const C=Ro(e=>{const t=wt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var To=Object.defineProperty,Ce=f((e,t)=>To(e,"name",{value:t,configurable:!0}),"m$4");const R=Ce(e=>e.handler||e,"getHandler"),k=Ce((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=m.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=m.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 a=await R(e.resolveId).call(this,o,r,n);return t.set(s,a,e.name),a},async transform(o,r){if(!e.transform)return null;const n=m.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 Ao=Object.defineProperty,qo=f((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"c$4");const Lo=/\.(?:m|c)?(?:j|t)sx?$/,Wo=/^use \w+$/,Bo=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 a=n.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,u)=>(u&&u.forEach(p=>{c.add(p)}),c),new Set),i=new P(r);a.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(c=>`'${c}';`).join(`
|
|
31
31
|
`)}
|
|
32
|
-
`));let
|
|
33
|
-
`)),a.size===0&&
|
|
32
|
+
`));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"}),i.prepend(`${l}
|
|
33
|
+
`)),a.size===0&&l===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=m.extname(n);if(!Lo.test(s))return null;let a=!1;const i=new P(r);if(r.startsWith("#")&&r[1]==="!"){let c=0;for(let u=2,p=r.length;u<p;u++){const d=r.codePointAt(u);if(d===10||d===13||d===8232||d===8233){c=u;break}}c&&(o[n]=r.slice(0,c),i.remove(0,c+1),a=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(i.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 u=null;"directive"in c?u=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Wo.test(c.expression.value)&&(u=c.expression.value),u!=="use strict"&&u&&(t[n]||=new Set,t[n].add(u),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(i.remove(c.start,c.end),a=!0),e.debug({message:`directive "${u}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Jo=Object.defineProperty,zo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"r$4");const Uo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Ho=zo((e={})=>{e={...e,...Uo};const t=T.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 Vo=Object.defineProperty,Xo=f((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"l$2");const V="\0__file_url__",Ie=Xo(()=>({async load(e){if(e.startsWith(V)){const t=be.fileURLToPath(e.slice(V.length));return await v.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${V}${e}`}}),"resolveFileUrl");var Go=Object.defineProperty,Re=f((e,t)=>Go(e,"name",{value:t,configurable:!0}),"i$3");const Ko=/__filename|__dirname|require\(|require\.resolve\(/,Te=`
|
|
34
34
|
// -- pack CommonJS Shims --
|
|
35
35
|
import __cjs_url__ from "node:url";
|
|
36
36
|
import __cjs_path__ from "node:path";
|
|
@@ -38,56 +38,56 @@ import __cjs_mod__ from "node:module";
|
|
|
38
38
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
39
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
40
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,
|
|
41
|
+
`,Ae=`
|
|
42
42
|
// -- pack CommonJS Shims Node 20.11 --
|
|
43
43
|
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
|
+
`,Yo=Re((e,t)=>{if(j.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Te)||e.includes(Ae)||!Ko.test(e)))return null;const o=W.findStaticImports(e).pop(),r=o?o.end:0,n=new P(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Qo=Re(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Te;if(e.engines?.node){const s=je.minVersion(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Ae)}return Yo(t,n)}return null}}),"cjsPlugin");var Zo=Object.defineProperty,I=f((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"s$6");const en=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,tn=/MIT License|MIT license|BSD license/,on=/\n{2,}/g,nn=/\b(\w+)\$\d+\b/g,rn=/[-/\\^$*+?.()|[\]{}]/g,sn=I(e=>e.replaceAll(rn,"\\$&"),"escapeRegex"),an=I(e=>[...new Set(e)],"unique"),ln=I(e=>e.replaceAll(en,t=>tn.test(t)?"":t).replaceAll(on,`
|
|
48
48
|
|
|
49
|
-
`),"cleanUnnecessaryComments"),
|
|
50
|
-
- ${
|
|
49
|
+
`),"cleanUnnecessaryComments"),ue=new Map;function qe(e,t,{identifierReplacements:o},r){const n=W.findStaticImports(e);for(const a in o){const i=n.find(c=>c.specifier===a&&c.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const l=o[a];for(const c in l){i.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${a}" for replacement`),j.exit(1));const u=l[c],p=sn(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=an(Array.from(e.matchAll(nn),a=>a[0]));if(s.length>0){const a=s.map(l=>`
|
|
50
|
+
- ${l}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");ue.has(i)||r.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"}),
|
|
52
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ue.set(i,!0)}return e}f(qe,"v$1");I(qe,"replaceConfusingTypeNames");function Le(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(Le,"N");I(Le,"removeInternal");function We(e,t){if(e.includes("@internal")){const o=new P(e),r=kt.parse(e,{plugins:["typescript"],sourceType:"module"});Fe(r,{enter(n){Le(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),j.exit(1))}return e}f(We,"S");I(We,"stripInternalTypes");const cn=I((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=qe.call(this,o,r,e,t),o=We.call(this,o,r),o=ln(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var pn=Object.defineProperty,Be=f((e,t)=>pn(e,"name",{value:t,configurable:!0}),"u$3");const Je=Be((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 a=m.resolve(m.dirname(r),n),i=[];if(s)for(const[l,c]of Object.entries(s)){const u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const y=[...T.normalizePath(m.resolve(a,d))].map(h=>h==="*"?`$${++p}`:h==="$"?"$$":h).join("");i.push({find:u,replacement:y})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...T.normalizePath(a)].map(l=>l==="$"?"$$":l).join("")}/$1`}),i},"getConfigAlias"),ze=Be((e,t)=>{const o=Je(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(r)){const l=r.replace(a,i),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 un=Object.defineProperty,Ue=f((e,t)=>un(e,"name",{value:t,configurable:!0}),"u$2");const dn=Ue((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 a of n){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(m.resolve(e,a))}return s},"getRootDirectories"),He=Ue((e,t,o)=>{const r=dn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,a){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const i of r){const l=m.join(i,n),c=await this.resolve(l,s,{skipSelf:!0,...a});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 mn=Object.defineProperty,fn=f((e,t)=>mn(e,"name",{value:t,configurable:!0}),"r$3");const Ve=fn(()=>{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 gn=Object.defineProperty,hn=f((e,t)=>gn(e,"name",{value:t,configurable:!0}),"s$5");const yn=hn(e=>{const t=m.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 vn=Object.defineProperty,bn=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"i$2");const X=bn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var $n=Object.defineProperty,de=f((e,t)=>$n(e,"name",{value:t,configurable:!0}),"c$2");const me=de((e,t)=>{const o=new Map;return de(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:a}=s,i=s.meta,l=X(i);if(!a){const c=o.get(r);if(c)return c;const u=yn(r);if(u)return o.set(r,u),u}if(a){const c=n.getModuleIds();for(const u of c)n.getModuleInfo(u)&&X(i)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([r,l]))}if(l&&!a&&e.has(r)){const c=[...e.get(r)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=n.getModuleInfo(p);return X(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(r)?o.get(r):void 0;const u=`${m.basename(r,m.extname(r))}-${l}`;return o.set(r,u),u}},"splitChunks")},"createSplitChunks");var jn=Object.defineProperty,wn=f((e,t)=>jn(e,"name",{value:t,configurable:!0}),"n$2");const N=wn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var kn=Object.defineProperty,xn=f((e,t)=>kn(e,"name",{value:t,configurable:!0}),"s$3");const En=process.platform==="win32",fe=xn((e,t)=>{const o=En?"\\":"/";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 On=Object.defineProperty,$=f((e,t)=>On(e,"name",{value:t,configurable:!0}),"p");const Sn=$((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"+j.versions.node.split(".")[0];if(t.pkg.engines?.node){const r=je.minVersion(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=H(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...H(o),...r])])}else t.options.rollup.esbuild.target=H(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"),Xe=$((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${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".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),
|
|
56
|
-
${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:
|
|
57
|
-
└─ ${
|
|
58
|
-
- `+g.cyan(i)+(
|
|
55
|
+
↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ge=new Map,Ge=$((e,t,o)=>{const r=$(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),n=Je(e.tsconfig,!1);return{external(s){const a=r(s);a&&(s=a);const i=Q(s),l=Y(e.options.externals,i)||Y(e.options.externals,s);if(l)return!0;if(s.startsWith(".")||m.isAbsolute(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))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!l&&!ge.has(s)&&e.logger.info({message:'Inlined implicit external "'+g.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ge.set(s,!0),l},input:Object.fromEntries(e.options.entries.map(s=>[s.name,m.resolve(e.options.rootDir,s.input)])),onLog:$((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
|
|
56
|
+
${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){Xe(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ke=$(async(e,t)=>{const o=te(e,"build");let r;return e.options.rollup.resolve&&(r=k($e.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...Ge(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(n=>N(e,n,"cjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(n=>N(e,n,"mjs"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>fe(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:me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Ie(),t),k(Ve(),t),e.tsconfig&&k(He(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ze(e.tsconfig,e.logger),t),e.options.rollup.replace&&xe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ke({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&St({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Pe({...e.options.rollup.json}),Bo(e.logger),Ft(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&>.wasm(e.options.rollup.wsam),e.options.transformer?.(Sn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ne({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ot(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Et({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&&Qo(e.pkg),e.options.rollup.raw&&Ho(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&_o({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Co({outDir:m.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&jo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Me({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&&yt.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),_n=$(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"),Dn=ho(_n),Ye=$(async(e,t)=>{const o=te(e,"types"),r={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k($e.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ge(e,o,"dts"),onwarn(i,l){Xe(i,e)||i.code!=="EMPTY_BUNDLE"&&l(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>N(e,i,"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:$(i=>N(e,i,"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:$(i=>N(e,i,"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:[k(Ie(),t),k(Ve(),t),e.options.rollup.json&&Pe({...e.options.rollup.json}),r,e.tsconfig&&k(He(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ze(e.tsconfig,e.logger),t),e.options.rollup.replace&&xe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ke({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await Dn(a)(e),e.options.cjsInterop&&e.options.emitCJS&&Ne({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&cn(e.options.rollup.patchTypes,e.logger),Mt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Me({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 Nn=Object.defineProperty,Pn=f((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"c$1");const Fn=Pn(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 r="rollup-build.json";o.cache=t.get(r);const n=await B.rollup(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,a=new Map;for(const i of s){const{output:l}=await n.write(i),c=new Set,u=l.filter(d=>d.type==="chunk");for(const d of u){c.add(d.fileName);for(const y of d.imports)e.usedImports.add(y);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(y=>u.find(h=>h.fileName===y)),exports:d.exports,modules:Object.entries(d.modules).map(([y,h])=>({bytes:h.renderedLength,id:y})),path:d.fileName,type:"entry"})}const p=l.filter(d=>d.type==="asset");for(const d of p)a.has(d.fileName)||a.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of c)e.usedImports.delete(d)}e.buildEntries.push(...a.values())},"build");var Mn=Object.defineProperty,q=f((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"r$1");const Cn=q(async(e,t)=>{const o=await Ye(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 B.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=>N(e,s,"d.cts"),"chunkFileNames"),dir:m.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:q(s=>N(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 n.write({chunkFileNames:q(s=>N(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 In=Object.defineProperty,Qe=f((e,t)=>In(e,"name",{value:t,configurable:!0}),"e");const he=Qe((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${g.cyan(m.relative(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),Rn=Qe(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");const r=B.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 a of n)s+=g.gray(`
|
|
57
|
+
└─ ${m.relative(process.cwd(),a)}`);if(e.logger.info(s),he(r,"bundle",e.logger),e.options.declaration){const a=await Ye(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=B.watch(a);await e.hooks.callHook("rollup:watch",e,i),he(i,"types",e.logger)}},"watch");var Tn=Object.defineProperty,An=f((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"i$1");const Ze=An(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var qn=Object.defineProperty,Ln=f((e,t)=>qn(e,"name",{value:t,configurable:!0}),"a$2");let Wn=class{static{f(this,"g")}static{Ln(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,r){this.#n=t,this.#e=G.findCacheDirectorySync("visulima-packem",{cwd:t}),this.#r=o,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:v.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(!v.isAccessibleSync(r))return;const n=v.readFileSync(r),s=JSON.parse(n);return this.#o.set(r,s),s}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)),v.writeFileSync(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(m.toNamespacedPath(this.#n),"");return r=r.replaceAll(":","-"),m.join(this.#e,this.#r,o?.replaceAll(":","-")??"",m.toNamespacedPath(r))}};var Bn=Object.defineProperty,L=f((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"l$1");const Jn=T.createFilter,zn=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=Jn(n,null,{resolve:e})}else r=L(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Un=Object.defineProperty,Hn=f((e,t)=>Un(e,"name",{value:t,configurable:!0}),"o");const Vn=Hn(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(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)o.delete(n);for(const n of t)!Y(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(Q(n))&&!e.options.peerDependencies.includes(Q(n))&&r.add(n);o.size>0&&A(e,`Potential unused dependencies found: ${[...o].map(n=>g.cyan(n)).join(", ")}`),r.size>0&&A(e,`Potential implicit dependencies found: ${[...r].map(n=>g.cyan(n)).join(", ")}`)},"validateDependencies");var Xn=Object.defineProperty,et=f((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"i");const Gn=et((e,t)=>xt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Kn=et((e,t)=>{const o=e.toLowerCase();return t.filter(r=>Gn(r.toLowerCase(),o))},"findAlternatives");var Yn=Object.defineProperty,ye=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"n");const Qn=ye((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&&m.resolve(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!Z.existsSync(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=ye(i=>m.relative(t.rootDir,m.resolve(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>n(i.path));let a="Potential missing or wrong package.json files:";for(const i of r){const l=Kn(i,s);a+=`
|
|
58
|
+
- `+g.cyan(i)+(l.length>0?g.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}A(t,a)}},"validatePackage");var Zn=Object.defineProperty,w=f((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"f");const ve=w((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
59
59
|
`),e.logger.warn(`Build is done with some warnings:
|
|
60
60
|
|
|
61
|
-
${[...e.warnings].map(
|
|
62
|
-
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),
|
|
61
|
+
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
62
|
+
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),j.exit(1)))},"logErrors"),er=w(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"),tr=w((e,t,o,r,n,s,a,i)=>{const l=er(i?.config.compilerOptions?.jsx),c=at.defu(n,r,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:j.env.NODE_ENV==="production",name:(a.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:l,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:j.env.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:w((u,p,d)=>`
|
|
63
63
|
# Licenses of bundled dependencies
|
|
64
64
|
The published ${d} artifact additionally contains code with the following licenses:
|
|
65
65
|
${u.join(", ")}
|
|
66
66
|
|
|
67
67
|
# Bundled dependencies:
|
|
68
|
-
`+p,"dependenciesTemplate"),dtsTemplate:
|
|
68
|
+
`+p,"dependenciesTemplate"),dtsTemplate:w((u,p,d)=>`
|
|
69
69
|
# Licenses of bundled types
|
|
70
70
|
The published ${d} artifact additionally contains code with the following licenses:
|
|
71
71
|
${u.join(", ")}
|
|
72
72
|
|
|
73
73
|
# Bundled types:
|
|
74
|
-
`+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:
|
|
74
|
+
`+p,"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:j.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:l,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:j.env.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:l,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:zn(t,a),preset:"recommended"},watch:{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(!c.transformerName){const u=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(u.has("esbuild"))c.transformerName="esbuild";else if(u.has("@swc/core"))c.transformerName="swc";else if(u.has("sucrase"))c.transformerName="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(c.transformerName)+'" as transformer.')}return c.rollup.resolve&&c.rollup.resolve.preferBuiltins===!0&&(c.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.
|
|
75
75
|
Because none of the third-party transpilers, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
|
|
76
|
-
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.`),
|
|
76
|
+
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.`),c.dependencies=Object.keys(a.dependencies??{}),c.peerDependencies=Object.keys(a.peerDependencies??{}),c.devDependencies=Object.keys(a.devDependencies??{}),c.optionalDependencies=Object.keys(a.optionalDependencies??{}),c.externals.push(...c.dependencies,...c.peerDependencies,...c.optionalDependencies),c},"generateOptions"),or=w(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),nr=w(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=m.isAbsolute(o.input)?m.relative(t,o.input):m.normalize(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=or(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Ze(o)}`);if(o.input=m.resolve(e.options.rootDir,o.input),!v.isAccessibleSync(o.input)){const r=new Set(await J.readdir(m.dirname(o.input)));let n=!1;for(const s of O.DEFAULT_EXTENSIONS)if(r.has(m.basename(o.input)+s)){n=!0;break}if(!n)throw new rt.NotFoundError("Your configured entry: "+g.cyan(o.input)+" does not exist.")}o.outDir=m.resolve(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),rr=w((e,t,o)=>{const r=w(s=>m.relative(t.rootDir,m.resolve(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const l of s.chunks??[])a+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let i=` ${g.bold(r(s.path))} (${["total size: "+g.cyan(D.formatBytes(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+g.cyan(D.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
|
|
77
77
|
exports: `+g.gray(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
|
|
78
|
-
${s.chunks.map(
|
|
79
|
-
`)}`),s.modules&&s.modules.length>0){const
|
|
80
|
-
`);i+=
|
|
78
|
+
${s.chunks.map(l=>{const c=t.buildEntries.find(u=>u.path===l)??{};return g.gray(" └─ "+r(l)+g.bold(c.bytes?" ("+D.formatBytes(c?.bytes)+")":""))}).join(`
|
|
79
|
+
`)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>g.gray(" 📦 "+r(c.id)+g.bold(c.bytes?" ("+D.formatBytes(c.bytes)+")":""))).join(`
|
|
80
|
+
`);i+=l.length>0?`
|
|
81
81
|
inlined modules:
|
|
82
|
-
`+
|
|
82
|
+
`+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 u=t.buildEntries.find(p=>p.path.endsWith(l));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(l))),i+=p&&c===o.type?`
|
|
83
83
|
types:
|
|
84
|
-
`+[u,p].map(d=>g.gray(" └─ ")+g.bold(r(d.path))+" (total size: "+g.cyan(
|
|
84
|
+
`+[u,p].map(d=>g.gray(" └─ ")+g.bold(r(d.path))+" (total size: "+g.cyan(D.formatBytes(d.bytes??0))+")").join(`
|
|
85
85
|
`):`
|
|
86
|
-
types: `+g.bold(r(u.path))+" (total size: "+g.cyan(
|
|
86
|
+
types: `+g.bold(r(u.path))+" (total size: "+g.cyan(D.formatBytes(u.bytes??0))+")"}}n=!0,i+=`
|
|
87
87
|
|
|
88
|
-
`,e.raw(s.chunk?g.gray(i):i)}return
|
|
89
|
-
`),
|
|
88
|
+
`,e.raw(s.chunk?g.gray(i):i)}return n&&e.raw("Σ Total dist size (byte size):",g.cyan(D.formatBytes(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
|
|
89
|
+
`),n},"showSizeInformation"),sr=w(async(e,t,o,r,n,s,a,i,l)=>{const c=io(n.preset??r.preset??"auto",t),u=tr(e,t,o,r,n,c,s,a);v.ensureDirSync(m.join(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:lt.createHooks(),logger:e,mode:o,options:u,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(c.hooks&&p.hooks.addHooks(c.hooks),r.hooks&&p.hooks.addHooks(r.hooks),n.hooks&&p.hooks.addHooks(n.hooks),i.isEnabled=p.options.fileCache,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)throw new Error("Cannot build declaration files without a tsconfig.json");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."),await nr(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(o==="watch"?d="Watching":o==="jit"&&(d="Stubbing"),p.logger.info(g.cyan(`${d} ${p.options.name}`)),p.logger.debug(`${g.bold("Root dir:")} ${p.options.rootDir}
|
|
90
90
|
${g.bold("Entries:")}
|
|
91
|
-
${p.options.entries.map(h=>` ${
|
|
92
|
-
`)}`),p.options.clean)for(const h of new Set(p.options.entries.map(b=>b.outDir).filter(Boolean).sort()))h===p.options.rootDir||p.options.rootDir.startsWith(h.endsWith("/")?h:`${h}/`)||
|
|
93
|
-
⚡️ Build`+(
|
|
91
|
+
${p.options.entries.map(h=>` ${Ze(h)}`).join(`
|
|
92
|
+
`)}`),p.options.clean)for(const h of new Set(p.options.entries.map(b=>b.outDir).filter(Boolean).sort()))h===p.options.rootDir||p.options.rootDir.startsWith(h.endsWith("/")?h:`${h}/`)||l.some(b=>h.startsWith(b))||(l.push(h),p.logger.info(`Cleaning dist directory: \`./${m.relative(p.options.rootDir,h)}\``),await v.emptyDir(h));if(p.options.stub){await zt(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await Rn(p,i),ve(p,!1);return}await Promise.all([Fn(p,i),p.options.declaration&&Cn(p,i)]),p.logger.success(g.green(`Build succeeded for ${p.options.name}`));for await(const h of v.walk(m.join(p.options.rootDir,p.options.outDir))){let b=p.buildEntries.find(E=>m.join(p.options.rootDir,p.options.outDir,E.path)===h.path);if(b||(b={chunk:!0,path:h.path},p.buildEntries.push(b)),!b.bytes){const E=await J.stat(m.resolve(p.options.rootDir,p.options.outDir,h.path));b.bytes=E.size}}const y=rr(p.logger,p,s);Vn(p),Qn(s,p),await p.hooks.callHook("build:done",p),ve(p,y)},"build"),ir=w(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...a}=o,i=[new U.MessageFormatterProcessor,new U.ErrorProcessor];n&&i.push(new U.CallerProcessor);const l=it.createPail({logLevel:n?"debug":"informational",processors:i,scope:"packem"});e=m.resolve(j.cwd(),e),l.debug("Root directory:",e);const c=m.join(e,"package.json"),u=st.parsePackageJson(c);l.debug("Using package.json found at",c);let p;if(s){const d=m.join(e,s);await v.isAccessible(d)||(l.error("tsconfig.json not found at",d),j.exit(1)),p={config:G.readTsConfig(d),path:d},l.info("Using tsconfig settings at",d)}else try{p=await G.findTSConfig(e),l.debug("Using tsconfig settings found at",p.path)}catch{l.info("No tsconfig.json or jsconfig.json found.")}try{const d=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(l.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),j.exit(1));const y=Ee(d,e);l.debug("Using packem config found at",m.join(e,d));const h=(Array.isArray(y)?y:[y]).filter(Boolean),b=Date.now(),E=w(()=>D.duration(Math.floor(Date.now()-b)),"getDuration"),F=[],M=[],S=C(u.version+JSON.stringify({...u.dependencies,...u.devDependencies,eNode:u.engines?.node})),_=new Wn(e,S,l);_.cachePath&&!v.isAccessibleSync(m.join(_.cachePath,S))&&v.isAccessibleSync(_.cachePath)&&(l.info("Clearing file cache because the cache key has changed."),await v.emptyDir(_.cachePath));for(const tt of h)M.push(sr(l,e,t,a,tt,u,p,_,F));await Promise.all(M),l.raw(`
|
|
93
|
+
⚡️ Build`+(M.length>1?"s":"")+" run in "+E()),l.restoreAll(),j.exit(0)}catch(d){l.error("An error occurred while building",d),j.exit(1)}},"createBundler");module.exports=ir;
|
package/dist/create-bundler.d.ts
CHANGED