@visulima/packem 1.0.0-alpha.22 → 1.0.0-alpha.24
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 +15 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +3 -3
- 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 +1 -93
- 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 +2 -94
- package/dist/shared/{packem.BK03IQfP.d.ts → packem.BzWrDnY8.d.ts} +1 -0
- package/dist/shared/{packem.CGAPjagQ.d.cts → packem.CnhGR3os.d.cts} +1 -0
- package/dist/shared/{packem.BchP_OVQ.d.mts → packem.DDrQsBAR.d.mts} +1 -0
- package/dist/shared/packem.DnU5ZLGg.cjs +93 -0
- package/dist/shared/packem.SDzDIaD5.mjs +101 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## @visulima/packem [1.0.0-alpha.24](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.23...@visulima/packem@1.0.0-alpha.24) (2024-05-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added file cache to rollup, added support of es5 ([c6734ac](https://github.com/visulima/packem/commit/c6734ac079db193d1c88e473cf01361a728c9bdd))
|
|
7
|
+
* added option to disable cache ([9ee5cac](https://github.com/visulima/packem/commit/9ee5cacb3db1f1e59419f5a00f0f245a5be43d3a))
|
|
8
|
+
|
|
9
|
+
## @visulima/packem [1.0.0-alpha.23](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.22...@visulima/packem@1.0.0-alpha.23) (2024-05-29)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* removed packem from package.json. fixed test runs ([05b346a](https://github.com/visulima/packem/commit/05b346a57749147fb7f5cbd810112eaf01ec2a56))
|
|
15
|
+
|
|
1
16
|
## @visulima/packem [1.0.0-alpha.22](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.21...@visulima/packem@1.0.0-alpha.22) (2024-05-29)
|
|
2
17
|
|
|
3
18
|
|
package/dist/cli.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var b=Object.defineProperty;var r=(n,e)=>b(n,"name",{value:e,configurable:!0});const k=require("@visulima/cerebro"),m=require("./shared/packem.DnU5ZLGg.cjs"),s=require("node:process"),h=require("@antfu/install-pkg"),i=require("@clack/prompts"),c=require("@visulima/fs"),j=require("@visulima/package/package-json"),l=require("@visulima/path"),w=r(n=>n&&typeof n=="object"&&"default"in n?n.default:n,"_interopDefaultCompat"),x=w(k);var C=Object.defineProperty,p=r((n,e)=>C(n,"name",{value:e,configurable:!0}),"n");const P=p(n=>{n.addCommand({description:"Demonstrate options required",execute:p(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const o={};if(e.env)for(const a of e.env)o[a.key]=a.value;await m.Oe(e.dir,t,{cjsInterop:e.cjsInterop,configPath:e.config??void 0,debug:e.debug,minify:e.minify,replace:{...o},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:p(e=>{const[t,o]=e.split("=");return{key:t,value:o}},"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");var S=Object.defineProperty,y=r((n,e)=>S(n,"name",{value:e,configurable:!0}),"i");const q=y(n=>{n.addCommand({description:"Initialize packem configuration",execute:y(async({logger:e,options:t})=>{if(i.intro("Welcome to packem setup"),c.isAccessibleSync(l.join(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),s.exit(0);if(i.isCancel(t.transformer))return i.cancel("Operation cancelled"),s.exit(0);if(t.transformer===void 0){const d=l.join(t.dir,"package.json");if(!c.isAccessibleSync(d))return e.error("No package.json found in the directory"),s.exit(1);const f=j.parsePackageJson(d),v=[...Object.keys(f.dependencies??{}),...Object.keys(f.devDependencies??{})];if(t.transformer=await i.select({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!v.includes(t.transformer)&&await i.confirm({message:"Do you want to install "+t.transformer+"?"})){const g=i.spinner();g.start("Installing "+t.transformer),await h.installPackage(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),g.stop("")}}const o=`import { defineConfig } from "@visulima/packem/config";
|
|
3
3
|
import transformer from "@visulima/packem/transformer/${t.transformer}";
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
6
|
transformer
|
|
7
7
|
});
|
|
8
|
-
`,
|
|
8
|
+
`,a=i.spinner();return a.start("Creating packem.config.ts"),c.writeFileSync(l.join(t.dir,"packem.config.ts"),o),a.stop("Created packem.config.ts"),i.outro("Now you can run `packem build` to build your project"),s.exit(0)},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),u=new x("packem",{packageName:m.name,packageVersion:m.version});q(u);P(u);u.run();
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var v=Object.defineProperty;var r=(i,e)=>v(i,"name",{value:e,configurable:!0});import
|
|
2
|
+
var v=Object.defineProperty;var r=(i,e)=>v(i,"name",{value:e,configurable:!0});import b from"@visulima/cerebro";import{O as k,n as h,v as j}from"./shared/packem.SDzDIaD5.mjs";import{exit as a}from"node:process";import{installPackage as w}from"@antfu/install-pkg";import{intro as C,isCancel as x,cancel as P,select as S,confirm as z,spinner as f,outro as B}from"@clack/prompts";import{isAccessibleSync as u,writeFileSync as O}from"@visulima/fs";import{parsePackageJson as I}from"@visulima/package/package-json";import{join as s}from"@visulima/path";
|
|
3
3
|
// -- pack CommonJS Shims --
|
|
4
4
|
import __cjs_url__ from "node:url";
|
|
5
5
|
import __cjs_path__ from "node:path";
|
|
@@ -7,10 +7,10 @@ import __cjs_mod__ from "node:module";
|
|
|
7
7
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
9
9
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
10
|
-
|
|
10
|
+
var N=Object.defineProperty,c=r((i,e)=>N(i,"name",{value:e,configurable:!0}),"n");const V=c(i=>{i.addCommand({description:"Demonstrate options required",execute:c(async({options:e})=>{let t="build";e.watch?t="watch":e.jit&&(t="jit");const n={};if(e.env)for(const o of e.env)n[o.key]=o.value;await k(e.dir,t,{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:c(e=>{const[t,n]=e.split("=");return{key:t,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");var D=Object.defineProperty,g=r((i,e)=>D(i,"name",{value:e,configurable:!0}),"i");const E=g(i=>{i.addCommand({description:"Initialize packem configuration",execute:g(async({logger:e,options:t})=>{if(C("Welcome to packem setup"),u(s(t.dir,"packem.config.ts")))return e.info("Packem project already initialized, you can use `packem build` to build your project"),a(0);if(x(t.transformer))return P("Operation cancelled"),a(0);if(t.transformer===void 0){const p=s(t.dir,"package.json");if(!u(p))return e.error("No package.json found in the directory"),a(1);const l=I(p),y=[...Object.keys(l.dependencies??{}),...Object.keys(l.devDependencies??{})];if(t.transformer=await S({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!y.includes(t.transformer)&&await z({message:"Do you want to install "+t.transformer+"?"})){const d=f();d.start("Installing "+t.transformer),await w(t.transformer==="swc"?"@swc/core":t.transformer,{cwd:t.dir,dev:!0,silent:!0}),d.stop("")}}const n=`import { defineConfig } from "@visulima/packem/config";
|
|
11
11
|
import transformer from "@visulima/packem/transformer/${t.transformer}";
|
|
12
12
|
|
|
13
13
|
export default defineConfig({
|
|
14
14
|
transformer
|
|
15
15
|
});
|
|
16
|
-
`,o=f();return o.start("Creating packem.config.ts"),
|
|
16
|
+
`,o=f();return o.start("Creating packem.config.ts"),O(s(t.dir,"packem.config.ts"),n),o.stop("Created packem.config.ts"),B("Now you can run `packem build` to build your project"),a(0)},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),m=new b("packem",{packageName:h,packageVersion:j});E(m);V(m);m.run();
|
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.CnhGR3os.cjs';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.CnhGR3os.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.DDrQsBAR.mjs';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.DDrQsBAR.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.BzWrDnY8.js';
|
|
2
|
+
export { b as BuildHooks } from './shared/packem.BzWrDnY8.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,93 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const s=new N(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&Y.test(s.code)&&o.dir){const i=f.resolve(o.dir,r);await H(i)}}}),"shebangPlugin"),xt=L(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Y,"")}}),"removeShebangPlugin"),Et=L((e,t=`
|
|
3
|
-
`)=>{const o=Y.exec(e);return o?o+t:""},"getShebang");var Ot=Object.defineProperty,_t=d((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"p$1");const K=_t((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const s=n[r];typeof s=="string"&&(o[r]=f.join(e.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var St=Object.defineProperty,Dt=d((e,t)=>St(e,"name",{value:t,configurable:!0}),"o$3");const Nt=Dt((e,t)=>{const o=ye(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Pt=Object.defineProperty,Mt=d((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"r$8");const C=Mt((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ft=Object.defineProperty,It=d((e,t)=>Ft(e,"name",{value:t,configurable:!0}),"u$6");const Ct=It(async e=>{const t=await A.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:oe&&oe.src||new URL("create-bundler.cjs",document.baseURI).href}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...K(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=f.resolve(e.options.rootDir,e.options.outDir,n.name),s=f.normalize(Nt(n.input,e.options.rootDir)||n.input),i=s.slice(0,Math.max(0,s.length-f.extname(s).length)),a=await b.readFile(s),p=Et(a);e.options.emitCJS&&await b.writeFile(`${r}.cjs`,p+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
|
|
4
|
-
`));let l=[];try{l=await A.resolveModuleExportNames(s,{extensions:D.DEFAULT_EXTENSIONS})}catch(c){C(e,`Cannot analyze ${s} for exports:${c}`);return}const u=l.includes("default")||l.length===0;await b.writeFile(`${r}.mjs`,p+[`import jiti from ${JSON.stringify(fe.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
|
|
5
|
-
export default _module;`:"",...l.filter(c=>c!=="default").map(c=>`export const ${c} = _module.${c};`)].join(`
|
|
6
|
-
`)),await b.writeFile(`${r}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
7
|
-
`)),await b.writeFile(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
8
|
-
`)),p&&(await H(`${r}.cjs`),await H(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Rt=Object.defineProperty,Tt=d((e,t)=>Rt(e,"name",{value:t,configurable:!0}),"a$b");const V=Tt((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var At=Object.defineProperty,qt=d((e,t)=>At(e,"name",{value:t,configurable:!0}),"a$a");const J=qt(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Bt=Object.defineProperty,Lt=d((e,t)=>Bt(e,"name",{value:t,configurable:!0}),"e$1");const X=Lt((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Wt=Object.defineProperty,$e=d((e,t)=>Wt(e,"name",{value:t,configurable:!0}),"s$c");const Jt=$e((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),i=n.get(s);if(i!==void 0)return i;const a=e(...r);return n.set(s,a),a}},"memoize"),zt=$e(e=>{const t=new Map;return o=>Jt(e,o,t)},"memoizeByKey");var Ut=Object.defineProperty,Ht=d((e,t)=>Ut(e,"name",{value:t,configurable:!0}),"m$5");const je=Ht(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const a=new N(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
9
|
-
module.exports.default = `+i[2]+";");let p=a.toString();return p=p.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:p,map:a.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(n);if(i===null||i.length<2)return null;const a=i[1].split(", "),p=[];let l="";for(const c of a)if(!c.includes("type"))if(c.includes("as")){const[m,y]=c.split(" as ");if(y==="default"&&(l=m,!e))continue;p.push(y+": typeof "+m+";")}else p.push(c+": typeof "+c+";");const u=new N(n);return u.replace(" "+l+" as default,",""),u.append(`
|
|
10
|
-
|
|
11
|
-
declare const defaultExport: {
|
|
12
|
-
`+(p.length>0?" ":"")+p.join(`
|
|
13
|
-
`)+`
|
|
14
|
-
} & typeof `+l+`;
|
|
15
|
-
|
|
16
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Vt=Object.defineProperty,Xt=d((e,t)=>Vt(e,"name",{value:t,configurable:!0}),"f$7");const Gt=Xt((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await pt.glob(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:bt(i.src),src:a}))));for(const i of s)for(const a of i.src){let p;o.has(a)?p=o.get(a):(p={copied:[],dest:[],timestamp:0},o.set(a,p));const l=n.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(a)));p.dest.includes(l)||p.dest.push(l),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let p;try{const l=await B.stat(i);if(!l.isFile())return;const u=l.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),p=await b.readFile(i,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const l of a.dest){if(n.copyOnce&&a.copied.includes(l))continue;const u=f.basename(i),c=f.join(l,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:c,source:p,type:"asset"}),t.debug({message:`copied ${i} → ${c}`,prefix:"plugin:copy"}),a.copied.push(l)}catch(m){t.error({context:[m],message:`error copying file ${i} → ${c}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Yt=Object.defineProperty,Kt=d((e,t)=>Yt(e,"name",{value:t,configurable:!0}),"n$7");const re="export default ",we=Kt(e=>{const t=$t(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(re)&&(r.code=r.code.replace(re,"module.exports = ")),r}}},"JSONPlugin");class Qt{static{d(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Zt extends Qt{static{d(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,p=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=p,l)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let p=0;p<a.length;p+=1){const l=a[p];se(l)&&(this.visit(l,t,s,p)||p--)}}else se(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const p=this.should_remove;if(this.replacement=i,this.should_remove=a,p)return null}}return t}}function se(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}d(se,"isNode");function ke(e,{enter:t,leave:o}){return new Zt(t,o).visit(e,null)}d(ke,"walk");var eo=Object.defineProperty,to=d((e,t)=>eo(e,"name",{value:t,configurable:!0}),"u$4");const oo=to(({attributes:e,logger:t})=>{const o=I.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(p),null}let i=!1;const a=new N(n);return ke(s,{enter(p){if(p.type==="CallExpression"&&p.callee.type==="Identifier"&&p.callee.name==="jsx"){const l=p.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of l)for(const c of u.properties)c.type==="Property"&&c.key.type==="Literal"&&c.value.type==="Literal"&&e.includes(c.key.value)&&(a.overwrite(c.start-2,c.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var no=Object.defineProperty,Q=d((e,t)=>no(e,"name",{value:t,configurable:!0}),"p");const ro=Q(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),so=Q((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
|
|
17
|
-
${o}
|
|
18
|
-
$2`)},"replaceContentWithin"),xe=Q(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:n,mode:r,packageName:s})=>jt({thirdParty(i){const a=new Set,p=i.sort(({name:u},{name:c})=>u>c?1:c>u?-1:0).map(({author:u,contributors:c,license:m,licenseText:y,maintainers:h,name:v,repository:$})=>{let O="## "+v+`
|
|
19
|
-
`;m&&(O+=`License: ${m}
|
|
20
|
-
`);const P=new Set;for(const k of[u,...h,...c]){const F=typeof k=="string"?k:k?.name;F&&P.add(F)}return P.size>0&&(O+=`By: ${[...P].join(", ")}
|
|
21
|
-
`),$&&(O+=`Repository: ${typeof $=="string"?$:$.url}
|
|
22
|
-
`),y&&(O+=`
|
|
23
|
-
`+y.trim().replaceAll(/(\r\n|\r)/g,`
|
|
24
|
-
`).split(`
|
|
25
|
-
`).map(k=>`> ${k}`).join(`
|
|
26
|
-
`)+`
|
|
27
|
-
`),m&&a.add(m),O}).join(`
|
|
28
|
-
---------------------------------------
|
|
29
|
-
|
|
30
|
-
`);if(p===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const l=t(ro(a),p,s);try{const u=b.readFileSync(e),c=so(u,n,l);if(!c){o.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+r});return}u!==c&&(b.writeFileSync(e,c),o.info({message:`${e} updated.`,prefix:"plugin:license:"+r}))}catch(u){o.error(u)}}}),"license");var io=Object.defineProperty,ao=d((e,t)=>io(e,"name",{value:t,configurable:!0}),"i$7");const lo=ao(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=f.resolve(e.outDir,"graph.json");b.writeJsonSync(o,t)},name:"packem:metafile"}),"metafilePlugin");var co=Object.defineProperty,po=d((e,t)=>co(e,"name",{value:t,configurable:!0}),"c$4");const uo=/\.(?:m|c)?(?:j|t)sx?$/,mo=/^use \w+$/,fo=po(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:s}){const i=r.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,u)=>(u&&u.forEach(c=>{l.add(c)}),l),new Set),a=new N(n);i.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(l=>`'${l}';`).join(`
|
|
31
|
-
`)}
|
|
32
|
-
`));let p=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(p=o[r.facadeModuleId]),p&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${p}
|
|
33
|
-
`)),i.size===0&&p===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=f.extname(r);if(!uo.test(s))return null;let i=!1;const a=new N(n);if(n.startsWith("#")&&n[1]==="!"){let l=0;for(let u=2,c=n.length;u<c;u++){const m=n.codePointAt(u);if(m===10||m===13||m===8232||m===8233){l=u;break}}l&&(o[r]=n.slice(0,l),a.remove(0,l+1),i=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(l),null}if(p.type!=="Program")return null;for(const l of p.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let u=null;"directive"in l?u=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&mo.test(l.expression.value)&&(u=l.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(a.remove(l.start,l.end),i=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var go=Object.defineProperty,ho=d((e,t)=>go(e,"name",{value:t,configurable:!0}),"r$6");const yo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},vo=ho((e={})=>{e={...e,...yo};const t=I.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var bo=Object.defineProperty,$o=d((e,t)=>bo(e,"name",{value:t,configurable:!0}),"l$5");const z="\0__file_url__",Ee=$o(()=>({async load(e){if(e.startsWith(z)){const t=fe.fileURLToPath(e.slice(z.length));return await b.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${z}${e}`}}),"resolveFileUrl");var jo=Object.defineProperty,Oe=d((e,t)=>jo(e,"name",{value:t,configurable:!0}),"i$4");const wo=/__filename|__dirname|require\(|require\.resolve\(/,_e=`
|
|
34
|
-
// -- pack CommonJS Shims --
|
|
35
|
-
import __cjs_url__ from "node:url";
|
|
36
|
-
import __cjs_path__ from "node:path";
|
|
37
|
-
import __cjs_mod__ from "node:module";
|
|
38
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
-
`,Se=`
|
|
42
|
-
// -- pack CommonJS Shims Node 20.11 --
|
|
43
|
-
import __cjs_mod__ from "node:module";
|
|
44
|
-
const __filename = import.meta.filename;
|
|
45
|
-
const __dirname = import.meta.dirname;
|
|
46
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
-
`,ko=Oe((e,t)=>{if(w.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(_e)||e.includes(Se)||!wo.test(e)))return null;const o=A.findStaticImports(e).pop(),n=o?o.end:0,r=new N(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),xo=Oe(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=_e;if(e.engines?.node){const s=he.minVersion(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=Se)}return ko(t,r)}return null}}),"cjsPlugin");var Eo=Object.defineProperty,M=d((e,t)=>Eo(e,"name",{value:t,configurable:!0}),"s$9");const Oo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,_o=/MIT License|MIT license|BSD license/,So=/\n{2,}/g,Do=/\b(\w+)\$\d+\b/g,No=/[-/\\^$*+?.()|[\]{}]/g,Po=M(e=>e.replaceAll(No,"\\$&"),"escapeRegex"),Mo=M(e=>[...new Set(e)],"unique"),Fo=M(e=>e.replaceAll(Oo,t=>_o.test(t)?"":t).replaceAll(So,`
|
|
48
|
-
|
|
49
|
-
`),"cleanUnnecessaryComments"),ie=new Map;function De(e,t,{identifierReplacements:o},n){const r=A.findStaticImports(e);for(const i in o){const a=r.find(l=>l.specifier===i&&l.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const p=o[i];for(const l in p){a.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${i}" for replacement`),w.exit(1));const u=p[l],c=Po(l);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${c},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${c}\\b`,"g"),u)}}const s=Mo(Array.from(e.matchAll(Do),i=>i[0]));if(s.length>0){const i=s.map(p=>`
|
|
50
|
-
- ${p}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");ie.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
51
|
-
|
|
52
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ie.set(a,!0)}return e}d(De,"v$2");M(De,"replaceConfusingTypeNames");function Ne(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}d(Ne,"N");M(Ne,"removeInternal");function Pe(e,t){if(e.includes("@internal")){const o=new N(e),n=ft.parse(e,{plugins:["typescript"],sourceType:"module"});ke(n,{enter(r){Ne(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),w.exit(1))}return e}d(Pe,"S");M(Pe,"stripInternalTypes");const Io=M((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=De.call(this,o,n,e,t),o=Pe.call(this,o,n),o=Fo(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Co=Object.defineProperty,Me=d((e,t)=>Co(e,"name",{value:t,configurable:!0}),"u$2");const Fe=Me((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const i=f.resolve(f.dirname(n),r),a=[];if(s)for(const[p,l]of Object.entries(s)){const u=new RegExp(`^${[...p].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let c=0;for(const m of l){const y=[...I.normalizePath(f.resolve(i,m))].map(h=>h==="*"?`$${++c}`:h==="$"?"$$":h).join("");a.push({find:u,replacement:y})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...I.normalizePath(i)].map(p=>p==="$"?"$$":p).join("")}/$1`}),a},"getConfigAlias"),Ie=Me((e,t)=>{const o=Fe(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(n)){const p=n.replace(i,a),l=await this.resolve(p,r,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var Ro=Object.defineProperty,Ce=d((e,t)=>Ro(e,"name",{value:t,configurable:!0}),"u$1");const To=Ce((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const s=[];for(const i of r){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(f.resolve(e,i))}return s},"getRootDirectories"),Re=Ce((e,t,o)=>{const n=To(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,i){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const p=f.join(a,r),l=await this.resolve(p,s,{skipSelf:!0,...i});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var Ao=Object.defineProperty,qo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"r$5");const Te=qo(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var Bo=Object.defineProperty,Lo=d((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"s$8");const Wo=Lo(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(D.DEFAULT_EXTENSIONS.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var Jo=Object.defineProperty,zo=d((e,t)=>Jo(e,"name",{value:t,configurable:!0}),"i$3");const U=zo(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Uo=Object.defineProperty,ae=d((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"c$2");const le=ae((e,t)=>{const o=new Map;return ae(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:i}=s,a=s.meta,p=U(a);if(!i){const l=o.get(n);if(l)return l;const u=Wo(n);if(u)return o.set(n,u),u}if(i){const l=r.getModuleIds();for(const u of l)r.getModuleInfo(u)&&U(a)===p&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,p]))}if(p&&!i&&e.has(n)){const l=[...e.get(n)];if(l.some(([c])=>{if(t.some(m=>m.path===c)){const m=r.getModuleInfo(c);return U(m?m.meta:{})===p}return!1}))return;if(l.every(([,c])=>c===p))return o.has(n)?o.get(n):void 0;const u=`${f.basename(n,f.extname(n))}-${p}`;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Ho=Object.defineProperty,Vo=d((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"n$5");const S=Vo((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Xo=Object.defineProperty,Go=d((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"s$6");const Yo=process.platform==="win32",ce=Go((e,t)=>{const o=Yo?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Ko=Object.defineProperty,j=d((e,t)=>Ko(e,"name",{value:t,configurable:!0}),"l$4");const Qo=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+w.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=he.minVersion(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=J(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...J(o),...n])])}else t.options.rollup.esbuild.target=J(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Ae=j((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${g.cyan(f.relative(f.resolve(),e.id))}"
|
|
53
|
-
Is the module installed? Note:
|
|
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"),pe=new Map,qe=j((e,t,o)=>{const n=j(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),r=Fe(e.tsconfig,!1);return{external(s){const i=n(s);i&&(s=i);const a=X(s),p=V(e.options.externals,a)||V(e.options.externals,s);if(p)return!0;if(s.startsWith(".")||f.isAbsolute(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(r){for(const{find:l}of r)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!p&&!pe.has(s)&&e.logger.info({message:'Inlined implicit external "'+g.cyan(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),pe.set(s,!0),p},input:Object.fromEntries(e.options.entries.map(s=>[s.name,f.resolve(e.options.rootDir,s.input)])),onLog:j((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
56
|
-
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Ae(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Be=j(async e=>{const t=K(e,"build");let o;return e.options.rollup.resolve&&(o=ge.nodeResolve({extensions:D.DEFAULT_EXTENSIONS,...e.options.rollup.resolve})),{...qe(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(n=>S(e,n,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(n=>ce(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!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:j(n=>S(e,n,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:j(n=>ce(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!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:[Ee(),Te(),e.tsconfig&&Re(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Ie(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:o?.resolveId,...e.options.rollup.alias,entries:t}),o,e.options.rollup.polyfillNode&&vt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&we({...e.options.rollup.json}),fo(e.logger),kt(e.options.entries.filter(n=>n.isExecutable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&at.wasm(e.options.rollup.wsam),e.options.transformer?.(Qo(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&je({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&yt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&ht({extensions:D.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&xo(e.pkg),e.options.rollup.raw&&vo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&oo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&lo({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Gt(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&xe({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ct.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Zo=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),en=zt(Zo),Le=j(async e=>{const t=K(e,"types"),o={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let r;e.options.rollup.resolve&&(r=ge.nodeResolve({extensions:D.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...qe(e,t,"dts"),onwarn(i,a){Ae(i,e)||i.code!=="EMPTY_BUNDLE"&&a(i)},output:[e.options.emitCJS&&{chunkFileNames:j(i=>S(e,i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:j(i=>S(e,i,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:j(i=>S(e,i,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[Ee(),Te(),e.options.rollup.json&&we({...e.options.rollup.json}),o,e.tsconfig&&Re(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Ie(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:r?.resolveId,...e.options.rollup.alias,entries:t}),r,await en(s)(e),e.options.cjsInterop&&e.options.emitCJS&&je({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Io(e.options.rollup.patchTypes,e.logger),xt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&xe({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var tn=Object.defineProperty,on=d((e,t)=>tn(e,"name",{value:t,configurable:!0}),"a$3");const nn=on(async e=>{const t=await Be(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=await q.rollup(t);await e.hooks.callHook("rollup:build",e,o);const n=t.output,r=new Map;for(const s of n){const{output:i}=await o.write(s),a=new Set,p=i.filter(u=>u.type==="chunk");for(const u of p){a.add(u.fileName);for(const c of u.imports)e.usedImports.add(c);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(c=>p.find(m=>m.fileName===c)),exports:u.exports,modules:Object.entries(u.modules).map(([c,m])=>({bytes:m.renderedLength,id:c})),path:u.fileName,type:"entry"})}const l=i.filter(u=>u.type==="asset");for(const u of l)r.has(u.fileName)||r.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of a)e.usedImports.delete(u)}e.buildEntries.push(...r.values())},"build");var rn=Object.defineProperty,R=d((e,t)=>rn(e,"name",{value:t,configurable:!0}),"r$3");const sn=R(async e=>{const t=await Le(e);if(await e.hooks.callHook("rollup:dts:options",e,t),Object.keys(t.input).length===0)return;const o=await q.rollup(t);await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:R(n=>S(e,n,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:R(n=>S(e,n,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:R(n=>S(e,n,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var an=Object.defineProperty,We=d((e,t)=>an(e,"name",{value:t,configurable:!0}),"l$3");const ue=We((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${g.cyan(f.relative(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",r=>{r.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:n}),r.code==="ERROR"&&o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n})})},"watchHandler"),ln=We(async e=>{const t=await Be(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=q.watch(t);await e.hooks.callHook("rollup:watch",e,o);const n=[...Array.isArray(t.input)?t.input:typeof t.input=="string"?[t.input]:Object.keys(t.input??{})];let r="Starting watchers for entries:";for(const s of n)r+=g.gray(`
|
|
57
|
-
└─ ${f.relative(process.cwd(),s)}`);if(e.logger.info(r),ue(o,"bundle",e.logger),e.options.declaration){const s=await Le(e);await e.hooks.callHook("rollup:dts:options",e,s);const i=q.watch(s);await e.hooks.callHook("rollup:watch",e,i),ue(i,"types",e.logger)}},"watch");var cn=Object.defineProperty,pn=d((e,t)=>cn(e,"name",{value:t,configurable:!0}),"i$2");const Je=pn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var un=Object.defineProperty,T=d((e,t)=>un(e,"name",{value:t,configurable:!0}),"l$2");const dn=I.createFilter,mn=T((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=T(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=T(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=dn(r,null,{resolve:e})}else n=T(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var fn=Object.defineProperty,gn=d((e,t)=>fn(e,"name",{value:t,configurable:!0}),"t$4");const hn=gn(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var yn=Object.defineProperty,ze=d((e,t)=>yn(e,"name",{value:t,configurable:!0}),"t$3");const Z=ze(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ue=ze((e,t,o,n)=>{if(o){const i=Z(o);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...s]=t;return Ue(r,s,o,n)},"inferExportType");var vn=Object.defineProperty,bn=d((e,t)=>vn(e,"name",{value:t,configurable:!0}),"f$3");const ee=bn((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=Z(e),s=t==="module"?"esm":"cjs";if(r&&r!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:r??s}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>r==="types"&&!o?[]:typeof s=="string"?{file:s,type:Ue(r,n,s,t)}:ee(s,t,o,[...n,r]))},"extractExportFilenames");var $n=Object.defineProperty,jn=d((e,t)=>$n(e,"name",{value:t,configurable:!0}),"e");const wn=jn(e=>{const t=f.normalize(e).split("/");return t.map((o,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var kn=Object.defineProperty,xn=d((e,t)=>kn(e,"name",{value:t,configurable:!0}),"h$1");const En=xn((e,t,o,n=".")=>{const r=[];t.sort((c,m)=>c.split("/").length-m.split("/").length);const s=ee(e.exports,e.type??"commonjs",o);if(e.bin){const c=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const m of c)s.push({file:m,isExecutable:!0})}e.main&&s.push({file:e.main,type:Z(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&s.push({file:e.module,type:"esm"}),o===void 0&&(e.types||e.typings)&&s.push({file:e.types??e.typings});const i=e.type==="module";for(const c of s.filter(m=>!m.type)){const m=c.file.endsWith(".js");i&&m||c.file.endsWith(".mjs")?c.type="esm":(!i&&m||c.file.endsWith(".cjs"))&&(c.type="cjs")}let a=!1,p=!1,l=!1;const u=[];for(const c of s){const m=c.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),y=m.endsWith("/");if(y&&["./","/"].includes(m))continue;const h=wn(m).reduce(($,O)=>{if($)return $;const P=new RegExp(`(?<=/|$)${O}${y?"":"\\.\\w+"}$`);return t.find(k=>P.test(k))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!h){G.existsSync(f.resolve(n,c.file))||r.push(`Could not find entrypoint for \`${c.file}\``);continue}c.type==="cjs"&&(a=!0),c.type==="esm"&&(p=!0);const v=u.find($=>$.input===h)??u[u.push({input:h})-1];/\.d\.(?:m|c)?ts$/.test(c.file)&&(l=!0),y&&(v.outDir=m),c.isExecutable&&(v.isExecutable=!0)}return{cjs:a,dts:l,entries:u,esm:p,warnings:r}},"inferEntries");var On=Object.defineProperty,_n=d((e,t)=>On(e,"name",{value:t,configurable:!0}),"t$2");const Sn=_n((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Dn=Object.defineProperty,Nn=d((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"t$1");const Pn={hooks:{"build:prepare":Nn(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,"src");if(!G.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=b.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=Sn(n,e.options.declaration));const r=En(n,o,e.options.declaration,e.options.rootDir);for(const s of r.warnings)C(e,s);if(e.options.entries.push(...r.entries),e.options.emitCJS===void 0&&r.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&r.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&r.dts&&(e.options.declaration=r.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",g.cyan(e.options.entries.map(s=>g.bold(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),g.gray([r.esm&&"esm",r.cjs&&"cjs",r.dts&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Mn=Object.defineProperty,Fn=d((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"r");const He=Fn((e,t)=>ye(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var In=Object.defineProperty,Cn=d((e,t)=>In(e,"name",{value:t,configurable:!0}),"t");const Rn=Cn((e,t)=>(e==="auto"?e=Pn:typeof e=="string"&&(e=He(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var Tn=Object.defineProperty,An=d((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"o");const qn=An(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(Array.isArray(e.options.dependencies))for(const r of e.options.dependencies)o.delete(r);for(const r of t)!V(e.options.externals,r)&&!r.startsWith("chunks/")&&!e.options.dependencies.includes(X(r))&&!e.options.peerDependencies.includes(X(r))&&n.add(r);o.size>0&&C(e,`Potential unused dependencies found: ${[...o].map(r=>g.cyan(r)).join(", ")}`),n.size>0&&C(e,`Potential implicit dependencies found: ${[...n].map(r=>g.cyan(r)).join(", ")}`)},"validateDependencies");var Bn=Object.defineProperty,Ve=d((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"i");const Ln=Ve((e,t)=>gt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),Wn=Ve((e,t)=>{const o=e.toLowerCase();return t.filter(n=>Ln(n.toLowerCase(),o))},"findAlternatives");var Jn=Object.defineProperty,de=d((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"n");const zn=de((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...ee(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&f.resolve(t.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!G.existsSync(r)&&n.push(r.replace(`${t.rootDir}/`,""));if(n.length>0){const r=de(a=>f.relative(t.rootDir,f.resolve(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>r(a.path));let i="Potential missing or wrong package.json files:";for(const a of n){const p=Wn(a,s);i+=`
|
|
58
|
-
- `+g.cyan(a)+(p.length>0?g.grey` (did you mean ${p.map(l=>`"${l}"`).join(", ")}?)`:"")}C(t,i)}},"validatePackage");var Un=Object.defineProperty,x=d((e,t)=>Un(e,"name",{value:t,configurable:!0}),"m");const me=x((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
59
|
-
`),e.logger.warn(`Build is done with some warnings:
|
|
60
|
-
|
|
61
|
-
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
62
|
-
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),w.exit(1)))},"logErrors"),Hn=x(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),Vn=x((e,t,o,n,r,s,i,a)=>{const p=Hn(a?.config.compilerOptions?.jsx),l=Ze.defu(r,i.packem,n,s,{alias:{},clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ne.builtinModules,...ne.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:w.env.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.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:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:w.env.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},json:{preferConst:!0},license:{dependenciesTemplate:x((u,c,m)=>`
|
|
63
|
-
# Licenses of bundled dependencies
|
|
64
|
-
The published ${m} artifact additionally contains code with the following licenses:
|
|
65
|
-
${u.join(", ")}
|
|
66
|
-
|
|
67
|
-
# Bundled dependencies:
|
|
68
|
-
`+c,"dependenciesTemplate"),dtsTemplate:x((u,c,m)=>`
|
|
69
|
-
# Licenses of bundled types
|
|
70
|
-
The published ${m} artifact additionally contains code with the following licenses:
|
|
71
|
-
${u.join(", ")}
|
|
72
|
-
|
|
73
|
-
# Bundled types:
|
|
74
|
-
`+c,"dtsTemplate")},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:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:w.env.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:p,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.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:a?.config.compilerOptions?.experimentalDecorators,dynamicImport:!0,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:w.env.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:p,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:mn(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:D.EXCLUDE_REGEXP}},rootDir:t,sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const u=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(u.has("esbuild"))l.transformerName="esbuild";else if(u.has("@swc/core"))l.transformerName="swc";else if(u.has("sucrase"))l.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+g.cyan(l.transformerName)+'" as transformer.')}return l.outDir=f.resolve(l.rootDir,l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
75
|
-
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.
|
|
76
|
-
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.`),l.dependencies=Object.keys(i.dependencies??{}),l.peerDependencies=Object.keys(i.peerDependencies??{}),l.devDependencies=Object.keys(i.devDependencies??{}),l.optionalDependencies=Object.keys(i.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),Xn=x(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let n=f.isAbsolute(o.input)?f.relative(t,o.input):f.normalize(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=hn(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Je(o)}`);if(!e.options.declaration&&o.declaration===void 0&&(o.declaration=e.options.declaration),o.input=f.resolve(e.options.rootDir,o.input),!b.isAccessibleSync(o.input)){const n=new Set(await B.readdir(f.dirname(o.input)));let r=!1;for(const s of D.DEFAULT_EXTENSIONS)if(n.has(f.basename(o.input)+s)){r=!0;break}if(!r)throw new Ye.NotFoundError("Your configured entry: "+g.cyan(o.input)+" does not exist.")}o.outDir=f.resolve(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Gn=x((e,t,o)=>{const n=x(s=>f.relative(t.rootDir,f.resolve(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const p of s.chunks??[])i+=t.buildEntries.find(l=>l.path===p)?.bytes??0;let a=` ${g.bold(n(s.path))} (${["total size: "+g.cyan(_.formatBytes(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+g.cyan(_.formatBytes(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
|
|
77
|
-
exports: `+g.gray(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
|
|
78
|
-
${s.chunks.map(p=>{const l=t.buildEntries.find(u=>u.path===p)??{};return g.gray(" └─ "+n(p)+g.bold(l.bytes?" ("+_.formatBytes(l?.bytes)+")":""))}).join(`
|
|
79
|
-
`)}`),s.modules&&s.modules.length>0){const p=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>g.gray(" 📦 "+n(l.id)+g.bold(l.bytes?" ("+_.formatBytes(l.bytes)+")":""))).join(`
|
|
80
|
-
`);a+=p.length>0?`
|
|
81
|
-
inlined modules:
|
|
82
|
-
`+p:""}if(t.options.declaration&&s.type==="entry"){let p=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?p=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",p=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(c=>c.path.endsWith(p));if(u){let c;(t.options.declaration===!0||t.options.declaration==="compatible")&&!p.includes(".d.ts")&&(p=p.replace(l==="commonjs"?".d.c":".d.m",".d."),c=t.buildEntries.find(m=>m.path.endsWith(p))),a+=c&&l===o.type?`
|
|
83
|
-
types:
|
|
84
|
-
`+[u,c].map(m=>g.gray(" └─ ")+g.bold(n(m.path))+" (total size: "+g.cyan(_.formatBytes(m.bytes??0))+")").join(`
|
|
85
|
-
`):`
|
|
86
|
-
types: `+g.bold(n(u.path))+" (total size: "+g.cyan(_.formatBytes(u.bytes??0))+")"}}r=!0,a+=`
|
|
87
|
-
|
|
88
|
-
`,e.raw(s.chunk?g.gray(a):a)}return r&&e.raw("Σ Total dist size (byte size):",g.cyan(_.formatBytes(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
|
|
89
|
-
`),r},"showSizeInformation"),Yn=x(async(e,t,o,n,r,s,i,a,p)=>{const l=Rn(n,t),u=Vn(e,t,o,r,s,l,i,a);b.ensureDirSync(u.outDir);const c={buildEntries:[],dependencyGraphMap:new Map,hooks:et.createHooks(),logger:e,mode:o,options:u,pkg:i,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&c.hooks.addHooks(l.hooks),r.hooks&&c.hooks.addHooks(r.hooks),s.hooks&&c.hooks.addHooks(s.hooks),await c.hooks.callHook("build:prepare",c),c.options.emitESM===!1&&c.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(c.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");c.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),c.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),c.options.declaration||e.info("Declaration files, are disabled."),await Xn(c,t),await c.hooks.callHook("build:before",c);let m="Building";if(o==="watch"?m="Watching":o==="jit"&&(m="Stubbing"),e.info(g.cyan(`${m} ${c.options.name}`)),e.debug(`${g.bold("Root dir:")} ${c.options.rootDir}
|
|
90
|
-
${g.bold("Entries:")}
|
|
91
|
-
${c.options.entries.map(h=>` ${Je(h)}`).join(`
|
|
92
|
-
`)}`),c.options.clean)for(const h of new Set(c.options.entries.map(v=>v.outDir).filter(Boolean).sort()))h===c.options.rootDir||c.options.rootDir.startsWith(h.endsWith("/")?h:`${h}/`)||p.some(v=>h.startsWith(v))||(p.push(h),e.info(`Cleaning dist directory: \`./${f.relative(c.options.rootDir,h)}\``),await b.emptyDir(h));if(c.options.stub){await Ct(c),await c.hooks.callHook("build:done",c);return}if(o==="watch"){await ln(c),me(c,!1);return}await Promise.all([nn(c),c.options.declaration&&sn(c)]),e.success(g.green(`Build succeeded for ${c.options.name}`));for await(const h of b.walk(c.options.outDir)){let v=c.buildEntries.find($=>f.join(c.options.outDir,$.path)===h.path);if(v||(v={chunk:!0,path:h.path},c.buildEntries.push(v)),!v.bytes){const $=await B.stat(f.resolve(c.options.outDir,h.path));v.bytes=$.size}}const y=Gn(e,c,i);qn(c),zn(i,c),await c.hooks.callHook("build:done",c),me(c,y)},"build"),Kn=x(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...i}=o,a=[new W.MessageFormatterProcessor,new W.ErrorProcessor];r&&a.push(new W.CallerProcessor);const p=Qe.createPail({logLevel:r?"debug":"informational",processors:a,scope:"packem"});p.wrapAll(),e=f.resolve(w.cwd(),e),p.debug("Root directory:",e);let l;if(s){const u=f.join(e,s);await b.isAccessible(u)||(p.error("tsconfig.json not found at",u),w.exit(1)),l={config:te.readTsConfig(u),path:u},p.info("Using tsconfig settings at",u)}else try{l=await te.findTSConfig(e),p.debug("Using tsconfig settings found at",l.path)}catch{p.info("No tsconfig.json or jsconfig.json found.")}try{const u=f.join(e,"package.json"),c=Ke.parsePackageJson(u);p.debug("Using package.json found at",u);const m=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(m)||(p.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),w.exit(1));const y=He(m,e);p.debug("Using packem config found at",f.join(e,m));const h=(Array.isArray(y)?y:[y]).filter(Boolean),v=Date.now(),$=x(()=>_.duration(Math.floor(Date.now()-v)),"getDuration");let O=c.packem?.preset??o.preset??"auto";const P=[],k=[];for(const F of h)F.preset&&(O=F.preset),k.push(Yn(p,e,t,O,i,F,c,l,P));await Promise.all(k),p.raw(`
|
|
93
|
-
⚡️ Build`+(k.length>1?"s":"")+" run in "+$()),p.restoreAll(),w.exit(0)}catch(u){p.error("An error occurred while building",u),w.exit(1)}},"createBundler");module.exports=Kn;
|
|
1
|
+
"use strict";require("node:fs/promises");require("node:module");require("node:process");require("@visulima/colorize");require("@visulima/fs");require("@visulima/fs/error");require("@visulima/humanizer");require("@visulima/package");require("@visulima/package/package-json");require("@visulima/pail");require("@visulima/pail/processor");require("@visulima/path");require("defu");require("hookable");const e=require("./shared/packem.DnU5ZLGg.cjs");require("./shared/packem.CKW9adaV.cjs");module.exports=e.Oe;
|
package/dist/create-bundler.d.ts
CHANGED
package/dist/create-bundler.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import"node:fs/promises";import"node:module";import"node:process";import"@visulima/colorize";import"@visulima/fs";import"@visulima/fs/error";import"@visulima/humanizer";import"@visulima/package";import"@visulima/package/package-json";import"@visulima/pail";import"@visulima/pail/processor";import"@visulima/path";import"defu";import"hookable";import{O as g}from"./shared/packem.SDzDIaD5.mjs";import"./shared/packem.CxExFSHU.mjs";
|
|
2
2
|
// -- pack CommonJS Shims --
|
|
3
3
|
import __cjs_url__ from "node:url";
|
|
4
4
|
import __cjs_path__ from "node:path";
|
|
@@ -6,96 +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
|
-
|
|
10
|
-
`)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new S(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&te.test(s.code)&&o.dir){const i=g(o.dir,n);await V(i)}}}),"shebangPlugin"),Vt=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(te,"")}}),"removeShebangPlugin"),Gt=z((e,t=`
|
|
11
|
-
`)=>{const o=te.exec(e);return o?o+t:""},"getShebang");var Xt=Object.defineProperty,Yt=m((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"p$1");const oe=Yt((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const s=r[n];typeof s=="string"&&(o[n]=x(e.rootDir,s))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(r=>[r.find,r.replacement]))):Object.assign(o,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Kt=Object.defineProperty,Qt=m((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"o$3");const Zt=Qt((e,t)=>{const o=ke(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var eo=Object.defineProperty,to=m((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$8");const T=to((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var oo=Object.defineProperty,ro=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$6");const no=ro(async e=>{const t=await Mt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...oe(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,r.name),s=J(Zt(r.input,e.options.rootDir)||r.input),i=s.slice(0,Math.max(0,s.length-K(s).length)),a=await Y(s),c=Gt(a);e.options.emitCJS&&await A(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
|
|
12
|
-
`));let l=[];try{l=await Ct(s,{extensions:F})}catch(p){T(e,`Cannot analyze ${s} for exports:${p}`);return}const u=l.includes("default")||l.length===0;await A(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(_t(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,u?`
|
|
13
|
-
export default _module;`:"",...l.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
|
|
14
|
-
`)),await A(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
15
|
-
`)),await A(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
|
|
16
|
-
`)),c&&(await V(`${n}.cjs`),await V(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=m((e,t)=>so(e,"name",{value:t,configurable:!0}),"a$b");const G=io((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$a");const U=lo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var po=Object.defineProperty,co=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"e$1");const X=co((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var uo=Object.defineProperty,Ne=m((e,t)=>uo(e,"name",{value:t,configurable:!0}),"s$c");const mo=Ne((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const a=e(...n);return r.set(s,a),a}},"memoize"),fo=Ne(e=>{const t=new Map;return o=>mo(e,o,t)},"memoizeByKey");var go=Object.defineProperty,ho=m((e,t)=>go(e,"name",{value:t,configurable:!0}),"m$5");const _e=ho(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,s){if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const a=new S(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
17
|
-
module.exports.default = `+i[2]+";");let c=a.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:a.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const a=i[1].split(", "),c=[];let l="";for(const p of a)if(!p.includes("type"))if(p.includes("as")){const[d,h]=p.split(" as ");if(h==="default"&&(l=d,!e))continue;c.push(h+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new S(r);return u.replace(" "+l+" as default,",""),u.append(`
|
|
18
|
-
|
|
19
|
-
declare const defaultExport: {
|
|
20
|
-
`+(c.length>0?" ":"")+c.join(`
|
|
21
|
-
`)+`
|
|
22
|
-
} & typeof `+l+`;
|
|
23
|
-
|
|
24
|
-
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"f$7");const bo=vo((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Wt(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:Bt(i.src),src:a}))));for(const i of s)for(const a of i.src){let c;o.has(a)?c=o.get(a):(c={copied:[],dest:[],timestamp:0},o.set(a,c));const l=r.flatten?J(i.dest):x(i.dest,D(i.parent,Q(a)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,a])=>{let c;try{const l=await $e(i);if(!l.isFile())return;const u=l.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),c=await Y(i,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const l of a.dest){if(r.copyOnce&&a.copied.includes(l))continue;const u=L(i),p=x(l,u);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${p}`,prefix:"plugin:copy"}),a.copied.push(l)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var $o=Object.defineProperty,jo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"n$7");const ce="export default ",Pe=jo(e=>{const t=Jt(e);return{...t,name:"packem:json",transform(o,r){const n=t.transform?.call(this,o,r);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class wo{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class ko extends wo{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const l=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=c,l)return t;if(u)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let c=0;c<a.length;c+=1){const l=a[c];ue(l)&&(this.visit(l,t,s,c)||c--)}}else ue(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_remove;if(this.replacement=i,this.should_remove=a,c)return null}}return t}}function ue(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ue,"isNode");function Me(e,{enter:t,leave:o}){return new ko(t,o).visit(e,null)}m(Me,"walk");var xo=Object.defineProperty,Eo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"u$4");const Oo=Eo(({attributes:e,logger:t})=>{const o=Z([/\.[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(r,n){if(!o(n))return null;let s=null;try{s=this.parse(r,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const a=new S(r);return Me(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of l)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var So=Object.defineProperty,re=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"p");const Do=re(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),No=re((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
|
|
25
|
-
${o}
|
|
26
|
-
$2`)},"replaceContentWithin"),Ce=re(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Lt({thirdParty(i){const a=new Set,c=i.sort(({name:u},{name:p})=>u>p?1:p>u?-1:0).map(({author:u,contributors:p,license:d,licenseText:h,maintainers:f,name:y,repository:v})=>{let k="## "+y+`
|
|
27
|
-
`;d&&(k+=`License: ${d}
|
|
28
|
-
`);const N=new Set;for(const j of[u,...f,...p]){const I=typeof j=="string"?j:j?.name;I&&N.add(I)}return N.size>0&&(k+=`By: ${[...N].join(", ")}
|
|
29
|
-
`),v&&(k+=`Repository: ${typeof v=="string"?v:v.url}
|
|
30
|
-
`),h&&(k+=`
|
|
31
|
-
`+h.trim().replaceAll(/(\r\n|\r)/g,`
|
|
32
|
-
`).split(`
|
|
33
|
-
`).map(j=>`> ${j}`).join(`
|
|
34
|
-
`)+`
|
|
35
|
-
`),d&&a.add(d),k}).join(`
|
|
36
|
-
---------------------------------------
|
|
37
|
-
|
|
38
|
-
`);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const l=t(Do(a),c,s);try{const u=ct(e),p=No(u,r,l);if(!p){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}u!==p&&(ut(e,p),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(u){o.error(u)}}}),"license");var _o=Object.defineProperty,Po=m((e,t)=>_o(e,"name",{value:t,configurable:!0}),"i$7");const Mo=Po(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const s of n.importedIds)t.push({source:r,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.outDir,"graph.json");mt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Co=Object.defineProperty,Io=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"c$4");const Fo=/\.(?:m|c)?(?:j|t)sx?$/,Ro=/^use \w+$/,To=Io(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(r,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,n,{sourcemap:s}){const i=n.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,u)=>(u&&u.forEach(p=>{l.add(p)}),l),new Set),a=new S(r);i.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(l=>`'${l}';`).join(`
|
|
39
|
-
`)}
|
|
40
|
-
`));let c=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(c=o[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${c}
|
|
41
|
-
`)),i.size===0&&c===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=K(n);if(!Fo.test(s))return null;let i=!1;const a=new S(r);if(r.startsWith("#")&&r[1]==="!"){let l=0;for(let u=2,p=r.length;u<p;u++){const d=r.codePointAt(u);if(d===10||d===13||d===8232||d===8233){l=u;break}}l&&(o[n]=r.slice(0,l),a.remove(0,l+1),i=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let u=null;"directive"in l?u=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&Ro.test(l.expression.value)&&(u=l.expression.value),u!=="use strict"&&u&&(t[n]||=new Set,t[n].add(u),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(a.remove(l.start,l.end),i=!0),e.debug({message:`directive "${u}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Ao=Object.defineProperty,Wo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"r$6");const Bo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Jo=Wo((e={})=>{e={...e,...Bo};const t=Z(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var Lo=Object.defineProperty,zo=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"l$5");const H="\0__file_url__",Ie=zo(()=>({async load(e){if(e.startsWith(H)){const t=Pt(e.slice(H.length));return await Y(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${H}${e}`}}),"resolveFileUrl");var Uo=Object.defineProperty,Fe=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"i$4");const Ho=/__filename|__dirname|require\(|require\.resolve\(/,Re=`
|
|
42
|
-
// -- pack CommonJS Shims --
|
|
43
|
-
import __cjs_url__ from "node:url";
|
|
44
|
-
import __cjs_path__ from "node:path";
|
|
45
|
-
import __cjs_mod__ from "node:module";
|
|
46
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
47
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
48
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
49
|
-
`,Te=`
|
|
50
|
-
// -- pack CommonJS Shims Node 20.11 --
|
|
51
|
-
import __cjs_mod__ from "node:module";
|
|
52
|
-
const __filename = import.meta.filename;
|
|
53
|
-
const __dirname = import.meta.dirname;
|
|
54
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
55
|
-
`,qo=Fe((e,t)=>{if(R.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Re)||e.includes(Te)||!Ho.test(e)))return null;const o=we(e).pop(),r=o?o.end:0,n=new S(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Vo=Fe(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Re;if(e.engines?.node){const s=De(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Te)}return qo(t,n)}return null}}),"cjsPlugin");var Go=Object.defineProperty,C=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"s$9");const Xo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Yo=/MIT License|MIT license|BSD license/,Ko=/\n{2,}/g,Qo=/\b(\w+)\$\d+\b/g,Zo=/[-/\\^$*+?.()|[\]{}]/g,er=C(e=>e.replaceAll(Zo,"\\$&"),"escapeRegex"),tr=C(e=>[...new Set(e)],"unique"),or=C(e=>e.replaceAll(Xo,t=>Yo.test(t)?"":t).replaceAll(Ko,`
|
|
56
|
-
|
|
57
|
-
`),"cleanUnnecessaryComments"),me=new Map;function Ae(e,t,{identifierReplacements:o},r){const n=we(e);for(const i in o){const a=n.find(l=>l.specifier===i&&l.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=o[i];for(const l in c){a.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${i}" for replacement`),M(1));const u=c[l],p=er(l);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const s=tr(Array.from(e.matchAll(Qo),i=>i[0]));if(s.length>0){const i=s.map(c=>`
|
|
58
|
-
- ${c}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");me.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
59
|
-
|
|
60
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),me.set(a,!0)}return e}m(Ae,"v$2");C(Ae,"replaceConfusingTypeNames");function We(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(We,"N");C(We,"removeInternal");function Be(e,t){if(e.includes("@internal")){const o=new S(e),r=zt(e,{plugins:["typescript"],sourceType:"module"});Me(r,{enter(n){We(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),M(1))}return e}m(Be,"S");C(Be,"stripInternalTypes");const rr=C((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Ae.call(this,o,r,e,t),o=Be.call(this,o,r),o=or(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var nr=Object.defineProperty,Je=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"u$2");const Le=Je((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const i=g(Q(r),n),a=[];if(s)for(const[c,l]of Object.entries(s)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of l){const h=[...pe(g(i,d))].map(f=>f==="*"?`$${++p}`:f==="$"?"$$":f).join("");a.push({find:u,replacement:h})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...pe(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),a},"getConfigAlias"),ze=Je((e,t)=>{const o=Le(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:a}of o)if(i.test(r)){const c=r.replace(i,a),l=await this.resolve(c,n,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var sr=Object.defineProperty,Ue=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"u$1");const ir=Ue((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(g(e,i))}return s},"getRootDirectories"),He=Ue((e,t,o)=>{const r=ir(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const c=x(a,n),l=await this.resolve(c,s,{skipSelf:!0,...i});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var ar=Object.defineProperty,lr=m((e,t)=>ar(e,"name",{value:t,configurable:!0}),"r$5");const qe=lr(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var pr=Object.defineProperty,cr=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"s$8");const ur=cr(e=>{const t=L(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(F.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var mr=Object.defineProperty,dr=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"i$3");const q=dr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var fr=Object.defineProperty,de=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"c$2");const fe=de((e,t)=>{const o=new Map;return de(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,a=s.meta,c=q(a);if(!i){const l=o.get(r);if(l)return l;const u=ur(r);if(u)return o.set(r,u),u}if(i){const l=n.getModuleIds();for(const u of l)n.getModuleInfo(u)&&q(a)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([r,c]))}if(c&&!i&&e.has(r)){const l=[...e.get(r)];if(l.some(([p])=>{if(t.some(d=>d.path===p)){const d=n.getModuleInfo(p);return q(d?d.meta:{})===c}return!1}))return;if(l.every(([,p])=>p===c))return o.has(r)?o.get(r):void 0;const u=`${L(r,K(r))}-${c}`;return o.set(r,u),u}},"splitChunks")},"createSplitChunks");var gr=Object.defineProperty,hr=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"n$5");const O=hr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var yr=Object.defineProperty,vr=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"s$6");const br=process.platform==="win32",ge=vr((e,t)=>{const o=br?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var $r=Object.defineProperty,$=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"l$4");const jr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+it.node.split(".")[0];if(t.pkg.engines?.node){const r=De(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=U(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...U(o),...r])])}else t.options.rollup.esbuild.target=U(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Ve=$((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 "${b(D(g(),e.id))}"
|
|
61
|
-
Is the module installed? Note:
|
|
62
|
-
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
63
|
-
↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),he=new Map,Ge=$((e,t,o)=>{const r=$(s=>{for(const[i,a]of Object.entries(t))if(s.startsWith(i))return s.replace(i,a)},"findAlias"),n=Le(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const a=X(s),c=G(e.options.externals,a)||G(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||je(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:l}of n)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!c&&!he.has(s)&&e.logger.info({message:'Inlined implicit external "'+b(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),he.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),onLog:$((s,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
64
|
-
${i.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Ve(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Xe=$(async e=>{const t=oe(e,"build");let o;return e.options.rollup.resolve&&(o=Oe({extensions:F,...e.options.rollup.resolve})),{...Ge(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>O(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>ge(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!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:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>O(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>ge(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!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:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[Ie(),qe(),e.tsconfig&&He(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&ze(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ee({customResolver:o?.resolveId,...e.options.rollup.alias,entries:t}),o,e.options.rollup.polyfillNode&&Tt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Pe({...e.options.rollup.json}),To(e.logger),qt(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?.(jr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&_e({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ft(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&It({extensions:F,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Vo(e.pkg),e.options.rollup.raw&&Jo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Oo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Mo({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&bo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ce({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&At({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),wr=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),kr=fo(wr),Ye=$(async e=>{const t=oe(e,"types"),o={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let n;e.options.rollup.resolve&&(n=Oe({extensions:F,...e.options.rollup.resolve}));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ge(e,t,"dts"),onwarn(i,a){Ve(i,e)||i.code!=="EMPTY_BUNDLE"&&a(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>O(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:$(i=>O(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:$(i=>O(e,i,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[Ie(),qe(),e.options.rollup.json&&Pe({...e.options.rollup.json}),o,e.tsconfig&&He(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&ze(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ee({customResolver:n?.resolveId,...e.options.rollup.alias,entries:t}),n,await kr(s)(e),e.options.cjsInterop&&e.options.emitCJS&&_e({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&rr(e.options.rollup.patchTypes,e.logger),Vt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ce({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var xr=Object.defineProperty,Er=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"a$3");const Or=Er(async e=>{const t=await Xe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=await xe(t);await e.hooks.callHook("rollup:build",e,o);const r=t.output,n=new Map;for(const s of r){const{output:i}=await o.write(s),a=new Set,c=i.filter(u=>u.type==="chunk");for(const u of c){a.add(u.fileName);for(const p of u.imports)e.usedImports.add(p);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(p=>c.find(d=>d.fileName===p)),exports:u.exports,modules:Object.entries(u.modules).map(([p,d])=>({bytes:d.renderedLength,id:p})),path:u.fileName,type:"entry"})}const l=i.filter(u=>u.type==="asset");for(const u of l)n.has(u.fileName)||n.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of a)e.usedImports.delete(u)}e.buildEntries.push(...n.values())},"build");var Sr=Object.defineProperty,W=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"r$3");const Dr=W(async e=>{const t=await Ye(e);if(await e.hooks.callHook("rollup:dts:options",e,t),Object.keys(t.input).length===0)return;const o=await xe(t);await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:W(r=>O(e,r,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:W(r=>O(e,r,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:W(r=>O(e,r,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Nr=Object.defineProperty,Ke=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"l$3");const ye=Ke((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${b(D(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),_r=Ke(async e=>{const t=await Xe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=le(t);await e.hooks.callHook("rollup:watch",e,o);const r=[...Array.isArray(t.input)?t.input:typeof t.input=="string"?[t.input]:Object.keys(t.input??{})];let n="Starting watchers for entries:";for(const s of r)n+=P(`
|
|
65
|
-
└─ ${D(process.cwd(),s)}`);if(e.logger.info(n),ye(o,"bundle",e.logger),e.options.declaration){const s=await Ye(e);await e.hooks.callHook("rollup:dts:options",e,s);const i=le(s);await e.hooks.callHook("rollup:watch",e,i),ye(i,"types",e.logger)}},"watch");var Pr=Object.defineProperty,Mr=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"i$2");const Qe=Mr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Cr=Object.defineProperty,B=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"l$2");const Ir=Z,Fr=B((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=B(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=B(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Ir(n,null,{resolve:e})}else r=B(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Rr=Object.defineProperty,Tr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"t$4");const Ar=Tr(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var Wr=Object.defineProperty,Ze=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"t$3");const ne=Ze(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),et=Ze((e,t,o,r)=>{if(o){const i=ne(o);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r==="commonjs"?"cjs":"esm";const[n,...s]=t;return et(n,s,o,r)},"inferExportType");var Br=Object.defineProperty,Jr=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"f$3");const se=Jr((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ne(e),s=t==="module"?"esm":"cjs";if(n&&n!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:n??s}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>n==="types"&&!o?[]:typeof s=="string"?{file:s,type:et(n,r,s,t)}:se(s,t,o,[...r,n]))},"extractExportFilenames");var Lr=Object.defineProperty,zr=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"e");const Ur=zr(e=>{const t=J(e).split("/");return t.map((o,r)=>t.slice(r).join("/")).filter(Boolean)},"getEntrypointPaths");var Hr=Object.defineProperty,qr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"h$1");const Vr=qr((e,t,o,r=".")=>{const n=[];t.sort((p,d)=>p.split("/").length-d.split("/").length);const s=se(e.exports,e.type??"commonjs",o);if(e.bin){const p=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of p)s.push({file:d,isExecutable:!0})}e.main&&s.push({file:e.main,type:ne(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&s.push({file:e.module,type:"esm"}),o===void 0&&(e.types||e.typings)&&s.push({file:e.types??e.typings});const i=e.type==="module";for(const p of s.filter(d=>!d.type)){const d=p.file.endsWith(".js");i&&d||p.file.endsWith(".mjs")?p.type="esm":(!i&&d||p.file.endsWith(".cjs"))&&(p.type="cjs")}let a=!1,c=!1,l=!1;const u=[];for(const p of s){const d=p.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),h=d.endsWith("/");if(h&&["./","/"].includes(d))continue;const f=Ur(d).reduce((v,k)=>{if(v)return v;const N=new RegExp(`(?<=/|$)${k}${h?"":"\\.\\w+"}$`);return t.find(j=>N.test(j))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!f){ee(g(r,p.file))||n.push(`Could not find entrypoint for \`${p.file}\``);continue}p.type==="cjs"&&(a=!0),p.type==="esm"&&(c=!0);const y=u.find(v=>v.input===f)??u[u.push({input:f})-1];/\.d\.(?:m|c)?ts$/.test(p.file)&&(l=!0),h&&(y.outDir=d),p.isExecutable&&(y.isExecutable=!0)}return{cjs:a,dts:l,entries:u,esm:c,warnings:n}},"inferEntries");var Gr=Object.defineProperty,Xr=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"t$2");const Yr=Xr((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Kr=Object.defineProperty,Qr=m((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"t$1");const Zr={hooks:{"build:prepare":Qr(function(e){if(e.options.entries.length>0)return;const t=x(e.options.rootDir,"src");if(!ee(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=dt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...e.pkg};r.publishConfig&&(r=Yr(r,e.options.declaration));const n=Vr(r,o,e.options.declaration,e.options.rootDir);for(const s of n.warnings)T(e,s);if(e.options.entries.push(...n.entries),e.options.emitCJS===void 0&&n.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&n.dts&&(e.options.declaration=n.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b(e.options.entries.map(s=>E(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),P([n.esm&&"esm",n.cjs&&"cjs",n.dts&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var en=Object.defineProperty,tn=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"r");const tt=tn((e,t)=>ke(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var on=Object.defineProperty,rn=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"t");const nn=rn((e,t)=>(e==="auto"?e=Zr:typeof e=="string"&&(e=tt(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var sn=Object.defineProperty,an=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"o");const ln=an(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),r=new Set;for(const n of e.usedImports)o.delete(n),t.add(n);if(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)o.delete(n);for(const n of t)!G(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(X(n))&&!e.options.peerDependencies.includes(X(n))&&r.add(n);o.size>0&&T(e,`Potential unused dependencies found: ${[...o].map(n=>b(n)).join(", ")}`),r.size>0&&T(e,`Potential implicit dependencies found: ${[...r].map(n=>b(n)).join(", ")}`)},"validateDependencies");var pn=Object.defineProperty,ot=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"i");const cn=ot((e,t)=>Ut(e,t)<=e.length/3||t.includes(e),"isSimilar"),un=ot((e,t)=>{const o=e.toLowerCase();return t.filter(r=>cn(r.toLowerCase(),o))},"findAlternatives");var mn=Object.defineProperty,ve=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"n");const dn=ve((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...se(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&g(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!ee(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=ve(a=>D(t.rootDir,g(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>n(a.path));let i="Potential missing or wrong package.json files:";for(const a of r){const c=un(a,s);i+=`
|
|
66
|
-
- `+b(a)+(c.length>0?lt` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}T(t,i)}},"validatePackage");var fn=Object.defineProperty,w=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"m");const be=w((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
67
|
-
`),e.logger.warn(`Build is done with some warnings:
|
|
68
|
-
|
|
69
|
-
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
70
|
-
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),M(1)))},"logErrors"),gn=w(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),hn=w((e,t,o,r,n,s,i,a)=>{const c=gn(a?.config.compilerOptions?.jsx),l=Dt(n,i.packem,r,s,{alias:{},clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:R.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.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:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:R.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},json:{preferConst:!0},license:{dependenciesTemplate:w((u,p,d)=>`
|
|
71
|
-
# Licenses of bundled dependencies
|
|
72
|
-
The published ${d} artifact additionally contains code with the following licenses:
|
|
73
|
-
${u.join(", ")}
|
|
74
|
-
|
|
75
|
-
# Bundled dependencies:
|
|
76
|
-
`+p,"dependenciesTemplate"),dtsTemplate:w((u,p,d)=>`
|
|
77
|
-
# Licenses of bundled types
|
|
78
|
-
The published ${d} artifact additionally contains code with the following licenses:
|
|
79
|
-
${u.join(", ")}
|
|
80
|
-
|
|
81
|
-
# Bundled types:
|
|
82
|
-
`+p,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ae,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:R.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.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:a?.config.compilerOptions?.experimentalDecorators,dynamicImport:!0,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:R.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Fr(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:ae}},rootDir:t,sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const u=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(u.has("esbuild"))l.transformerName="esbuild";else if(u.has("@swc/core"))l.transformerName="swc";else if(u.has("sucrase"))l.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+b(l.transformerName)+'" as transformer.')}return l.outDir=g(l.rootDir,l.outDir),l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
83
|
-
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.
|
|
84
|
-
To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),l.dependencies=Object.keys(i.dependencies??{}),l.peerDependencies=Object.keys(i.peerDependencies??{}),l.devDependencies=Object.keys(i.devDependencies??{}),l.optionalDependencies=Object.keys(i.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),yn=w(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let r=je(o.input)?D(t,o.input):J(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=Ar(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Qe(o)}`);if(!e.options.declaration&&o.declaration===void 0&&(o.declaration=e.options.declaration),o.input=g(e.options.rootDir,o.input),!ft(o.input)){const r=new Set(await st(Q(o.input)));let n=!1;for(const s of F)if(r.has(L(o.input)+s)){n=!0;break}if(!n)throw new bt("Your configured entry: "+b(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),vn=w((e,t,o)=>{const r=w(s=>D(t.rootDir,g(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const c of s.chunks??[])i+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let a=` ${E(r(s.path))} (${["total size: "+b(_(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+b(_(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
|
|
85
|
-
exports: `+P(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
|
|
86
|
-
${s.chunks.map(c=>{const l=t.buildEntries.find(u=>u.path===c)??{};return P(" └─ "+r(c)+E(l.bytes?" ("+_(l?.bytes)+")":""))}).join(`
|
|
87
|
-
`)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,u)=>(u.bytes||0)-(l.bytes||0)).map(l=>P(" 📦 "+r(l.id)+E(l.bytes?" ("+_(l.bytes)+")":""))).join(`
|
|
88
|
-
`);a+=c.length>0?`
|
|
89
|
-
inlined modules:
|
|
90
|
-
`+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",c=s.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),a+=p&&l===o.type?`
|
|
91
|
-
types:
|
|
92
|
-
`+[u,p].map(d=>P(" └─ ")+E(r(d.path))+" (total size: "+b(_(d.bytes??0))+")").join(`
|
|
93
|
-
`):`
|
|
94
|
-
types: `+E(r(u.path))+" (total size: "+b(_(u.bytes??0))+")"}}n=!0,a+=`
|
|
95
|
-
|
|
96
|
-
`,e.raw(s.chunk?P(a):a)}return n&&e.raw("Σ Total dist size (byte size):",b(_(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
|
|
97
|
-
`),n},"showSizeInformation"),bn=w(async(e,t,o,r,n,s,i,a,c)=>{const l=nn(r,t),u=hn(e,t,o,n,s,l,i,a);gt(u.outDir);const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Nt(),logger:e,mode:o,options:u,pkg:i,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),n.hooks&&p.hooks.addHooks(n.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),p.options.emitESM===!1&&p.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(p.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");p.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),p.options.declaration||e.info("Declaration files, are disabled."),await yn(p,t),await p.hooks.callHook("build:before",p);let d="Building";if(o==="watch"?d="Watching":o==="jit"&&(d="Stubbing"),e.info(b(`${d} ${p.options.name}`)),e.debug(`${E("Root dir:")} ${p.options.rootDir}
|
|
98
|
-
${E("Entries:")}
|
|
99
|
-
${p.options.entries.map(f=>` ${Qe(f)}`).join(`
|
|
100
|
-
`)}`),p.options.clean)for(const f of new Set(p.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===p.options.rootDir||p.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||c.some(y=>f.startsWith(y))||(c.push(f),e.info(`Cleaning dist directory: \`./${D(p.options.rootDir,f)}\``),await ht(f));if(p.options.stub){await no(p),await p.hooks.callHook("build:done",p);return}if(o==="watch"){await _r(p),be(p,!1);return}await Promise.all([Or(p),p.options.declaration&&Dr(p)]),e.success(pt(`Build succeeded for ${p.options.name}`));for await(const f of yt(p.options.outDir)){let y=p.buildEntries.find(v=>x(p.options.outDir,v.path)===f.path);if(y||(y={chunk:!0,path:f.path},p.buildEntries.push(y)),!y.bytes){const v=await $e(g(p.options.outDir,f.path));y.bytes=v.size}}const h=vn(e,p,i);ln(p),dn(i,p),await p.hooks.callHook("build:done",p),be(p,h)},"build"),ns=w(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...i}=o,a=[new Et,new Ot];n&&a.push(new St);const c=xt({logLevel:n?"debug":"informational",processors:a,scope:"packem"});c.wrapAll(),e=g(at(),e),c.debug("Root directory:",e);let l;if(s){const u=x(e,s);await vt(u)||(c.error("tsconfig.json not found at",u),M(1)),l={config:jt(u),path:u},c.info("Using tsconfig settings at",u)}else try{l=await wt(e),c.debug("Using tsconfig settings found at",l.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=x(e,"package.json"),p=kt(u);c.debug("Using package.json found at",u);const d=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),M(1));const h=tt(d,e);c.debug("Using packem config found at",x(e,d));const f=(Array.isArray(h)?h:[h]).filter(Boolean),y=Date.now(),v=w(()=>$t(Math.floor(Date.now()-y)),"getDuration");let k=p.packem?.preset??o.preset??"auto";const N=[],j=[];for(const I of f)I.preset&&(k=I.preset),j.push(bn(c,e,t,k,i,I,p,l,N));await Promise.all(j),c.raw(`
|
|
101
|
-
⚡️ Build`+(j.length>1?"s":"")+" run in "+v()),c.restoreAll(),M(0)}catch(u){c.error("An error occurred while building",u),M(1)}},"createBundler");export{ns as default};
|
|
9
|
+
export{g as default};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";var Ye=Object.defineProperty;var m=(e,t)=>Ye(e,"name",{value:t,configurable:!0});const L=require("node:fs/promises"),Ke=require("node:module"),w=require("node:process"),g=require("@visulima/colorize"),v=require("@visulima/fs"),Qe=require("@visulima/fs/error"),S=require("@visulima/humanizer"),H=require("@visulima/package"),Ze=require("@visulima/package/package-json"),et=require("@visulima/pail"),W=require("@visulima/pail/processor"),f=require("@visulima/path"),tt=require("defu"),st=require("hookable"),N=require("./packem.CKW9adaV.cjs"),fe=require("node:url"),A=require("mlly"),nt=require("magic-string"),ot=require("jiti"),q=require("rollup"),rt=require("@rollup/plugin-alias"),it=require("@rollup/plugin-commonjs"),at=require("@rollup/plugin-dynamic-import-vars"),ge=require("@rollup/plugin-node-resolve"),lt=require("@rollup/plugin-replace"),ct=require("@rollup/plugin-wasm"),pt=require("rollup-plugin-polyfill-node"),ut=require("rollup-plugin-visualizer"),he=require("semver"),dt=require("glob"),mt=require("glob-parent"),ft=require("@rollup/plugin-json"),I=require("@rollup/pluginutils"),gt=require("rollup-plugin-license"),ht=require("@babel/parser"),yt=require("node:crypto"),Y=require("node:fs"),vt=require("fastest-levenshtein");var se=typeof document<"u"?document.currentScript:null;const k=m(e=>e&&typeof e=="object"&&"default"in e?e.default:e,"_interopDefaultCompat"),ne=k(Ke),P=k(nt),ye=k(ot),ve=k(rt),bt=k(it),jt=k(at),be=k(lt),$t=k(pt),wt=k(mt),xt=k(ft),kt=k(gt),je="@visulima/packem",$e="1.0.0-alpha.23",Et="A fast and modern bundler for Node.js and TypeScript.",_t=["anolilab","assets","bundle","bundler","cjs","commonjs","compiler","css","declaration","es6","esbuild","esm","exports","package.json","packem","rollup","sucrase","swc","typescript","visulima","zero config"],Ot="https://www.visulima.com/docs/package/packem",St={type:"git",url:"https://github.com/visulima/packem.git",directory:"packages/packem"},Dt=[{type:"github",url:"https://github.com/sponsors/prisis"},{type:"consulting",url:"https://anolilab.com/support"}],Nt="MIT",Pt={name:"Daniel Bannert",email:"d.bannert@anolilab.de"},Mt=!1,It="module",Ct={".":{require:{types:"./dist/create-bundler.d.cts",default:"./dist/create-bundler.cjs"},import:{types:"./dist/create-bundler.d.mts",default:"./dist/create-bundler.mjs"}},"./config":{require:{types:"./dist/config.d.cts",default:"./dist/config.cjs"},import:{types:"./dist/config.d.mts",default:"./dist/config.mjs"}},"./transformer/esbuild":{require:{types:"./dist/rollup/plugins/esbuild/index.d.cts",default:"./dist/rollup/plugins/esbuild/index.cjs"},import:{types:"./dist/rollup/plugins/esbuild/index.d.mts",default:"./dist/rollup/plugins/esbuild/index.mjs"}},"./transformer/swc":{require:{types:"./dist/rollup/plugins/swc/index.d.cts",default:"./dist/rollup/plugins/swc/index.cjs"},import:{types:"./dist/rollup/plugins/swc/index.d.mts",default:"./dist/rollup/plugins/swc/index.mjs"}},"./transformer/sucrase":{require:{types:"./dist/rollup/plugins/sucrase/index.d.cts",default:"./dist/rollup/plugins/sucrase/index.cjs"},import:{types:"./dist/rollup/plugins/sucrase/index.d.mts",default:"./dist/rollup/plugins/sucrase/index.mjs"}},"./package.json":"./package.json"},Ft="./dist/create-bundler.cjs",Rt="./dist/create-bundler.mjs",Tt="./dist/create-bundler.d.ts",At={packem:"./dist/cli.cjs"},qt=["dist/**","README.md","CHANGELOG.md","LICENSE.md"],Lt={build:"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build","build:prod":"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build --minify",clean:"rimraf node_modules dist .eslintcache",dev:"pnpm run build","lint:eslint":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs","lint:eslint:fix":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix","lint:packagejson":"publint --strict","lint:prettier":"prettier --config=.prettierrc.cjs --check .","lint:prettier:fix":"prettier --config=.prettierrc.cjs --write .","lint:types":"tsc --noEmit",test:"vitest run","test:coverage":"vitest run --coverage","test:ui":"vitest --ui --coverage.enabled=true","test:watch":"vitest"},Bt={"@antfu/install-pkg":"^0.3.3","@babel/parser":"^7.24.6","@rollup/plugin-alias":"^5.1.0","@rollup/plugin-commonjs":"^25.0.8","@rollup/plugin-dynamic-import-vars":"^2.1.2","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-wasm":"^6.2.2","@rollup/pluginutils":"^5.1.0","@visulima/cerebro":"^1.0.29","@visulima/colorize":"^1.4.1","@visulima/fs":"^2.1.2","@visulima/humanizer":"^1.0.3","@visulima/package":"^1.8.3","@visulima/pail":"^1.1.11","@visulima/path":"^1.0.1","@clack/prompts":"^0.7.0",defu:"6.1.4","es-module-lexer":"^1.5.3","fastest-levenshtein":"^1.0.16",glob:"^10.4.1","glob-parent":"^6.0.2",hookable:"^5.5.3","magic-string":"^0.30.10",mlly:"^1.7.0",rollup:"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-license":"^3.4.0","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-visualizer":"^5.12.0",semver:"^7.6.2"},Wt={"@anolilab/eslint-config":"^15.0.3","@anolilab/prettier-config":"^5.0.14","@anolilab/semantic-release-pnpm":"^1.1.0","@anolilab/semantic-release-preset":"^8.1.0","@babel/core":"^7.24.6","@rushstack/eslint-plugin-security":"^0.8.1","@secretlint/secretlint-rule-preset-recommend":"^8.2.4","@swc/core":"^1.5.7","@swc/types":"0.1.7","@total-typescript/ts-reset":"^0.5.1","@types/estree":"^1.0.5","@types/glob":"^8.1.0","@types/glob-parent":"^5.1.3","@types/micromatch":"^4.0.7","@types/node":"18.18.14","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/semver":"^7.5.8","@vitest/coverage-v8":"^1.6.0","@vitest/ui":"^1.6.0","cross-env":"^7.0.3",esbuild:"^0.21.4",eslint:"^8.56.0","eslint-plugin-deprecation":"^2.0.0","eslint-plugin-etc":"^2.0.3","eslint-plugin-import":"npm:eslint-plugin-i@^2.29.1","eslint-plugin-mdx":"^3.1.5","eslint-plugin-vitest":"^0.4.1","eslint-plugin-vitest-globals":"^1.5.0","estree-walker":"^3.0.3",execa:"^9.1.0",jiti:"^1.21.0",prettier:"^3.2.5",react:"^18.3.1","react-dom":"^18.3.1",rimraf:"^5.0.7",secretlint:"8.2.4","semantic-release":"^23.1.1","sort-package-json":"^2.10.0",sucrase:"^3.35.0",tempy:"^3.1.0","ts-essentials":"^10.0.0",typescript:"^5.4.5",vitest:"^1.6.0"},Jt={"@swc/core":"^1.5.7",esbuild:"^0.20.2 || ^0.21.3",jiti:"^1.21.0",sucrase:"^3.35.0",typescript:"^4.5 || ^5.0"},zt={"@swc/core":{optional:!0},esbuild:{optional:!0},sucrase:{optional:!0},typescript:{optional:!0}},Ut={node:">=18.* <=21.*"},Ht={access:"public",provenance:!0},Vt={"eslint-config":{plugin:{tsdoc:!1,"testing-library-react":!1,"react-usememo":!1,"react-hooks":!1,"jsx-a11y":!1,react:!1,"validate-jsx-nesting":!1,"ssr-friendly":!1},warn_on_unsupported_typescript_version:!1,info_on_disabling_jsx_react_rule:!1,info_on_disabling_prettier_conflict_rule:!1,info_on_disabling_jsonc_sort_keys_rule:!1,info_on_disabling_etc_no_deprecated:!1}},Xt={name:je,version:$e,description:Et,keywords:_t,homepage:Ot,repository:St,funding:Dt,license:Nt,author:Pt,sideEffects:Mt,type:It,exports:Ct,main:Ft,module:Rt,types:Tt,bin:At,files:qt,scripts:Lt,dependencies:Bt,devDependencies:Wt,peerDependencies:Jt,peerDependenciesMeta:zt,engines:Ut,publishConfig:Ht,anolilab:Vt};var Gt=Object.defineProperty,B=m((e,t)=>Gt(e,"name",{value:t,configurable:!0}),"i$a");const K=/^#![^\n]*/,V=B(async e=>{await L.chmod(e,493).catch(()=>{})},"makeExecutable"),Yt=B((e,t=`#!/usr/bin/env node
|
|
2
|
+
`)=>({name:"packem:shebang",renderChunk:{handler(s,n,o){if(!n.isEntry||!n.facadeModuleId||s.startsWith("#")&&s[1]==="!")return null;if(e.includes(n.name)){const r=new P(s);return r.prepend(t),{code:r.toString(),map:o.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(s,n){for(const[o,r]of Object.entries(n))if(r.type==="chunk"&&K.test(r.code)&&s.dir){const i=f.resolve(s.dir,o);await V(i)}}}),"shebangPlugin"),Kt=B(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(K,"")}}),"removeShebangPlugin"),Qt=B((e,t=`
|
|
3
|
+
`)=>{const s=K.exec(e);return s?s+t:""},"getShebang");var Zt=Object.defineProperty,es=m((e,t)=>Zt(e,"name",{value:t,configurable:!0}),"p$2");const Q=es((e,t)=>{let s={};if(e.pkg.name&&(s[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const o in n){if(o.startsWith("#"))continue;const r=n[o];typeof r=="string"&&(s[o]=f.join(e.rootDir,r))}}return s={...s,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(s,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(s,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(s),prefix:t}),s},"resolveAliases");var ts=Object.defineProperty,ss=m((e,t)=>ts(e,"name",{value:t,configurable:!0}),"o$3");const ns=ss((e,t)=>{const s=ye(t,{esmResolve:!0,interopDefault:!0});try{return s.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 os=Object.defineProperty,rs=m((e,t)=>os(e,"name",{value:t,configurable:!0}),"r$8");const C=rs((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var is=Object.defineProperty,as=m((e,t)=>is(e,"name",{value:t,configurable:!0}),"u$9");const ls=as(async e=>{const t=await A.resolvePath("jiti",{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:se&&se.src||new URL("shared/packem.DnU5ZLGg.cjs",document.baseURI).href}),s=JSON.stringify({...e.options.stubOptions.jiti,alias:{...Q(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),r=f.normalize(ns(n.input,e.options.rootDir)||n.input),i=r.slice(0,Math.max(0,r.length-f.extname(r).length)),a=await v.readFile(r),p=Qt(a);e.options.emitCJS&&await v.writeFile(`${o}.cjs`,p+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
|
|
4
|
+
`));let c=[];try{c=await A.resolveModuleExportNames(r,{extensions:N.DEFAULT_EXTENSIONS})}catch(l){C(e,`Cannot analyze ${r} for exports:${l}`);return}const u=c.includes("default")||c.length===0;await v.writeFile(`${o}.mjs`,p+[`import jiti from ${JSON.stringify(fe.pathToFileURL(t).href)};`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(r)})} */`,`const _module = await _jiti.import(${JSON.stringify(r)});`,u?`
|
|
5
|
+
export default _module;`:"",...c.filter(l=>l!=="default").map(l=>`export const ${l} = _module.${l};`)].join(`
|
|
6
|
+
`)),await v.writeFile(`${o}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
7
|
+
`)),await v.writeFile(`${o}.d.mts`,[`export * from ${JSON.stringify(r)};`,u?`export { default } from ${JSON.stringify(r)};`:""].join(`
|
|
8
|
+
`)),p&&(await V(`${o}.cjs`),await V(`${o}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var cs=Object.defineProperty,ps=m((e,t)=>cs(e,"name",{value:t,configurable:!0}),"a$a");const X=ps((e,t)=>e.some(s=>s instanceof RegExp?s.test(t):s===t),"arrayIncludes");var us=Object.defineProperty,ds=m((e,t)=>us(e,"name",{value:t,configurable:!0}),"a$9");const J=ds(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var ms=Object.defineProperty,fs=m((e,t)=>ms(e,"name",{value:t,configurable:!0}),"e$2");const G=fs((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var gs=Object.defineProperty,we=m((e,t)=>gs(e,"name",{value:t,configurable:!0}),"s$d");const hs=we((e,t,s)=>{const n=s??new Map;return(...o)=>{const r=t?typeof t=="function"?t(...o):t:JSON.stringify({args:o}),i=n.get(r);if(i!==void 0)return i;const a=e(...o);return n.set(r,a),a}},"memoize"),ys=we(e=>{const t=new Map;return s=>hs(e,s,t)},"memoizeByKey");var vs=Object.defineProperty,bs=m((e,t)=>vs(e,"name",{value:t,configurable:!0}),"m$5");const xe=bs(({addDefaultProperty:e=!1,logger:t,type:s})=>({name:"packem:cjs-interop",renderChunk(n,o,r){if(o.type!=="chunk"||!o.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(i===null||i.length<3)return null;const a=new P(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
9
|
+
module.exports.default = `+i[2]+";");let p=a.toString();return p=p.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"plugin:cjs-interop"}),{code:p,map:a.generateMap({hires:!0})}}if(r.format==="es"&&/\.d\.(?:ts|cts)$/.test(o.fileName)){if(s!=="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 a=i[1].split(", "),p=[];let c="";for(const l of a)if(!l.includes("type"))if(l.includes("as")){const[d,y]=l.split(" as ");if(y==="default"&&(c=d,!e))continue;p.push(y+": typeof "+d+";")}else p.push(l+": typeof "+l+";");const u=new P(n);return u.replace(" "+c+" as default,",""),u.append(`
|
|
10
|
+
|
|
11
|
+
declare const defaultExport: {
|
|
12
|
+
`+(p.length>0?" ":"")+p.join(`
|
|
13
|
+
`)+`
|
|
14
|
+
} & typeof `+c+`;
|
|
15
|
+
|
|
16
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+o.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var js=Object.defineProperty,$s=m((e,t)=>js(e,"name",{value:t,configurable:!0}),"f$9");const ws=$s((e,t)=>{const s=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:o}=n;return Array.isArray(o)?o=o.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof o=="string"&&(o=[{src:o}]),{async buildStart(){const r=await Promise.all(o.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await dt.glob(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:wt(i.src),src:a}))));for(const i of r)for(const a of i.src){let p;s.has(a)?p=s.get(a):(p={copied:[],dest:[],timestamp:0},s.set(a,p));const c=n.flatten?f.normalize(i.dest):f.join(i.dest,f.relative(i.parent,f.dirname(a)));p.dest.includes(c)||p.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...s].map(async([i,a])=>{let p;try{const c=await L.stat(i);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),p=await v.readFile(i,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const u=f.basename(i),l=f.join(c,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:l,source:p,type:"asset"}),t.debug({message:`copied ${i} → ${l}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${l}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var xs=Object.defineProperty,ks=m((e,t)=>xs(e,"name",{value:t,configurable:!0}),"n$6");const oe="export default ",ke=ks(e=>{const t=xt(e);return{...t,name:"packem:json",transform(s,n){const o=t.transform?.call(this,s,n);return o&&typeof o!="string"&&"code"in o&&o.code?.startsWith(oe)&&(o.code=o.code.replace(oe,"module.exports = ")),o}}},"JSONPlugin");class Es{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,s,n,o){t&&s&&(n!=null?t[s][n]=o:t[s]=o)}remove(t,s,n){t&&s&&(n!=null?t[s].splice(n,1):delete t[s])}}class _s extends Es{static{m(this,"SyncWalker")}constructor(t,s){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=s}visit(t,s,n,o){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,p=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,s,n,o),this.replacement&&(t=this.replacement,this.replace(s,n,o,t)),this.should_remove&&this.remove(s,n,o);const c=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=p,c)return t;if(u)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let p=0;p<a.length;p+=1){const c=a[p];re(c)&&(this.visit(c,t,r,p)||p--)}}else re(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,s,n,o),this.replacement&&(t=this.replacement,this.replace(s,n,o,t)),this.should_remove&&this.remove(s,n,o);const p=this.should_remove;if(this.replacement=i,this.should_remove=a,p)return null}}return t}}function re(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(re,"isNode");function Ee(e,{enter:t,leave:s}){return new _s(t,s).visit(e,null)}m(Ee,"walk");var Os=Object.defineProperty,Ss=m((e,t)=>Os(e,"name",{value:t,configurable:!0}),"u$7");const Ds=Ss(({attributes:e,logger:t})=>{const s=I.createFilter([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,o){if(!s(o))return null;let r=null;try{r=this.parse(n,{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${o}" and remove the jsx attribute.`}),t.warn(p),null}let i=!1;const a=new P(n);return Ee(r,{enter(p){if(p.type==="CallExpression"&&p.callee.type==="Identifier"&&p.callee.name==="jsx"){const c=p.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const l of u.properties)l.type==="Property"&&l.key.type==="Literal"&&l.value.type==="Literal"&&e.includes(l.key.value)&&(a.overwrite(l.start-2,l.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Ns=Object.defineProperty,Z=m((e,t)=>Ns(e,"name",{value:t,configurable:!0}),"p$1");const Ps=Z(e=>{const t=[],s=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):s.push(n)}),[...s.sort(),...t.sort()]},"sortLicenses"),Ms=Z((e,t,s)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
|
|
17
|
+
${s}
|
|
18
|
+
$2`)},"replaceContentWithin"),_e=Z(({licenseFilePath:e,licenseTemplate:t,logger:s,marker:n,mode:o,packageName:r})=>kt({thirdParty(i){const a=new Set,p=i.sort(({name:u},{name:l})=>u>l?1:l>u?-1:0).map(({author:u,contributors:l,license:d,licenseText:y,maintainers:h,name:b,repository:j})=>{let E="## "+b+`
|
|
19
|
+
`;d&&(E+=`License: ${d}
|
|
20
|
+
`);const _=new Set;for(const O of[u,...h,...l]){const F=typeof O=="string"?O:O?.name;F&&_.add(F)}return _.size>0&&(E+=`By: ${[..._].join(", ")}
|
|
21
|
+
`),j&&(E+=`Repository: ${typeof j=="string"?j:j.url}
|
|
22
|
+
`),y&&(E+=`
|
|
23
|
+
`+y.trim().replaceAll(/(\r\n|\r)/g,`
|
|
24
|
+
`).split(`
|
|
25
|
+
`).map(O=>`> ${O}`).join(`
|
|
26
|
+
`)+`
|
|
27
|
+
`),d&&a.add(d),E}).join(`
|
|
28
|
+
---------------------------------------
|
|
29
|
+
|
|
30
|
+
`);if(p===""){s.info({message:"No dependencies license information found.",prefix:"plugin:license:"+o});return}const c=t(Ps(a),p,r);try{const u=v.readFileSync(e),l=Ms(u,n,c);if(!l){s.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+o});return}u!==l&&(v.writeFileSync(e,l),s.info({message:`${e} updated.`,prefix:"plugin:license:"+o}))}catch(u){s.error(u)}}}),"license");var Is=Object.defineProperty,Cs=m((e,t)=>Is(e,"name",{value:t,configurable:!0}),"i$7");const Fs=Cs(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const o=this.getModuleInfo(n);if(o!=null&&!o.isExternal)for(const r of o.importedIds)t.push({source:n,target:r})}if(Array.isArray(t)&&t.length===0)return;const s=f.resolve(e.outDir,"graph.json");v.writeJsonSync(s,t)},name:"packem:metafile"}),"metafilePlugin");var Rs=Object.defineProperty,Ts=m((e,t)=>Rs(e,"name",{value:t,configurable:!0}),"c$3");const As=/\.(?:m|c)?(?:j|t)sx?$/,qs=/^use \w+$/,Ls=Ts(e=>{const t={},s={};return{name:"packem:preserve-directives",onLog(n,o){return o.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,o,{sourcemap:r}){const i=o.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,u)=>(u&&u.forEach(l=>{c.add(l)}),c),new Set),a=new P(n);i.size>0&&(e.debug({message:`directives for chunk "${o.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(c=>`'${c}';`).join(`
|
|
31
|
+
`)}
|
|
32
|
+
`));let p=null;return o.facadeModuleId&&typeof s[o.facadeModuleId]=="string"&&(p=s[o.facadeModuleId]),p&&(e.debug({message:`shebang for chunk "${o.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${p}
|
|
33
|
+
`)),i.size===0&&p===null?null:{code:a.toString(),map:r?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,o){const r=f.extname(o);if(!As.test(r))return null;let i=!1;const a=new P(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let u=2,l=n.length;u<l;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){c=u;break}}c&&(s[o]=n.slice(0,c),a.remove(0,c+1),i=!0,e.debug({message:`shebang for module "${o}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(a.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(p.type!=="Program")return null;for(const c of p.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let u=null;"directive"in c?u=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&qs.test(c.expression.value)&&(u=c.expression.value),u!=="use strict"&&u&&(t[o]||=new Set,t[o].add(u),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(a.remove(c.start,c.end),i=!0),e.debug({message:`directive "${u}" for module "${o}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[o]??[]],shebang:s[o]??null}}}:null},order:"post"}}},"preserveDirectives");var Bs=Object.defineProperty,Ws=m((e,t)=>Bs(e,"name",{value:t,configurable:!0}),"r$6");const Js={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},zs=Ws((e={})=>{e={...e,...Js};const t=I.createFilter(e.include,e.exclude);return{name:"packem:raw",transform(s,n){return t(n)?{code:`export default ${JSON.stringify(s)}`,map:null}:null}}},"rawPlugin");var Us=Object.defineProperty,Hs=m((e,t)=>Us(e,"name",{value:t,configurable:!0}),"l$4");const z="\0__file_url__",Oe=Hs(()=>({async load(e){if(e.startsWith(z)){const t=fe.fileURLToPath(e.slice(z.length));return await v.readFile(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${z}${e}`}}),"resolveFileUrl");var Vs=Object.defineProperty,Se=m((e,t)=>Vs(e,"name",{value:t,configurable:!0}),"i$4");const Xs=/__filename|__dirname|require\(|require\.resolve\(/,De=`
|
|
34
|
+
// -- pack CommonJS Shims --
|
|
35
|
+
import __cjs_url__ from "node:url";
|
|
36
|
+
import __cjs_path__ from "node:path";
|
|
37
|
+
import __cjs_mod__ from "node:module";
|
|
38
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
39
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
40
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
41
|
+
`,Ne=`
|
|
42
|
+
// -- pack CommonJS Shims Node 20.11 --
|
|
43
|
+
import __cjs_mod__ from "node:module";
|
|
44
|
+
const __filename = import.meta.filename;
|
|
45
|
+
const __dirname = import.meta.dirname;
|
|
46
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
47
|
+
`,Gs=Se((e,t)=>{if(w.env.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(De)||e.includes(Ne)||!Xs.test(e)))return null;const s=A.findStaticImports(e).pop(),n=s?s.end:0,o=new P(e);return o.appendRight(n,t),{code:o.toString(),map:o.generateMap()}},"CJSToESM"),Ys=Se(e=>({name:"packem:cjs",renderChunk(t,s,n){if(n.format==="es"){let o=De;if(e.engines?.node){const r=he.minVersion(e.engines.node);r&&r.major>=20&&r.minor>=11&&(o=Ne)}return Gs(t,o)}return null}}),"cjsPlugin");var Ks=Object.defineProperty,M=m((e,t)=>Ks(e,"name",{value:t,configurable:!0}),"s$a");const Qs=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Zs=/MIT License|MIT license|BSD license/,en=/\n{2,}/g,tn=/\b(\w+)\$\d+\b/g,sn=/[-/\\^$*+?.()|[\]{}]/g,nn=M(e=>e.replaceAll(sn,"\\$&"),"escapeRegex"),on=M(e=>[...new Set(e)],"unique"),rn=M(e=>e.replaceAll(Qs,t=>Zs.test(t)?"":t).replaceAll(en,`
|
|
48
|
+
|
|
49
|
+
`),"cleanUnnecessaryComments"),ie=new Map;function Pe(e,t,{identifierReplacements:s},n){const o=A.findStaticImports(e);for(const i in s){const a=o.find(c=>c.specifier===i&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const p=s[i];for(const c in p){a.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${i}" for replacement`),w.exit(1));const u=p[c],l=nn(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${l},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${l}\\b`,"g"),u)}}const r=on(Array.from(e.matchAll(tn),i=>i[0]));if(r.length>0){const i=r.map(p=>`
|
|
50
|
+
- ${p}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");ie.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
51
|
+
|
|
52
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),ie.set(a,!0)}return e}m(Pe,"v$2");M(Pe,"replaceConfusingTypeNames");function Me(e,t){if(t.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,s),!0}return!1}m(Me,"N$1");M(Me,"removeInternal");function Ie(e,t){if(e.includes("@internal")){const s=new P(e),n=ht.parse(e,{plugins:["typescript"],sourceType:"module"});Ee(n,{enter(o){Me(s,o)&&this.skip()}}),e=s.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),w.exit(1))}return e}m(Ie,"S$1");M(Ie,"stripInternalTypes");const an=M((e,t)=>({name:"packem:patch-types",renderChunk(s,n){return s=Pe.call(this,s,n,e,t),s=Ie.call(this,s,n),s=rn(s),s},resolveId(s){return s.startsWith("types/")?{external:!0,id:"../../"+(s.endsWith(".js")?s:s+".js")}:null}}),"patchTypescriptTypes");var ln=Object.defineProperty,Ce=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"u$5");const Fe=Ce((e,t=!0)=>{if(!e)return null;const{config:s,path:n}=e;if(!s.compilerOptions)return null;const{baseUrl:o,paths:r}=s.compilerOptions;if(!o)return null;const i=f.resolve(f.dirname(n),o),a=[];if(r)for(const[p,c]of Object.entries(r)){const u=new RegExp(`^${[...p].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let l=0;for(const d of c){const y=[...I.normalizePath(f.resolve(i,d))].map(h=>h==="*"?`$${++l}`:h==="$"?"$$":h).join("");a.push({find:u,replacement:y})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...I.normalizePath(i)].map(p=>p==="$"?"$$":p).join("")}/$1`}),a},"getConfigAlias"),Re=Ce((e,t)=>{const s=Fe(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,o,r){if(!s||n.includes("\0"))return null;for(const{find:i,replacement:a}of s)if(i.test(n)){const p=n.replace(i,a),c=await this.resolve(p,o,{skipSelf:!0,...r});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var cn=Object.defineProperty,Te=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"u$4");const pn=Te((e,t)=>{if(!t)return null;const{config:s,path:n}=t;if(!s.compilerOptions)return null;const{rootDirs:o}=s.compilerOptions;if(!o)return null;const r=[];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}.`);r.push(f.resolve(e,i))}return r},"getRootDirectories"),Ae=Te((e,t,s)=>{const n=pn(e,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(o,r,i){if(n===null||n.length===0)return null;if(o.startsWith("."))for(const a of n){const p=f.join(a,o),c=await this.resolve(p,r,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${o} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var un=Object.defineProperty,dn=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"r$5");const qe=dn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,s,n){return e.test(t)&&s?await this.resolve(t.replace(/js(x?)$/,"ts$1"),s,n):null}}},"resolveTypescriptMjsCts");var mn=Object.defineProperty,fn=m((e,t)=>mn(e,"name",{value:t,configurable:!0}),"s$9");const gn=fn(e=>{const t=f.basename(e).split(".");if(t.length>=2){const[s,n]=t.slice(-2),o=t[0],r=/^(\w+)-runtime$/.exec(s)?.[1];if(N.DEFAULT_EXTENSIONS.includes(n)&&r&&r.length>0)return o+"-"+r}},"getCustomModuleLayer");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"i$3");const U=yn(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var vn=Object.defineProperty,ae=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"c$1");const le=ae((e,t)=>{const s=new Map;return ae(function(n,o){const r=o.getModuleInfo(n);if(!r)return;const{isEntry:i}=r,a=r.meta,p=U(a);if(!i){const c=s.get(n);if(c)return c;const u=gn(n);if(u)return s.set(n,u),u}if(i){const c=o.getModuleIds();for(const u of c)o.getModuleInfo(u)&&U(a)===p&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,p]))}if(p&&!i&&e.has(n)){const c=[...e.get(n)];if(c.some(([l])=>{if(t.some(d=>d.path===l)){const d=o.getModuleInfo(l);return U(d?d.meta:{})===p}return!1}))return;if(c.every(([,l])=>l===p))return s.has(n)?s.get(n):void 0;const u=`${f.basename(n,f.extname(n))}-${p}`;return s.set(n,u),u}},"splitChunks")},"createSplitChunks");var bn=Object.defineProperty,jn=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"n$4");const D=jn((e,t,s)=>t.isDynamicEntry?`chunks/[name].${s}`:`shared/${e.options.name}.[hash].${s}`,"getChunkFilename");var $n=Object.defineProperty,wn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"s$7");const xn=process.platform==="win32",ce=wn((e,t)=>{const s=xn?"\\":"/";return e.name?.includes("node_modules"+s+".pnpm")?(e.name.replace("node_modules"+s+".pnpm","external")+"."+t).replace("node_modules"+s,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var kn=Object.defineProperty,$=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"l$3");const En=$((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 s="node"+w.versions.node.split(".")[0];if(t.pkg.engines?.node){const n=he.minVersion(t.pkg.engines.node);n&&(s="node"+n.major)}if(t.options.rollup.esbuild.target){const n=J(t.options.rollup.esbuild.target);n.some(o=>o.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...J(s),...n])])}else t.options.rollup.esbuild.target=J(s);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,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Le=$((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${g.cyan(f.relative(f.resolve(),e.id))}"
|
|
53
|
+
Is the module installed? Note:
|
|
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"),pe=new Map,Be=$((e,t,s)=>{const n=$(r=>{for(const[i,a]of Object.entries(t))if(r.startsWith(i))return r.replace(i,a)},"findAlias"),o=Fe(e.tsconfig,!1);return{external(r){const i=n(r);i&&(r=i);const a=G(r),p=X(e.options.externals,a)||X(e.options.externals,r);if(p)return!0;if(r.startsWith(".")||f.isAbsolute(r)||/src[/\\]/.test(r)||e.pkg.name&&r.startsWith(e.pkg.name))return!1;if(o){for(const{find:c}of o)if(c.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${c.source}`,prefix:s}),!1}return!p&&!pe.has(r)&&e.logger.info({message:'Inlined implicit external "'+g.cyan(r)+'". If this is incorrect, add it to the "externals" option.',prefix:s}),pe.set(r,!0),p},input:Object.fromEntries(e.options.entries.map(r=>[r.name,f.resolve(e.options.rootDir,r.input)])),onLog:$((r,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
56
|
+
${i.stack}`),r){case"info":{e.logger.info({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(r,i){Le(r,e)||r.code||i(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),We=$(async e=>{const t=Q(e,"build");let s;return e.options.rollup.resolve&&(s=ge.nodeResolve({extensions:N.DEFAULT_EXTENSIONS,...e.options.rollup.resolve})),{...Be(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(n=>D(e,n,"cjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>ce(n,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,...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:$(n=>D(e,n,"mjs"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:$(n=>ce(n,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,...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:[Oe(),qe(),e.tsconfig&&Ae(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Re(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:s?.resolveId,...e.options.rollup.alias,entries:t}),s,e.options.rollup.polyfillNode&&$t({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ke({...e.options.rollup.json}),Ls(e.logger),Yt(e.options.entries.filter(n=>n.isExecutable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&ct.wasm(e.options.rollup.wsam),e.options.transformer?.(En(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&jt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&bt({extensions:N.DEFAULT_EXTENSIONS,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Ys(e.pkg),e.options.rollup.raw&&zs(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Ds({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Fs({outDir:f.resolve(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&ws(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&_e({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ut.visualizer({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),_n=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),On=ys(_n),Je=$(async e=>{const t=Q(e,"types"),s={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let o;e.options.rollup.resolve&&(o=ge.nodeResolve({extensions:N.DEFAULT_EXTENSIONS,...e.options.rollup.resolve}));const r="dts-plugin:"+process.pid+e.tsconfig.path;return{...Be(e,t,"dts"),onwarn(i,a){Le(i,e)||i.code!=="EMPTY_BUNDLE"&&a(i)},output:[e.options.emitCJS&&{chunkFileNames:$(i=>D(e,i,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:$(i=>D(e,i,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:$(i=>D(e,i,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[Oe(),qe(),e.options.rollup.json&&ke({...e.options.rollup.json}),s,e.tsconfig&&Ae(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&Re(e.tsconfig,e.logger),e.options.rollup.replace&&be({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&ve({customResolver:o?.resolveId,...e.options.rollup.alias,entries:t}),o,await On(r)(e),e.options.cjsInterop&&e.options.emitCJS&&xe({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&an(e.options.rollup.patchTypes,e.logger),Kt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&_e({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Sn=Object.defineProperty,Dn=m((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"f$5");const Nn=Dn(async(e,t)=>{const s=await We(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-build");const n=await q.rollup(s);t.set("rollup-build",n.cache),await e.hooks.callHook("rollup:build",e,n);const o=s.output,r=new Map;for(const i of o){const{output:a}=await n.write(i),p=new Set,c=a.filter(l=>l.type==="chunk");for(const l of c){p.add(l.fileName);for(const d of l.imports)e.usedImports.add(d);l.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(l.code,"utf8"),chunks:l.imports.filter(d=>c.find(y=>y.fileName===d)),exports:l.exports,modules:Object.entries(l.modules).map(([d,y])=>({bytes:y.renderedLength,id:d})),path:l.fileName,type:"entry"})}const u=a.filter(l=>l.type==="asset");for(const l of u)r.has(l.fileName)||r.set(l.fileName,{bytes:Buffer.byteLength(l.source,"utf8"),path:l.fileName,type:"asset"});for(const l of p)e.usedImports.delete(l)}e.buildEntries.push(...r.values())},"build");var Pn=Object.defineProperty,R=m((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"r$3");const Mn=R(async(e,t)=>{const s=await Je(e);if(await e.hooks.callHook("rollup:dts:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-dts");const n=await q.rollup(s);t.set("rollup-dts",n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:R(o=>D(e,o,"d.cts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:R(o=>D(e,o,"d.mts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:R(o=>D(e,o,"d.ts"),"chunkFileNames"),dir:f.resolve(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var In=Object.defineProperty,ze=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"e$1");const ue=ze((e,t,s)=>{const n="watcher:"+t;e.on("change",(o,{event:r})=>{s.info({message:`${g.cyan(f.relative(".",o))} was ${r}d`,prefix:n})}),e.on("restart",()=>{s.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",o=>{o.code==="END"&&s.success({message:"Rebuild "+t+" finished",prefix:n}),o.code==="ERROR"&&s.error({context:[o.error],message:"Rebuild "+t+" failed: "+o.error.message,prefix:n})})},"watchHandler"),Cn=ze(async(e,t)=>{const s=await We(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-watch");const n=q.watch(s);await e.hooks.callHook("rollup:watch",e,n);const o=[...Array.isArray(s.input)?s.input:typeof s.input=="string"?[s.input]:Object.keys(s.input??{})];let r="Starting watchers for entries:";for(const i of o)r+=g.gray(`
|
|
57
|
+
└─ ${f.relative(process.cwd(),i)}`);if(e.logger.info(r),ue(n,"bundle",e.logger),e.options.declaration){const i=await Je(e);await e.hooks.callHook("rollup:dts:options",e,i);const a=q.watch(i);await e.hooks.callHook("rollup:watch",e,a),ue(a,"types",e.logger)}},"watch");var Fn=Object.defineProperty,Rn=m((e,t)=>Fn(e,"name",{value:t,configurable:!0}),"i$2");const Ue=Rn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Tn=Object.defineProperty,An=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"s$5");let qn=class{static{m(this,"h")}static{An(this,"FileCache")}#e;#t;#s=!0;constructor(t,s,n){this.#e=H.findCacheDirectorySync("visulima-packem",{create:!0,cwd:t});const o=yt.createHash("md5");o.update(s),this.#t=o.digest("hex"),this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#s=t}get(t){if(!this.#s||this.#e===void 0)return;const s=`${this.#e}/${t}-${this.#t}.json`;if(v.isAccessibleSync(s))return v.readJsonSync(s)}set(t,s){this.#s&&(this.#e===void 0||s===void 0||v.writeJsonSync(`${this.#e}/${t}-${this.#t}.json`,s,{indent:2,overwrite:!0}))}};var Ln=Object.defineProperty,T=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"l$2");const Bn=I.createFilter,Wn=T((e,t)=>{const{sideEffects:s}=t;let n;if(typeof s=="boolean")n=T(()=>s,"hasSideEffects");else if(Array.isArray(s))if(s.length<=0)n=T(()=>!1,"hasSideEffects");else{const o=s.map(r=>r.includes("/")?r:`**/${r}`);n=Bn(o,null,{resolve:e})}else n=T(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Jn=Object.defineProperty,zn=m((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"t$4");const Un=zn(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var Hn=Object.defineProperty,He=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"t$3");const ee=He(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Ve=He((e,t,s,n)=>{if(s){const i=ee(s);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,...r]=t;return Ve(o,r,s,n)},"inferExportType");var Vn=Object.defineProperty,Xn=m((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"f$3");const te=Xn((e,t,s,n=[])=>{if(!e)return[];if(typeof e=="string"){const o=ee(e),r=t==="module"?"esm":"cjs";if(o&&o!==r)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:o??r}]}return Object.entries(e).filter(([o])=>!o.endsWith(".json")).flatMap(([o,r])=>o==="types"&&!s?[]:typeof r=="string"?{file:r,type:Ve(o,n,r,t)}:te(r,t,s,[...n,o]))},"extractExportFilenames");var Gn=Object.defineProperty,Yn=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"e");const Kn=Yn(e=>{const t=f.normalize(e).split("/");return t.map((s,n)=>t.slice(n).join("/")).filter(Boolean)},"getEntrypointPaths");var Qn=Object.defineProperty,Zn=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"h$1");const eo=Zn((e,t,s,n=".")=>{const o=[];t.sort((l,d)=>l.split("/").length-d.split("/").length);const r=te(e.exports,e.type??"commonjs",s);if(e.bin){const l=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of l)r.push({file:d,isExecutable:!0})}e.main&&r.push({file:e.main,type:ee(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,type:"esm"}),s===void 0&&(e.types||e.typings)&&r.push({file:e.types??e.typings});const i=e.type==="module";for(const l of r.filter(d=>!d.type)){const d=l.file.endsWith(".js");i&&d||l.file.endsWith(".mjs")?l.type="esm":(!i&&d||l.file.endsWith(".cjs"))&&(l.type="cjs")}let a=!1,p=!1,c=!1;const u=[];for(const l of r){const d=l.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),y=d.endsWith("/");if(y&&["./","/"].includes(d))continue;const h=Kn(d).reduce((j,E)=>{if(j)return j;const _=new RegExp(`(?<=/|$)${E}${y?"":"\\.\\w+"}$`);return t.find(O=>_.test(O))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!h){Y.existsSync(f.resolve(n,l.file))||o.push(`Could not find entrypoint for \`${l.file}\``);continue}l.type==="cjs"&&(a=!0),l.type==="esm"&&(p=!0);const b=u.find(j=>j.input===h)??u[u.push({input:h})-1];/\.d\.(?:m|c)?ts$/.test(l.file)&&(c=!0),y&&(b.outDir=d),l.isExecutable&&(b.isExecutable=!0)}return{cjs:a,dts:c,entries:u,esm:p,warnings:o}},"inferEntries");var to=Object.defineProperty,so=m((e,t)=>to(e,"name",{value:t,configurable:!0}),"t$2");const no=so((e,t)=>{const{publishConfig:s}=e;return s&&(s.bin&&(typeof s.bin=="object"||typeof s.bin=="string")&&(e.bin=s.bin),s.type&&typeof s.type=="string"&&s.type!==""&&(e.type=s.type),s.main&&typeof s.main=="string"&&s.main!==""&&(e.main=s.main),s.module&&typeof s.module=="string"&&s.module!==""&&(e.module=s.module),t===void 0&&s.types&&typeof s.types=="string"&&s.types!==""?e.types=s.types:t===void 0&&s.typings&&typeof s.typings=="string"&&s.typings!==""&&(e.typings=s.typings),s.exports&&typeof s.exports=="object"&&(e.exports=s.exports)),e},"overwriteWithPublishConfig");var oo=Object.defineProperty,ro=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"t$1");const io={hooks:{"build:prepare":ro(function(e){if(e.options.entries.length>0)return;const t=f.join(e.options.rootDir,"src");if(!Y.existsSync(t))throw new Error("No 'src' directory found. Please provide entries manually.");const s=v.collectSync(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(s.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=no(n,e.options.declaration));const o=eo(n,s,e.options.declaration,e.options.rootDir);for(const r of o.warnings)C(e,r);if(e.options.entries.push(...o.entries),e.options.emitCJS===void 0&&o.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&o.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&o.dts&&(e.options.declaration=o.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",g.cyan(e.options.entries.map(r=>g.bold(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),g.gray([o.esm&&"esm",o.cjs&&"cjs",o.dts&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"r");const Xe=lo((e,t)=>ye(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var co=Object.defineProperty,po=m((e,t)=>co(e,"name",{value:t,configurable:!0}),"t");const uo=po((e,t)=>(e==="auto"?e=io:typeof e=="string"&&(e=Xe(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var mo=Object.defineProperty,fo=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"o");const go=fo(e=>{const t=new Set,s=new Set(Object.keys(e.pkg.dependencies??{})),n=new Set;for(const o of e.usedImports)s.delete(o),t.add(o);if(Array.isArray(e.options.dependencies))for(const o of e.options.dependencies)s.delete(o);for(const o of t)!X(e.options.externals,o)&&!o.startsWith("chunks/")&&!e.options.dependencies.includes(G(o))&&!e.options.peerDependencies.includes(G(o))&&n.add(o);s.size>0&&C(e,`Potential unused dependencies found: ${[...s].map(o=>g.cyan(o)).join(", ")}`),n.size>0&&C(e,`Potential implicit dependencies found: ${[...n].map(o=>g.cyan(o)).join(", ")}`)},"validateDependencies");var ho=Object.defineProperty,Ge=m((e,t)=>ho(e,"name",{value:t,configurable:!0}),"i");const yo=Ge((e,t)=>vt.distance(e,t)<=e.length/3||t.includes(e),"isSimilar"),vo=Ge((e,t)=>{const s=e.toLowerCase();return t.filter(n=>yo(n.toLowerCase(),s))},"findAlternatives");var bo=Object.defineProperty,de=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"n");const jo=de((e,t)=>{const s=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...te(e.exports,e.type??"commonjs",t.options.declaration).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 s)o&&!o.includes("*")&&!Y.existsSync(o)&&n.push(o.replace(`${t.rootDir}/`,""));if(n.length>0){const o=de(a=>f.relative(t.rootDir,f.resolve(t.options.outDir,a)),"rPath"),r=t.buildEntries.filter(a=>!a.chunk).map(a=>o(a.path));let i="Potential missing or wrong package.json files:";for(const a of n){const p=vo(a,r);i+=`
|
|
58
|
+
- `+g.cyan(a)+(p.length>0?g.grey` (did you mean ${p.map(c=>`"${c}"`).join(", ")}?)`:"")}C(t,i)}},"validatePackage");var $o=Object.defineProperty,x=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"m");const me=x((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
59
|
+
`),e.logger.warn(`Build is done with some warnings:
|
|
60
|
+
|
|
61
|
+
${[...e.warnings].map(s=>`- ${s}`).join(`
|
|
62
|
+
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),w.exit(1)))},"logErrors"),wo=x(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),xo=x((e,t,s,n,o,r,i,a)=>{const p=wo(a?.config.compilerOptions?.jsx),c=tt.defu(o,n,r,{alias:{},cache:!0,clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ne.builtinModules,...ne.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:w.env.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.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:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:w.env.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},json:{preferConst:!0},license:{dependenciesTemplate:x((u,l,d)=>`
|
|
63
|
+
# Licenses of bundled dependencies
|
|
64
|
+
The published ${d} artifact additionally contains code with the following licenses:
|
|
65
|
+
${u.join(", ")}
|
|
66
|
+
|
|
67
|
+
# Bundled dependencies:
|
|
68
|
+
`+l,"dependenciesTemplate"),dtsTemplate:x((u,l,d)=>`
|
|
69
|
+
# Licenses of bundled types
|
|
70
|
+
The published ${d} artifact additionally contains code with the following licenses:
|
|
71
|
+
${u.join(", ")}
|
|
72
|
+
|
|
73
|
+
# Bundled types:
|
|
74
|
+
`+l,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:N.EXCLUDE_REGEXP,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:w.env.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:p,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.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:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:w.env.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:p,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Wn(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:N.EXCLUDE_REGEXP}},rootDir:t,sourcemap:!1,stub:s==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!c.transformerName){const u=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(u.has("esbuild"))c.transformerName="esbuild";else if(u.has("@swc/core"))c.transformerName="swc";else if(u.has("sucrase"))c.transformerName="sucrase";else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info('Using "'+g.cyan(c.transformerName)+'" as transformer.')}return c.outDir=f.resolve(c.rootDir,c.outDir),c.rollup.resolve&&c.rollup.resolve.preferBuiltins===!0&&(c.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
75
|
+
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.
|
|
76
|
+
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.`),c.dependencies=Object.keys(i.dependencies??{}),c.peerDependencies=Object.keys(i.peerDependencies??{}),c.devDependencies=Object.keys(i.devDependencies??{}),c.optionalDependencies=Object.keys(i.optionalDependencies??{}),c.externals.push(...c.dependencies,...c.peerDependencies,...c.optionalDependencies),c},"generateOptions"),ko=x(async(e,t)=>{e.options.entries=e.options.entries.map(s=>typeof s=="string"?{input:s}:s);for await(const s of e.options.entries){if(typeof s.name!="string"){let n=f.isAbsolute(s.input)?f.relative(t,s.input):f.normalize(s.input);n.startsWith("./")&&(n=n.slice(2)),s.name=Un(n.replace(/^src\//,""))}if(!s.input)throw new Error(`Missing entry input: ${Ue(s)}`);if(!e.options.declaration&&s.declaration===void 0&&(s.declaration=e.options.declaration),s.input=f.resolve(e.options.rootDir,s.input),!v.isAccessibleSync(s.input)){const n=new Set(await L.readdir(f.dirname(s.input)));let o=!1;for(const r of N.DEFAULT_EXTENSIONS)if(n.has(f.basename(s.input)+r)){o=!0;break}if(!o)throw new Qe.NotFoundError("Your configured entry: "+g.cyan(s.input)+" does not exist.")}s.outDir=f.resolve(e.options.rootDir,s.outDir??e.options.outDir)}},"prepareEntries"),Eo=x((e,t,s)=>{const n=x(r=>f.relative(t.rootDir,f.resolve(t.options.outDir,r)),"rPath");let o=!1;for(const r of t.buildEntries.filter(i=>!i.chunk)){let i=r.bytes??0;for(const p of r.chunks??[])i+=t.buildEntries.find(c=>c.path===p)?.bytes??0;let a=` ${g.bold(n(r.path))} (${["total size: "+g.cyan(S.formatBytes(i)),r.type!=="asset"&&r.bytes&&"chunk size: "+g.cyan(S.formatBytes(r.bytes))].filter(Boolean).join(", ")})`;if(a+=r.exports?.length?`
|
|
77
|
+
exports: `+g.gray(r.exports.join(", ")):"",r.chunks?.length&&(a+=`
|
|
78
|
+
${r.chunks.map(p=>{const c=t.buildEntries.find(u=>u.path===p)??{};return g.gray(" └─ "+n(p)+g.bold(c.bytes?" ("+S.formatBytes(c?.bytes)+")":""))}).join(`
|
|
79
|
+
`)}`),r.modules&&r.modules.length>0){const p=r.modules.filter(c=>c.id.includes("node_modules")).sort((c,u)=>(u.bytes||0)-(c.bytes||0)).map(c=>g.gray(" 📦 "+n(c.id)+g.bold(c.bytes?" ("+S.formatBytes(c.bytes)+")":""))).join(`
|
|
80
|
+
`);a+=p.length>0?`
|
|
81
|
+
inlined modules:
|
|
82
|
+
`+p:""}if(t.options.declaration&&r.type==="entry"){let p=r.path.replace(/\.js$/,".d.ts"),c="commonjs";r.path.endsWith(".cjs")?p=r.path.replace(/\.cjs$/,".d.cts"):r.path.endsWith(".mjs")&&(c="module",p=r.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(l=>l.path.endsWith(p));if(u){let l;(t.options.declaration===!0||t.options.declaration==="compatible")&&!p.includes(".d.ts")&&(p=p.replace(c==="commonjs"?".d.c":".d.m",".d."),l=t.buildEntries.find(d=>d.path.endsWith(p))),a+=l&&c===s.type?`
|
|
83
|
+
types:
|
|
84
|
+
`+[u,l].map(d=>g.gray(" └─ ")+g.bold(n(d.path))+" (total size: "+g.cyan(S.formatBytes(d.bytes??0))+")").join(`
|
|
85
|
+
`):`
|
|
86
|
+
types: `+g.bold(n(u.path))+" (total size: "+g.cyan(S.formatBytes(u.bytes??0))+")"}}o=!0,a+=`
|
|
87
|
+
|
|
88
|
+
`,e.raw(r.chunk?g.gray(a):a)}return o&&e.raw("Σ Total dist size (byte size):",g.cyan(S.formatBytes(t.buildEntries.reduce((r,i)=>r+(i.bytes??0),0))),`
|
|
89
|
+
`),o},"showSizeInformation"),_o=x(async(e,t,s,n,o,r,i,a,p)=>{const c=uo(o.preset??n.preset??"auto",t),u=xo(e,t,s,n,o,c,r,i);a.isEnabled=u.cache,v.ensureDirSync(u.outDir);const l={buildEntries:[],dependencyGraphMap:new Map,hooks:st.createHooks(),logger:e,mode:s,options:u,pkg:r,rootDir:t,tsconfig:i,usedImports:new Set,warnings:new Set};if(c.hooks&&l.hooks.addHooks(c.hooks),n.hooks&&l.hooks.addHooks(n.hooks),o.hooks&&l.hooks.addHooks(o.hooks),await l.hooks.callHook("build:prepare",l),l.options.emitESM===!1&&l.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&i===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");l.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),l.options.declaration||e.info("Declaration files, are disabled."),await ko(l,t),await l.hooks.callHook("build:before",l);let d="Building";if(s==="watch"?d="Watching":s==="jit"&&(d="Stubbing"),e.info(g.cyan(`${d} ${l.options.name}`)),e.debug(`${g.bold("Root dir:")} ${l.options.rootDir}
|
|
90
|
+
${g.bold("Entries:")}
|
|
91
|
+
${l.options.entries.map(h=>` ${Ue(h)}`).join(`
|
|
92
|
+
`)}`),l.options.clean)for(const h of new Set(l.options.entries.map(b=>b.outDir).filter(Boolean).sort()))h===l.options.rootDir||l.options.rootDir.startsWith(h.endsWith("/")?h:`${h}/`)||p.some(b=>h.startsWith(b))||(p.push(h),e.info(`Cleaning dist directory: \`./${f.relative(l.options.rootDir,h)}\``),await v.emptyDir(h));if(l.options.stub){await ls(l),await l.hooks.callHook("build:done",l);return}if(s==="watch"){await Cn(l,a),me(l,!1);return}await Promise.all([Nn(l,a),l.options.declaration&&Mn(l,a)]),e.success(g.green(`Build succeeded for ${l.options.name}`));for await(const h of v.walk(l.options.outDir)){let b=l.buildEntries.find(j=>f.join(l.options.outDir,j.path)===h.path);if(b||(b={chunk:!0,path:h.path},l.buildEntries.push(b)),!b.bytes){const j=await L.stat(f.resolve(l.options.outDir,h.path));b.bytes=j.size}}const y=Eo(e,l,r);go(l),jo(r,l),await l.hooks.callHook("build:done",l),me(l,y)},"build"),Oo=x(async(e,t,s={})=>{const{configPath:n,debug:o,tsconfigPath:r,...i}=s,a=[new W.MessageFormatterProcessor,new W.ErrorProcessor];o&&a.push(new W.CallerProcessor);const p=et.createPail({logLevel:o?"debug":"informational",processors:a,scope:"packem"});e=f.resolve(w.cwd(),e),p.debug("Root directory:",e);const c=f.join(e,"package.json"),u=Ze.parsePackageJson(c);p.debug("Using package.json found at",c);let l;if(r){const d=f.join(e,r);await v.isAccessible(d)||(p.error("tsconfig.json not found at",d),w.exit(1)),l={config:H.readTsConfig(d),path:d},p.info("Using tsconfig settings at",d)}else try{l=await H.findTSConfig(e),p.debug("Using tsconfig settings found at",l.path)}catch{p.info("No tsconfig.json or jsconfig.json found.")}try{const d=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(p.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),w.exit(1));const y=Xe(d,e);p.debug("Using packem config found at",f.join(e,d));const h=(Array.isArray(y)?y:[y]).filter(Boolean),b=Date.now(),j=x(()=>S.duration(Math.floor(Date.now()-b)),"getDuration"),E=[],_=[],O=new qn(e,Xt.version,p);for(const F of h)_.push(_o(p,e,t,i,F,u,l,O,E));await Promise.all(_),p.raw(`
|
|
93
|
+
⚡️ Build`+(_.length>1?"s":"")+" run in "+j()),p.restoreAll(),w.exit(0)}catch(d){p.error("An error occurred while building",d),w.exit(1)}},"createBundler");exports.Oe=Oo;exports.name=je;exports.version=$e;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var rt=Object.defineProperty;var m=(e,t)=>rt(e,"name",{value:t,configurable:!0});import{chmod as it,stat as je,readdir as at}from"node:fs/promises";import ie from"node:module";import{env as R,exit as M,versions as lt,cwd as pt}from"node:process";import{cyan as b,gray as P,bold as O,grey as ct,green as ut}from"@visulima/colorize";import{readFile as Y,writeFile as A,readFileSync as dt,writeFileSync as mt,writeJsonSync as $e,isAccessibleSync as we,readJsonSync as ft,collectSync as gt,ensureDirSync as ht,emptyDir as yt,walk as vt,isAccessible as bt}from"@visulima/fs";import{NotFoundError as jt}from"@visulima/fs/error";import{formatBytes as N,duration as $t}from"@visulima/humanizer";import{findCacheDirectorySync as wt,readTsConfig as kt,findTSConfig as xt}from"@visulima/package";import{parsePackageJson as Et}from"@visulima/package/package-json";import{createPail as Ot}from"@visulima/pail";import{MessageFormatterProcessor as _t,ErrorProcessor as Dt,CallerProcessor as St}from"@visulima/pail/processor";import{resolve as g,join as E,normalize as B,extname as K,relative as S,dirname as Q,basename as J,isAbsolute as ke}from"@visulima/path";import{defu as Nt}from"defu";import{createHooks as Pt}from"hookable";import{a as I,E as ae}from"./packem.CxExFSHU.mjs";import{pathToFileURL as Mt,fileURLToPath as Ct}from"node:url";import{resolvePath as It,resolveModuleExportNames as Rt,findStaticImports as xe}from"mlly";import D from"magic-string";import Ee from"jiti";import{rollup as Oe,watch as le}from"rollup";import _e from"@rollup/plugin-alias";import Ft from"@rollup/plugin-commonjs";import Tt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as De}from"@rollup/plugin-node-resolve";import Se from"@rollup/plugin-replace";import{wasm as At}from"@rollup/plugin-wasm";import Lt from"rollup-plugin-polyfill-node";import{visualizer as Wt}from"rollup-plugin-visualizer";import{minVersion as Ne}from"semver";import{glob as Bt}from"glob";import Jt from"glob-parent";import zt from"@rollup/plugin-json";import{createFilter as Z,normalizePath as pe}from"@rollup/pluginutils";import Ut from"rollup-plugin-license";import{parse as Ht}from"@babel/parser";import{createHash as qt}from"node:crypto";import{existsSync as ee}from"node:fs";import{distance as Vt}from"fastest-levenshtein";
|
|
2
|
+
// -- pack CommonJS Shims --
|
|
3
|
+
import __cjs_url__ from "node:url";
|
|
4
|
+
import __cjs_path__ from "node:path";
|
|
5
|
+
import __cjs_mod__ from "node:module";
|
|
6
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
8
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
9
|
+
const Gt="@visulima/packem",Xt="1.0.0-alpha.23",Yt="A fast and modern bundler for Node.js and TypeScript.",Kt=["anolilab","assets","bundle","bundler","cjs","commonjs","compiler","css","declaration","es6","esbuild","esm","exports","package.json","packem","rollup","sucrase","swc","typescript","visulima","zero config"],Qt="https://www.visulima.com/docs/package/packem",Zt={type:"git",url:"https://github.com/visulima/packem.git",directory:"packages/packem"},es=[{type:"github",url:"https://github.com/sponsors/prisis"},{type:"consulting",url:"https://anolilab.com/support"}],ts="MIT",ss={name:"Daniel Bannert",email:"d.bannert@anolilab.de"},os=!1,ns="module",rs={".":{require:{types:"./dist/create-bundler.d.cts",default:"./dist/create-bundler.cjs"},import:{types:"./dist/create-bundler.d.mts",default:"./dist/create-bundler.mjs"}},"./config":{require:{types:"./dist/config.d.cts",default:"./dist/config.cjs"},import:{types:"./dist/config.d.mts",default:"./dist/config.mjs"}},"./transformer/esbuild":{require:{types:"./dist/rollup/plugins/esbuild/index.d.cts",default:"./dist/rollup/plugins/esbuild/index.cjs"},import:{types:"./dist/rollup/plugins/esbuild/index.d.mts",default:"./dist/rollup/plugins/esbuild/index.mjs"}},"./transformer/swc":{require:{types:"./dist/rollup/plugins/swc/index.d.cts",default:"./dist/rollup/plugins/swc/index.cjs"},import:{types:"./dist/rollup/plugins/swc/index.d.mts",default:"./dist/rollup/plugins/swc/index.mjs"}},"./transformer/sucrase":{require:{types:"./dist/rollup/plugins/sucrase/index.d.cts",default:"./dist/rollup/plugins/sucrase/index.cjs"},import:{types:"./dist/rollup/plugins/sucrase/index.d.mts",default:"./dist/rollup/plugins/sucrase/index.mjs"}},"./package.json":"./package.json"},is="./dist/create-bundler.cjs",as="./dist/create-bundler.mjs",ls="./dist/create-bundler.d.ts",ps={packem:"./dist/cli.cjs"},cs=["dist/**","README.md","CHANGELOG.md","LICENSE.md"],us={build:"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build","build:prod":"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build --minify",clean:"rimraf node_modules dist .eslintcache",dev:"pnpm run build","lint:eslint":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs","lint:eslint:fix":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix","lint:packagejson":"publint --strict","lint:prettier":"prettier --config=.prettierrc.cjs --check .","lint:prettier:fix":"prettier --config=.prettierrc.cjs --write .","lint:types":"tsc --noEmit",test:"vitest run","test:coverage":"vitest run --coverage","test:ui":"vitest --ui --coverage.enabled=true","test:watch":"vitest"},ds={"@antfu/install-pkg":"^0.3.3","@babel/parser":"^7.24.6","@rollup/plugin-alias":"^5.1.0","@rollup/plugin-commonjs":"^25.0.8","@rollup/plugin-dynamic-import-vars":"^2.1.2","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-wasm":"^6.2.2","@rollup/pluginutils":"^5.1.0","@visulima/cerebro":"^1.0.29","@visulima/colorize":"^1.4.1","@visulima/fs":"^2.1.2","@visulima/humanizer":"^1.0.3","@visulima/package":"^1.8.3","@visulima/pail":"^1.1.11","@visulima/path":"^1.0.1","@clack/prompts":"^0.7.0",defu:"6.1.4","es-module-lexer":"^1.5.3","fastest-levenshtein":"^1.0.16",glob:"^10.4.1","glob-parent":"^6.0.2",hookable:"^5.5.3","magic-string":"^0.30.10",mlly:"^1.7.0",rollup:"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-license":"^3.4.0","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-visualizer":"^5.12.0",semver:"^7.6.2"},ms={"@anolilab/eslint-config":"^15.0.3","@anolilab/prettier-config":"^5.0.14","@anolilab/semantic-release-pnpm":"^1.1.0","@anolilab/semantic-release-preset":"^8.1.0","@babel/core":"^7.24.6","@rushstack/eslint-plugin-security":"^0.8.1","@secretlint/secretlint-rule-preset-recommend":"^8.2.4","@swc/core":"^1.5.7","@swc/types":"0.1.7","@total-typescript/ts-reset":"^0.5.1","@types/estree":"^1.0.5","@types/glob":"^8.1.0","@types/glob-parent":"^5.1.3","@types/micromatch":"^4.0.7","@types/node":"18.18.14","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/semver":"^7.5.8","@vitest/coverage-v8":"^1.6.0","@vitest/ui":"^1.6.0","cross-env":"^7.0.3",esbuild:"^0.21.4",eslint:"^8.56.0","eslint-plugin-deprecation":"^2.0.0","eslint-plugin-etc":"^2.0.3","eslint-plugin-import":"npm:eslint-plugin-i@^2.29.1","eslint-plugin-mdx":"^3.1.5","eslint-plugin-vitest":"^0.4.1","eslint-plugin-vitest-globals":"^1.5.0","estree-walker":"^3.0.3",execa:"^9.1.0",jiti:"^1.21.0",prettier:"^3.2.5",react:"^18.3.1","react-dom":"^18.3.1",rimraf:"^5.0.7",secretlint:"8.2.4","semantic-release":"^23.1.1","sort-package-json":"^2.10.0",sucrase:"^3.35.0",tempy:"^3.1.0","ts-essentials":"^10.0.0",typescript:"^5.4.5",vitest:"^1.6.0"},fs={"@swc/core":"^1.5.7",esbuild:"^0.20.2 || ^0.21.3",jiti:"^1.21.0",sucrase:"^3.35.0",typescript:"^4.5 || ^5.0"},gs={"@swc/core":{optional:!0},esbuild:{optional:!0},sucrase:{optional:!0},typescript:{optional:!0}},hs={node:">=18.* <=21.*"},ys={access:"public",provenance:!0},vs={"eslint-config":{plugin:{tsdoc:!1,"testing-library-react":!1,"react-usememo":!1,"react-hooks":!1,"jsx-a11y":!1,react:!1,"validate-jsx-nesting":!1,"ssr-friendly":!1},warn_on_unsupported_typescript_version:!1,info_on_disabling_jsx_react_rule:!1,info_on_disabling_prettier_conflict_rule:!1,info_on_disabling_jsonc_sort_keys_rule:!1,info_on_disabling_etc_no_deprecated:!1}},bs={name:Gt,version:Xt,description:Yt,keywords:Kt,homepage:Qt,repository:Zt,funding:es,license:ts,author:ss,sideEffects:os,type:ns,exports:rs,main:is,module:as,types:ls,bin:ps,files:cs,scripts:us,dependencies:ds,devDependencies:ms,peerDependencies:fs,peerDependenciesMeta:gs,engines:hs,publishConfig:ys,anolilab:vs};var js=Object.defineProperty,z=m((e,t)=>js(e,"name",{value:t,configurable:!0}),"i$a");const te=/^#![^\n]*/,V=z(async e=>{await it(e,493).catch(()=>{})},"makeExecutable"),$s=z((e,t=`#!/usr/bin/env node
|
|
10
|
+
`)=>({name:"packem:shebang",renderChunk:{handler(s,o,n){if(!o.isEntry||!o.facadeModuleId||s.startsWith("#")&&s[1]==="!")return null;if(e.includes(o.name)){const r=new D(s);return r.prepend(t),{code:r.toString(),map:n.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(s,o){for(const[n,r]of Object.entries(o))if(r.type==="chunk"&&te.test(r.code)&&s.dir){const i=g(s.dir,n);await V(i)}}}),"shebangPlugin"),ws=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(te,"")}}),"removeShebangPlugin"),ks=z((e,t=`
|
|
11
|
+
`)=>{const s=te.exec(e);return s?s+t:""},"getShebang");var xs=Object.defineProperty,Es=m((e,t)=>xs(e,"name",{value:t,configurable:!0}),"p$2");const se=Es((e,t)=>{let s={};if(e.pkg.name&&(s[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:o}=e.pkg;for(const n in o){if(n.startsWith("#"))continue;const r=o[n];typeof r=="string"&&(s[n]=E(e.rootDir,r))}}return s={...s,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(s,Object.fromEntries(e.options.rollup.alias.entries.map(o=>[o.find,o.replacement]))):Object.assign(s,e.options.rollup.alias.entries||e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(s),prefix:t}),s},"resolveAliases");var Os=Object.defineProperty,_s=m((e,t)=>Os(e,"name",{value:t,configurable:!0}),"o$3");const Ds=_s((e,t)=>{const s=Ee(t,{esmResolve:!0,interopDefault:!0});try{return s.resolve(e)}catch(o){if(o.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:o});return e}},"tryResolve");var Ss=Object.defineProperty,Ns=m((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"r$8");const F=Ns((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ps=Object.defineProperty,Ms=m((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"u$9");const Cs=Ms(async e=>{const t=await It("jiti",{url:import.meta.url}),s=JSON.stringify({...e.options.stubOptions.jiti,alias:{...se(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const o of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,o.name),r=B(Ds(o.input,e.options.rootDir)||o.input),i=r.slice(0,Math.max(0,r.length-K(r).length)),a=await Y(r),c=ks(a);e.options.emitCJS&&await A(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
|
|
12
|
+
`));let p=[];try{p=await Rt(r,{extensions:I})}catch(l){F(e,`Cannot analyze ${r} for exports:${l}`);return}const u=p.includes("default")||p.length===0;await A(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(Mt(t).href)};`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(r)})} */`,`const _module = await _jiti.import(${JSON.stringify(r)});`,u?`
|
|
13
|
+
export default _module;`:"",...p.filter(l=>l!=="default").map(l=>`export const ${l} = _module.${l};`)].join(`
|
|
14
|
+
`)),await A(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
|
|
15
|
+
`)),await A(`${n}.d.mts`,[`export * from ${JSON.stringify(r)};`,u?`export { default } from ${JSON.stringify(r)};`:""].join(`
|
|
16
|
+
`)),c&&(await V(`${n}.cjs`),await V(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Is=Object.defineProperty,Rs=m((e,t)=>Is(e,"name",{value:t,configurable:!0}),"a$a");const G=Rs((e,t)=>e.some(s=>s instanceof RegExp?s.test(t):s===t),"arrayIncludes");var Fs=Object.defineProperty,Ts=m((e,t)=>Fs(e,"name",{value:t,configurable:!0}),"a$9");const U=Ts(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var As=Object.defineProperty,Ls=m((e,t)=>As(e,"name",{value:t,configurable:!0}),"e$2");const X=Ls((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Ws=Object.defineProperty,Pe=m((e,t)=>Ws(e,"name",{value:t,configurable:!0}),"s$d");const Bs=Pe((e,t,s)=>{const o=s??new Map;return(...n)=>{const r=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=o.get(r);if(i!==void 0)return i;const a=e(...n);return o.set(r,a),a}},"memoize"),Js=Pe(e=>{const t=new Map;return s=>Bs(e,s,t)},"memoizeByKey");var zs=Object.defineProperty,Us=m((e,t)=>zs(e,"name",{value:t,configurable:!0}),"m$5");const Me=Us(({addDefaultProperty:e=!1,logger:t,type:s})=>({name:"packem:cjs-interop",renderChunk(o,n,r){if(n.type!=="chunk"||!n.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(o);if(i===null||i.length<3)return null;const a=new D(o);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
17
|
+
module.exports.default = `+i[2]+";");let c=a.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:a.generateMap({hires:!0})}}if(r.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(s!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(o);if(i===null||i.length<2)return null;const a=i[1].split(", "),c=[];let p="";for(const l of a)if(!l.includes("type"))if(l.includes("as")){const[d,h]=l.split(" as ");if(h==="default"&&(p=d,!e))continue;c.push(h+": typeof "+d+";")}else c.push(l+": typeof "+l+";");const u=new D(o);return u.replace(" "+p+" as default,",""),u.append(`
|
|
18
|
+
|
|
19
|
+
declare const defaultExport: {
|
|
20
|
+
`+(c.length>0?" ":"")+c.join(`
|
|
21
|
+
`)+`
|
|
22
|
+
} & typeof `+p+`;
|
|
23
|
+
|
|
24
|
+
export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Hs=Object.defineProperty,qs=m((e,t)=>Hs(e,"name",{value:t,configurable:!0}),"f$9");const Vs=qs((e,t)=>{const s=new Map,o={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=o;return Array.isArray(n)?n=n.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const r=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Bt(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:Jt(i.src),src:a}))));for(const i of r)for(const a of i.src){let c;s.has(a)?c=s.get(a):(c={copied:[],dest:[],timestamp:0},s.set(a,c));const p=o.flatten?B(i.dest):E(i.dest,S(i.parent,Q(a)));c.dest.includes(p)||c.dest.push(p),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...s].map(async([i,a])=>{let c;try{const p=await je(i);if(!p.isFile())return;const u=p.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),c=await Y(i,{buffer:!0})}catch(p){t.error({context:[p],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const p of a.dest){if(o.copyOnce&&a.copied.includes(p))continue;const u=J(i),l=E(p,u);try{this.emitFile({[o.exactFileNames?"fileName":"name"]:l,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${l}`,prefix:"plugin:copy"}),a.copied.push(p)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${l}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Gs=Object.defineProperty,Xs=m((e,t)=>Gs(e,"name",{value:t,configurable:!0}),"n$6");const ce="export default ",Ce=Xs(e=>{const t=zt(e);return{...t,name:"packem:json",transform(s,o){const n=t.transform?.call(this,s,o);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class Ys{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,s,o,n){t&&s&&(o!=null?t[s][o]=n:t[s]=n)}remove(t,s,o){t&&s&&(o!=null?t[s].splice(o,1):delete t[s])}}class Ks extends Ys{static{m(this,"SyncWalker")}constructor(t,s){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(o=>this.replacement=o,"replace")},this.enter=t,this.leave=s}visit(t,s,o,n){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const p=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=c,p)return t;if(u)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let c=0;c<a.length;c+=1){const p=a[c];ue(p)&&(this.visit(p,t,r,c)||c--)}}else ue(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const c=this.should_remove;if(this.replacement=i,this.should_remove=a,c)return null}}return t}}function ue(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ue,"isNode");function Ie(e,{enter:t,leave:s}){return new Ks(t,s).visit(e,null)}m(Ie,"walk");var Qs=Object.defineProperty,Zs=m((e,t)=>Qs(e,"name",{value:t,configurable:!0}),"u$7");const eo=Zs(({attributes:e,logger:t})=>{const s=Z([/\.[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(o,n){if(!s(n))return null;let r=null;try{r=this.parse(o,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const a=new D(o);return Ie(r,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const p=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of p)for(const l of u.properties)l.type==="Property"&&l.key.type==="Literal"&&l.value.type==="Literal"&&e.includes(l.key.value)&&(a.overwrite(l.start-2,l.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var to=Object.defineProperty,oe=m((e,t)=>to(e,"name",{value:t,configurable:!0}),"p$1");const so=oe(e=>{const t=[],s=[];return e.forEach(o=>{o.startsWith("(")?t.push(o):s.push(o)}),[...s.sort(),...t.sort()]},"sortLicenses"),oo=oe((e,t,s)=>{const o=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(o.test(e))return e.replace(o,`$1
|
|
25
|
+
${s}
|
|
26
|
+
$2`)},"replaceContentWithin"),Re=oe(({licenseFilePath:e,licenseTemplate:t,logger:s,marker:o,mode:n,packageName:r})=>Ut({thirdParty(i){const a=new Set,c=i.sort(({name:u},{name:l})=>u>l?1:l>u?-1:0).map(({author:u,contributors:l,license:d,licenseText:h,maintainers:f,name:y,repository:v})=>{let w="## "+y+`
|
|
27
|
+
`;d&&(w+=`License: ${d}
|
|
28
|
+
`);const k=new Set;for(const x of[u,...f,...l]){const T=typeof x=="string"?x:x?.name;T&&k.add(T)}return k.size>0&&(w+=`By: ${[...k].join(", ")}
|
|
29
|
+
`),v&&(w+=`Repository: ${typeof v=="string"?v:v.url}
|
|
30
|
+
`),h&&(w+=`
|
|
31
|
+
`+h.trim().replaceAll(/(\r\n|\r)/g,`
|
|
32
|
+
`).split(`
|
|
33
|
+
`).map(x=>`> ${x}`).join(`
|
|
34
|
+
`)+`
|
|
35
|
+
`),d&&a.add(d),w}).join(`
|
|
36
|
+
---------------------------------------
|
|
37
|
+
|
|
38
|
+
`);if(c===""){s.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const p=t(so(a),c,r);try{const u=dt(e),l=oo(u,o,p);if(!l){s.error({message:`Could not find the license marker: <!-- ${o} --> in ${e}`,prefix:"plugin:license:"+n});return}u!==l&&(mt(e,l),s.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(u){s.error(u)}}}),"license");var no=Object.defineProperty,ro=m((e,t)=>no(e,"name",{value:t,configurable:!0}),"i$7");const io=ro(e=>({async buildEnd(){const t=[];for(const o of this.getModuleIds()){const n=this.getModuleInfo(o);if(n!=null&&!n.isExternal)for(const r of n.importedIds)t.push({source:o,target:r})}if(Array.isArray(t)&&t.length===0)return;const s=g(e.outDir,"graph.json");$e(s,t)},name:"packem:metafile"}),"metafilePlugin");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"c$3");const po=/\.(?:m|c)?(?:j|t)sx?$/,co=/^use \w+$/,uo=lo(e=>{const t={},s={};return{name:"packem:preserve-directives",onLog(o,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&o==="warn"?!1:null},renderChunk:{handler(o,n,{sourcemap:r}){const i=n.moduleIds.map(p=>t[p]?t[p]:null).reduce((p,u)=>(u&&u.forEach(l=>{p.add(l)}),p),new Set),a=new D(o);i.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(p=>`'${p}';`).join(`
|
|
39
|
+
`)}
|
|
40
|
+
`));let c=null;return n.facadeModuleId&&typeof s[n.facadeModuleId]=="string"&&(c=s[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${c}
|
|
41
|
+
`)),i.size===0&&c===null?null:{code:a.toString(),map:r?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(o,n){const r=K(n);if(!po.test(r))return null;let i=!1;const a=new D(o);if(o.startsWith("#")&&o[1]==="!"){let p=0;for(let u=2,l=o.length;u<l;u++){const d=o.codePointAt(u);if(d===10||d===13||d===8232||d===8233){p=u;break}}p&&(s[n]=o.slice(0,p),a.remove(0,p+1),i=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(p),null}if(c.type!=="Program")return null;for(const p of c.body.filter(Boolean)){if(p.type!=="ExpressionStatement")break;let u=null;"directive"in p?u=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&co.test(p.expression.value)&&(u=p.expression.value),u!=="use strict"&&u&&(t[n]||=new Set,t[n].add(u),"start"in p&&typeof p.start=="number"&&"end"in p&&typeof p.end=="number"&&(a.remove(p.start,p.end),i=!0),e.debug({message:`directive "${u}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:s[n]??null}}}:null},order:"post"}}},"preserveDirectives");var mo=Object.defineProperty,fo=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"r$6");const go={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},ho=fo((e={})=>{e={...e,...go};const t=Z(e.include,e.exclude);return{name:"packem:raw",transform(s,o){return t(o)?{code:`export default ${JSON.stringify(s)}`,map:null}:null}}},"rawPlugin");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"l$4");const H="\0__file_url__",Fe=vo(()=>({async load(e){if(e.startsWith(H)){const t=Ct(e.slice(H.length));return await Y(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${H}${e}`}}),"resolveFileUrl");var bo=Object.defineProperty,Te=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"i$4");const jo=/__filename|__dirname|require\(|require\.resolve\(/,Ae=`
|
|
42
|
+
// -- pack CommonJS Shims --
|
|
43
|
+
import __cjs_url__ from "node:url";
|
|
44
|
+
import __cjs_path__ from "node:path";
|
|
45
|
+
import __cjs_mod__ from "node:module";
|
|
46
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
47
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
48
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
49
|
+
`,Le=`
|
|
50
|
+
// -- pack CommonJS Shims Node 20.11 --
|
|
51
|
+
import __cjs_mod__ from "node:module";
|
|
52
|
+
const __filename = import.meta.filename;
|
|
53
|
+
const __dirname = import.meta.dirname;
|
|
54
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
55
|
+
`,$o=Te((e,t)=>{if(R.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Ae)||e.includes(Le)||!jo.test(e)))return null;const s=xe(e).pop(),o=s?s.end:0,n=new D(e);return n.appendRight(o,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),wo=Te(e=>({name:"packem:cjs",renderChunk(t,s,o){if(o.format==="es"){let n=Ae;if(e.engines?.node){const r=Ne(e.engines.node);r&&r.major>=20&&r.minor>=11&&(n=Le)}return $o(t,n)}return null}}),"cjsPlugin");var ko=Object.defineProperty,C=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"s$a");const xo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Eo=/MIT License|MIT license|BSD license/,Oo=/\n{2,}/g,_o=/\b(\w+)\$\d+\b/g,Do=/[-/\\^$*+?.()|[\]{}]/g,So=C(e=>e.replaceAll(Do,"\\$&"),"escapeRegex"),No=C(e=>[...new Set(e)],"unique"),Po=C(e=>e.replaceAll(xo,t=>Eo.test(t)?"":t).replaceAll(Oo,`
|
|
56
|
+
|
|
57
|
+
`),"cleanUnnecessaryComments"),de=new Map;function We(e,t,{identifierReplacements:s},o){const n=xe(e);for(const i in s){const a=n.find(p=>p.specifier===i&&p.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=s[i];for(const p in c){a.imports.includes(p)||(this.warn(`${t.fileName} does not import "${p}" from "${i}" for replacement`),M(1));const u=c[p],l=So(p);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${l},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${l}\\b`,"g"),u)}}const r=No(Array.from(e.matchAll(_o),i=>i[0]));if(r.length>0){const i=r.map(c=>`
|
|
58
|
+
- ${c}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");de.has(a)||o.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
59
|
+
|
|
60
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),de.set(a,!0)}return e}m(We,"v$2");C(We,"replaceConfusingTypeNames");function Be(e,t){if(t.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,s),!0}return!1}m(Be,"N$1");C(Be,"removeInternal");function Je(e,t){if(e.includes("@internal")){const s=new D(e),o=Ht(e,{plugins:["typescript"],sourceType:"module"});Ie(o,{enter(n){Be(s,n)&&this.skip()}}),e=s.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),M(1))}return e}m(Je,"S$1");C(Je,"stripInternalTypes");const Mo=C((e,t)=>({name:"packem:patch-types",renderChunk(s,o){return s=We.call(this,s,o,e,t),s=Je.call(this,s,o),s=Po(s),s},resolveId(s){return s.startsWith("types/")?{external:!0,id:"../../"+(s.endsWith(".js")?s:s+".js")}:null}}),"patchTypescriptTypes");var Co=Object.defineProperty,ze=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"u$5");const Ue=ze((e,t=!0)=>{if(!e)return null;const{config:s,path:o}=e;if(!s.compilerOptions)return null;const{baseUrl:n,paths:r}=s.compilerOptions;if(!n)return null;const i=g(Q(o),n),a=[];if(r)for(const[c,p]of Object.entries(r)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let l=0;for(const d of p){const h=[...pe(g(i,d))].map(f=>f==="*"?`$${++l}`:f==="$"?"$$":f).join("");a.push({find:u,replacement:h})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...pe(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),a},"getConfigAlias"),He=ze((e,t)=>{const s=Ue(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(o,n,r){if(!s||o.includes("\0"))return null;for(const{find:i,replacement:a}of s)if(i.test(o)){const c=o.replace(i,a),p=await this.resolve(c,n,{skipSelf:!0,...r});if(p)return t.debug({message:`Resolved ${o} to ${p.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),p.id}return null}}},"resolveTsconfigPaths");var Io=Object.defineProperty,qe=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"u$4");const Ro=qe((e,t)=>{if(!t)return null;const{config:s,path:o}=t;if(!s.compilerOptions)return null;const{rootDirs:n}=s.compilerOptions;if(!n)return null;const r=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${o}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${o}.`);r.push(g(e,i))}return r},"getRootDirectories"),Ve=qe((e,t,s)=>{const o=Ro(e,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,r,i){if(o===null||o.length===0)return null;if(n.startsWith("."))for(const a of o){const c=E(a,n),p=await this.resolve(c,r,{skipSelf:!0,...i});if(p)return t.debug({message:`Resolved ${n} to ${p.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),p.id}return null}}},"resolveTsconfigRootDirectories");var Fo=Object.defineProperty,To=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$5");const Ge=To(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,s,o){return e.test(t)&&s?await this.resolve(t.replace(/js(x?)$/,"ts$1"),s,o):null}}},"resolveTypescriptMjsCts");var Ao=Object.defineProperty,Lo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"s$9");const Wo=Lo(e=>{const t=J(e).split(".");if(t.length>=2){const[s,o]=t.slice(-2),n=t[0],r=/^(\w+)-runtime$/.exec(s)?.[1];if(I.includes(o)&&r&&r.length>0)return n+"-"+r}},"getCustomModuleLayer");var Bo=Object.defineProperty,Jo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"i$3");const q=Jo(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var zo=Object.defineProperty,me=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"c$1");const fe=me((e,t)=>{const s=new Map;return me(function(o,n){const r=n.getModuleInfo(o);if(!r)return;const{isEntry:i}=r,a=r.meta,c=q(a);if(!i){const p=s.get(o);if(p)return p;const u=Wo(o);if(u)return s.set(o,u),u}if(i){const p=n.getModuleIds();for(const u of p)n.getModuleInfo(u)&&q(a)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([o,c]))}if(c&&!i&&e.has(o)){const p=[...e.get(o)];if(p.some(([l])=>{if(t.some(d=>d.path===l)){const d=n.getModuleInfo(l);return q(d?d.meta:{})===c}return!1}))return;if(p.every(([,l])=>l===c))return s.has(o)?s.get(o):void 0;const u=`${J(o,K(o))}-${c}`;return s.set(o,u),u}},"splitChunks")},"createSplitChunks");var Uo=Object.defineProperty,Ho=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"n$4");const _=Ho((e,t,s)=>t.isDynamicEntry?`chunks/[name].${s}`:`shared/${e.options.name}.[hash].${s}`,"getChunkFilename");var qo=Object.defineProperty,Vo=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"s$7");const Go=process.platform==="win32",ge=Vo((e,t)=>{const s=Go?"\\":"/";return e.name?.includes("node_modules"+s+".pnpm")?(e.name.replace("node_modules"+s+".pnpm","external")+"."+t).replace("node_modules"+s,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Xo=Object.defineProperty,j=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"l$3");const Yo=j((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let s="node"+lt.node.split(".")[0];if(t.pkg.engines?.node){const o=Ne(t.pkg.engines.node);o&&(s="node"+o.major)}if(t.options.rollup.esbuild.target){const o=U(t.options.rollup.esbuild.target);o.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...U(s),...o])])}else t.options.rollup.esbuild.target=U(s);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,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Xe=j((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${b(S(g(),e.id))}"
|
|
61
|
+
Is the module installed? Note:
|
|
62
|
+
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
63
|
+
↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),he=new Map,Ye=j((e,t,s)=>{const o=j(r=>{for(const[i,a]of Object.entries(t))if(r.startsWith(i))return r.replace(i,a)},"findAlias"),n=Ue(e.tsconfig,!1);return{external(r){const i=o(r);i&&(r=i);const a=X(r),c=G(e.options.externals,a)||G(e.options.externals,r);if(c)return!0;if(r.startsWith(".")||ke(r)||/src[/\\]/.test(r)||e.pkg.name&&r.startsWith(e.pkg.name))return!1;if(n){for(const{find:p}of n)if(p.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${p.source}`,prefix:s}),!1}return!c&&!he.has(r)&&e.logger.info({message:'Inlined implicit external "'+b(r)+'". If this is incorrect, add it to the "externals" option.',prefix:s}),he.set(r,!0),c},input:Object.fromEntries(e.options.entries.map(r=>[r.name,g(e.options.rootDir,r.input)])),onLog:j((r,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
|
|
64
|
+
${i.stack}`),r){case"info":{e.logger.info({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(r,i){Xe(r,e)||r.code||i(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ke=j(async e=>{const t=se(e,"build");let s;return e.options.rollup.resolve&&(s=De({extensions:I,...e.options.rollup.resolve})),{...Ye(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(o=>_(e,o,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>ge(o,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(o=>_(e,o,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>ge(o,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[Fe(),Ge(),e.tsconfig&&Ve(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&He(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&_e({customResolver:s?.resolveId,...e.options.rollup.alias,entries:t}),s,e.options.rollup.polyfillNode&&Lt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ce({...e.options.rollup.json}),uo(e.logger),$s(e.options.entries.filter(o=>o.isExecutable).map(o=>o.name).filter(Boolean)),e.options.rollup.wsam&&At(e.options.rollup.wsam),e.options.transformer?.(Yo(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Tt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&Ft({extensions:I,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:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Vs(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Re({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&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"),Ko=j(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Qo=Js(Ko),Qe=j(async e=>{const t=se(e,"types"),s={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},o=e.tsconfig?.config.compilerOptions;delete o?.lib;let n;e.options.rollup.resolve&&(n=De({extensions:I,...e.options.rollup.resolve}));const r="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ye(e,t,"dts"),onwarn(i,a){Xe(i,e)||i.code!=="EMPTY_BUNDLE"&&a(i)},output:[e.options.emitCJS&&{chunkFileNames:j(i=>_(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:j(i=>_(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:j(i=>_(e,i,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[Fe(),Ge(),e.options.rollup.json&&Ce({...e.options.rollup.json}),s,e.tsconfig&&Ve(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&He(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&_e({customResolver:n?.resolveId,...e.options.rollup.alias,entries:t}),n,await Qo(r)(e),e.options.cjsInterop&&e.options.emitCJS&&Me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Mo(e.options.rollup.patchTypes,e.logger),ws(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Re({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Zo=Object.defineProperty,en=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"f$5");const tn=en(async(e,t)=>{const s=await Ke(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-build");const o=await Oe(s);t.set("rollup-build",o.cache),await e.hooks.callHook("rollup:build",e,o);const n=s.output,r=new Map;for(const i of n){const{output:a}=await o.write(i),c=new Set,p=a.filter(l=>l.type==="chunk");for(const l of p){c.add(l.fileName);for(const d of l.imports)e.usedImports.add(d);l.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(l.code,"utf8"),chunks:l.imports.filter(d=>p.find(h=>h.fileName===d)),exports:l.exports,modules:Object.entries(l.modules).map(([d,h])=>({bytes:h.renderedLength,id:d})),path:l.fileName,type:"entry"})}const u=a.filter(l=>l.type==="asset");for(const l of u)r.has(l.fileName)||r.set(l.fileName,{bytes:Buffer.byteLength(l.source,"utf8"),path:l.fileName,type:"asset"});for(const l of c)e.usedImports.delete(l)}e.buildEntries.push(...r.values())},"build");var sn=Object.defineProperty,L=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"r$3");const on=L(async(e,t)=>{const s=await Qe(e);if(await e.hooks.callHook("rollup:dts:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-dts");const o=await Oe(s);t.set("rollup-dts",o.cache),await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:L(n=>_(e,n,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:L(n=>_(e,n,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:L(n=>_(e,n,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var nn=Object.defineProperty,Ze=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"e$1");const ye=Ze((e,t,s)=>{const o="watcher:"+t;e.on("change",(n,{event:r})=>{s.info({message:`${b(S(".",n))} was ${r}d`,prefix:o})}),e.on("restart",()=>{s.info({message:"Rebuilding "+t+"...",prefix:o})}),e.on("event",n=>{n.code==="END"&&s.success({message:"Rebuild "+t+" finished",prefix:o}),n.code==="ERROR"&&s.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:o})})},"watchHandler"),rn=Ze(async(e,t)=>{const s=await Ke(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-watch");const o=le(s);await e.hooks.callHook("rollup:watch",e,o);const n=[...Array.isArray(s.input)?s.input:typeof s.input=="string"?[s.input]:Object.keys(s.input??{})];let r="Starting watchers for entries:";for(const i of n)r+=P(`
|
|
65
|
+
└─ ${S(process.cwd(),i)}`);if(e.logger.info(r),ye(o,"bundle",e.logger),e.options.declaration){const i=await Qe(e);await e.hooks.callHook("rollup:dts:options",e,i);const a=le(i);await e.hooks.callHook("rollup:watch",e,a),ye(a,"types",e.logger)}},"watch");var an=Object.defineProperty,ln=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"i$2");const et=ln(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var pn=Object.defineProperty,cn=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"s$5");let un=class{static{m(this,"h")}static{cn(this,"FileCache")}#e;#t;#s=!0;constructor(t,s,o){this.#e=wt("visulima-packem",{create:!0,cwd:t});const n=qt("md5");n.update(s),this.#t=n.digest("hex"),this.#e===void 0?o.debug("Could not create cache directory."):o.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#s=t}get(t){if(!this.#s||this.#e===void 0)return;const s=`${this.#e}/${t}-${this.#t}.json`;if(we(s))return ft(s)}set(t,s){this.#s&&(this.#e===void 0||s===void 0||$e(`${this.#e}/${t}-${this.#t}.json`,s,{indent:2,overwrite:!0}))}};var dn=Object.defineProperty,W=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"l$2");const mn=Z,fn=W((e,t)=>{const{sideEffects:s}=t;let o;if(typeof s=="boolean")o=W(()=>s,"hasSideEffects");else if(Array.isArray(s))if(s.length<=0)o=W(()=>!1,"hasSideEffects");else{const n=s.map(r=>r.includes("/")?r:`**/${r}`);o=mn(n,null,{resolve:e})}else o=W(()=>null,"hasSideEffects");return o},"getPackageSideEffect");var gn=Object.defineProperty,hn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"t$4");const yn=hn(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var vn=Object.defineProperty,tt=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"t$3");const ne=tt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),st=tt((e,t,s,o)=>{if(s){const i=ne(s);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o==="commonjs"?"cjs":"esm";const[n,...r]=t;return st(n,r,s,o)},"inferExportType");var bn=Object.defineProperty,jn=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"f$3");const re=jn((e,t,s,o=[])=>{if(!e)return[];if(typeof e=="string"){const n=ne(e),r=t==="module"?"esm":"cjs";if(n&&n!==r)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:n??r}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,r])=>n==="types"&&!s?[]:typeof r=="string"?{file:r,type:st(n,o,r,t)}:re(r,t,s,[...o,n]))},"extractExportFilenames");var $n=Object.defineProperty,wn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"e");const kn=wn(e=>{const t=B(e).split("/");return t.map((s,o)=>t.slice(o).join("/")).filter(Boolean)},"getEntrypointPaths");var xn=Object.defineProperty,En=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"h$1");const On=En((e,t,s,o=".")=>{const n=[];t.sort((l,d)=>l.split("/").length-d.split("/").length);const r=re(e.exports,e.type??"commonjs",s);if(e.bin){const l=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of l)r.push({file:d,isExecutable:!0})}e.main&&r.push({file:e.main,type:ne(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,type:"esm"}),s===void 0&&(e.types||e.typings)&&r.push({file:e.types??e.typings});const i=e.type==="module";for(const l of r.filter(d=>!d.type)){const d=l.file.endsWith(".js");i&&d||l.file.endsWith(".mjs")?l.type="esm":(!i&&d||l.file.endsWith(".cjs"))&&(l.type="cjs")}let a=!1,c=!1,p=!1;const u=[];for(const l of r){const d=l.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),h=d.endsWith("/");if(h&&["./","/"].includes(d))continue;const f=kn(d).reduce((v,w)=>{if(v)return v;const k=new RegExp(`(?<=/|$)${w}${h?"":"\\.\\w+"}$`);return t.find(x=>k.test(x))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!f){ee(g(o,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}l.type==="cjs"&&(a=!0),l.type==="esm"&&(c=!0);const y=u.find(v=>v.input===f)??u[u.push({input:f})-1];/\.d\.(?:m|c)?ts$/.test(l.file)&&(p=!0),h&&(y.outDir=d),l.isExecutable&&(y.isExecutable=!0)}return{cjs:a,dts:p,entries:u,esm:c,warnings:n}},"inferEntries");var _n=Object.defineProperty,Dn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"t$2");const Sn=Dn((e,t)=>{const{publishConfig:s}=e;return s&&(s.bin&&(typeof s.bin=="object"||typeof s.bin=="string")&&(e.bin=s.bin),s.type&&typeof s.type=="string"&&s.type!==""&&(e.type=s.type),s.main&&typeof s.main=="string"&&s.main!==""&&(e.main=s.main),s.module&&typeof s.module=="string"&&s.module!==""&&(e.module=s.module),t===void 0&&s.types&&typeof s.types=="string"&&s.types!==""?e.types=s.types:t===void 0&&s.typings&&typeof s.typings=="string"&&s.typings!==""&&(e.typings=s.typings),s.exports&&typeof s.exports=="object"&&(e.exports=s.exports)),e},"overwriteWithPublishConfig");var Nn=Object.defineProperty,Pn=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"t$1");const Mn={hooks:{"build:prepare":Pn(function(e){if(e.options.entries.length>0)return;const t=E(e.options.rootDir,"src");if(!ee(t))throw new Error("No 'src' directory found. Please provide entries manually.");const s=gt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(s.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let o={...e.pkg};o.publishConfig&&(o=Sn(o,e.options.declaration));const n=On(o,s,e.options.declaration,e.options.rootDir);for(const r of n.warnings)F(e,r);if(e.options.entries.push(...n.entries),e.options.emitCJS===void 0&&n.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&n.dts&&(e.options.declaration=n.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b(e.options.entries.map(r=>O(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),P([n.esm&&"esm",n.cjs&&"cjs",n.dts&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Cn=Object.defineProperty,In=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"r");const ot=In((e,t)=>Ee(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Rn=Object.defineProperty,Fn=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"t");const Tn=Fn((e,t)=>(e==="auto"?e=Mn:typeof e=="string"&&(e=ot(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var An=Object.defineProperty,Ln=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"o");const Wn=Ln(e=>{const t=new Set,s=new Set(Object.keys(e.pkg.dependencies??{})),o=new Set;for(const n of e.usedImports)s.delete(n),t.add(n);if(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)s.delete(n);for(const n of t)!G(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(X(n))&&!e.options.peerDependencies.includes(X(n))&&o.add(n);s.size>0&&F(e,`Potential unused dependencies found: ${[...s].map(n=>b(n)).join(", ")}`),o.size>0&&F(e,`Potential implicit dependencies found: ${[...o].map(n=>b(n)).join(", ")}`)},"validateDependencies");var Bn=Object.defineProperty,nt=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"i");const Jn=nt((e,t)=>Vt(e,t)<=e.length/3||t.includes(e),"isSimilar"),zn=nt((e,t)=>{const s=e.toLowerCase();return t.filter(o=>Jn(o.toLowerCase(),s))},"findAlternatives");var Un=Object.defineProperty,ve=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"n");const Hn=ve((e,t)=>{const s=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...re(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&g(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),o=[];for(const n of s)n&&!n.includes("*")&&!ee(n)&&o.push(n.replace(`${t.rootDir}/`,""));if(o.length>0){const n=ve(a=>S(t.rootDir,g(t.options.outDir,a)),"rPath"),r=t.buildEntries.filter(a=>!a.chunk).map(a=>n(a.path));let i="Potential missing or wrong package.json files:";for(const a of o){const c=zn(a,r);i+=`
|
|
66
|
+
- `+b(a)+(c.length>0?ct` (did you mean ${c.map(p=>`"${p}"`).join(", ")}?)`:"")}F(t,i)}},"validatePackage");var qn=Object.defineProperty,$=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"m");const be=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
|
|
67
|
+
`),e.logger.warn(`Build is done with some warnings:
|
|
68
|
+
|
|
69
|
+
${[...e.warnings].map(s=>`- ${s}`).join(`
|
|
70
|
+
`)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),M(1)))},"logErrors"),Vn=$(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"),Gn=$((e,t,s,o,n,r,i,a)=>{const c=Vn(a?.config.compilerOptions?.jsx),p=Nt(n,o,r,{alias:{},cache:!0,clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:R.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.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:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:R.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((u,l,d)=>`
|
|
71
|
+
# Licenses of bundled dependencies
|
|
72
|
+
The published ${d} artifact additionally contains code with the following licenses:
|
|
73
|
+
${u.join(", ")}
|
|
74
|
+
|
|
75
|
+
# Bundled dependencies:
|
|
76
|
+
`+l,"dependenciesTemplate"),dtsTemplate:$((u,l,d)=>`
|
|
77
|
+
# Licenses of bundled types
|
|
78
|
+
The published ${d} artifact additionally contains code with the following licenses:
|
|
79
|
+
${u.join(", ")}
|
|
80
|
+
|
|
81
|
+
# Bundled types:
|
|
82
|
+
`+l,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ae,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:R.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.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:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:R.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:fn(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:ae}},rootDir:t,sourcemap:!1,stub:s==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(u.has("esbuild"))p.transformerName="esbuild";else if(u.has("@swc/core"))p.transformerName="swc";else if(u.has("sucrase"))p.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 "'+b(p.transformerName)+'" as transformer.')}return p.outDir=g(p.rootDir,p.outDir),p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
83
|
+
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.
|
|
84
|
+
To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),p.dependencies=Object.keys(i.dependencies??{}),p.peerDependencies=Object.keys(i.peerDependencies??{}),p.devDependencies=Object.keys(i.devDependencies??{}),p.optionalDependencies=Object.keys(i.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),Xn=$(async(e,t)=>{e.options.entries=e.options.entries.map(s=>typeof s=="string"?{input:s}:s);for await(const s of e.options.entries){if(typeof s.name!="string"){let o=ke(s.input)?S(t,s.input):B(s.input);o.startsWith("./")&&(o=o.slice(2)),s.name=yn(o.replace(/^src\//,""))}if(!s.input)throw new Error(`Missing entry input: ${et(s)}`);if(!e.options.declaration&&s.declaration===void 0&&(s.declaration=e.options.declaration),s.input=g(e.options.rootDir,s.input),!we(s.input)){const o=new Set(await at(Q(s.input)));let n=!1;for(const r of I)if(o.has(J(s.input)+r)){n=!0;break}if(!n)throw new jt("Your configured entry: "+b(s.input)+" does not exist.")}s.outDir=g(e.options.rootDir,s.outDir??e.options.outDir)}},"prepareEntries"),Yn=$((e,t,s)=>{const o=$(r=>S(t.rootDir,g(t.options.outDir,r)),"rPath");let n=!1;for(const r of t.buildEntries.filter(i=>!i.chunk)){let i=r.bytes??0;for(const c of r.chunks??[])i+=t.buildEntries.find(p=>p.path===c)?.bytes??0;let a=` ${O(o(r.path))} (${["total size: "+b(N(i)),r.type!=="asset"&&r.bytes&&"chunk size: "+b(N(r.bytes))].filter(Boolean).join(", ")})`;if(a+=r.exports?.length?`
|
|
85
|
+
exports: `+P(r.exports.join(", ")):"",r.chunks?.length&&(a+=`
|
|
86
|
+
${r.chunks.map(c=>{const p=t.buildEntries.find(u=>u.path===c)??{};return P(" └─ "+o(c)+O(p.bytes?" ("+N(p?.bytes)+")":""))}).join(`
|
|
87
|
+
`)}`),r.modules&&r.modules.length>0){const c=r.modules.filter(p=>p.id.includes("node_modules")).sort((p,u)=>(u.bytes||0)-(p.bytes||0)).map(p=>P(" 📦 "+o(p.id)+O(p.bytes?" ("+N(p.bytes)+")":""))).join(`
|
|
88
|
+
`);a+=c.length>0?`
|
|
89
|
+
inlined modules:
|
|
90
|
+
`+c:""}if(t.options.declaration&&r.type==="entry"){let c=r.path.replace(/\.js$/,".d.ts"),p="commonjs";r.path.endsWith(".cjs")?c=r.path.replace(/\.cjs$/,".d.cts"):r.path.endsWith(".mjs")&&(p="module",c=r.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(l=>l.path.endsWith(c));if(u){let l;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(p==="commonjs"?".d.c":".d.m",".d."),l=t.buildEntries.find(d=>d.path.endsWith(c))),a+=l&&p===s.type?`
|
|
91
|
+
types:
|
|
92
|
+
`+[u,l].map(d=>P(" └─ ")+O(o(d.path))+" (total size: "+b(N(d.bytes??0))+")").join(`
|
|
93
|
+
`):`
|
|
94
|
+
types: `+O(o(u.path))+" (total size: "+b(N(u.bytes??0))+")"}}n=!0,a+=`
|
|
95
|
+
|
|
96
|
+
`,e.raw(r.chunk?P(a):a)}return n&&e.raw("Σ Total dist size (byte size):",b(N(t.buildEntries.reduce((r,i)=>r+(i.bytes??0),0))),`
|
|
97
|
+
`),n},"showSizeInformation"),Kn=$(async(e,t,s,o,n,r,i,a,c)=>{const p=Tn(n.preset??o.preset??"auto",t),u=Gn(e,t,s,o,n,p,r,i);a.isEnabled=u.cache,ht(u.outDir);const l={buildEntries:[],dependencyGraphMap:new Map,hooks:Pt(),logger:e,mode:s,options:u,pkg:r,rootDir:t,tsconfig:i,usedImports:new Set,warnings:new Set};if(p.hooks&&l.hooks.addHooks(p.hooks),o.hooks&&l.hooks.addHooks(o.hooks),n.hooks&&l.hooks.addHooks(n.hooks),await l.hooks.callHook("build:prepare",l),l.options.emitESM===!1&&l.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&i===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");l.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),l.options.declaration||e.info("Declaration files, are disabled."),await Xn(l,t),await l.hooks.callHook("build:before",l);let d="Building";if(s==="watch"?d="Watching":s==="jit"&&(d="Stubbing"),e.info(b(`${d} ${l.options.name}`)),e.debug(`${O("Root dir:")} ${l.options.rootDir}
|
|
98
|
+
${O("Entries:")}
|
|
99
|
+
${l.options.entries.map(f=>` ${et(f)}`).join(`
|
|
100
|
+
`)}`),l.options.clean)for(const f of new Set(l.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===l.options.rootDir||l.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||c.some(y=>f.startsWith(y))||(c.push(f),e.info(`Cleaning dist directory: \`./${S(l.options.rootDir,f)}\``),await yt(f));if(l.options.stub){await Cs(l),await l.hooks.callHook("build:done",l);return}if(s==="watch"){await rn(l,a),be(l,!1);return}await Promise.all([tn(l,a),l.options.declaration&&on(l,a)]),e.success(ut(`Build succeeded for ${l.options.name}`));for await(const f of vt(l.options.outDir)){let y=l.buildEntries.find(v=>E(l.options.outDir,v.path)===f.path);if(y||(y={chunk:!0,path:f.path},l.buildEntries.push(y)),!y.bytes){const v=await je(g(l.options.outDir,f.path));y.bytes=v.size}}const h=Yn(e,l,r);Wn(l),Hn(r,l),await l.hooks.callHook("build:done",l),be(l,h)},"build"),Ar=$(async(e,t,s={})=>{const{configPath:o,debug:n,tsconfigPath:r,...i}=s,a=[new _t,new Dt];n&&a.push(new St);const c=Ot({logLevel:n?"debug":"informational",processors:a,scope:"packem"});e=g(pt(),e),c.debug("Root directory:",e);const p=E(e,"package.json"),u=Et(p);c.debug("Using package.json found at",p);let l;if(r){const d=E(e,r);await bt(d)||(c.error("tsconfig.json not found at",d),M(1)),l={config:kt(d),path:d},c.info("Using tsconfig settings at",d)}else try{l=await xt(e),c.debug("Using tsconfig settings found at",l.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const d=o??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),M(1));const h=ot(d,e);c.debug("Using packem config found at",E(e,d));const f=(Array.isArray(h)?h:[h]).filter(Boolean),y=Date.now(),v=$(()=>$t(Math.floor(Date.now()-y)),"getDuration"),w=[],k=[],x=new un(e,bs.version,c);for(const T of f)k.push(Kn(c,e,t,i,T,u,l,x,w));await Promise.all(k),c.raw(`
|
|
101
|
+
⚡️ Build`+(k.length>1?"s":"")+" run in "+v()),c.restoreAll(),M(0)}catch(d){c.error("An error occurred while building",d),M(1)}},"createBundler");export{Ar as O,Gt as n,Xt as v};
|