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