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