@visulima/packem 1.0.0-alpha.5 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/create-bundler.cjs +33 -33
- package/dist/create-bundler.d.cts +1 -1
- package/dist/create-bundler.d.mts +1 -1
- package/dist/create-bundler.d.ts +1 -1
- package/dist/create-bundler.mjs +30 -30
- package/dist/shared/{packem.Bx49YBYz.d.cts → packem.B6x1BqsW.d.cts} +2 -1
- package/dist/shared/{packem.CRdgUXSu.d.ts → packem.D1XYCEcD.d.ts} +2 -1
- package/dist/shared/{packem.DIUR7hAQ.d.mts → packem.DbDxKBpP.d.mts} +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## @visulima/packem [1.0.0-alpha.6](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.5...@visulima/packem@1.0.0-alpha.6) (2024-05-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added target options to esbuild and swc ([5d3100b](https://github.com/visulima/packem/commit/5d3100b6bce15819a90b97f537b5626498bb6b18))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Styles
|
|
10
|
+
|
|
11
|
+
* cs fix ([78752e4](https://github.com/visulima/packem/commit/78752e434e62c20c5efb800015d321899770030f))
|
|
12
|
+
|
|
1
13
|
## @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
14
|
|
|
3
15
|
|
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.5";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.5";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/config.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BuildConfig, a as BuildPreset } from './shared/packem.
|
|
2
|
-
export { b as BuildHooks } from './shared/packem.
|
|
1
|
+
import { B as BuildConfig, a as BuildPreset } from './shared/packem.B6x1BqsW.cjs';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.B6x1BqsW.cjs';
|
|
3
3
|
import '@rollup/plugin-alias';
|
|
4
4
|
import '@rollup/plugin-commonjs';
|
|
5
5
|
import '@rollup/plugin-json';
|
package/dist/config.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BuildConfig, a as BuildPreset } from './shared/packem.
|
|
2
|
-
export { b as BuildHooks } from './shared/packem.
|
|
1
|
+
import { B as BuildConfig, a as BuildPreset } from './shared/packem.DbDxKBpP.mjs';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.DbDxKBpP.mjs';
|
|
3
3
|
import '@rollup/plugin-alias';
|
|
4
4
|
import '@rollup/plugin-commonjs';
|
|
5
5
|
import '@rollup/plugin-json';
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BuildConfig, a as BuildPreset } from './shared/packem.
|
|
2
|
-
export { b as BuildHooks } from './shared/packem.
|
|
1
|
+
import { B as BuildConfig, a as BuildPreset } from './shared/packem.D1XYCEcD.js';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.D1XYCEcD.js';
|
|
3
3
|
import '@rollup/plugin-alias';
|
|
4
4
|
import '@rollup/plugin-commonjs';
|
|
5
5
|
import '@rollup/plugin-json';
|
package/dist/create-bundler.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
"use strict";var
|
|
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 c=[];try{c=await
|
|
5
|
-
export default _module;`:"",...c.filter(
|
|
6
|
-
`)),await k.writeFile(`${o}.d.cts`,[`export * from ${JSON.stringify(s)};`,
|
|
7
|
-
`)),await k.writeFile(`${o}.d.mts`,[`export * from ${JSON.stringify(i)};`,
|
|
8
|
-
`)),u&&(await
|
|
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
|
|
1
|
+
"use strict";var Ye=Object.defineProperty;var f=(e,t)=>Ye(e,"name",{value:t,configurable:!0});const L=require("node:fs/promises"),Ze=require("node:module"),O=require("node:process"),y=require("@visulima/colorize"),k=require("@visulima/fs"),Ke=require("@visulima/fs/error"),F=require("@visulima/humanizer"),X=require("@visulima/package"),Qe=require("@visulima/pail"),V=require("@visulima/pail/processor"),g=require("@visulima/path"),et=require("defu"),tt=require("hookable"),ie=require("semver"),S=require("./shared/packem.uvB0cQX0.cjs"),ae=require("node:url"),W=require("mlly"),ot=require("magic-string"),rt=require("jiti"),J=require("rollup"),nt=require("@rollup/plugin-alias"),st=require("@rollup/plugin-commonjs"),it=require("@rollup/plugin-dynamic-import-vars"),U=require("@rollup/plugin-node-resolve"),at=require("@rollup/plugin-replace"),lt=require("@rollup/plugin-wasm"),ct=require("rollup-plugin-dts"),pt=require("rollup-plugin-polyfill-node"),ut=require("rollup-plugin-visualizer"),dt=require("glob"),mt=require("glob-parent"),ft=require("@rollup/plugin-json"),A=require("@rollup/pluginutils"),gt=require("rollup-plugin-license"),ht=require("@babel/parser"),G=require("node:fs"),yt=require("fastest-levenshtein");var le=typeof document<"u"?document.currentScript:null;function _(e){return e&&typeof e=="object"&&"default"in e?e.default:e}f(_,"_interopDefaultCompat");const ce=_(Ze),N=_(ot),pe=_(rt),ue=_(nt),vt=_(st),bt=_(it),de=_(at),$t=_(pt),jt=_(mt),wt=_(ft),kt=_(gt);var xt=Object.defineProperty,z=f((e,t)=>xt(e,"name",{value:t,configurable:!0}),"i$8");const Y=/^#![^\n]*/,Z=z(async e=>{await L.chmod(e,493).catch(()=>{})},"makeExecutable"),Et=z((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 N(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"&&Y.test(i.code)&&r.dir){const s=g.resolve(r.dir,o);await Z(s)}}}),"shebangPlugin"),Ot=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Y,"")}}),"removeShebangPlugin"),_t=z((e,t=`
|
|
3
|
+
`)=>{const r=Y.exec(e);return r?r+t:""},"getShebang");var St=Object.defineProperty,Dt=f((e,t)=>St(e,"name",{value:t,configurable:!0}),"p$2");const K=Dt((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,Pt=f((e,t)=>Nt(e,"name",{value:t,configurable:!0}),"o$4");const Ft=Pt((e,t)=>{const r=pe(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 Mt=Object.defineProperty,It=f((e,t)=>Mt(e,"name",{value:t,configurable:!0}),"r$6");const q=It((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Rt=Object.defineProperty,Tt=f((e,t)=>Rt(e,"name",{value:t,configurable:!0}),"u$8");const Ct=Tt(async e=>{const t=await W.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:le&&le.src||new URL("create-bundler.cjs",document.baseURI).href}),r=JSON.stringify({...e.options.stubOptions.jiti,alias:{...K(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(Ft(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=_t(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 W.resolveModuleExportNames(i,{extensions:S.DEFAULT_EXTENSIONS})}catch(l){q(e,`Cannot analyze ${i} for exports:${l}`);return}const a=c.includes("default")||c.length===0;await k.writeFile(`${o}.mjs`,u+[`import jiti from ${JSON.stringify(ae.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,a?`
|
|
5
|
+
export default _module;`:"",...c.filter(l=>l!=="default").map(l=>`export const ${l} = _module.${l};`)].join(`
|
|
6
|
+
`)),await k.writeFile(`${o}.d.cts`,[`export * from ${JSON.stringify(s)};`,a?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
7
|
+
`)),await k.writeFile(`${o}.d.mts`,[`export * from ${JSON.stringify(i)};`,a?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
8
|
+
`)),u&&(await Z(`${o}.cjs`),await Z(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var At=Object.defineProperty,qt=f((e,t)=>At(e,"name",{value:t,configurable:!0}),"a$a");const Q=qt((e,t)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),"arrayIncludes");var Bt=Object.defineProperty,Lt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"a$9");const R=Lt(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Wt=Object.defineProperty,Jt=f((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"e$2");const ee=Jt((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Ut=Object.defineProperty,zt=f((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"m$4");const me=zt(({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 N(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 l of p)if(!l.includes("type"))if(l.includes("as")){const[m,j]=l.split(" as ");if(j==="default"&&(c=m,!e))continue;u.push(j+": typeof "+m+";")}else u.push(l+": typeof "+l+";");const a=new N(n);return a.replace(" "+c+" as default,",""),a.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:
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:a.toString(),map:a.generateMap({hires:!0})}}return null}}),"cjsInterop");var Ht=Object.defineProperty,Xt=f((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"u$7");const Vt=Xt((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 dt.glob(s.src,{ignore:s.exclude}).then(p=>({dest:s.dest??"",parent:jt(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 a=c.mtime.getTime();a>p.timestamp&&(p.timestamp=a,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 a=g.basename(s),l=g.join(c,a);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:l,source:u,type:"asset"}),t.debug({message:`copied ${s} → ${l}`,prefix:"copy"}),p.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${s} → ${l}`,prefix:"copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Gt=Object.defineProperty,Yt=f((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"n$7");const fe="export default ",ge=Yt(e=>{const t=wt(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(fe)&&(o.code=o.code.replace(fe,"module.exports = ")),o}}},"JSONPlugin");class Zt{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 Kt extends Zt{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,a=this.should_remove;if(this.should_skip=s,this.should_remove=p,this.replacement=u,c)return t;if(a)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];he(c)&&(this.visit(c,t,i,u)||u--)}}else he(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 he(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(he,"isNode");function ye(e,{enter:t,leave:r}){return new Kt(t,r).visit(e,null)}f(ye,"walk");var Qt=Object.defineProperty,eo=f((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"u$6");const to=eo(({attributes:e,logger:t})=>{const r=A.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 N(n);return ye(i,{enter(u){if(u.type==="CallExpression"&&u.callee.type==="Identifier"&&u.callee.name==="jsx"){const c=u.arguments.filter(a=>a.type==="ObjectExpression"&&Array.isArray(a.properties));for(const a of c)for(const l of a.properties)l.type==="Property"&&l.key.type==="Literal"&&l.value.type==="Literal"&&e.includes(l.key.value)&&(p.overwrite(l.start-2,l.end,""),s=!0)}}}),s?{code:p.toString(),map:p.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var oo=Object.defineProperty,te=f((e,t)=>oo(e,"name",{value:t,configurable:!0}),"p$1");const ro=te(e=>{const t=[],r=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):r.push(n)}),[...r.sort(),...t.sort()]},"sortLicenses"),no=te((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"),
|
|
18
|
+
$2`)},"replaceContentWithin"),ve=te(({licenseFilePath:e,licenseTemplate:t,logger:r,marker:n,mode:o,packageName:i})=>kt({thirdParty(s){const p=new Set,u=s.sort(({name:a},{name:l})=>a>l?1:l>a?-1:0).map(({author:a,contributors:l,license:m,licenseText:j,maintainers:w,name:E,repository:d})=>{let h=`## ${E}
|
|
19
19
|
`;m&&(h+=`License: ${m}
|
|
20
|
-
`);const v=new Set;for(const b of[
|
|
20
|
+
`);const v=new Set;for(const b of[a,...w,...l]){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}
|
|
22
22
|
`),j&&(h+=`
|
|
23
23
|
`+j.trim().replaceAll(/(\r\n|\r)/g,`
|
|
@@ -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(ro(p),u,i);try{const a=k.readFileSync(e),l=no(a,n,c);if(!l){r.error(`Could not find the license marker: <!-- ${n} --> in ${e}`);return}a!==l&&(k.writeFileSync(e,l),r.info({message:`${e} updated.`,prefix:`license:${o}`}))}catch(a){r.error(a)}}}),"license");var so=Object.defineProperty,io=f((e,t)=>so(e,"name",{value:t,configurable:!0}),"i$5");const ao=io(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 lo=Object.defineProperty,co=f((e,t)=>lo(e,"name",{value:t,configurable:!0}),"c$4");const po=/\.(?:m|c)?(?:j|t)sx?$/,uo=/^use \w+$/,mo=co(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,a)=>(a&&a.forEach(l=>{c.add(l)}),c),new Set),p=new N(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(!po.test(i))return null;let s=!1;const p=new N(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let a=2,l=n.length;a<l;a++){const m=n.codePointAt(a);if(m===10||m===13||m===8232||m===8233){c=a;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 a=null;"directive"in c?a=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&uo.test(c.expression.value)&&(a=c.expression.value),a!=="use strict"&&a&&(t[o]||=new Set,t[o].add(a),"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 "${a}" 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 fo=Object.defineProperty,go=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"r$4");const ho={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},yo=go((e={})=>{e={...e,...ho};const t=A.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 vo=Object.defineProperty,bo=f((e,t)=>vo(e,"name",{value:t,configurable:!0}),"l$3");const oe="\0__file_url__",be=bo(()=>({async load(e){if(e.startsWith(oe)){const t=ae.fileURLToPath(e.slice(oe.length));return await k.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${oe}${e}`}}),"resolveFileUrl");var $o=Object.defineProperty,$e=f((e,t)=>$o(e,"name",{value:t,configurable:!0}),"m$2");const jo=/__filename|__dirname|require\(|require\.resolve\(/,je=`
|
|
34
34
|
// -- pack CommonJS Shims --
|
|
35
35
|
import __cjs_url__ from "node:url";
|
|
36
36
|
import __cjs_path__ from "node:path";
|
|
@@ -38,27 +38,27 @@ import __cjs_mod__ from "node:module";
|
|
|
38
38
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
39
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
40
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,
|
|
41
|
+
`,we=`
|
|
42
42
|
// -- pack CommonJS Shims Node 20.11 --
|
|
43
43
|
import __cjs_mod__ from "node:module";
|
|
44
44
|
const __filename = import.meta.filename;
|
|
45
45
|
const __dirname = import.meta.dirname;
|
|
46
46
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
-
`,
|
|
47
|
+
`,wo=$e((e,t)=>{if(e.includes(je)||e.includes(we)||!jo.test(e))return null;const r=W.findStaticImports(e).pop(),n=r?r.end:0,o=new N(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),ko=$e(e=>({name:"packem:cjs",renderChunk(t,r,n){if(n.format==="es"){let o=je;if(e.engines?.node){const i=ie.minVersion(e.engines.node);i&&i.major>=20&&i.minor>=11&&(o=we)}return wo(t,o)}return null}}),"cjsPlugin");var xo=Object.defineProperty,M=f((e,t)=>xo(e,"name",{value:t,configurable:!0}),"s$a");const Eo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Oo=/MIT License|MIT license|BSD license/,_o=/\n{2,}/g,So=/\b(\w+)\$\d+\b/g,Do=/[-/\\^$*+?.()|[\]{}]/g,No=M(e=>e.replaceAll(Do,"\\$&"),"escapeRegex"),Po=M(e=>[...new Set(e)],"unique"),Fo=M(e=>e.replaceAll(Eo,t=>Oo.test(t)?"":t).replaceAll(_o,`
|
|
48
48
|
|
|
49
|
-
`),"cleanUnnecessaryComments"),
|
|
50
|
-
- ${u}`).join(""),p=t.fileName.replace(/\.[^/.]+$/,"");
|
|
49
|
+
`),"cleanUnnecessaryComments"),ke=new Map;function xe(e,t,{identifierReplacements:r},n){const o=W.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 a=u[c],l=No(c);a.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${l},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${l}\\b`,"g"),a)}}const i=Po(Array.from(e.matchAll(So),s=>s[0]));if(i.length>0){const s=i.map(u=>`
|
|
50
|
+
- ${u}`).join(""),p=t.fileName.replace(/\.[^/.]+$/,"");ke.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"}),
|
|
52
|
+
To replace these, add them to the "patchTypes -> identifierReplacements" option in your packem config.`,prefix:"patch-types"}),ke.set(p,!0)}return e}f(xe,"v$2"),M(xe,"replaceConfusingTypeNames");function Ee(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(Ee,"N$2"),M(Ee,"removeInternal");function Oe(e,t){if(e.includes("@internal")){const r=new N(e),n=ht.parse(e,{plugins:["typescript"],sourceType:"module"});ye(n,{enter(o){Ee(r,o)&&this.skip()}}),e=r.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),O.exit(1))}return e}f(Oe,"S$1"),M(Oe,"stripInternalTypes");const Mo=M((e,t)=>({name:"packem:patch-types",renderChunk(r,n){return r=xe.call(this,r,n,e,t),r=Oe.call(this,r,n),r=Fo(r),r},resolveId(r){return r.startsWith("types/")?{external:!0,id:"../../"+(r.endsWith(".js")?r:r+".js")}:null}}),"patchTypescriptTypes");var Io=Object.defineProperty,_e=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"u$3");const Se=_e((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 a=new RegExp(`^${[...u].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let l=0;for(const m of c){const j=[...A.normalizePath(g.resolve(s,m))].map(w=>w==="*"?`$${++l}`:w==="$"?"$$":w).join("");p.push({find:a,replacement:j})}}return t&&p.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...A.normalizePath(s)].map(u=>u==="$"?"$$":u).join("")}/$1`}),p},"getConfigAlias"),De=_e((e,t)=>{const r=Se(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 Ro=Object.defineProperty,Ne=f((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"u$2");const To=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"),Pe=Ne((e,t,r)=>{const n=To(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 Co=Object.defineProperty,Ao=f((e,t)=>Co(e,"name",{value:t,configurable:!0}),"r$3");const Fe=Ao(()=>{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 qo=Object.defineProperty,Bo=f((e,t)=>qo(e,"name",{value:t,configurable:!0}),"s$9");const Lo=Bo(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 Wo=Object.defineProperty,Jo=f((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"i$2");const re=Jo(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Uo=Object.defineProperty,Me=f((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"c$2");const Ie=Me((e,t)=>{const r=new Map;return Me(function(n,o){const i=o.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,p=i.meta,u=re(p);if(!s){const c=r.get(n);if(c)return c;const a=Lo(n);if(a)return r.set(n,a),a}if(s){const c=o.getModuleIds();for(const a of c)o.getModuleInfo(a)&&re(p)===u&&(e.has(a)||e.set(a,new Set),e.get(a).add([n,u]))}if(u&&!s&&e.has(n)){const c=[...e.get(n)];if(c.some(([l])=>{if(console.log(l),t.some(m=>m.path===l)){const m=o.getModuleInfo(l);return re(m?m.meta:{})===u}return!1}))return;if(c.every(([,l])=>l===u))return r.has(n)?r.get(n):void 0;const a=`${g.basename(n,g.extname(n))}-${u}`;return r.set(n,a),a}},"splitChunks")},"createSplitChunks");var zo=Object.defineProperty,Ho=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"n$5");const P=Ho((e,t,r)=>t.isDynamicEntry?`chunks/[name].${r}`:`shared/${e.options.name}.[hash].${r}`,"getChunkFilename");var Xo=Object.defineProperty,Vo=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"s$7");const Go=process.platform==="win32",Re=Vo((e,t)=>{const r=Go?"\\":"/";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 Yo=Object.defineProperty,x=f((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"e$1");const Zo=x((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");if(t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5"),t.options.rollup.esbuild.jsx==="preserve"){let r="Packem does not support 'preserve' jsx option. Please use 'transform' or 'automatic' instead.";throw t.tsconfig?.config.compilerOptions?.jsx&&(r="Packem does not support '"+t.tsconfig.config.compilerOptions.jsx+"' jsx option. Please change it to 'react' or 'react-jsx' or 'react-jsxdev' instead."),new Error(r)}if(t.options.rollup.esbuild.target){const r=R(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...R(t.options.target),...r])])}else t.options.rollup.esbuild.target=R(t.options.target);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");if(typeof t.options.rollup.swc.env!="object"&&(t.options.rollup.swc.env={}),t.options.rollup.swc.env.targets){const r=R(t.options.rollup.swc.env.targets);r.some(n=>n.startsWith("node"))||(t.options.rollup.swc.env.targets=[...new Set([...R(t.options.target),...r])])}else t.options.rollup.swc.env.targets=R(t.options.target);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"),Te=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"),
|
|
56
|
-
└─ ${g.relative(process.cwd(),i)}`);if(e.logger.info(o),Le(r,"bundle",e.logger),e.options.declaration){const i=
|
|
57
|
-
- `+y.cyan(p)+(u.length>0?y.grey` (did you mean ${u.map(c=>`"${c}"`).join(", ")}?)`:"")}
|
|
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"),Ce=new Map,Ae=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=Se(e.tsconfig,!1);return{external(o){const i=r(o);i&&(o=i);const s=ee(o),p=Q(e.options.externals,s)||Q(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&&Ce.has(o)&&e.logger.info('Inlined implicit external "'+y.cyan(o)+'". If this is incorrect, add it to the "externals" option.'),Ce.set(o,!0),p},input:Object.fromEntries(e.options.entries.map(o=>[o.name,g.resolve(e.options.rootDir,o.input)])),onwarn(o,i){Te(o,e)||o.code||i(o)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),qe=x(async e=>{const t=K(e,"build");return{...Ae(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=>Re(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:Ie(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=>Re(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:Ie(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[be(),Fe(),e.tsconfig&&Pe(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&De(e.tsconfig,e.logger),e.options.rollup.replace&&de({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ue({customResolver:U.nodeResolve({extensions:S.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&U.nodeResolve({extensions:S.DEFAULT_EXTENSIONS,rootDir:e.rootDir,...e.options.rollup.resolve}),e.options.rollup.polyfillNode&&$t({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ge({...e.options.rollup.json}),mo(e.logger),Et(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&<.wasm(e.options.rollup.wsam),e.options.transformer?.(Zo(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&bt(),e.options.rollup.commonjs&&vt({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&&ko(e.pkg),e.options.rollup.raw&&yo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&to({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&ao({outDir:g.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Vt(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.template=="function"&&ve({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&&ut.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"),Be=x(e=>{const t=K(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,{...Ae(e,t),onwarn(o,i){Te(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:[be(),Fe(),e.options.rollup.json&&ge({...e.options.rollup.json}),r,e.tsconfig&&Pe(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&De(e.tsconfig,e.logger),e.options.rollup.replace&&de({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ue({customResolver:U.nodeResolve({extensions:S.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&U.nodeResolve({extensions:S.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),ct.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&&me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Mo(e.options.rollup.patchTypes,e.logger),Ot(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&ve({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 Ko=Object.defineProperty,T=f((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"p");const Le=T((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"),Qo=T(async e=>{const t=await qe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=J.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=Be(e);await e.hooks.callHook("rollup:dts:options",e,i);const s=J.watch(i);await e.hooks.callHook("rollup:watch",e,s),Le(s,"types",e.logger)}},"watch"),er=T(async e=>{const t=await qe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=await J.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(a=>a.type==="chunk");for(const a of u){p.add(a.fileName);for(const l of a.imports)e.usedImports.add(l);a.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(a.code,"utf8"),chunks:a.imports.filter(l=>u.find(m=>m.fileName===l)),exports:a.exports,modules:Object.entries(a.modules).map(([l,m])=>({bytes:m.renderedLength,id:l})),path:a.fileName,type:"entry"})}const c=s.filter(a=>a.type==="asset");for(const a of c)o.has(a.fileName)||o.set(a.fileName,{bytes:Buffer.byteLength(a.source,"utf8"),path:a.fileName,type:"asset"});for(const a of p)e.usedImports.delete(a)}if(e.buildEntries.push(...o.values()),e.options.declaration){const i=Be(e);if(await e.hooks.callHook("rollup:dts:options",e,i),Object.keys(i.input).length===0)return;const s=await J.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:T(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:T(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:T(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 tr=Object.defineProperty,or=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"i$1");const We=or(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var rr=Object.defineProperty,H=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"l$2");const nr=A.createFilter,sr=H((e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=H(()=>r,"hasSideEffects");else if(Array.isArray(r))if(r.length<=0)n=H(()=>!1,"hasSideEffects");else{const o=r.map(i=>i.includes("/")?i:`**/${i}`);n=nr(o,null,{resolve:e})}else n=H(()=>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,Je=f((e,t)=>cr(e,"name",{value:t,configurable:!0}),"t$2");const ne=Je(e=>{if(e.endsWith(".d.ts")||e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"cjs"},"inferExportTypeFromFileName"),Ue=Je((e,t,r,n)=>{if(r){const s=ne(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 Ue(o,i,r,n)},"inferExportType");var pr=Object.defineProperty,ur=f((e,t)=>pr(e,"name",{value:t,configurable:!0}),"s$4");const se=ur((e,t,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ne(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:Ue(n,r,o,t)}:se(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((a,l)=>a.split("/").length-l.split("/").length);const o=se(e.exports,e.type||"commonjs");if(e.bin){const a=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const l of a)o.push({file:l,isExecutable:!0})}e.main&&o.push({file:e.main,type:ne(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 a of o.filter(l=>!l.type)){const l=a.file.endsWith(".js");i&&l||a.file.endsWith(".mjs")?a.type="esm":(!i&&l||a.file.endsWith(".cjs"))&&(a.type="cjs")}let s=!1,p=!1,u=!1;const c=[];for(const a of o){const l=a.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),m=l.endsWith("/");if(m&&["./","/"].includes(l))continue;const j=fr(l).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){G.existsSync(g.resolve(r,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}a.type==="cjs"&&(s=!0),a.type==="esm"&&(p=!0);const w=c.find(E=>E.input===j)??c[c.push({input:j})-1];/\.d\.(?:m|c)?ts$/.test(a.file)&&(u=!0),m&&(w.outDir=l),a.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(!G.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)q(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 ze=Er((e,t,r)=>{const n=pe(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=ze(e,t,{})),typeof e=="function"&&(e=e()),e),"resolvePreset");var Dr=Object.defineProperty,Nr=f((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"o");const Pr=Nr(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)!Q(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(ee(o))&&!e.options.peerDependencies.includes(ee(o))&&n.add(o);r.size>0&&q(e,`Potential unused dependencies found: ${[...r].map(o=>y.cyan(o)).join(", ")}`),n.size>0&&q(e,`Potential implicit dependencies found: ${[...n].map(o=>y.cyan(o)).join(", ")}`)},"validateDependencies");var Fr=Object.defineProperty,He=f((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"i");const Mr=He((e,t)=>yt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Ir=He((e,t)=>{const r=e.toLowerCase();return t.filter(n=>Mr(n.toLowerCase(),r))},"findAlternatives");var Rr=Object.defineProperty,Xe=f((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"n");const Tr=Xe((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,...se(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("*")&&!G.existsSync(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=Xe(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(", ")}?)`:"")}q(t,s)}},"validatePackage");var Cr=Object.defineProperty,I=f((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"g");const Ve=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"),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"),
|
|
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"),Ge=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=ie.minVersion(i.engines.node);d&&(c=`node${d.major}`)}const a=Ar(s?.config.compilerOptions?.jsx),l=et.defu(o,i.packem,n,u,{alias:{},clean:!0,declaration:!1,dependencies:[],devDependencies:[],emitCJS:!1,emitESM:!0,entries:[],externals:[...ce.builtinModules,...ce.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*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:a,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: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:
|
|
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:a,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:a,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(!l.transformerName){const d=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(d.has("esbuild"))l.transformerName="esbuild";else if(d.has("@swc/core"))l.transformerName="swc";else if(d.has("sucrase"))l.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(l.transformerName)+'" as transformer.')}if(l.emitESM===!1&&l.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");l.outDir=g.resolve(l.rootDir,l.outDir),k.ensureDirSync(l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.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:tt.createHooks(),logger:e,mode:r,options:l,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),l.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: ${We(d)}`);if(l.declaration!==void 0&&d.declaration===void 0&&(d.declaration=l.declaration),d.input=g.resolve(l.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 Ke.NotFoundError("Your configured entry: "+y.cyan(d.input)+" does not exist.")}d.outDir=g.resolve(l.rootDir,d.outDir??l.outDir)}l.dependencies=Object.keys(i.dependencies??{}),l.peerDependencies=Object.keys(i.peerDependencies??{}),l.devDependencies=Object.keys(i.devDependencies??{}),l.optionalDependencies=Object.keys(i.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.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} ${l.name}`)),e.debug(`${y.bold("Root dir:")} ${l.rootDir}
|
|
76
76
|
${y.bold("Entries:")}
|
|
77
|
-
${m.options.entries.map(d=>` ${
|
|
78
|
-
`)}`),
|
|
77
|
+
${m.options.entries.map(d=>` ${We(d)}`).join(`
|
|
78
|
+
`)}`),l.clean)for(const d of new Set(m.options.entries.map(h=>h.outDir).filter(Boolean).sort()))d!==l.rootDir&&(p.push(d),e.info(`Cleaning dist directory: \`./${g.relative(l.rootDir,d)}\``),await k.emptyDir(d));if(l.stub){await Ct(m),await m.hooks.callHook("build:done",m);return}if(r==="watch"){await Qo(m),Ve(m,!1);return}await er(m),e.success(y.green(`Build succeeded for ${l.name}`));for await(const d of k.walk(l.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(l.outDir,d.path));h.bytes=v.size}}const w=I(d=>g.relative(m.rootDir,g.resolve(l.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(
|
|
81
|
-
`)}`),d.modules&&d.modules.length>0){const b=d.modules.filter($=>$.id.includes("node_modules")).sort(($,
|
|
80
|
+
${d.chunks.map(b=>{const $=m.buildEntries.find(D=>D.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(($,D)=>(D.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
|
-
`+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
|
|
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 D=m.buildEntries.find(C=>C.path.endsWith(b));if(D){let C;(m.options.declaration===!0||m.options.declaration==="compatible")&&!b.includes(".d.ts")&&(b=b.replace($==="commonjs"?".d.c":".d.m",".d."),C=m.buildEntries.find(B=>B.path.endsWith(b))),v+=C&&$===i.type?`
|
|
85
85
|
types:
|
|
86
|
-
`+[
|
|
86
|
+
`+[D,C].map(B=>y.gray(" └─ ")+y.bold(w(B.path))+" (total size: "+y.cyan(F.formatBytes(B.bytes??0))+")").join(`
|
|
87
87
|
`):`
|
|
88
|
-
types: `+y.bold(w(
|
|
88
|
+
types: `+y.bold(w(D.path))+" (total size: "+y.cyan(F.formatBytes(D.bytes??0))+")"}}E=!0,v+=`
|
|
89
89
|
|
|
90
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),
|
|
91
|
+
`),Pr(m),Tr(i,m),await m.hooks.callHook("build:done",m),Ve(m,E)},"build"),qr=I(async(e,t,r={})=>{const{configPath:n,debug:o,tsconfigPath:i,...s}=r,p=[new V.MessageFormatterProcessor,new V.ErrorProcessor];o&&p.push(new V.CallerProcessor);const u=Qe.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:X.readTsConfig(i),path:i},u.debug("Using tsconfig.json found at",i);else try{c=await X.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:a,path:l}=await X.findPackageJson(e);u.debug("Using package.json found at",l);const m=ze(n??"./packem.config",e,[]),j=(Array.isArray(m)?m:[m]).filter(Boolean);if(j.length===0)await Ge(u,e,t,s,{},a,c,[]);else{const w=[];for(const E of j)await Ge(u,e,t,s,E,a,c,w)}u.restoreAll(),O.exit(0)}catch(a){u.error("An error occurred while building",a),O.exit(1)}},"createBundler");module.exports=qr;
|
package/dist/create-bundler.d.ts
CHANGED
package/dist/create-bundler.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
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
|
|
5
|
-
export default _module;`:"",...p.filter(
|
|
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
|
|
1
|
+
var st=Object.defineProperty;var f=(e,t)=>st(e,"name",{value:t,configurable:!0});import{chmod as it,stat as ce,readdir as at}from"node:fs/promises";import ue from"node:module";import{exit as F,versions as lt,env as z,cwd as pt}from"node:process";import{cyan as w,gray as P,bold as E,grey as ct,green as ut}from"@visulima/colorize";import{readFile as X,writeFile as U,readFileSync as mt,writeFileSync as dt,writeJsonSync as ft,collectSync as gt,ensureDirSync as ht,isAccessibleSync as yt,emptyDir as vt,walk as bt,isAccessible as $t}from"@visulima/fs";import{NotFoundError as jt}from"@visulima/fs/error";import{formatBytes as M}from"@visulima/humanizer";import{readTsConfig as wt,findTSConfig as kt,findPackageJson as xt}from"@visulima/package";import{createPail as Ot}from"@visulima/pail";import{MessageFormatterProcessor as Et,ErrorProcessor as Dt,CallerProcessor as _t}from"@visulima/pail/processor";import{resolve as h,join as I,normalize as H,extname as Y,relative as D,dirname as Z,basename as B,isAbsolute as me}from"@visulima/path";import{defu as Nt}from"defu";import{createHooks as St}from"hookable";import{minVersion as de}from"semver";import{a as _,E as fe}from"./shared/packem.Bj4QPFg7.mjs";import{pathToFileURL as Pt,fileURLToPath as Mt}from"node:url";import{resolvePath as Rt,resolveModuleExportNames as Ct,findStaticImports as ge}from"mlly";import N from"magic-string";import he from"jiti";import{watch as ye,rollup as ve}from"rollup";import be from"@rollup/plugin-alias";import Ft from"@rollup/plugin-commonjs";import It from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as q}from"@rollup/plugin-node-resolve";import $e from"@rollup/plugin-replace";import{wasm as Tt}from"@rollup/plugin-wasm";import{dts as At}from"rollup-plugin-dts";import Wt from"rollup-plugin-polyfill-node";import{visualizer as Bt}from"rollup-plugin-visualizer";import{glob as Jt}from"glob";import Lt from"glob-parent";import zt from"@rollup/plugin-json";import{createFilter as K,normalizePath as je}from"@rollup/pluginutils";import Ut from"rollup-plugin-license";import{parse as Ht}from"@babel/parser";import{existsSync as Q}from"node:fs";import{distance as qt}from"fastest-levenshtein";var Vt=Object.defineProperty,V=f((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"i$8");const ee=/^#![^\n]*/,te=V(async e=>{await it(e,493).catch(()=>{})},"makeExecutable"),Gt=V((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 N(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"&&ee.test(i.code)&&r.dir){const s=h(r.dir,o);await te(s)}}}),"shebangPlugin"),Xt=V(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ee,"")}}),"removeShebangPlugin"),Yt=V((e,t=`
|
|
3
|
+
`)=>{const r=ee.exec(e);return r?r+t:""},"getShebang");var Zt=Object.defineProperty,Kt=f((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"p$2");const oe=Kt((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 Qt=Object.defineProperty,eo=f((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"o$4");const to=eo((e,t)=>{const r=he(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 oo=Object.defineProperty,ro=f((e,t)=>oo(e,"name",{value:t,configurable:!0}),"r$6");const J=ro((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var no=Object.defineProperty,so=f((e,t)=>no(e,"name",{value:t,configurable:!0}),"u$8");const io=so(async e=>{const t=await Rt("jiti",{url:import.meta.url}),r=JSON.stringify({...e.options.stubOptions.jiti,alias:{...oe(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=H(to(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-Y(i).length)),c=await X(i),u=Yt(c);e.options.emitCJS&&await U(`${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 Ct(i,{extensions:_})}catch(l){J(e,`Cannot analyze ${i} for exports:${l}`);return}const a=p.includes("default")||p.length===0;await U(`${o}.mjs`,u+[`import jiti from ${JSON.stringify(Pt(t).href)};`,"",`const _jiti = jiti(null, ${r})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,a?`
|
|
5
|
+
export default _module;`:"",...p.filter(l=>l!=="default").map(l=>`export const ${l} = _module.${l};`)].join(`
|
|
6
|
+
`)),await U(`${o}.d.cts`,[`export * from ${JSON.stringify(s)};`,a?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
7
|
+
`)),await U(`${o}.d.mts`,[`export * from ${JSON.stringify(i)};`,a?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
8
|
+
`)),u&&(await te(`${o}.cjs`),await te(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var ao=Object.defineProperty,lo=f((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$a");const re=lo((e,t)=>e.some(r=>r instanceof RegExp?r.test(t):r===t),"arrayIncludes");var po=Object.defineProperty,co=f((e,t)=>po(e,"name",{value:t,configurable:!0}),"a$9");const T=co(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var uo=Object.defineProperty,mo=f((e,t)=>uo(e,"name",{value:t,configurable:!0}),"e$2");const ne=mo((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var fo=Object.defineProperty,go=f((e,t)=>fo(e,"name",{value:t,configurable:!0}),"m$4");const we=go(({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(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 l of c)if(!l.includes("type"))if(l.includes("as")){const[d,$]=l.split(" as ");if($==="default"&&(p=d,!e))continue;u.push($+": typeof "+d+";")}else u.push(l+": typeof "+l+";");const a=new N(n);return a.replace(" "+p+" as default,",""),a.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:
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"cjs-interop"}),{code:a.toString(),map:a.generateMap({hires:!0})}}return null}}),"cjsInterop");var ho=Object.defineProperty,yo=f((e,t)=>ho(e,"name",{value:t,configurable:!0}),"u$7");const vo=yo((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 Jt(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?H(s.dest):I(s.dest,D(s.parent,Z(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 ce(s);if(!p.isFile())return;const a=p.mtime.getTime();a>c.timestamp&&(c.timestamp=a,c.copied=[]),u=await X(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 a=B(s),l=I(p,a);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:l,source:u,type:"asset"}),t.debug({message:`copied ${s} → ${l}`,prefix:"copy"}),c.copied.push(p)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${l}`,prefix:"copy"})}}}))},name:"packem:copy"}},"copyPlugin");var bo=Object.defineProperty,$o=f((e,t)=>bo(e,"name",{value:t,configurable:!0}),"n$7");const ke="export default ",xe=$o(e=>{const t=zt(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(ke)&&(o.code=o.code.replace(ke,"module.exports = ")),o}}},"JSONPlugin");class jo{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 wo extends jo{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,a=this.should_remove;if(this.should_skip=s,this.should_remove=c,this.replacement=u,p)return t;if(a)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];Oe(p)&&(this.visit(p,t,i,u)||u--)}}else Oe(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 Oe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(Oe,"isNode");function Ee(e,{enter:t,leave:r}){return new wo(t,r).visit(e,null)}f(Ee,"walk");var ko=Object.defineProperty,xo=f((e,t)=>ko(e,"name",{value:t,configurable:!0}),"u$6");const Oo=xo(({attributes:e,logger:t})=>{const r=K([/\.[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(n);return Ee(i,{enter(u){if(u.type==="CallExpression"&&u.callee.type==="Identifier"&&u.callee.name==="jsx"){const p=u.arguments.filter(a=>a.type==="ObjectExpression"&&Array.isArray(a.properties));for(const a of p)for(const l of a.properties)l.type==="Property"&&l.key.type==="Literal"&&l.value.type==="Literal"&&e.includes(l.key.value)&&(c.overwrite(l.start-2,l.end,""),s=!0)}}}),s?{code:c.toString(),map:c.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Eo=Object.defineProperty,se=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"p$1");const Do=se(e=>{const t=[],r=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):r.push(n)}),[...r.sort(),...t.sort()]},"sortLicenses"),_o=se((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"),
|
|
18
|
+
$2`)},"replaceContentWithin"),De=se(({licenseFilePath:e,licenseTemplate:t,logger:r,marker:n,mode:o,packageName:i})=>Ut({thirdParty(s){const c=new Set,u=s.sort(({name:a},{name:l})=>a>l?1:l>a?-1:0).map(({author:a,contributors:l,license:d,licenseText:$,maintainers:j,name:x,repository:m})=>{let g=`## ${x}
|
|
19
19
|
`;d&&(g+=`License: ${d}
|
|
20
|
-
`);const y=new Set;for(const v of[
|
|
20
|
+
`);const y=new Set;for(const v of[a,...j,...l]){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}
|
|
22
22
|
`),$&&(g+=`
|
|
23
23
|
`+$.trim().replaceAll(/(\r\n|\r)/g,`
|
|
@@ -27,10 +27,10 @@ $2`)},"replaceContentWithin"),Ee=ne(({licenseFilePath:e,licenseTemplate:t,logger
|
|
|
27
27
|
`),d&&c.add(d),g}).join(`
|
|
28
28
|
---------------------------------------
|
|
29
29
|
|
|
30
|
-
`),p=t(
|
|
30
|
+
`),p=t(Do(c),u,i);try{const a=mt(e),l=_o(a,n,p);if(!l){r.error(`Could not find the license marker: <!-- ${n} --> in ${e}`);return}a!==l&&(dt(e,l),r.info({message:`${e} updated.`,prefix:`license:${o}`}))}catch(a){r.error(a)}}}),"license");var No=Object.defineProperty,So=f((e,t)=>No(e,"name",{value:t,configurable:!0}),"i$5");const Po=So(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");ft(r,t)},name:"packem:metafile"}),"metafilePlugin");var Mo=Object.defineProperty,Ro=f((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"c$4");const Co=/\.(?:m|c)?(?:j|t)sx?$/,Fo=/^use \w+$/,Io=Ro(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,a)=>(a&&a.forEach(l=>{p.add(l)}),p),new Set),c=new N(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=
|
|
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=Y(o);if(!Co.test(i))return null;let s=!1;const c=new N(n);if(n.startsWith("#")&&n[1]==="!"){let p=0;for(let a=2,l=n.length;a<l;a++){const d=n.codePointAt(a);if(d===10||d===13||d===8232||d===8233){p=a;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 a=null;"directive"in p?a=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&Fo.test(p.expression.value)&&(a=p.expression.value),a!=="use strict"&&a&&(t[o]||=new Set,t[o].add(a),"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 "${a}" 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 To=Object.defineProperty,Ao=f((e,t)=>To(e,"name",{value:t,configurable:!0}),"r$4");const Wo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Bo=Ao((e={})=>{e={...e,...Wo};const t=K(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 Jo=Object.defineProperty,Lo=f((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"l$3");const ie="\0__file_url__",_e=Lo(()=>({async load(e){if(e.startsWith(ie)){const t=Mt(e.slice(ie.length));return await X(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${ie}${e}`}}),"resolveFileUrl");var zo=Object.defineProperty,Ne=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"m$2");const Uo=/__filename|__dirname|require\(|require\.resolve\(/,Se=`
|
|
34
34
|
// -- pack CommonJS Shims --
|
|
35
35
|
import __cjs_url__ from "node:url";
|
|
36
36
|
import __cjs_path__ from "node:path";
|
|
@@ -38,27 +38,27 @@ import __cjs_mod__ from "node:module";
|
|
|
38
38
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
39
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
40
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,
|
|
41
|
+
`,Pe=`
|
|
42
42
|
// -- pack CommonJS Shims Node 20.11 --
|
|
43
43
|
import __cjs_mod__ from "node:module";
|
|
44
44
|
const __filename = import.meta.filename;
|
|
45
45
|
const __dirname = import.meta.dirname;
|
|
46
46
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
-
`,
|
|
47
|
+
`,Ho=Ne((e,t)=>{if(e.includes(Se)||e.includes(Pe)||!Uo.test(e))return null;const r=ge(e).pop(),n=r?r.end:0,o=new N(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),qo=Ne(e=>({name:"packem:cjs",renderChunk(t,r,n){if(n.format==="es"){let o=Se;if(e.engines?.node){const i=de(e.engines.node);i&&i.major>=20&&i.minor>=11&&(o=Pe)}return Ho(t,o)}return null}}),"cjsPlugin");var Vo=Object.defineProperty,R=f((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"s$a");const Go=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Xo=/MIT License|MIT license|BSD license/,Yo=/\n{2,}/g,Zo=/\b(\w+)\$\d+\b/g,Ko=/[-/\\^$*+?.()|[\]{}]/g,Qo=R(e=>e.replaceAll(Ko,"\\$&"),"escapeRegex"),er=R(e=>[...new Set(e)],"unique"),tr=R(e=>e.replaceAll(Go,t=>Xo.test(t)?"":t).replaceAll(Yo,`
|
|
48
48
|
|
|
49
|
-
`),"cleanUnnecessaryComments"),
|
|
50
|
-
- ${u}`).join(""),c=t.fileName.replace(/\.[^/.]+$/,"");
|
|
49
|
+
`),"cleanUnnecessaryComments"),Me=new Map;function Re(e,t,{identifierReplacements:r},n){const o=ge(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 a=u[p],l=Qo(p);a.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${l},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${l}\\b`,"g"),a)}}const i=er(Array.from(e.matchAll(Zo),s=>s[0]));if(i.length>0){const s=i.map(u=>`
|
|
50
|
+
- ${u}`).join(""),c=t.fileName.replace(/\.[^/.]+$/,"");Me.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"}),
|
|
52
|
+
To replace these, add them to the "patchTypes -> identifierReplacements" option in your packem config.`,prefix:"patch-types"}),Me.set(c,!0)}return e}f(Re,"v$2"),R(Re,"replaceConfusingTypeNames");function Ce(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(Ce,"N$2"),R(Ce,"removeInternal");function Fe(e,t){if(e.includes("@internal")){const r=new N(e),n=Ht(e,{plugins:["typescript"],sourceType:"module"});Ee(n,{enter(o){Ce(r,o)&&this.skip()}}),e=r.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),F(1))}return e}f(Fe,"S$1"),R(Fe,"stripInternalTypes");const or=R((e,t)=>({name:"packem:patch-types",renderChunk(r,n){return r=Re.call(this,r,n,e,t),r=Fe.call(this,r,n),r=tr(r),r},resolveId(r){return r.startsWith("types/")?{external:!0,id:"../../"+(r.endsWith(".js")?r:r+".js")}:null}}),"patchTypescriptTypes");var rr=Object.defineProperty,Ie=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"u$3");const Te=Ie((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(Z(n),o),c=[];if(i)for(const[u,p]of Object.entries(i)){const a=new RegExp(`^${[...u].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let l=0;for(const d of p){const $=[...je(h(s,d))].map(j=>j==="*"?`$${++l}`:j==="$"?"$$":j).join("");c.push({find:a,replacement:$})}}return t&&c.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...je(s)].map(u=>u==="$"?"$$":u).join("")}/$1`}),c},"getConfigAlias"),Ae=Ie((e,t)=>{const r=Te(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 nr=Object.defineProperty,We=f((e,t)=>nr(e,"name",{value:t,configurable:!0}),"u$2");const sr=We((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"),Be=We((e,t,r)=>{const n=sr(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 ir=Object.defineProperty,ar=f((e,t)=>ir(e,"name",{value:t,configurable:!0}),"r$3");const Je=ar(()=>{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 lr=Object.defineProperty,pr=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"s$9");const cr=pr(e=>{const t=B(e).split(".");if(t.length>=2){const[r,n]=t.slice(-2),o=t[0],i=/^(\w+)-runtime$/.exec(r)?.[1];if(_.includes(n)&&i&&i.length>0)return o+"-"+i}},"getCustomModuleLayer");var ur=Object.defineProperty,mr=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"i$2");const ae=mr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var dr=Object.defineProperty,Le=f((e,t)=>dr(e,"name",{value:t,configurable:!0}),"c$2");const ze=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=ae(c);if(!s){const p=r.get(n);if(p)return p;const a=cr(n);if(a)return r.set(n,a),a}if(s){const p=o.getModuleIds();for(const a of p)o.getModuleInfo(a)&&ae(c)===u&&(e.has(a)||e.set(a,new Set),e.get(a).add([n,u]))}if(u&&!s&&e.has(n)){const p=[...e.get(n)];if(p.some(([l])=>{if(console.log(l),t.some(d=>d.path===l)){const d=o.getModuleInfo(l);return ae(d?d.meta:{})===u}return!1}))return;if(p.every(([,l])=>l===u))return r.has(n)?r.get(n):void 0;const a=`${B(n,Y(n))}-${u}`;return r.set(n,a),a}},"splitChunks")},"createSplitChunks");var fr=Object.defineProperty,gr=f((e,t)=>fr(e,"name",{value:t,configurable:!0}),"n$5");const S=gr((e,t,r)=>t.isDynamicEntry?`chunks/[name].${r}`:`shared/${e.options.name}.[hash].${r}`,"getChunkFilename");var hr=Object.defineProperty,yr=f((e,t)=>hr(e,"name",{value:t,configurable:!0}),"s$7");const vr=process.platform==="win32",Ue=yr((e,t)=>{const r=vr?"\\":"/";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 br=Object.defineProperty,k=f((e,t)=>br(e,"name",{value:t,configurable:!0}),"e$1");const $r=k((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");if(t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5"),t.options.rollup.esbuild.jsx==="preserve"){let r="Packem does not support 'preserve' jsx option. Please use 'transform' or 'automatic' instead.";throw t.tsconfig?.config.compilerOptions?.jsx&&(r="Packem does not support '"+t.tsconfig.config.compilerOptions.jsx+"' jsx option. Please change it to 'react' or 'react-jsx' or 'react-jsxdev' instead."),new Error(r)}if(t.options.rollup.esbuild.target){const r=T(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...T(t.options.target),...r])])}else t.options.rollup.esbuild.target=T(t.options.target);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");if(typeof t.options.rollup.swc.env!="object"&&(t.options.rollup.swc.env={}),t.options.rollup.swc.env.targets){const r=T(t.options.rollup.swc.env.targets);r.some(n=>n.startsWith("node"))||(t.options.rollup.swc.env.targets=[...new Set([...T(t.options.target),...r])])}else t.options.rollup.swc.env.targets=T(t.options.target);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"),He=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"),
|
|
56
|
-
└─ ${D(process.cwd(),i)}`);if(e.logger.info(o),
|
|
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"),qe=new Map,Ve=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=Te(e.tsconfig,!1);return{external(o){const i=r(o);i&&(o=i);const s=ne(o),c=re(e.options.externals,s)||re(e.options.externals,o);if(c)return!0;if(o.startsWith(".")||me(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&&qe.has(o)&&e.logger.info('Inlined implicit external "'+w(o)+'". If this is incorrect, add it to the "externals" option.'),qe.set(o,!0),c},input:Object.fromEntries(e.options.entries.map(o=>[o.name,h(e.options.rootDir,o.input)])),onwarn(o,i){He(o,e)||o.code||i(o)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ge=k(async e=>{const t=oe(e,"build");return{...Ve(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=>Ue(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:ze(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=>Ue(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:ze(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[_e(),Je(),e.tsconfig&&Be(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Ae(e.tsconfig,e.logger),e.options.rollup.replace&&$e({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&be({customResolver:q({extensions:_,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&q({extensions:_,rootDir:e.rootDir,...e.options.rollup.resolve}),e.options.rollup.polyfillNode&&Wt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&xe({...e.options.rollup.json}),Io(e.logger),Gt(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&Tt(e.options.rollup.wsam),e.options.transformer?.($r(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&we({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&It(),e.options.rollup.commonjs&&Ft({extensions:_,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&qo(e.pkg),e.options.rollup.raw&&Bo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Oo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Po({outDir:h(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&vo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.template=="function"&&De({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&&Bt({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"),Xe=k(e=>{const t=oe(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,{...Ve(e,t),onwarn(o,i){He(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:[_e(),Je(),e.options.rollup.json&&xe({...e.options.rollup.json}),r,e.tsconfig&&Be(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Ae(e.tsconfig,e.logger),e.options.rollup.replace&&$e({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&be({customResolver:q({extensions:_,...e.options.rollup.resolve}),...e.options.rollup.alias,entries:t}),e.options.rollup.resolve&&q({extensions:_,...e.options.rollup.resolve}),At({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&&we({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&or(e.options.rollup.patchTypes,e.logger),Xt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&De({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 jr=Object.defineProperty,A=f((e,t)=>jr(e,"name",{value:t,configurable:!0}),"p");const Ye=A((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"),wr=A(async e=>{const t=await Ge(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=ye(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),Ye(r,"bundle",e.logger),e.options.declaration){const i=Xe(e);await e.hooks.callHook("rollup:dts:options",e,i);const s=ye(i);await e.hooks.callHook("rollup:watch",e,s),Ye(s,"types",e.logger)}},"watch"),kr=A(async e=>{const t=await Ge(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const r=await ve(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(a=>a.type==="chunk");for(const a of u){c.add(a.fileName);for(const l of a.imports)e.usedImports.add(l);a.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(a.code,"utf8"),chunks:a.imports.filter(l=>u.find(d=>d.fileName===l)),exports:a.exports,modules:Object.entries(a.modules).map(([l,d])=>({bytes:d.renderedLength,id:l})),path:a.fileName,type:"entry"})}const p=s.filter(a=>a.type==="asset");for(const a of p)o.has(a.fileName)||o.set(a.fileName,{bytes:Buffer.byteLength(a.source,"utf8"),path:a.fileName,type:"asset"});for(const a of c)e.usedImports.delete(a)}if(e.buildEntries.push(...o.values()),e.options.declaration){const i=Xe(e);if(await e.hooks.callHook("rollup:dts:options",e,i),Object.keys(i.input).length===0)return;const s=await ve(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:A(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:A(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:A(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 xr=Object.defineProperty,Or=f((e,t)=>xr(e,"name",{value:t,configurable:!0}),"i$1");const Ze=Or(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Er=Object.defineProperty,G=f((e,t)=>Er(e,"name",{value:t,configurable:!0}),"l$2");const Dr=K,_r=G((e,t)=>{const{sideEffects:r}=t;let n;if(typeof r=="boolean")n=G(()=>r,"hasSideEffects");else if(Array.isArray(r))if(r.length<=0)n=G(()=>!1,"hasSideEffects");else{const o=r.map(i=>i.includes("/")?i:`**/${i}`);n=Dr(o,null,{resolve:e})}else n=G(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Nr=Object.defineProperty,Sr=f((e,t)=>Nr(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,Ke=f((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"t$2");const le=Ke(e=>{if(e.endsWith(".d.ts")||e.endsWith(".mjs"))return"esm";if(e.endsWith(".cjs"))return"cjs"},"inferExportTypeFromFileName"),Qe=Ke((e,t,r,n)=>{if(r){const s=le(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 Qe(o,i,r,n)},"inferExportType");var Rr=Object.defineProperty,Cr=f((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"s$4");const pe=Cr((e,t,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=le(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:Qe(n,r,o,t)}:pe(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=H(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((a,l)=>a.split("/").length-l.split("/").length);const o=pe(e.exports,e.type||"commonjs");if(e.bin){const a=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const l of a)o.push({file:l,isExecutable:!0})}e.main&&o.push({file:e.main,type:le(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 a of o.filter(l=>!l.type)){const l=a.file.endsWith(".js");i&&l||a.file.endsWith(".mjs")?a.type="esm":(!i&&l||a.file.endsWith(".cjs"))&&(a.type="cjs")}let s=!1,c=!1,u=!1;const p=[];for(const a of o){const l=a.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),d=l.endsWith("/");if(d&&["./","/"].includes(l))continue;const $=Tr(l).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(!$){Q(h(r,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}a.type==="cjs"&&(s=!0),a.type==="esm"&&(c=!0);const j=p.find(x=>x.input===$)??p[p.push({input:$})-1];/\.d\.(?:m|c)?ts$/.test(a.file)&&(u=!0),d&&(j.outDir=l),a.isExecutable&&(j.isExecutable=!0)}return{cjs:s,dts:u,entries:p,esm:c,warnings:n}},"inferEntries");var Jr=Object.defineProperty,Lr=f((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"o$1");const zr=Lr(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(!Q(t))throw new Error("No 'src' directory found. Please provide entries manually.");const r=gt(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)J(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 et=Gr((e,t,r)=>{const n=he(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 Zr=Yr((e,t)=>(e==="auto"?e=qr:typeof e=="string"&&(e=et(e,t,{})),typeof e=="function"&&(e=e()),e),"resolvePreset");var Kr=Object.defineProperty,Qr=f((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"o");const en=Qr(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)!re(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(ne(o))&&!e.options.peerDependencies.includes(ne(o))&&n.add(o);r.size>0&&J(e,`Potential unused dependencies found: ${[...r].map(o=>w(o)).join(", ")}`),n.size>0&&J(e,`Potential implicit dependencies found: ${[...n].map(o=>w(o)).join(", ")}`)},"validateDependencies");var tn=Object.defineProperty,tt=f((e,t)=>tn(e,"name",{value:t,configurable:!0}),"i");const on=tt((e,t)=>qt(e,t)<=e.length/3||t.includes(e),"isSimilar"),rn=tt((e,t)=>{const r=e.toLowerCase();return t.filter(n=>on(n.toLowerCase(),r))},"findAlternatives");var nn=Object.defineProperty,ot=f((e,t)=>nn(e,"name",{value:t,configurable:!0}),"n");const sn=ot((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,...pe(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("*")&&!Q(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=ot(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?ct` (did you mean ${u.map(p=>`"${p}"`).join(", ")}?)`:"")}J(t,s)}},"validatePackage");var an=Object.defineProperty,C=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"g");const rt=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`."),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"),
|
|
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"),nt=C(async(e,t,r,n,o,i,s,c)=>{const u=Zr(o.preset??i.packem?.preset??n.preset??"auto",t);let p=`node${lt.node.split(".")[0]}`;if(i.engines?.node){const m=de(i.engines.node);m&&(p=`node${m.major}`)}const a=ln(s?.config.compilerOptions?.jsx),l=Nt(o,i.packem,n,u,{alias:{},clean:!0,declaration:!1,dependencies:[],devDependencies:[],emitCJS:!1,emitESM:!0,entries:[],externals:[...ue.builtinModules,...ue.builtinModules.map(m=>`node:${m}`)],failOnWarn:!0,minify:z.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*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:a,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:z.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(", ")}
|
|
@@ -70,22 +70,22 @@ The published ${y} artifact additionally contains code with the following licens
|
|
|
70
70
|
${m.join(", ")}
|
|
71
71
|
|
|
72
72
|
# Bundled dependencies:
|
|
73
|
-
`+g,"template")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:
|
|
73
|
+
`+g,"template")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:fe,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:z.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:a,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:z.NODE_ENV!=="production",pragma:s?.config.compilerOptions?.jsxFactory,pragmaFrag:s?.config.compilerOptions?.jsxFragmentFactory,runtime:a,throwIfNamespace:!0,useBuiltins:!0}}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:_r(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:fe}},rootDir:t,sourcemap:!1,stub:r==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},target:p,transformerName:void 0});if(!l.transformerName){const m=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(m.has("esbuild"))l.transformerName="esbuild";else if(m.has("@swc/core"))l.transformerName="swc";else if(m.has("sucrase"))l.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(l.transformerName)+'" as transformer.')}if(l.emitESM===!1&&l.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");l.outDir=h(l.rootDir,l.outDir),ht(l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.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:St(),logger:e,mode:r,options:l,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),l.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=me(m.input)?D(t,m.input):H(m.input);g.startsWith("./")&&(g=g.slice(2)),m.name=Pr(g.replace(/^src\//,""))}if(!m.input)throw new Error(`Missing entry input: ${Ze(m)}`);if(l.declaration!==void 0&&m.declaration===void 0&&(m.declaration=l.declaration),m.input=h(l.rootDir,m.input),!yt(m.input)){const g=new Set(await at(Z(m.input)));let y=!1;for(const v of _)if(g.has(B(m.input)+v)){y=!0;break}if(!y)throw new jt("Your configured entry: "+w(m.input)+" does not exist.")}m.outDir=h(l.rootDir,m.outDir??l.outDir)}l.dependencies=Object.keys(i.dependencies??{}),l.peerDependencies=Object.keys(i.peerDependencies??{}),l.devDependencies=Object.keys(i.devDependencies??{}),l.optionalDependencies=Object.keys(i.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),await d.hooks.callHook("build:before",d);let $="Building";if(r==="watch"?$="Watching":r==="jit"&&($="Stubbing"),e.info(w(`${$} ${l.name}`)),e.debug(`${E("Root dir:")} ${l.rootDir}
|
|
76
76
|
${E("Entries:")}
|
|
77
|
-
${d.options.entries.map(m=>` ${
|
|
78
|
-
`)}`),
|
|
77
|
+
${d.options.entries.map(m=>` ${Ze(m)}`).join(`
|
|
78
|
+
`)}`),l.clean)for(const m of new Set(d.options.entries.map(g=>g.outDir).filter(Boolean).sort()))m!==l.rootDir&&(c.push(m),e.info(`Cleaning dist directory: \`./${D(l.rootDir,m)}\``),await vt(m));if(l.stub){await io(d),await d.hooks.callHook("build:done",d);return}if(r==="watch"){await wr(d),rt(d,!1);return}await kr(d),e.success(ut(`Build succeeded for ${l.name}`));for await(const m of bt(l.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 ce(h(l.outDir,m.path));g.bytes=y.size}}const j=C(m=>D(d.rootDir,h(l.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
79
|
exports: `+P(m.exports.join(", ")):"",m.chunks?.length&&(y+=`
|
|
80
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
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(
|
|
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(W=>W.path.endsWith(v));if(O){let W;(d.options.declaration===!0||d.options.declaration==="compatible")&&!v.includes(".d.ts")&&(v=v.replace(b==="commonjs"?".d.c":".d.m",".d."),W=d.buildEntries.find(L=>L.path.endsWith(v))),y+=W&&b===i.type?`
|
|
85
85
|
types:
|
|
86
|
-
`+[O,
|
|
86
|
+
`+[O,W].map(L=>P(" └─ ")+E(j(L.path))+" (total size: "+w(M(L.bytes??0))+")").join(`
|
|
87
87
|
`):`
|
|
88
88
|
types: `+E(j(O.path))+" (total size: "+w(M(O.bytes??0))+")"}}x=!0,y+=`
|
|
89
89
|
|
|
90
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),
|
|
91
|
+
`),en(d),sn(i,d),await d.hooks.callHook("build:done",d),rt(d,x)},"build"),pn=C(async(e,t,r={})=>{const{configPath:n,debug:o,tsconfigPath:i,...s}=r,c=[new Et,new Dt];o&&c.push(new _t);const u=Ot({logLevel:o?"debug":"informational",processors:c,scope:"packem"});e=h(pt(),e);let p;if(i)await $t(i)||(u.error("tsconfig.json not found at",i),F(1)),p={config:wt(i),path:i},u.debug("Using tsconfig.json found at",i);else try{p=await kt(e),u.debug("Using "+B(p.path)+" found at",p.path)}catch{u.info("No tsconfig.json or jsconfig.json found.")}try{const{packageJson:a,path:l}=await xt(e);u.debug("Using package.json found at",l);const d=et(n??"./packem.config",e,[]),$=(Array.isArray(d)?d:[d]).filter(Boolean);if($.length===0)await nt(u,e,t,s,{},a,p,[]);else{const j=[];for(const x of $)await nt(u,e,t,s,x,a,p,j)}u.restoreAll(),F(0)}catch(a){u.error("An error occurred while building",a),F(1)}},"createBundler");export{pn as default};
|
|
@@ -98,6 +98,7 @@ type BuildEntry = {
|
|
|
98
98
|
name?: string;
|
|
99
99
|
outDir?: string;
|
|
100
100
|
};
|
|
101
|
+
type Target = "chrome" | "deno" | "edge" | "firefox" | "hermes" | "ie" | "ios" | "node" | "opera" | "rhino" | "safari" | "esnext" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023";
|
|
101
102
|
interface BuildOptions {
|
|
102
103
|
alias: Record<string, string>;
|
|
103
104
|
cjsInterop?: boolean;
|
|
@@ -123,7 +124,7 @@ interface BuildOptions {
|
|
|
123
124
|
stubOptions: {
|
|
124
125
|
jiti: Omit<JITIOptions, "onError" | "transform">;
|
|
125
126
|
};
|
|
126
|
-
target:
|
|
127
|
+
target: Target | Target[];
|
|
127
128
|
transformer?: (config: SwcPluginConfig | SucrasePluginConfig | EsbuildPluginConfig) => Plugin;
|
|
128
129
|
}
|
|
129
130
|
interface BuildHooks {
|
|
@@ -98,6 +98,7 @@ type BuildEntry = {
|
|
|
98
98
|
name?: string;
|
|
99
99
|
outDir?: string;
|
|
100
100
|
};
|
|
101
|
+
type Target = "chrome" | "deno" | "edge" | "firefox" | "hermes" | "ie" | "ios" | "node" | "opera" | "rhino" | "safari" | "esnext" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023";
|
|
101
102
|
interface BuildOptions {
|
|
102
103
|
alias: Record<string, string>;
|
|
103
104
|
cjsInterop?: boolean;
|
|
@@ -123,7 +124,7 @@ interface BuildOptions {
|
|
|
123
124
|
stubOptions: {
|
|
124
125
|
jiti: Omit<JITIOptions, "onError" | "transform">;
|
|
125
126
|
};
|
|
126
|
-
target:
|
|
127
|
+
target: Target | Target[];
|
|
127
128
|
transformer?: (config: SwcPluginConfig | SucrasePluginConfig | EsbuildPluginConfig) => Plugin;
|
|
128
129
|
}
|
|
129
130
|
interface BuildHooks {
|
|
@@ -98,6 +98,7 @@ type BuildEntry = {
|
|
|
98
98
|
name?: string;
|
|
99
99
|
outDir?: string;
|
|
100
100
|
};
|
|
101
|
+
type Target = "chrome" | "deno" | "edge" | "firefox" | "hermes" | "ie" | "ios" | "node" | "opera" | "rhino" | "safari" | "esnext" | "es5" | "es6" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023";
|
|
101
102
|
interface BuildOptions {
|
|
102
103
|
alias: Record<string, string>;
|
|
103
104
|
cjsInterop?: boolean;
|
|
@@ -123,7 +124,7 @@ interface BuildOptions {
|
|
|
123
124
|
stubOptions: {
|
|
124
125
|
jiti: Omit<JITIOptions, "onError" | "transform">;
|
|
125
126
|
};
|
|
126
|
-
target:
|
|
127
|
+
target: Target | Target[];
|
|
127
128
|
transformer?: (config: SwcPluginConfig | SucrasePluginConfig | EsbuildPluginConfig) => Plugin;
|
|
128
129
|
}
|
|
129
130
|
interface BuildHooks {
|