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