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