@visulima/packem 1.0.0-alpha.63 → 1.0.0-alpha.64
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 +6 -0
- package/dist/cli.mjs +2 -2
- package/dist/create-bundler.cjs +36 -36
- package/dist/create-bundler.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## @visulima/packem [1.0.0-alpha.64](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.63...@visulima/packem@1.0.0-alpha.64) (2024-08-04)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* fixed more tests, fixed package imports dont show external warning ([038f05d](https://github.com/visulima/packem/commit/038f05da499e90695eec4c25a475e7204bae1ed1))
|
|
6
|
+
|
|
1
7
|
## @visulima/packem [1.0.0-alpha.63](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.62...@visulima/packem@1.0.0-alpha.63) (2024-08-04)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/dist/cli.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import __cjs_mod__ from "node:module";
|
|
|
7
7
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
9
9
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
10
|
-
const xo="@visulima/packem",Eo="1.0.0-alpha.
|
|
10
|
+
const xo="@visulima/packem",Eo="1.0.0-alpha.63",T=[...Xt.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],Oo=["development","production"],Ye=["react-server","react-native","edge-light"];[...Oo,...Ye];const X=/node_modules/;var Do=Object.defineProperty,G=d((e,t)=>Do(e,"name",{value:t,configurable:!0}),"i$d");const ue=/^#![^\n]*/,ne=G(async e=>{await It(e,493).catch(()=>{})},"makeExecutable"),So=G((e,t=`#!/usr/bin/env node
|
|
11
11
|
`)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new P(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&ue.test(s.code)&&o.dir){const i=g(o.dir,n);await ne(i)}}}),"shebangPlugin"),No=G(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ue,"")}}),"removeShebangPlugin"),Po=G((e,t=`
|
|
12
12
|
`)=>{const o=ue.exec(e);return o?o+t:""},"getShebang");var _o=Object.defineProperty,Co=d((e,t)=>_o(e,"name",{value:t,configurable:!0}),"p$4");const de=Co((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const s=r[n];typeof s=="string"&&(o[n]=h(e.options.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Mo=Object.defineProperty,Io=d((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o$3");const Fo=Io((e,t)=>{const o=Ve(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var Ro=Object.defineProperty,To=d((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"r$a");const B=To((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ao=Object.defineProperty,Bo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"u$9");const Jo=Bo(async e=>{const t=await eo("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...de(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,r.name),s=ae(Fo(r.input,e.options.rootDir)||r.input),i=s.slice(0,Math.max(0,s.length-le(s).length)),a=await ie(s),l=Po(a);e.options.emitCJS&&await J(`${n}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
|
|
13
13
|
`));let c=[];try{c=await to(s,{extensions:T})}catch(u){B(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await J(`${n}.mjs`,l+[`import jiti from ${JSON.stringify(Zt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
|
|
@@ -61,7 +61,7 @@ const require = __cjs_mod__.createRequire(import.meta.url);
|
|
|
61
61
|
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Se.set(a,!0)}return e}d(pt,"I$1");F(pt,"replaceConfusingTypeNames");function ut(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(ut,"N");F(ut,"removeInternal");function dt(e,t){if(e.includes("@internal")){const o=new P(e),r=fo(e,{plugins:["typescript"],sourceType:"module"});if(rt(r,{enter(n){ut(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}d(dt,"S");F(dt,"stripInternalTypes");const an=F((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=pt.call(this,o,r,e,t),o=dt.call(this,o,r),o=sn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var ln=Object.defineProperty,mt=d((e,t)=>ln(e,"name",{value:t,configurable:!0}),"u$5");const ft=mt((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=g(ce(r),n),a=[];if(s)for(const[l,c]of Object.entries(s)){const p=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of c){const f=[...je(g(i,m))].map(b=>b==="*"?"$"+(++u+""):b==="$"?"$$":b).join("");a.push({find:p,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...je(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),gt=mt((e,t)=>{const o=ft(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(r)){const l=r.replace(i,a),c=await this.resolve(l,n,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var cn=Object.defineProperty,ht=d((e,t)=>cn(e,"name",{value:t,configurable:!0}),"u$4");const pn=ht((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(g(e,i))}return s},"getRootDirectories"),yt=ht((e,t,o)=>{const r=pn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=h(a,n),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var un=Object.defineProperty,dn=d((e,t)=>un(e,"name",{value:t,configurable:!0}),"r$3");const vt=dn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var mn=Object.defineProperty,fn=d((e,t)=>mn(e,"name",{value:t,configurable:!0}),"s$9");const gn=fn(e=>{const t=H(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var hn=Object.defineProperty,yn=d((e,t)=>hn(e,"name",{value:t,configurable:!0}),"i$4");const ee=yn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var vn=Object.defineProperty,Ne=d((e,t)=>vn(e,"name",{value:t,configurable:!0}),"c$5");const Pe=Ne((e,t)=>{const o=new Map;return Ne(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,a=s.meta,l=ee(a);if(!i){const c=o.get(r);if(c)return c;const p=gn(r);if(p)return o.set(r,p),p}if(i){const c=n.getModuleIds();for(const p of c)n.getModuleInfo(p)&&ee(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,l]))}if(l&&!i&&e.has(r)){const c=[...e.get(r)];if(c.some(([u])=>{if(t.some(m=>m.path===u)){const m=n.getModuleInfo(u);return ee(m?m.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(r)?o.get(r):void 0;const p=`${H(r,le(r))}-${l}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var bn=Object.defineProperty,$n=d((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n");const N=$n((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var wn=Object.defineProperty,jn=d((e,t)=>wn(e,"name",{value:t,configurable:!0}),"s$7");const kn=process.platform==="win32",_e=jn((e,t)=>{const o=kn?"\\":"/";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 xn=Object.defineProperty,w=d((e,t)=>xn(e,"name",{value:t,configurable:!0}),"p$2");const En=w((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"+_t.node.split(".")[0];if(t.pkg.engines?.node){const r=Ge(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=Z(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...Z(o),...r])])}else t.options.rollup.esbuild.target=Z(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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),bt=w((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v(D(g(),e.id))}"
|
|
62
62
|
Is the module installed? Note:
|
|
63
63
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
64
|
-
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Ce=new Map,$t=w((e,t,o)=>{const r=w(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=ft(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=Qe(s);if(se(e.options.externals,a)||se(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||We(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name))return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return Ce.has(s)||e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ce.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
64
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Ce=new Map,$t=w((e,t,o)=>{const r=w(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=ft(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=Qe(s);if(se(e.options.externals,a)||se(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||We(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name)||l?.imports?.[s]!==void 0)return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return Ce.has(s)||e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ce.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
65
65
|
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){bt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),wt=w(async(e,t)=>{const o=de(e,"build");let r;return e.options.rollup.resolve&&(r=k(ze({extensions:T,...e.options.rollup.resolve}),t)),{...$t(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:w(n=>N(e,n,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>_e(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Pe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:w(n=>N(e,n,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>_e(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Pe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(it(),t),k(vt(),t),e.tsconfig&&k(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&qe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&He({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&io({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ot({...e.options.rollup.json}),Jr(e.logger),So(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&so(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&br(h(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(En(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&no(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(ro({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Kr(e.pkg),e.options.rollup.raw&&Ur(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Or({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Cr({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&yr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&nt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ao({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"),On=w(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Dn=dr(On),jt=w(async(e,t)=>{const o=de(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k(ze({extensions:T,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...$t(e,o,"dts"),onwarn(a,l){bt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:w(a=>N(e,a,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:w(a=>N(e,a,"d.mts"),"chunkFileNames"),dir:g(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:w(a=>N(e,a,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(it(),t),k(vt(),t),e.options.rollup.json&&ot({...e.options.rollup.json}),r,e.tsconfig&&k(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&qe({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&He({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await Dn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&tt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&an(e.options.rollup.patchTypes,e.logger),No(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&nt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Sn=Object.defineProperty,Nn=d((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"c$4");const te=Nn(async(e,t)=>{const o=await wt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-build.json";o.cache=t.get(r);const n=await Le(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=new Map;for(const i of o.output){const{output:a}=await n.write(i),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>c.find(f=>f.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,f])=>({bytes:f.renderedLength,id:m})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)s.has(u.fileName)||s.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(...s.values())},"build");var Pn=Object.defineProperty,L=d((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"s$6");const oe=L(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await jt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-dts.json";o.cache=t.get(r);const n=await Le(o);t.set(r,n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:L(s=>N(e,s,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:L(s=>N(e,s,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:L(s=>N(e,s,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var _n=Object.defineProperty,he=d((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i$2");const Cn=he(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
|
|
66
66
|
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),Mn=he(e=>`
|
|
67
67
|
${e.replaceAll(/^\n|\n$/g,"")}
|
package/dist/create-bundler.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use strict";var lt=Object.defineProperty;var f=(e,t)=>lt(e,"name",{value:t,configurable:!0});const z=require("node:fs/promises"),ct=require("node:module"),E=require("node:process"),h=require("@visulima/colorize"),y=require("@visulima/fs"),pt=require("@visulima/fs/error"),S=require("@visulima/humanizer"),ut=require("@visulima/package/package-json"),d=require("@visulima/path"),le=require("@visulima/tsconfig"),dt=require("defu"),ft=require("hookable"),T=require("rollup"),O=require("./shared/packem.NVRVuzg1.cjs"),Ee=require("node:url"),J=require("mlly"),mt=require("magic-string"),gt=require("jiti"),U=require("node:fs"),ht=require("@rollup/plugin-alias"),yt=require("@rollup/plugin-commonjs"),vt=require("@rollup/plugin-dynamic-import-vars"),xe=require("@rollup/plugin-node-resolve"),bt=require("@rollup/plugin-replace"),$t=require("@rollup/plugin-wasm"),wt=require("rollup-plugin-polyfill-node"),jt=require("rollup-plugin-visualizer"),Oe=require("semver"),kt=require("glob"),Et=require("glob-parent"),I=require("@rollup/pluginutils"),xt=require("@rollup/plugin-json"),Ot=require("rollup-plugin-license"),Dt=require("node:crypto"),St=require("@babel/parser"),_t=require("@visulima/find-cache-dir"),Nt=require("fastest-levenshtein");var ce=typeof document<"u"?document.currentScript:null;const x=f(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),pe=x(ct),N=x(mt),De=x(gt),Se=x(ht),Pt=x(yt),Mt=x(vt),_e=x(bt),Ft=x(wt),Ct=x(Et),It=x(xt),Rt=x(Ot);var Tt=Object.defineProperty,H=f((e,t)=>Tt(e,"name",{value:t,configurable:!0}),"i$d");const te=/^#![^\n]*/,Z=H(async e=>{await z.chmod(e,493).catch(()=>{})},"makeExecutable"),At=H((e,t=`#!/usr/bin/env node
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(o,r
|
|
3
|
-
`)=>{const o=te.exec(e);return o?o+t:""},"getShebang");var Bt=Object.defineProperty,Jt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"p$3");const oe=Jt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:
|
|
4
|
-
`));let c=[];try{c=await J.resolveModuleExportNames(s,{extensions:O.DEFAULT_EXTENSIONS})}catch(u){A(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await y.writeFile(`${
|
|
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 N(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"&&te.test(s.code)&&o.dir){const i=d.resolve(o.dir,r);await Z(i)}}}),"shebangPlugin"),qt=H(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(te,"")}}),"removeShebangPlugin"),Lt=H((e,t=`
|
|
3
|
+
`)=>{const o=te.exec(e);return o?o+t:""},"getShebang");var Bt=Object.defineProperty,Jt=f((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"p$3");const oe=Jt((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]=d.join(e.options.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 Wt=Object.defineProperty,zt=f((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"o$3");const Ut=zt((e,t)=>{const o=De(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 Ht=Object.defineProperty,Vt=f((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"r$9");const A=Vt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Xt=Object.defineProperty,Gt=f((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"u$9");const Yt=Gt(async e=>{const t=await J.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:ce&&ce.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...oe(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=d.resolve(e.options.rootDir,e.options.outDir,n.name),s=d.normalize(Ut(n.input,e.options.rootDir)||n.input),i=s.slice(0,Math.max(0,s.length-d.extname(s).length)),a=await y.readFile(s),l=Lt(a);e.options.emitCJS&&await y.writeFile(`${r}.cjs`,l+[`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 c=[];try{c=await J.resolveModuleExportNames(s,{extensions:O.DEFAULT_EXTENSIONS})}catch(u){A(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await y.writeFile(`${r}.mjs`,l+[`import jiti from ${JSON.stringify(Ee.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
|
|
5
5
|
export default _module;`:"",...c.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
|
|
6
|
-
`)),await y.writeFile(`${
|
|
7
|
-
`)),await y.writeFile(`${
|
|
8
|
-
`)),l&&(await Z(`${
|
|
9
|
-
module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+
|
|
6
|
+
`)),await y.writeFile(`${r}.d.cts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
7
|
+
`)),await y.writeFile(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
8
|
+
`)),l&&(await Z(`${r}.cjs`),await Z(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Kt=Object.defineProperty,Qt=f((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"r$8");const Ne=Qt((e,t)=>De(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Zt=Object.defineProperty,Pe=f((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"t$5");const W=Pe(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Me=Pe((e,t,o,n)=>{if(o){const i=W(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 Me(r,s,o,n)},"inferExportType");var eo=Object.defineProperty,to=f((e,t)=>eo(e,"name",{value:t,configurable:!0}),"n$7");const ne=to((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=W(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,key:"exports",type:r??s}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>r==="types"&&o===!1?[]:typeof s=="string"?{file:s,key:"exports",...["browser","default","deno","development","import","node","node-addons","production","require","types"].includes(r)?{subKey:r}:{},type:Me(r,n,s,t)}:ne(s,t,o,[...n,r]))},"extractExportFilenames");var oo=Object.defineProperty,re=f((e,t)=>oo(e,"name",{value:t,configurable:!0}),"y$1");const no=re(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(E.env.NODE_ENV){if(!E.env.NODE_ENV.includes("production")&&!E.env.NODE_ENV.includes("development"))throw new Error(`Invalid NODE_ENV value: ${E.env.NODE_ENV}, must be either "production" or "development".`);return E.env.NODE_ENV}return"production"},"getEnvironment"),q=re((e,t,o,n,r,s)=>{const i=e.find(a=>a.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=n),r.isExecutable)i.executable=!0,i.declaration=!1,r.type==="cjs"&&(i.cjs=!0),r.type==="esm"&&(i.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&s!==!1&&(i.declaration=s),r.type==="cjs"&&(i.cjs=!0),r.type==="esm"&&(i.esm=!0);for(const a of O.RUNTIME_EXPORT_CONVENTIONS)if(r.file.includes("."+a+".")){i.runtime=a;break}}i.runtime===void 0&&(i.runtime="node"),i.environment=no(r)},"createOrUpdateEntry"),ue=/(?:\.d\.[mc]?ts|\.\w+)$/;let de=!1;const ro=re((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs",s=ne(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=W(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type}".`);s.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&s.push({file:e.main,key:"main",type:W(e.main)??r}),e.module&&s.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&s.push({file:e.types??e.typings,key:"types"});const i=[];for(const a of s){const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const p=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if(a.file.includes("/*")&&a.key==="exports"){de||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),de=!0);const g=[],b=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const $ of t)b.test($)&&g.push($.replace(ue,""));if(g.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const $ of g)q(i,$,c,l,a,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),m=t.find(g=>u.test(g))?.replace(ue,"");if(!m){U.existsSync(d.resolve(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}y.isAccessibleSync(m+".cts")&&y.isAccessibleSync(m+".mts")?(q(i,m+".cts",c,l,{...a,type:"cjs"},o.options.declaration),q(i,m+".mts",c,l,{...a,type:"esm"},o.options.declaration)):q(i,m,c,l,a,o.options.declaration)}return{entries:i,warnings:n}},"inferEntries");var so=Object.defineProperty,io=f((e,t)=>so(e,"name",{value:t,configurable:!0}),"t$4");const ao=io((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 lo=Object.defineProperty,co=f((e,t)=>lo(e,"name",{value:t,configurable:!0}),"t$3");const po={hooks:{"build:prepare":co(function(e){if(e.options.entries.length>0)return;const t=d.join(e.options.rootDir,e.options.sourceDir);if(!U.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=y.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=ao(n,e.options.declaration));const r=ro(n,o,e);for(const s of r.warnings)A(e,s);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h.cyan(e.options.entries.map(s=>h.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),h.gray([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var uo=Object.defineProperty,fo=f((e,t)=>uo(e,"name",{value:t,configurable:!0}),"t$2");const mo=fo((e,t)=>(e==="auto"?e=po:typeof e=="string"&&(e=Ne(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var go=Object.defineProperty,ho=f((e,t)=>go(e,"name",{value:t,configurable:!0}),"a$c");const ee=ho((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var yo=Object.defineProperty,vo=f((e,t)=>yo(e,"name",{value:t,configurable:!0}),"a$b");const X=vo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var bo=Object.defineProperty,$o=f((e,t)=>bo(e,"name",{value:t,configurable:!0}),"a$a");const Fe=$o((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var wo=Object.defineProperty,Ce=f((e,t)=>wo(e,"name",{value:t,configurable:!0}),"s$c");const jo=Ce((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 a=e(...r);return n.set(s,a),a}},"memoize"),ko=Ce(e=>{const t=new Map;return o=>jo(e,o,t)},"memoizeByKey");var Eo=Object.defineProperty,xo=f((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"m$6");const Ie=xo(({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 a=new N(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
9
|
+
module.exports.default = `+i[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.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 a=i[1].split(", "),l=[];let c="";for(const u of a)if(!u.includes("type"))if(u.includes("as")){const[m,g]=u.split(" as ");if(g==="default"&&(c=m,!e))continue;l.push(g+": typeof "+m+";")}else l.push(u+": typeof "+u+";");const p=new N(n);return p.replace(" "+c+" as default,",""),p.append(`
|
|
10
10
|
|
|
11
11
|
declare const defaultExport: {
|
|
12
12
|
`+(l.length>0?" ":"")+l.join(`
|
|
13
13
|
`)+`
|
|
14
14
|
} & typeof `+c+`;
|
|
15
15
|
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var Oo=Object.defineProperty,Do=f((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"f$5");const So=Do((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(a=>({...i,src:a})):i).map(async i=>await kt.glob(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:Ct(i.src),src:a}))));for(const i of s)for(const a of i.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?d.normalize(i.dest):d.join(i.dest,d.relative(i.parent,d.dirname(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let l;try{const c=await z.stat(i);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),l=await y.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const p=d.basename(i),u=d.join(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:u,source:l,type:"asset"}),t.debug({message:`copied ${i} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${i} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var _o=Object.defineProperty,fe=f((e,t)=>_o(e,"name",{value:t,configurable:!0}),"c$8");const No=fe(e=>(t,o={})=>{const n=I.createFilter(o.include,o.exclude),r={},s=fe((i,a)=>{r[i.replace(/\..?[jt]s$/,"")]=a},"addOutput");return{generateBundle(i,a){let{entryFileNames:l}=i;typeof l=="function"&&(l=l(a));const c=l.replace(/\.(.)?[jt]s$/,(p,u)=>`.d.${u||""}ts`);for(const[p,u]of Object.entries(r))this.emitFile({fileName:c.replace("[name]",d.relative(e,p)),source:u,type:"asset"})},name:"packem:isolated-declarations",async transform(i,a){if(!n(a))return;const l=await t(a,i),{errors:c,sourceText:p}=l;c.length>0?o.ignoreErrors?this.warn(c[0]):this.error(c[0]):s(a,p)}}},"isolatedDeclarationsPlugin");var Po=Object.defineProperty,Mo=f((e,t)=>Po(e,"name",{value:t,configurable:!0}),"n$2");const me="export default ",Re=Mo(e=>{const t=It(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(me)&&(r.code=r.code.replace(me,"module.exports = ")),r}}},"JSONPlugin");class Fo{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,o,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 Co extends Fo{static{f(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(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,a=this.should_remove,l=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 c=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=l,c)return t;if(p)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let l=0;l<a.length;l+=1){const c=a[l];ge(c)&&(this.visit(c,t,s,l)||l--)}}else ge(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=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 l=this.should_remove;if(this.replacement=i,this.should_remove=a,l)return null}}return t}}function ge(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(ge,"isNode");function Te(e,{enter:t,leave:o}){return new Co(t,o).visit(e,null)}f(Te,"walk");var Io=Object.defineProperty,Ro=f((e,t)=>Io(e,"name",{value:t,configurable:!0}),"u$7");const To=Ro(({attributes:e,logger:t})=>{const o=I.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(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let i=!1;const a=new N(n);return Te(s,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(a.overwrite(u.start-2,u.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Ao=Object.defineProperty,se=f((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"g$4");const qo=se(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Lo=se((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"),Ae=se(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:
|
|
18
|
+
$2`)},"replaceContentWithin"),Ae=se(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:s,packageName:i})=>Rt({thirdParty(a){const l=new Set,c=a.sort(({name:u},{name:m})=>(u||0)>(m||0)?1:(m||0)>(u||0)?-1:0).map(({author:u,contributors:m,license:g,licenseText:b,maintainers:$,name:D,repository:v})=>{let P="## "+D+`
|
|
19
19
|
`;g&&(P+=`License: ${g}
|
|
20
20
|
`);const V=new Set;for(const C of[u,...$,...m]){const ae=typeof C=="string"?C:C?.name;ae&&V.add(ae)}return V.size>0&&(P+=`By: ${[...V].join(", ")}
|
|
21
21
|
`),v&&(P+=`Repository: ${typeof v=="string"?v:v.url}
|
|
22
22
|
`),b&&(P+=`
|
|
23
23
|
`+b.trim().replaceAll(/\r\n|\r/g,`
|
|
24
|
-
`).replaceAll(`<!-- ${
|
|
24
|
+
`).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
|
|
25
25
|
`).map(C=>C?`> ${C}`:">").join(`
|
|
26
26
|
`)+`
|
|
27
27
|
`),g&&l.add(g),P}).join(`
|
|
28
28
|
---------------------------------------
|
|
29
29
|
|
|
30
|
-
`);if(c===""){
|
|
30
|
+
`);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+s});return}const p=o(qo(l),c,i);try{const u=y.readFileSync(t),m=Lo(u,r,p);if(!m){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+s});return}u!==m&&(y.writeFileSync(t,m),n.info({message:`${t} updated.`,prefix:"plugin:license:"+s}))}catch(u){n.error(u)}}}),"license");var Bo=Object.defineProperty,Jo=f((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"i$9");const Wo=Jo(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=d.resolve(e.rootDir,e.outDir,"graph.json");y.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var zo=Object.defineProperty,Uo=f((e,t)=>zo(e,"name",{value:t,configurable:!0}),"r$5");const M=Uo(e=>{const t=Dt.createHash("md5");return t.update(e),t.digest("hex")},"getHash");var Ho=Object.defineProperty,qe=f((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"m$4");const R=qe(e=>e.handler||e,"getHandler"),k=qe((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await R(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await R(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=d.join("load",M(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await R(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const s=d.join("resolveId",M(o),n?M(n):"",M(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const i=await R(e.resolveId).call(this,o,n,r);return t.set(s,i,e.name),i},async transform(o,n){if(!e.transform)return null;const r=d.join("transform",M(n),M(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await R(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var Vo=Object.defineProperty,Xo=f((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"c$6");const Go=/\.(?:m|c)?(?:j|t)sx?$/,Yo=/^use \w+$/,Ko=Xo(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(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),a=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(c=>`'${c}';`).join(`
|
|
31
31
|
`)}
|
|
32
|
-
`));let l=null;return
|
|
33
|
-
`)),i.size===0&&l===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r
|
|
32
|
+
`));let l=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(l=o[r.facadeModuleId]),l&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${l}
|
|
33
|
+
`)),i.size===0&&l===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=d.extname(r);if(!Go.test(s))return null;let i=!1;const a=new N(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let p=2,u=n.length;p<u;p++){const m=n.codePointAt(p);if(m===10||m===13||m===8232||m===8233){c=p;break}}c&&(o[r]=n.slice(0,c),a.remove(0,c+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(c),null}if(l.type!=="Program")return null;for(const c of l.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let p=null;"directive"in c?p=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Yo.test(c.expression.value)&&(p=c.expression.value),p!=="use strict"&&p&&(t[r]||=new Set,t[r].add(p),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(a.remove(c.start,c.end),i=!0),e.debug({message:`directive "${p}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Qo=Object.defineProperty,Zo=f((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"r$4");const en={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},tn=Zo((e={})=>{e={...e,...en};const t=I.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 on=Object.defineProperty,nn=f((e,t)=>on(e,"name",{value:t,configurable:!0}),"l$4");const G="\0__file_url__",Le=nn(()=>({async load(e){if(e.startsWith(G)){const t=Ee.fileURLToPath(e.slice(G.length));return await y.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${G}${e}`}}),"resolveFileUrl");var rn=Object.defineProperty,Be=f((e,t)=>rn(e,"name",{value:t,configurable:!0}),"i$5");const sn=/__filename|__dirname|require\(|require\.resolve\(/,Je=`
|
|
34
34
|
// -- pack CommonJS Shims --
|
|
35
35
|
import __cjs_url__ from "node:url";
|
|
36
36
|
import __cjs_path__ from "node:path";
|
|
@@ -44,28 +44,28 @@ 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
|
+
`,an=Be((e,t)=>{if(E.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Je)||e.includes(We)||!sn.test(e)))return null;const o=J.findStaticImports(e).pop(),n=o?o.end:0,r=new N(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),ln=Be(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=Je;if(e.engines?.node){const s=Oe.minVersion(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=We)}return an(t,r)}return null}}),"cjsPlugin");var cn=Object.defineProperty,F=f((e,t)=>cn(e,"name",{value:t,configurable:!0}),"r$3");const pn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,un=/MIT License|MIT license|BSD license/,dn=/\n{2,}/g,fn=/\b(\w+)\$\d+\b/g,mn=/[-/\\^$*+?.()|[\]{}]/g,gn=F(e=>e.replaceAll(mn,"\\$&"),"escapeRegex"),hn=F(e=>[...new Set(e)],"unique"),yn=F(e=>e.replaceAll(pn,t=>un.test(t)?"":t).replaceAll(dn,`
|
|
48
48
|
|
|
49
|
-
`),"cleanUnnecessaryComments"),he=new Map;function ze(e,t,{identifierReplacements:o},
|
|
50
|
-
- ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");he.has(a)||
|
|
49
|
+
`),"cleanUnnecessaryComments"),he=new Map;function ze(e,t,{identifierReplacements:o},n){const r=J.findStaticImports(e);for(const i in o){const a=r.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=o[i];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${i}" for replacement`);const p=l[c],u=gn(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const s=hn(Array.from(e.matchAll(fn),i=>i[0]));if(s.length>0){const i=s.map(l=>`
|
|
50
|
+
- ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");he.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
51
51
|
|
|
52
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),he.set(a,!0)}return e}f(ze,"I$1");F(ze,"replaceConfusingTypeNames");function Ue(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}f(Ue,"N");F(Ue,"removeInternal");function He(e,t){if(e.includes("@internal")){const o=new N(e),
|
|
52
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),he.set(a,!0)}return e}f(ze,"I$1");F(ze,"replaceConfusingTypeNames");function Ue(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}f(Ue,"N");F(Ue,"removeInternal");function He(e,t){if(e.includes("@internal")){const o=new N(e),n=St.parse(e,{plugins:["typescript"],sourceType:"module"});if(Te(n,{enter(r){Ue(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}f(He,"S");F(He,"stripInternalTypes");const vn=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=ze.call(this,o,n,e,t),o=He.call(this,o,n),o=yn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var bn=Object.defineProperty,Ve=f((e,t)=>bn(e,"name",{value:t,configurable:!0}),"u$5");const Xe=Ve((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=d.resolve(d.dirname(n),r),a=[];if(s)for(const[l,c]of Object.entries(s)){const p=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of c){const g=[...I.normalizePath(d.resolve(i,m))].map(b=>b==="*"?"$"+(++u+""):b==="$"?"$$":b).join("");a.push({find:p,replacement:g})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...I.normalizePath(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),Ge=Ve((e,t)=>{const o=Xe(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(n)){const l=n.replace(i,a),c=await this.resolve(l,r,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var $n=Object.defineProperty,Ye=f((e,t)=>$n(e,"name",{value:t,configurable:!0}),"u$4");const wn=Ye((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(d.resolve(e,i))}return s},"getRootDirectories"),Ke=Ye((e,t,o)=>{const n=wn(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 a of n){const l=d.join(a,r),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var jn=Object.defineProperty,kn=f((e,t)=>jn(e,"name",{value:t,configurable:!0}),"r$2");const Qe=kn(()=>{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 En=Object.defineProperty,xn=f((e,t)=>En(e,"name",{value:t,configurable:!0}),"s$8");const On=xn(e=>{const t=d.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 Dn=Object.defineProperty,Sn=f((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"i$4");const Y=Sn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var _n=Object.defineProperty,ye=f((e,t)=>_n(e,"name",{value:t,configurable:!0}),"c$4");const ve=ye((e,t)=>{const o=new Map;return ye(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,a=s.meta,l=Y(a);if(!i){const c=o.get(n);if(c)return c;const p=On(n);if(p)return o.set(n,p),p}if(i){const c=r.getModuleIds();for(const p of c)r.getModuleInfo(p)&&Y(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,l]))}if(l&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([u])=>{if(t.some(m=>m.path===u)){const m=r.getModuleInfo(u);return Y(m?m.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(n)?o.get(n):void 0;const p=`${d.basename(n,d.extname(n))}-${l}`;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var Nn=Object.defineProperty,Pn=f((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"n");const _=Pn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Mn=Object.defineProperty,Fn=f((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"s$6");const Cn=process.platform==="win32",be=Fn((e,t)=>{const o=Cn?"\\":"/";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 In=Object.defineProperty,w=f((e,t)=>In(e,"name",{value:t,configurable:!0}),"p$1");const Rn=w((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"+E.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=Oe.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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Ze=w((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${h.cyan(d.relative(d.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".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),$e=new Map,et=w((e,t,o)=>{const
|
|
56
|
-
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Ze(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),tt=w(async(e,t)=>{const o=oe(e,"build");let
|
|
57
|
-
`;return
|
|
55
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),$e=new Map,et=w((e,t,o)=>{const n=w(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),r=Xe(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const a=Fe(s);if(ee(e.options.externals,a)||ee(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||d.isAbsolute(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name)||l?.imports?.[s]!==void 0)return!1;if(r){for(const{find:c}of r)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return $e.has(s)||e.logger.info({message:'Inlined implicit external "'+h.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),$e.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,d.resolve(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
56
|
+
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Ze(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),tt=w(async(e,t)=>{const o=oe(e,"build");let n;return e.options.rollup.resolve&&(n=k(xe.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t)),{...et(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:w(r=>_(e,r,"cjs"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:w(r=>be(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ve(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:w(r=>_(e,r,"mjs"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:w(r=>be(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:ve(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Le(),t),k(Qe(),t),e.tsconfig&&k(Ke(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(Ge(e.tsconfig,e.logger),t),e.options.rollup.replace&&_e({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Se({customResolver:n?.resolveId,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Ft({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Re({...e.options.rollup.json}),Ko(e.logger),At(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&$t.wasm(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&No(d.join(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(Rn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ie({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Mt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Pt({extensions:O.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&ln(e.pkg),e.options.rollup.raw&&tn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&To({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Wo({outDir:d.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&So(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ae({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&jt.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"),Tn=w(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"),An=ko(Tn),ot=w(async(e,t)=>{const o=oe(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let s;e.options.rollup.resolve&&(s=k(xe.nodeResolve({extensions:O.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...et(e,o,"dts"),onwarn(a,l){Ze(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:w(a=>_(e,a,"d.cts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:w(a=>_(e,a,"d.mts"),"chunkFileNames"),dir:d.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:w(a=>_(e,a,"d.ts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(Le(),t),k(Qe(),t),e.options.rollup.json&&Re({...e.options.rollup.json}),n,e.tsconfig&&k(Ke(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(Ge(e.tsconfig,e.logger),t),e.options.rollup.replace&&_e({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Se({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await An(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ie({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&vn(e.options.rollup.patchTypes,e.logger),qt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ae({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var qn=Object.defineProperty,Ln=f((e,t)=>qn(e,"name",{value:t,configurable:!0}),"c$3");const K=Ln(async(e,t)=>{const o=await tt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=new Map;for(const i of o.output){const{output:a}=await r.write(i),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>c.find(g=>g.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,g])=>({bytes:g.renderedLength,id:m})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)s.has(u.fileName)||s.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(...s.values())},"build");var Bn=Object.defineProperty,L=f((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"s$5");const Q=L(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await ot(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await T.rollup(o);t.set(n,r.cache),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:L(s=>_(e,s,"d.cts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:L(s=>_(e,s,"d.mts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await r.write({chunkFileNames:L(s=>_(e,s,"d.ts"),"chunkFileNames"),dir:d.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Jn=Object.defineProperty,ie=f((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"i$2");const Wn=ie(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
|
|
57
|
+
`;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),zn=ie(e=>`
|
|
58
58
|
${e.replaceAll(/^\n|\n$/g,"")}
|
|
59
|
-
`,"normalizeCodeFrame"),
|
|
59
|
+
`,"normalizeCodeFrame"),nt=ie(e=>{const t=Wn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
|
|
60
60
|
file: ${h.cyan(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
|
|
61
|
-
`+h.yellow(
|
|
62
|
-
${t}`)},"enhanceRollupError");var
|
|
63
|
-
└─ ${d.relative(process.cwd(),i)}`);if(e.logger.info(s),we(
|
|
64
|
-
- `+h.cyan(a)+(l.length>0?h.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}A(t,i)}},"validatePackage");var
|
|
61
|
+
`+h.yellow(zn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
|
|
62
|
+
${t}`)},"enhanceRollupError");var Un=Object.defineProperty,rt=f((e,t)=>Un(e,"name",{value:t,configurable:!0}),"l$3");const we=rt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${h.cyan(d.relative(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:h.cyan("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:h.cyan(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{nt(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Hn=rt(async(e,t)=>{const o=await tt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[d.join(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=T.watch(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const i of r)s+=h.gray(`
|
|
63
|
+
└─ ${d.relative(process.cwd(),i)}`);if(e.logger.info(s),we(n,"bundle",e.logger),e.options.declaration){const i=await ot(e,t);await e.hooks.callHook("rollup:dts:options",e,i);const a=T.watch(i);await e.hooks.callHook("rollup:watch",e,a),we(a,"types",e.logger)}},"watch");var Vn=Object.defineProperty,Xn=f((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"i$1");const st=Xn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Gn=Object.defineProperty,Yn=f((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"a$3");class Kn{static{f(this,"p")}static{Yn(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#s;constructor(t,o,n){this.#n=t,this.#e=_t.findCacheDirSync("@visulima/packem",{cwd:t}),this.#r=o,this.#s=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:y.isAccessibleSync(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!y.isAccessibleSync(n))return;const r=y.readFileSync(n);try{const s=JSON.parse(r);return this.#o.set(n,s),s}catch{this.#s.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),U.rmSync(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),y.writeFileSync(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(d.toNamespacedPath(this.#n),"");return n=n.replaceAll(":","-"),d.join(this.#e,this.#r,o?.replaceAll(":","-")??"",d.toNamespacedPath(n))}}var Qn=Object.defineProperty,B=f((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"l$2");const Zn=I.createFilter,er=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=Zn(r,null,{resolve:e})}else n=B(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var tr=Object.defineProperty,or=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"y");const nr=or((e,t,o)=>e.reduce((n,r)=>{const s=r[t],i=r[o];return n[s]||(n[s]={}),n[s][i]||(n[s][i]=[]),n[s][i].push(r),n},{}),"groupByKeys");var rr=Object.defineProperty,sr=f((e,t)=>rr(e,"name",{value:t,configurable:!0}),"a$2");const ir=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,ar=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),je=sr(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(ir.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(ar.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=d.resolve(o);if(!y.isAccessibleSync(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var lr=Object.defineProperty,cr=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"o");const pr=cr(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(e.pkg.dependencies)for(const r of Object.keys(e.pkg.dependencies))o.delete(r);for(const r of t){const s=Fe(r);!ee(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg.dependencies?.[s]===void 0&&e.pkg.peerDependencies?.[s]===void 0&&n.add(r)}o.size>0&&A(e,`Potential unused dependencies found: ${[...o].map(r=>h.cyan(r)).join(", ")}`),n.size>0&&A(e,`Potential implicit dependencies found: ${[...n].map(r=>h.cyan(r)).join(", ")}`)},"validateDependencies");var ur=Object.defineProperty,it=f((e,t)=>ur(e,"name",{value:t,configurable:!0}),"i");const dr=it((e,t)=>Nt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),fr=it((e,t)=>{const o=e.toLowerCase();return t.filter(n=>dr(n.toLowerCase(),o))},"findAlternatives");var mr=Object.defineProperty,ke=f((e,t)=>mr(e,"name",{value:t,configurable:!0}),"s");const gr=ke((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&&d.resolve(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!U.existsSync(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=ke(a=>d.relative(t.options.rootDir,d.resolve(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>r(a.path));let i="Potential missing or wrong package.json files:";for(const a of n){const l=fr(a,s);i+=`
|
|
64
|
+
- `+h.cyan(a)+(l.length>0?h.grey` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}A(t,i)}},"validatePackage");var hr=Object.defineProperty,j=f((e,t)=>hr(e,"name",{value:t,configurable:!0}),"h");const at=j((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
65
65
|
`),e.logger.warn(`Build is done with some warnings:
|
|
66
66
|
|
|
67
67
|
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
68
|
-
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),
|
|
68
|
+
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),yr=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"),vr=j((e,t,o,n,r,s,i,a,l)=>{const c=yr(l?.config.compilerOptions?.jsx),p=dt.defu(s,r,i,{alias:{},clean:!0,debug:n,declaration:!0,emitCJS:!0,emitESM:!0,entries:[],externals:[...pe.builtinModules,...pe.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:E.env.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",outDir:"dist",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,moduleResolution:100,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,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:O.EXCLUDE_REGEXP,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:j((u,m,g)=>`
|
|
69
69
|
# Licenses of bundled dependencies
|
|
70
70
|
The published ${g} artifact additionally contains code with the following licenses:
|
|
71
71
|
`+(u.length>0?`${u.join(", ")}
|
|
@@ -79,24 +79,24 @@ The published ${g} artifact additionally contains code with the following licens
|
|
|
79
79
|
|
|
80
80
|
`:`
|
|
81
81
|
`)+`# Bundled types:
|
|
82
|
-
`+m,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:O.EXCLUDE_REGEXP,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:E.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: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,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:E.env.NODE_ENV!=="production",pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:
|
|
82
|
+
`+m,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:O.EXCLUDE_REGEXP,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:E.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: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,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:E.env.NODE_ENV!=="production",pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:er(t,a),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:O.EXCLUDE_REGEXP}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let m="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",m=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",m=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",m=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+h.cyan("rollup ")+T.VERSION),e.info({message:"Using "+h.cyan(p.transformerName)+" "+m,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.devDependencies?.typescript&&!l?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
83
83
|
Because none of the third-party transpiler, 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.
|
|
84
|
-
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&&p.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&p.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&p.externals.push(...Object.keys(a.optionalDependencies)),je(p.alias),p.rollup.alias&&p.rollup.alias.entries&&je(p.rollup.alias.entries),p},"generateOptions"),
|
|
84
|
+
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&&p.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&p.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&p.externals.push(...Object.keys(a.optionalDependencies)),je(p.alias),p.rollup.alias&&p.rollup.alias.entries&&je(p.rollup.alias.entries),p},"generateOptions"),br=j(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),$r=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=d.isAbsolute(o.input)?d.relative(t,o.input):d.normalize(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=br(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${st(o)}`);if(o.input=d.resolve(e.options.rootDir,o.input),!y.isAccessibleSync(o.input)){const n=new Set(await z.readdir(d.dirname(o.input)));let r=!1;for(const s of O.DEFAULT_EXTENSIONS)if(n.has(d.basename(o.input)+s)){r=!0;break}if(!r)throw new pt.NotFoundError("Your configured entry: "+h.cyan(o.input)+" does not exist.")}o.outDir=d.resolve(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),wr=j((e,t,o)=>{const n=j(s=>d.relative(t.options.rootDir,d.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 l of s.chunks??[])i+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let a=` ${h.bold(n(s.path))} (${["total size: "+h.cyan(S.formatBytes(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+h.cyan(S.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
|
|
85
85
|
exports: `+h.gray(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
|
|
86
|
-
${s.chunks.map(l=>{const c=t.buildEntries.find(p=>p.path===l)??{};return h.gray(" └─ "+
|
|
87
|
-
`)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>h.gray(" 📦 "+
|
|
86
|
+
${s.chunks.map(l=>{const c=t.buildEntries.find(p=>p.path===l)??{};return h.gray(" └─ "+n(l)+h.bold(c.bytes?" ("+S.formatBytes(c?.bytes)+")":""))}).join(`
|
|
87
|
+
`)}`),s.modules&&s.modules.length>0){const l=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>h.gray(" 📦 "+n(c.id)+h.bold(c.bytes?" ("+S.formatBytes(c.bytes)+")":""))).join(`
|
|
88
88
|
`);a+=l.length>0?`
|
|
89
89
|
inlined modules:
|
|
90
90
|
`+l:""}if(t.options.declaration&&s.type==="entry"){let l=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?l=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",l=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(l));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(m=>m.path.endsWith(l))),a+=u&&c===o.type?`
|
|
91
91
|
types:
|
|
92
|
-
`+[p,u].map(m=>h.gray(" └─ ")+h.bold(
|
|
92
|
+
`+[p,u].map(m=>h.gray(" └─ ")+h.bold(n(m.path))+" (total size: "+h.cyan(S.formatBytes(m.bytes??0))+")").join(`
|
|
93
93
|
`):`
|
|
94
|
-
types: `+h.bold(
|
|
94
|
+
types: `+h.bold(n(p.path))+" (total size: "+h.cyan(S.formatBytes(p.bytes??0))+")"}}r=!0,a+=`
|
|
95
95
|
|
|
96
|
-
`,e.raw(s.chunk?h.gray(a):a)}return
|
|
97
|
-
`),
|
|
96
|
+
`,e.raw(s.chunk?h.gray(a):a)}return r&&e.raw("Σ Total dist size (byte size):",h.cyan(S.formatBytes(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
|
|
97
|
+
`),r},"showSizeInformation"),jr=j(async(e,t,o,n,r,s,i,a)=>{const l=mo(s.preset??r.preset??"auto",t),c=vr(e,t,o,n,r,s,l,i,a);y.ensureDirSync(d.join(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:ft.createHooks(),logger:e,mode:o,options:c,pkg:i,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.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&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&a===void 0&&i.devDependencies?.typescript)throw new Error(" Cannot build declaration files without a tsconfig.json");return p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled."),i.devDependencies?.typescript||(p.options.declaration=!1),p.options.declaration||p.logger.info("Declaration files, are disabled."),p},"createContext"),kr=j(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${d.relative(e.options.rootDir,o)}\``),await y.emptyDir(o))},"cleanDistributionDirectories"),Er=j(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=nr(e.options.entries,"environment","runtime"),r=[];for(const[i,a]of Object.entries(n))for(const[l,c]of Object.entries(a)){e.logger.info("Preparing build for "+h.cyan(i)+" environment with "+h.cyan(l)+" runtime"),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:i},l==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime="edge-runtime")):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const p=[],u=[],m=[];for(const g of c)g.cjs&&g.esm?p.push(g):g.cjs?m.push(g):g.esm&&u.push(g);if(p.length>0){const g={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:p}};r.push(K(g,o));const b=g.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&r.push(Q({...g,options:{...g.options,entries:b}},o))}if(u.length>0){const g={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:u}};r.push(K(g,o));const b=g.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&r.push(Q({...g,options:{...g.options,entries:b}},o))}if(m.length>0){const g={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:m}};r.push(K(g,o));const b=g.options.entries.filter($=>$.declaration);e.options.declaration&&b.length>0&&r.push(Q({...g,options:{...g.options,entries:b}},o))}}await Promise.all(r),e.logger.success(h.green(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const i of y.walk(d.join(e.options.rootDir,e.options.outDir))){let a=e.buildEntries.find(l=>d.join(e.options.rootDir,e.options.outDir,l.path)===i.path);if(a||(a={chunk:!0,path:i.path},e.buildEntries.push(a)),!a.bytes){const l=await z.stat(d.resolve(e.options.rootDir,e.options.outDir,i.path));a.bytes=l.size}}const s=wr(e.logger,e,t);pr(e),gr(t,e),await e.hooks.callHook("build:done",e),at(e,s)},"build"),xr=j(async(e,t,o,n={})=>{const{configPath:r,debug:s,tsconfigPath:i,...a}=n;o.wrapAll(),e=d.resolve(E.cwd(),e),o.debug("Root directory:",e);const l=d.join(e,"package.json");if(!y.isAccessibleSync(l))throw new Error("package.json not found at "+l);const c=ut.parsePackageJson(l);o.debug("Using package.json found at",l);let p;if(i){const u=d.join(e,i);if(!await y.isAccessible(u))throw new Error("tsconfig.json not found at "+u);p={config:le.readTsConfig(u),path:u},o.info("Using tsconfig settings at",u)}else if(c.devDependencies?.typescript)try{p=await le.findTsConfig(e),o.debug("Using tsconfig settings found at",p.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";if(!/\.(?:js|mjs|cjs|ts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed.");const m=Ne(u,e);o.debug("Using packem config found at",d.join(e,u));const g=Date.now(),b=j(()=>S.duration(Math.floor(Date.now()-g)),"getDuration"),$=M(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types})),D=new Kn(e,$,o);D.cachePath&&!y.isAccessibleSync(d.join(D.cachePath,$))&&y.isAccessibleSync(D.cachePath)&&(o.info("Clearing file cache because the cache key has changed."),await y.emptyDir(D.cachePath));const v=await jr(o,e,t,s??!1,a,m,c,p);if(D.isEnabled=v.options.fileCache,await $r(v,e),v.logger.info(h.cyan((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+v.options.name)),v.logger.debug(`${h.bold("Root dir:")} ${v.options.rootDir}
|
|
98
98
|
${h.bold("Entries:")}
|
|
99
99
|
${v.options.entries.map(P=>` ${st(P)}`).join(`
|
|
100
|
-
`)}`),await
|
|
100
|
+
`)}`),await kr(v),v.options.stub){await Yt(v),await v.hooks.callHook("build:done",v);return}if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Hn(v,D),at(v,!1);return}await Er(v,c,D),o.raw(`
|
|
101
101
|
⚡️ Build run in `+b()),o.restoreAll()}catch(u){throw o.raw(`
|
|
102
|
-
`),
|
|
102
|
+
`),nt(u),u}},"createBundler");module.exports=xr;
|
package/dist/create-bundler.mjs
CHANGED
|
@@ -60,7 +60,7 @@ const require = __cjs_mod__.createRequire(import.meta.url);
|
|
|
60
60
|
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),xe.set(a,!0)}return e}d(nt,"I$1");R(nt,"replaceConfusingTypeNames");function st(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(st,"N");R(st,"removeInternal");function it(e,t){if(e.includes("@internal")){const o=new _(e),r=so(e,{plugins:["typescript"],sourceType:"module"});if(Xe(r,{enter(n){st(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}d(it,"S");R(it,"stripInternalTypes");const Lr=R((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=nt.call(this,o,r,e,t),o=it.call(this,o,r),o=Wr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var zr=Object.defineProperty,at=d((e,t)=>zr(e,"name",{value:t,configurable:!0}),"u$5");const lt=at((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=g(ie(r),n),a=[];if(s)for(const[l,c]of Object.entries(s)){const p=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of c){const f=[...ve(g(i,m))].map(v=>v==="*"?"$"+(++u+""):v==="$"?"$$":v).join("");a.push({find:p,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...ve(i)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),ct=at((e,t)=>{const o=lt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(r)){const l=r.replace(i,a),c=await this.resolve(l,n,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Ur=Object.defineProperty,pt=d((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"u$4");const Hr=pt((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(g(e,i))}return s},"getRootDirectories"),ut=pt((e,t,o)=>{const r=Hr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=b(a,n),c=await this.resolve(l,s,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var Vr=Object.defineProperty,qr=d((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"r$2");const dt=qr(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var Yr=Object.defineProperty,Gr=d((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"s$8");const Kr=Gr(e=>{const t=H(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var Xr=Object.defineProperty,Qr=d((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"i$4");const Q=Qr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Zr=Object.defineProperty,Ee=d((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"c$4");const Oe=Ee((e,t)=>{const o=new Map;return Ee(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,a=s.meta,l=Q(a);if(!i){const c=o.get(r);if(c)return c;const p=Kr(r);if(p)return o.set(r,p),p}if(i){const c=n.getModuleIds();for(const p of c)n.getModuleInfo(p)&&Q(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,l]))}if(l&&!i&&e.has(r)){const c=[...e.get(r)];if(c.some(([u])=>{if(t.some(m=>m.path===u)){const m=n.getModuleInfo(u);return Q(m?m.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(r)?o.get(r):void 0;const p=`${H(r,se(r))}-${l}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var en=Object.defineProperty,tn=d((e,t)=>en(e,"name",{value:t,configurable:!0}),"n");const N=tn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var on=Object.defineProperty,rn=d((e,t)=>on(e,"name",{value:t,configurable:!0}),"s$6");const nn=process.platform==="win32",De=rn((e,t)=>{const o=nn?"\\":"/";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 sn=Object.defineProperty,w=d((e,t)=>sn(e,"name",{value:t,configurable:!0}),"p$1");const an=w((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"+Et.node.split(".")[0];if(t.pkg.engines?.node){const r=ze(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=K(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...K(o),...r])])}else t.options.rollup.esbuild.target=K(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")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),mt=w((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${y(D(g(),e.id))}"
|
|
61
61
|
Is the module installed? Note:
|
|
62
62
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
63
|
-
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Se=new Map,ft=w((e,t,o)=>{const r=w(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=lt(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=qe(s);if(oe(e.options.externals,a)||oe(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||Fe(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name))return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return Se.has(s)||e.logger.info({message:'Inlined implicit external "'+y(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Se.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
63
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Se=new Map,ft=w((e,t,o)=>{const r=w(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=lt(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=qe(s);if(oe(e.options.externals,a)||oe(e.options.externals,s))return!0;const{pkg:l}=e;if(s.startsWith(".")||Fe(s)||/src[/\\]/.test(s)||l.name&&s.startsWith(l.name)||l?.imports?.[s]!==void 0)return!1;if(n){for(const{find:c}of n)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return Se.has(s)||e.logger.info({message:'Inlined implicit external "'+y(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Se.set(s,!0),!1},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:w((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
64
64
|
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){mt(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),gt=w(async(e,t)=>{const o=ce(e,"build");let r;return e.options.rollup.resolve&&(r=k(We({extensions:T,...e.options.rollup.resolve}),t)),{...ft(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:w(n=>N(e,n,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>De(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Oe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:w(n=>N(e,n,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:w(n=>De(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Oe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(et(),t),k(dt(),t),e.tsconfig&&k(ut(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ct(e.tsconfig,e.logger),t),e.options.rollup.replace&&Le({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Be({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Qt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ke({...e.options.rollup.json}),jr(e.logger),co(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&Xt(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&tr(b(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(an(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ge({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Kt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Gt({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Mr(e.pkg),e.options.rollup.raw&&Or(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&lr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&fr({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Zo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Qe({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&Zt({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"),ln=w(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"),cn=Yo(ln),ht=w(async(e,t)=>{const o=ce(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k(We({extensions:T,...e.options.rollup.resolve}),t));const i="dts-plugin:"+process.pid+e.tsconfig.path;return{...ft(e,o,"dts"),onwarn(a,l){mt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:w(a=>N(e,a,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:w(a=>N(e,a,"d.mts"),"chunkFileNames"),dir:g(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:w(a=>N(e,a,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(et(),t),k(dt(),t),e.options.rollup.json&&Ke({...e.options.rollup.json}),r,e.tsconfig&&k(ut(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(ct(e.tsconfig,e.logger),t),e.options.rollup.replace&&Le({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Be({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await cn(i)(e),e.options.cjsInterop&&e.options.emitCJS&&Ge({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Lr(e.options.rollup.patchTypes,e.logger),po(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Qe({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var pn=Object.defineProperty,un=d((e,t)=>pn(e,"name",{value:t,configurable:!0}),"c$3");const Z=un(async(e,t)=>{const o=await gt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-build.json";o.cache=t.get(r);const n=await Te(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=new Map;for(const i of o.output){const{output:a}=await n.write(i),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>c.find(f=>f.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,f])=>({bytes:f.renderedLength,id:m})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)s.has(u.fileName)||s.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(...s.values())},"build");var dn=Object.defineProperty,L=d((e,t)=>dn(e,"name",{value:t,configurable:!0}),"s$5");const ee=L(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await ht(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-dts.json";o.cache=t.get(r);const n=await Te(o);t.set(r,n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:L(s=>N(e,s,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:L(s=>N(e,s,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:L(s=>N(e,s,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var mn=Object.defineProperty,me=d((e,t)=>mn(e,"name",{value:t,configurable:!0}),"i$2");const fn=me(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
|
|
65
65
|
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),gn=me(e=>`
|
|
66
66
|
${e.replaceAll(/^\n|\n$/g,"")}
|