@visulima/packem 2.0.0-alpha.72 → 2.0.0-alpha.74
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 +28 -0
- package/dist/builder/typedoc/index.d.ts +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/config/index.d.ts +1 -1
- package/dist/config/preset/preact.d.ts +1 -1
- package/dist/config/preset/react.d.ts +1 -1
- package/dist/config/preset/solid.d.ts +1 -1
- package/dist/config/preset/svelte.d.ts +1 -1
- package/dist/config/preset/vue.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/packem_shared/{index-CBiZaA3V.js → index-Bq_O7_ZY.js} +33 -33
- package/dist/packem_shared/{types.d-2tvt70BP.d.ts → types.d-CRug-s8c.d.ts} +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## @visulima/packem [2.0.0-alpha.74](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.73...@visulima/packem@2.0.0-alpha.74) (2026-04-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **packem:** externalize transitive bare specifiers from workspace-sibling .d.ts ([b9e9fb9](https://github.com/visulima/packem/commit/b9e9fb942a7db26d2a0df14117be0fef6cb89fe8))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.61
|
|
11
|
+
* **@visulima/packem-share:** upgraded to 1.0.0-alpha.42
|
|
12
|
+
* **@visulima/rollup-plugin-css:** upgraded to 1.0.0-alpha.41
|
|
13
|
+
* **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.22
|
|
14
|
+
|
|
15
|
+
## @visulima/packem [2.0.0-alpha.73](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.72...@visulima/packem@2.0.0-alpha.73) (2026-04-24)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* forward resolveId options + silence DTS-only circular warnings ([eaf1798](https://github.com/visulima/packem/commit/eaf1798e711bbf1ee0aeb50a20a8aa018c4526ac))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Dependencies
|
|
23
|
+
|
|
24
|
+
* **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.60
|
|
25
|
+
* **@visulima/packem-share:** upgraded to 1.0.0-alpha.41
|
|
26
|
+
* **@visulima/rollup-plugin-css:** upgraded to 1.0.0-alpha.40
|
|
27
|
+
* **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.21
|
|
28
|
+
|
|
1
29
|
## @visulima/packem [2.0.0-alpha.72](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.71...@visulima/packem@2.0.0-alpha.72) (2026-04-24)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildContext } from '@visulima/packem-share/types';
|
|
2
|
-
import { I as InternalBuildOptions } from "../../packem_shared/types.d-
|
|
2
|
+
import { I as InternalBuildOptions } from "../../packem_shared/types.d-CRug-s8c.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-rollup';
|
|
5
5
|
import '@visulima/packem-rollup/oxc';
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Q=Object.defineProperty;var w=(s,t)=>Q(s,"name",{value:t,configurable:!0});import{createCerebro as Z}from"@visulima/cerebro";import ee from"@visulima/cerebro/logger/pail";import{SimpleReporter as te}from"@visulima/pail/reporter/simple";import C,{cwd as V,exit as se}from"node:process";import{installPackage as x}from"@antfu/install-pkg";import{confirm as v,select as h,multiselect as U,spinner as B,cancel as ae,intro as ie,log as T,outro as ne}from"@clack/prompts";import{isAccessible as re,readFile as oe,writeFile as ce,isAccessibleSync as L,writeJsonSync as le,writeFileSync as de}from"@visulima/fs";import{parsePackageJson as G}from"@visulima/package/package-json";import{join as $,resolve as N}from"@visulima/path";import pe from"magic-string";import{exec as ue}from"tinyexec";import{PRODUCTION_ENV as R,DEVELOPMENT_ENV as me}from"@visulima/packem-share/constants";import{createJiti as fe}from"jiti";import{c as ge,$ as ye,S as be}from"../packem_shared/index-
|
|
2
|
+
var Q=Object.defineProperty;var w=(s,t)=>Q(s,"name",{value:t,configurable:!0});import{createCerebro as Z}from"@visulima/cerebro";import ee from"@visulima/cerebro/logger/pail";import{SimpleReporter as te}from"@visulima/pail/reporter/simple";import C,{cwd as V,exit as se}from"node:process";import{installPackage as x}from"@antfu/install-pkg";import{confirm as v,select as h,multiselect as U,spinner as B,cancel as ae,intro as ie,log as T,outro as ne}from"@clack/prompts";import{isAccessible as re,readFile as oe,writeFile as ce,isAccessibleSync as L,writeJsonSync as le,writeFileSync as de}from"@visulima/fs";import{parsePackageJson as G}from"@visulima/package/package-json";import{join as $,resolve as N}from"@visulima/path";import pe from"magic-string";import{exec as ue}from"tinyexec";import{PRODUCTION_ENV as R,DEVELOPMENT_ENV as me}from"@visulima/packem-share/constants";import{createJiti as fe}from"jiti";import{c as ge,$ as ye,S as be}from"../packem_shared/index-Bq_O7_ZY.js";import{existsSync as A}from"node:fs";import{parseEnv as F}from"node:util";import{readFile as ve,writeFile as we}from"node:fs/promises";import{createInterface as he}from"node:readline/promises";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
3
3
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
4
|
-
var ke="@visulima/packem",z="2.0.0-alpha.
|
|
4
|
+
var ke="@visulima/packem",z="2.0.0-alpha.73";const q={version:z};var Se=Object.defineProperty,$e=w((s,t)=>Se(s,"name",{value:t,configurable:!0}),"t");const W=$e(async(s,t="")=>{let a=t;if(!a){const e=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const n of e)if(await re($(s,n))){a=`./${n}`;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(a))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return a},"findPackemFile"),_={less:["less"],lightningcss:["lightningcss"],"node-sass":["node-sass"],postcss:["postcss","postcss-load-config","postcss-modules-extract-imports","postcss-modules-local-by-default","postcss-modules-scope","postcss-modules-values","postcss-value-parser","@csstools/css-parser-algorithms","@csstools/css-tokenizer","@csstools/postcss-slow-plugins","icss-utils","@visulima/css-style-inject"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"],tailwindcss:["@tailwindcss/node","@tailwindcss/oxide","tailwindcss"]};var je=Object.defineProperty,b=w((s,t)=>je(s,"name",{value:t,configurable:!0}),"r$1");const Ce=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Pe=["@babel/core","@babel/preset-react"],xe=["react","react-dom"],De=["@babel/core","babel-preset-solid"],Me=["solid-js"],Oe=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],Ee=["preact"],Ie=["unplugin-vue"],Ne=["vue"],Le=["rollup-plugin-svelte"],Be=["svelte"],D=b((s,t,a)=>s.includes(`preset: '${t}'`)||s.includes(`preset: "${t}"`)||s.includes(`preset: '${t}',`)||s.includes(`preset: "${t}",`)||s.includes(a)||s.includes(`@visulima/packem/config/preset/${t}`),"checkPresetExists"),M=b((s,t)=>{const{logger:a,magic:e,packemConfig:n}=s,r=n.match(/defineConfig\s*\(\s*\{/);if(r&&r.index!==void 0){const o=r.index+r[0].length;if(n.includes("preset:")){const i=n.match(/preset:\s*['"]([^'"]+)['"]/);if(i)e.replace(i[0],`preset: '${t}'`);else throw a.warn(`A preset already exists in the config. Please manually set it to '${t}'.`),new Error("Preset exists but is not a string")}else e.appendLeft(o,`
|
|
5
5
|
preset: '${t}',`)}else if(n.includes("transformer:"))e.replace("transformer:",`preset: '${t}',
|
|
6
6
|
transformer:`);else{const o=n.indexOf("{");o!==-1&&e.appendLeft(o+1,`
|
|
7
7
|
preset: '${t}',`)}},"insertPreset"),Ve=b(async s=>{try{return((await ue("git",["status","--porcelain"],{nodeOptions:{cwd:s,stdio:["pipe","pipe","pipe"]}})).stdout?.trim().length??0)>0}catch{return!1}},"checkGitDirty"),H=b(async s=>{const t=$(s,"package.json"),a=await G(t,{resolveCatalogs:!0});return!!(a.devDependencies?.typescript??a.dependencies?.typescript)},"checkTypeScriptInstalled"),Ae=b(async s=>{const t=await H(s),a=[...xe],e=[...Pe];return t?e.push("@types/react","@types/react-dom"):await v({initialValue:!1,message:"Do you want to use TypeScript?"})&&e.push("typescript","@types/react","@types/react-dom"),{devPackages:e,packages:a}},"getReactTypeDependencies"),O=b(async(s,t,a)=>{const{rootDirectory:e,spinner:n}=s;n.start("Installing packages"),await x(a,{cwd:e,dev:!1,silent:!0}),await x(t,{cwd:e,dev:!0,silent:!0}),n.stop("Installed packages")},"installPackages"),Te=b(async s=>{const{logger:t,magic:a,packemConfig:e,packemConfigFormat:n,rootDirectory:r,spinner:o,transformerReplaceKey:i,transformerSearchKey:l}=s;if(e.includes("typedoc: typedocBuilder")||e.includes("@visulima/packem/builder/typedoc")){t.warn("Typedoc has already been added to the packem config.");return}n==="cjs"?a.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildConfig,
|
|
1
|
+
import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from "../packem_shared/types.d-CRug-s8c.js";
|
|
2
2
|
export { type BuildHooks } from '@visulima/packem-share/types';
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-rollup';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BabelPluginConfig } from '@visulima/packem-rollup/babel';
|
|
2
|
-
import { B as BuildConfig } from "../../packem_shared/types.d-
|
|
2
|
+
import { B as BuildConfig } from "../../packem_shared/types.d-CRug-s8c.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-rollup';
|
|
5
5
|
import '@visulima/packem-rollup/oxc';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BabelPluginConfig } from '@visulima/packem-rollup/babel';
|
|
2
|
-
import { B as BuildConfig } from "../../packem_shared/types.d-
|
|
2
|
+
import { B as BuildConfig } from "../../packem_shared/types.d-CRug-s8c.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-rollup';
|
|
5
5
|
import '@visulima/packem-rollup/oxc';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BabelPluginConfig } from '@visulima/packem-rollup/babel';
|
|
2
|
-
import { B as BuildConfig } from "../../packem_shared/types.d-
|
|
2
|
+
import { B as BuildConfig } from "../../packem_shared/types.d-CRug-s8c.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-rollup';
|
|
5
5
|
import '@visulima/packem-rollup/oxc';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConstructorOptions } from '@visulima/pail';
|
|
2
|
-
import { B as BuildConfig } from "./packem_shared/types.d-
|
|
3
|
-
export { type
|
|
2
|
+
import { B as BuildConfig } from "./packem_shared/types.d-CRug-s8c.js";
|
|
3
|
+
export { type a as BuildEntry, type b as BuildOptions, type R as RollupBuildOptions } from "./packem_shared/types.d-CRug-s8c.js";
|
|
4
4
|
export { type TransformerFn, type TransformerName } from '@visulima/packem-rollup';
|
|
5
5
|
import { Environment, Mode } from '@visulima/packem-share/types';
|
|
6
6
|
export { type BuildContext, type BuildContextBuildAssetAndChunk, type BuildContextBuildEntry, type BuildHooks, type Environment, type Mode, type Runtime } from '@visulima/packem-share/types';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import{createPail as s}from"@visulima/pail";import{SimpleReporter as u}from"@visulima/pail/reporter/simple";import{S as g}from"./packem_shared/index-
|
|
1
|
+
var c=Object.defineProperty;var o=(e,r)=>c(e,"name",{value:r,configurable:!0});import{createPail as s}from"@visulima/pail";import{SimpleReporter as u}from"@visulima/pail/reporter/simple";import{S as g}from"./packem_shared/index-Bq_O7_ZY.js";var f=Object.defineProperty,l=o((e,r)=>f(e,"name",{value:r,configurable:!0}),"r");const C=l(async(e,r={})=>{const{debug:t,environment:i,logger:a,mode:n,tsconfigPath:m,...d}={debug:!1,environment:"production",logger:{},mode:"build",tsconfigPath:void 0,...r},p=s({reporters:[new u({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem",...a});await g(e,n,i,p,t,d,m)},"packem");export{C as packem};
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
var Zo=Object.defineProperty;var k=(e,t)=>Zo(e,"name",{value:t,configurable:!0});import ve,{versions as
|
|
1
|
+
var Zo=Object.defineProperty;var k=(e,t)=>Zo(e,"name",{value:t,configurable:!0});import ve,{versions as Be,platform as je}from"node:process";import{cyan as K,bold as X,gray as re,blue as Fe,yellow as Se,red as ye,green as Zt,dim as eo,grey as en}from"@visulima/colorize";import{findCacheDirSync as tn}from"@visulima/find-cache-dir";import{isAccessibleSync as ue,collectSync as ft,isAccessible as le,readFileSync as on,writeFileSync as Ce,emptyDir as nn,readJson as to,walk as rn,writeJson as sn,ensureDirSync as an}from"@visulima/fs";import{parseBytes as mt,formatBytes as H,duration as gt}from"@visulima/humanizer";import{hasPackageJsonAnyDependency as oo,ensurePackages as ln}from"@visulima/package";import{arrayify as ht,memoizeByKey as pn,enhanceRollupError as no,FileCache as cn}from"@visulima/packem-share";import{RUNTIME_EXPORT_CONVENTIONS as io,SPECIAL_EXPORT_CONVENTIONS as ro,PRODUCTION_ENV as Oe,DEVELOPMENT_ENV as yt,DEFAULT_EXTENSIONS as st,ENDING_REGEX as at,EXCLUDE_REGEXP as $e,ALLOWED_TRANSFORM_EXTENSIONS_REGEX as ae,VALID_EXPORT_EXTENSIONS as un}from"@visulima/packem-share/constants";import{warn as P,getDtsExtension as se,getOutputExtension as te,getPackageName as dn,getChunkFilename as De,getEntryFileNames as fn,sortUserPlugins as so,arrayify as bt,getHash as wt}from"@visulima/packem-share/utils";import{extname as ao,resolve as R,toNamespacedPath as mn,join as T,isAbsolute as lt,relative as Q,normalize as gn,dirname as pe,basename as hn}from"@visulima/path";import yn from"browserslist";import{createHooks as bn}from"hookable";import{createJiti as wn}from"jiti";import{watch as vt,rollup as lo,VERSION as vn}from"rollup";import{importTrace as po,patchErrorWithTrace as $n}from"rollup-plugin-import-trace";import{x as ze,exec as xn}from"tinyexec";import jn,{stat as pt,readdir as kn,rm as Ve,mkdtemp as co,readFile as En,rename as Sn,mkdir as uo,writeFile as fo,chmod as On}from"node:fs/promises";import $t from"node:path/posix";import{parsePackageJsonSync as mo}from"@visulima/package/package-json";import{readTsConfig as Dn,findTsConfig as Pn}from"@visulima/tsconfig";import{NotFoundError as Nn}from"@visulima/fs/error";import{isRelative as Cn,toPath as xt,resolveAlias as Mn}from"@visulima/path/utils";import{isDynamicPattern as et,globSync as go}from"tinyglobby";import{getShebang as Tn,makeExecutable as jt,shebangPlugin as An,removeShebangPlugin as Rn}from"@visulima/packem-rollup/plugin/shebang";import{fileURLToPath as Fn,resolveModuleExportNames as In,resolvePath as kt,pathToFileURL as Wn,isNodeBuiltin as Me,parseNodeModulePath as Et}from"mlly";import Jn,{existsSync as ho,watch as Bn,createReadStream as yo}from"node:fs";import{browserslistToEsbuild as Te,nodeResolve as zn,createSplitChunks as Kn,purePlugin as _n,pureNewExpressionPlugin as Un,cachingPlugin as q,resolveFileUrlPlugin as bo,replace as wo,alias as vo,polyfillNode as Ln,chunkSplitter as Vn,wasm as Hn,fixDynamicImportExtension as qn,dynamicImportVars as Gn,commonjs as Yn,metafilePlugin as Xn,visualizer as Qn}from"@visulima/packem-rollup";import{babelTransformPlugin as Zn}from"@visulima/packem-rollup/babel";import{oxcResolvePlugin as ei}from"@visulima/packem-rollup/oxc";import{cjsInteropPlugin as $o}from"@visulima/packem-rollup/plugin/cjs-interop";import{copyPlugin as ti}from"@visulima/packem-rollup/plugin/copy";import{dataUriPlugin as oi}from"@visulima/packem-rollup/plugin/data-uri";import{debarrelPlugin as ni}from"@visulima/packem-rollup/plugin/debarrel";import{importAttributesPlugin as ii}from"@visulima/packem-rollup/plugin/import-attributes";import{esmShimCjsSyntaxPlugin as ri}from"@visulima/packem-rollup/plugin/esm-shim-cjs-syntax";import{fixDtsDefaultCjsExportsPlugin as si}from"@visulima/packem-rollup/plugin/fix-dts-default-cjs-exports";import{JsonPlugin as ai}from"@visulima/packem-rollup/plugin/json";import{jsxRemoveAttributes as li}from"@visulima/packem-rollup/plugin/jsx-remove-attributes";import{licensePlugin as xo}from"@visulima/packem-rollup/plugin/license";import{minifyHTMLLiteralsPlugin as pi}from"@visulima/packem-rollup/plugin/minify-html-literals";import{nativeModulesPlugin as ci}from"@visulima/packem-rollup/plugin/native-modules";import{preserveDirectivesPlugin as ui}from"@visulima/packem-rollup/plugin/preserve-directives";import{rawPlugin as di}from"@visulima/packem-rollup/plugin/raw";import{requireCJSTransformerPlugin as fi}from"@visulima/packem-rollup/plugin/require-cjs-transformer";import{sourcemapsPlugin as mi}from"@visulima/packem-rollup/plugin/source-maps";import{urlPlugin as gi}from"@visulima/packem-rollup/plugin/url";import{resolveTypescriptMjsCtsPlugin as jo,resolveTsconfigRootDirectoriesPlugin as ko,resolveTsconfigPathsPlugin as Eo,patchTypescriptTypesPlugin as hi}from"@visulima/packem-rollup/typescript";import{rollupCssPlugin as yi,cssModulesTypesPlugin as bi}from"@visulima/rollup-plugin-css";import{minVersion as So,coerce as Ie,satisfies as Oo,validRange as wi,valid as vi}from"semver";import $i from"magic-string";import{createDefu as xi}from"defu";import{m as ji}from"./create-or-update-key-storage-Ddq46eG8.js";import{createFilter as ki}from"@rollup/pluginutils";import Ei from"child_process";import Si from"node:child_process";import{tmpdir as Do,homedir as Oi}from"node:os";import{promisify as Di,debuglog as Pi}from"node:util";import{createTable as Ni}from"@visulima/tabular";import{ROUNDED_BORDER as Ci}from"@visulima/tabular/style";import{distance as Mi}from"fastest-levenshtein";import Ti from"picomatch";import{createBrotliCompress as Ai,constants as Ri,createGzip as Fi}from"node:zlib";import Po from"semver/functions/satisfies.js";import{Buffer as Ii}from"node:buffer";import Wi from"semver/functions/valid.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
2
|
const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
3
3
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
4
|
-
var Ji=Object.defineProperty,No=k((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"s$a");const _e=No(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),et=No((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const r=_e(n);if(r)return r}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[i,...s]=t;return et(i,s,o,n)},"inferExportType");var Bi=Object.defineProperty,zi=k((e,t)=>Bi(e,"name",{value:t,configurable:!0}),"x$1");const Ki=new Set(["browser","bun","default","deno","electron","import","module-sync","node","node-addons","require","types","workerd",...io,...ro]),pt=zi((e,t,o,n=[],i=[])=>{if(!e)return[];if(typeof e=="string"){const s=_e(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}if(typeof e=="object"){const s=Object.entries(e).filter(([a])=>!a.endsWith(".json"));let r=[];for(const[a,u]of s){const c=a.replace("./",""),l=i.some(p=>c===p||c.startsWith(`${p}/`));if(typeof u=="string"){let p={};Number.isInteger(+a)?p={exportKey:"*"}:a.startsWith("./")?p={exportKey:a.replace("./","")}:p={exportKey:a==="."?".":"*",subKey:a},r.push({...p,file:u,key:"exports",type:et(a,n,t,u),...l&&{ignored:!0}})}else if(typeof u=="object"&&u!==void 0)for(const[p,f]of Object.entries(u)){if(o===!1&&p==="types")continue;const d=Number.isInteger(+a)?p:a;if(typeof f=="string")r.push({exportKey:d.replace("./",""),file:f,key:"exports",...Ki.has(p)?{subKey:p}:{},type:et(p,n,t,f),...l&&{ignored:!0}});else{const g=d.replace("./",""),h=l||i.some(m=>g===m||g.startsWith(`${m}/`)),y=pt({[d]:f},t,o,[...n,p],i);h&&y.forEach(m=>{m.ignored=!0}),r=[...r,...y]}}}return r}return[]},"extractExportFilenames");var _i=Object.defineProperty,oe=k((e,t)=>_i(e,"name",{value:t,configurable:!0}),"R$2");const tt=new Map,ot=/\.[^./]+$/,Co=oe((e,t)=>{const o=e.match(/\.d\.[mc]?ts$/);if(o)return o[0];if(t)for(const n of Object.values(t)){const i=n.startsWith(".")?n:`.${n}`;if(e.endsWith(i))return i}return ao(e)},"getFullExtension"),Ui=oe(async e=>{try{return await jn.readdir(e,{withFileTypes:!0})}catch(t){const{code:o}=t;if(o==="ENOENT")return[];throw t}},"safeReaddir"),Mo=oe(async(e,t)=>{const o=await Ui(e);return(await Promise.all(o.map(async n=>{const i=$t.join(e,n.name);return n.isDirectory()?Mo(i,t):n.isFile()?$t.relative(t,i):[]}))).flat()},"getDirectoryFilesRecursive"),Li=oe(async e=>{let t=tt.get(e);return t||(t=Mo(e,e),tt.set(e,t)),t},"getDirectoryFiles"),St=oe((e,t,o)=>{const n=e.replace(ot,"");if(t==="*"){const a=n.split("/").filter(Boolean);return a.length===0?void 0:o&&o>1?a:[a[0]]}const i=t.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),s=new RegExp(`^${i}$`),r=n.match(s);return r?r.slice(1):void 0},"matchWildcardPattern"),de=oe((e,t)=>{let o=e;for(const n of t)o=o.replace("*",n);return o},"substituteWildcards"),Vi=oe((e,t)=>e.key==="exports"&&e.subKey===Oe?Oe:e.key==="exports"&&e.subKey===yt?yt:t,"getEnvironment"),Hi=oe(e=>{const t=e.replace(/^\.\/dist\//,"").replace(/^dist\//,"").replace(/\.[^./]+$/,"").split("/"),o=t.at(-1)||"",n=[".browser",".server",".development",".production",".node",".workerd"];for(const s of n)if(o.includes(s)){const r=o.replace(s,""),a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${r}`:r,pattern:s}}const i=o.split(".");if(i.length>2){const s=i.slice(0,-2).join("."),r=`.${i[i.length-2]}`,a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${s}`:s,pattern:r}}},"detectFilePattern"),qi=oe((e,t,o,n)=>{const i=`${t.replace(new RegExp(`^${n}/?`),"")}${o}`,s=i.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),r=new RegExp(String.raw`${s}\.([cm]?[tj]sx?|ts|js)$`),a=e.find(c=>{const l=c.replace(n,"").replace(/^\//,"");return r.test(l)});if(a)return a;const u=`${n}/${i}`;return e.find(c=>{const l=c.replace(/\.[^./]+$/,"");return l===u||l.endsWith(`/${i}`)})||void 0},"tryFindPatternFile"),he=oe((e,t,o,n,i,s,r,a)=>{const u=Vi(i,s.environment);let c=s.options.runtime;const l=i.subKey==="browser"||i.subKey?.includes("browser"),p=i.file.includes(".browser");if(l||p)c="browser";else{for(const w of io)if(i.file.includes(`.${w}.`)||i.subKey===w){c=w;break}(i.subKey==="node"||i.subKey==="workerd"||i.file.includes(".node")||i.file.includes(".workerd")||i.file.includes(".server"))&&(c="node")}const f=Co(i.file,s.options.outputExtensionMap),d=i.file.replace(f,""),g=s.options.outDir.replace(/^\.\//,""),h=d.replace(new RegExp(`^(./)?${g}/`),""),y=t.replace(/\.[^./]+$/,"").split("/").pop()||"",m=h.split("/").pop()||"",C=!t.includes(h)&&y!==m;let v=e.find(w=>w.input===t&&w.environment===u&&w.runtime===c&&w.fileAlias===(C?h:void 0));if(v===void 0?v=e[e.push({environment:u,exportKey:new Set([i.exportKey].filter(Boolean)),fileAlias:C?h:void 0,input:t,runtime:c})-1]:v.exportKey&&i.exportKey&&v.exportKey.add(i.exportKey),r&&(v.isGlob=!0),o&&(v.outDir=n),i.isExecutable)v.executable=!0,v.declaration=!1,i.type==="cjs"?v.cjs=!0:i.type==="esm"&&(v.esm=!0);else{const w=/\.d\.[mc]?ts$/.test(i.file),$=a.filter(b=>b.exportKey===i.exportKey),M=$.length>0&&$.every(b=>/\.d\.[mc]?ts$/.test(b.file));if(w&&s.options.declaration!==!1){v.declaration=s.options.declaration;const b=i.file.endsWith(".d.mts")?"d.mts":i.file.endsWith(".d.cts")?"d.cts":"d.ts";v.declarationExtensions??=new Set,v.declarationExtensions.add(b)}if(w||M){M&&s.options.declaration!==!1&&(v.declaration=s.options.declaration);const b=$.some(O=>/\.d\.mts$/.test(O.file)),j=$.some(O=>/\.d\.cts$/.test(O.file));if(b&&j?((s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible"),s.options.emitCJS=!0,s.options.emitESM=!0):j?(s.options.emitCJS=!0,(s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible")):b&&(s.options.emitESM=!0,(s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible")),M){const O=a.filter(N=>/\.d\.[mc]?ts$/.test(N.file)),x=O.some(N=>/\.d\.mts$/.test(N.file)),E=O.some(N=>/\.d\.cts$/.test(N.file));$.every(N=>!N.subKey||N.subKey==="types")?(E&&(v.cjs=!0),x&&(v.esm=!0)):(E&&(v.declarationCjs=!0),x&&(v.declarationEsm=!0))}}else i.type==="cjs"?v.cjs=!0:i.type==="esm"&&(v.esm=!0)}C&&!v.fileAlias&&(v.fileAlias=h)},"createOrUpdateEntry");let Ot=!1;const Dt=oe(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Gi=oe(async(e,t,o)=>{const n=e.types||e.typings;tt.clear();const i=[];t.sort((d,g)=>d.split("/").length-g.split("/").length);const s=e.type==="module"?"esm":"cjs",r=o.options.declaration??"node16",a=pt(e.exports,s,r,[],o.options.ignoreExportKeys??[]).filter(d=>!d.ignored),u=new Set;for(const d of a){const g=a.filter(h=>h.exportKey===d.exportKey);if(g.length>0&&g.every(h=>/\.d\.[mc]?ts$/.test(h.file))&&!u.has(d.exportKey)){u.add(d.exportKey),g.some(m=>m.file.endsWith(".d.ts"));const h=g.some(m=>m.file.endsWith(".d.mts")),y=g.some(m=>m.file.endsWith(".d.cts"));h&&y?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):y?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):h&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0)}}o.options.declaration===void 0&&(o.options.declaration="node16");const c=a.some(d=>d.type==="esm"&&!/\.d\.mts$/.test(d.file)),l=a.some(d=>d.type==="cjs"&&!/\.d\.cts$/.test(d.file));c&&l?(o.options.emitESM=!0,o.options.emitCJS=!0):c?o.options.emitESM=!0:l?o.options.emitCJS=!0:s==="esm"?o.options.emitESM=!0:s==="cjs"&&(o.options.emitCJS=!0);const p=o.options.emitCJS&&o.options.emitESM;if(o.options.declaration==="node16"&&p&&(o.options.declaration="compatible"),e.bin){const d=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const g of d){const h=_e(g);if(h&&h!==s)throw new Error(`Exported file "${g}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);a.push({file:g,isExecutable:!0,key:"bin",type:h??s})}}e.main&&a.push({file:e.main,key:"main",type:_e(e.main)??s}),e.module&&a.push({file:e.module,key:"module",type:"esm"}),n&&(Dt(o),(o.options.declaration===void 0||o.options.declaration==="node16")&&p&&(o.options.declaration="compatible"),a.push({file:e.types??e.typings,key:"types"}));const f=[];if(!o.options.outputExtensionMap){const d=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".mjs")),g=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".cjs")),h=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".js"));d&&!g&&!h?o.options.outputExtensionMap={esm:"mjs"}:g&&!d&&!h&&(o.options.outputExtensionMap={cjs:"cjs"})}for await(const d of a){const g=/\.d\.[mc]?ts$/.test(d.file),h=Co(d.file,o.options.outputExtensionMap),y=[...rt];if(o.options.outputExtensionMap)for(const x of Object.values(o.options.outputExtensionMap)){const E=x.startsWith(".")?x:`.${x}`;y.includes(E)||y.push(E)}if(!g&&h!==""&&!y.includes(h)||!g&&/\.(tsx?|cts|mts)$/.test(d.file))continue;let m=d.type;if(!m&&g){if(d.file.endsWith(".d.mts"))m="esm";else if(d.file.endsWith(".d.cts"))m="cjs";else if(d.file.endsWith(".d.ts")){const x=a.some(N=>N.subKey==="import"&&N.file.endsWith(".d.mts")),E=a.some(N=>N.subKey==="require"&&N.file.endsWith(".d.cts"));x&&E?m=void 0:m=o.pkg?.type==="module"?"esm":"cjs"}}if(/\.d\.[mc]?ts$/.test(d.file)||(o.options.emitCJS===void 0&&(m==="cjs"||d.type==="cjs")&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&(m==="esm"||d.type==="esm")&&(o.options.emitESM=!0)),o.options.declaration===void 0||o.options.declaration==="node16"){const x=o.options.emitCJS&&o.options.emitESM;o.options.declaration=x?"compatible":"node16"}let C=d.file;if(o.options.outputExtensionMap)for(const x of Object.values(o.options.outputExtensionMap)){const E=x.startsWith(".")?x:`.${x}`;if(d.file.endsWith(E)){C=d.file.slice(0,-E.length);break}}C===d.file&&(C=d.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$`),""));const v=C.endsWith("/");if(v&&["./","/"].includes(C))continue;const w=C.replace(new RegExp(`(./)?${o.options.outDir}`),o.options.sourceDir).replace("./",""),$=v?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?))$`,M="(?:^|/)";if((d.file.includes("/*")||C.includes("*"))&&d.key==="exports"){Ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ot=!0);let x;d.exportKey?x=d.exportKey.startsWith("./")?d.exportKey.slice(2):d.exportKey:x=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(/^dist\//,"");const E=d.file,N=E.match(/\.\w+$/);if(E.includes("*")&&!N&&d.exportKey&&!d.subKey){const W=E.replace(/\*.*$/,"").replace(/^\.\//,""),R=x.replace(/\*.*$/,"").replace(/^\.\//,"");if(W!==R){const J=`package.json#exports["${d.exportKey==="."?".":`./${d.exportKey}`}"]`;i.push(`Wildcard pattern must include a file extension: ${E} at ${J}`);continue}}const V=o.options.sourceDir.replace(/^\.\//,""),_=F(o.options.rootDir,V),U=[],me=await Li(_),B=(E.match(/\*/g)||[]).length,ce=(x.match(/\*/g)||[]).length;for(const W of me){const R=St(W,x,B);if(R){if(B>ce&&B>1){if(R.length>=B){const A=R[0];if(R.every(S=>S===A)){const S=de(E,R.slice(0,B));S.includes("*")||U.push({input:F(_,W),output:S})}continue}const D=W.replace(ot,"").split("/").filter(Boolean);if(D.length>=B){const A=Math.floor(D.length/B),S=[];for(let z=0;z<B;z++){const Y=z*A,L=z===B-1?D.length:(z+1)*A;S.push(D.slice(Y,L).join("/"))}const I=S[0];if(S.every(z=>z===I)){const z=de(E,S);z.includes("*")||U.push({input:F(_,W),output:z})}}else if(D.length>0){const A=D[0];if(D.every(S=>S===A)){const S=new Array(B).fill(A),I=de(E,S);I.includes("*")||U.push({input:F(_,W),output:I})}}continue}if(R.length<B)continue;if(ce>0&&ce<B&&B>1&&R.length>1){const D=R[0];if(!R.every(A=>A===D))continue}const J=de(E,R);if(J.includes("*"))continue;U.push({input:F(_,W),output:J})}}if(U.length===0&&E.includes("*")){let W=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(/^dist\//,"");W=W.replace(/\.\w+$/,""),(W.match(/\*/g)||[]).length;for(const R of me){const J=St(R,W,B);if(J){if(B>1&&ce<B){if(J.length>=B){const S=J[0];if(J.every(I=>I===S)){const I=de(E,J);I.includes("*")||U.push({input:F(_,R),output:I});continue}}const D=R.replace(ot,""),A=W.split("*");if(A.length>=2){const S=A.map(L=>L.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`));let I=`${S[0]}(.+)`;for(let L=1;L<S.length;L++)I+=S[L],L<S.length-1&&(I+=String.raw`\1`);const z=new RegExp(`^${I}$`),Y=D.match(z);if(Y){const L=Y[1],ge=de(E,new Array(B).fill(L));ge.includes("*")||U.push({input:F(_,R),output:ge})}}continue}if(J.length>=B){if(ce>0&&ce<B&&B>1&&J.length>1){const A=J[0];if(!J.every(S=>S===A))continue}const D=de(E,J);D.includes("*")||U.push({input:F(_,R),output:D})}}}}if(U.length===0){a.length>1||i.push(`Could not find entrypoints matching pattern \`${x}\` for output \`${E}\``);continue}const Q=a.filter(W=>W.exportKey===d.exportKey);if(Q.length>0&&Q.every(W=>/\.d\.[mc]?ts$/.test(W.file))){const W=Q.some(S=>S.file.endsWith(".d.ts")),R=Q.some(S=>S.file.endsWith(".d.mts")),J=Q.some(S=>S.file.endsWith(".d.cts"));R&&J?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):J?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):R&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0);const D=Q.find(S=>S.file.endsWith(".d.ts")),A=D||Q.find(S=>S.file.endsWith(".d.mts"))||Q.find(S=>S.file.endsWith(".d.cts"))||d;if(!(A===d||D&&d===D||!D&&A===d))continue;for(const{input:S,output:I}of U){let z=I;if(I.endsWith(".d.mts")||I.endsWith(".d.cts"))z=I.replace(/\.d\.[mc]ts$/,".d.ts");else if(!I.endsWith(".d.ts")){const L=I.replace(/\.d\.[mc]ts$/,".d.ts");W&&(z=L)}const Y={...A,file:z,subKey:"types",type:void 0};he(f,S,!1,C,Y,o,!0,a)}}else for(const{input:W,output:R}of U){const J=/\.d\.[mc]?ts$/.test(R);let D=d.type;J||(R.endsWith(".mjs")?D="esm":R.endsWith(".cjs")?D="cjs":R.endsWith(".js")&&!D&&(D=o.pkg?.type==="module"?"esm":"cjs"));const A={...d,file:R,...!J&&D&&{type:D}};he(f,W,!1,C,A,o,!0,a)}continue}const b=new RegExp(M+w.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);let j=t.find(x=>b.test(x));if(j===void 0){const x=o.options.sourceDir.replace(/^\.\//,""),E=F(o.options.rootDir,x),N=Hi(d.file);if(N){const V=qi(t,N.baseName,N.pattern,E);if(V)j=V;else{const _=N.baseName,U=new RegExp(M+_.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);j=t.find(me=>U.test(me))}}else{const V=w.replace(/^(.+?)\.[^.]*$/,"$1").replace(/\/$/,"");if(ro.has(d.subKey)){const _=new RegExp(M+V.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);j=t.find(U=>_.test(U))}}}if(j===void 0){ue(F(o.options.rootDir,d.file))||i.push(`Could not find entrypoint for \`${d.file}\``);continue}ue(j)&&/\.[cm]?tsx?$/.test(j)&&Dt(o);const O=a.filter(x=>x.exportKey===d.exportKey);if(O.length>0&&O.every(x=>/\.d\.[mc]?ts$/.test(x.file))){O.some(V=>V.file.endsWith(".d.ts"));const x=O.some(V=>V.file.endsWith(".d.mts")),E=O.some(V=>V.file.endsWith(".d.cts"));x&&E?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):E?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):x&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0);const N={...d,subKey:"types",type:void 0};he(f,j,v,C,N,o,!1,a)}else{const x=mn(j.replace(st,""));ue(`${x}.cts`)&&ue(`${x}.mts`)?(he(f,`${x}.cts`,v,C,{...d,type:"cjs"},o,!1,a),he(f,`${x}.mts`,v,C,{...d,type:"esm"},o,!1,a)):he(f,j,v,C,d,o,!1,a)}}return{entries:f,warnings:i}},"inferEntries");var Yi=Object.defineProperty,Xi=k((e,t)=>Yi(e,"name",{value:t,configurable:!0}),"o$5");const Qi=Xi((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 Zi=Object.defineProperty,er=k((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"f$5");const tr={hooks:{"build:prepare":er(async function(e){if(e.options.unbundle){e.options.entries.length=0;const i=T(e.options.rootDir,e.options.sourceDir);if(!ue(i))throw new Error("No 'src' directory found. Please provide entries manually.");const s=ft(i,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[$e,/.*\/dist\/.*/]}).filter(r=>ae.test(r)&&!r.endsWith(".d.ts"));for(const r of s){const a=r.replace(`${i}/`,"").replace(ae,"").replaceAll("/","/");e.options.entries.push({input:r,name:a})}return}if(e.options.entries.length>0)return;const t=T(e.options.rootDir,e.options.sourceDir);if(!ue(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ft(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[$e,/.*\/dist\/.*/]});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};if(n.publishConfig&&(e.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(n.publishConfig).join(", ")}".`),e.logger.debug(n.publishConfig),n=Qi(n,e.options.declaration)),e.options.unbundle){e.logger.info("Unbundle mode detected, creating entries for all source files");const i=o.filter(s=>ae.test(s)&&!s.endsWith(".d.ts"));e.logger.info(`Found ${i.length} code files for unbundle mode`);for(const s of i){const r=s.replace(`${t}/`,"").replace(ae,"").replaceAll("/","/");e.logger.info(`Adding entry: ${r} -> ${s}`),e.options.entries.push({input:s,name:r})}}else{const i=await Gi(n,o,e);for(const s of i.warnings)e.logger.warn(s);e.options.entries.push(...i.entries)}if(e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",K(e.options.entries.map(i=>i.fileAlias?`${X(i.fileAlias)} => ${X(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:X(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),re([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var or=Object.defineProperty,nr=k((e,t)=>or(e,"name",{value:t,configurable:!0}),"e$5");const qe=nr(e=>{const t=T(e,"package.json");if(!ue(t))throw new Error(`package.json not found at ${t}`);const o=mo(t,{resolveCatalogs:!0});return o.publishConfig&&Object.assign(o,o.publishConfig),{packageJson:o,packageJsonPath:t}},"loadPackageJson");var ir=Object.defineProperty,rr=k((e,t)=>ir(e,"name",{value:t,configurable:!0}),"a$c");const sr=rr(async(e,t,o,n)=>{let i;if(n){const s=T(e,n);if(!await le(s))throw new Error(`tsconfig.json not found at ${s}`);i={config:Dn(s),path:s},o.info("Using tsconfig settings at",s)}else if(oo(t,["typescript"]))try{i=await Pn(e),o.debug("Using tsconfig settings found at",i.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}return i},"loadTsconfig");var ar=Object.defineProperty,To=k((e,t)=>ar(e,"name",{value:t,configurable:!0}),"l$b");const Pt=To(async(e,t)=>{if(typeof e.name!="string"){let o=at(e.input)?te(t.options.rootDir,e.input):gn(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(st,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Cn(e.input)&&(e.input=F(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(e.declaration&&e.cjs===void 0&&e.esm===void 0||(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM))),e.outDir=F(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Ao=To(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:Ze(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:Ze(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,i=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")i.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const r of e.options.rollup.watch.exclude)typeof r=="string"&&i.push(r)}const s=go([n.input],{cwd:e.options.rootDir,dot:!1,ignore:i,onlyFiles:!0});if(s.length===0)throw new Nn(`No files found in the glob pattern: ${K(T(e.options.rootDir,n.input))}`);for(const r of s)e.options.entries.push({...n,input:F(e.options.rootDir,r)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries){if(t.runtime)continue;const o=t.exportKey&&[...t.exportKey].some(i=>i.includes("browser")||i==="browser"),n=t.fileAlias?.includes(".browser")??!1;if(o||n)t.runtime="browser";else if(t.exportKey){for(const i of t.exportKey)if(i==="node"||i==="workerd"||i.includes("node")||i.includes("workerd")){t.runtime="node";break}}!t.runtime&&t.fileAlias&&(t.fileAlias.includes(".server")||t.fileAlias.includes(".node")||t.fileAlias.includes(".workerd"))&&(t.runtime="node")}for(const t of e.options.entries)if(t.fileAlias){let o=t.fileAlias;for(;o.startsWith("./")||o.startsWith("../");)o=o.replace(/^\.\.?\//,"");t.name=o}for(const t of e.options.entries.filter(o=>!o.fileAlias))await Pt(t,e);for(const t of e.options.entries.filter(o=>o.fileAlias))await Pt(t,e),t.fileAlias=void 0},"prepareEntries");var lr=Object.defineProperty,pr=k((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$2");const Ge=pr((e,t)=>{let o={};return e.name&&(o[e.name]=t.rootDir),o={...o,...t.alias},t.rollup.alias&&t.rollup.alias.entries&&(Array.isArray(t.rollup.alias.entries)?Object.assign(o,Object.fromEntries(t.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,t.rollup.alias.entries)),o},"resolveAliases");var cr=Object.defineProperty,ur=k((e,t)=>cr(e,"name",{value:t,configurable:!0}),"h$5");const dr=/^[_$a-z\u00A0-\uFFFF][\w$\u00A0-\uFFFF]*$/iu,fr=ur(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...Ge(e.pkg,e.options),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},void 0,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?`[${t.map((i,s)=>{if(Array.isArray(i)){const[r,...a]=i;return o.push(r),`[${[`plugin${s}`,...a.map(u=>JSON.stringify(u))].join(", ")}]`}return o.push(i),`plugin${s}`}).join(",")}]`:"[]");for(const i of e.options.entries){const s=F(e.options.rootDir,e.options.outDir,i.name),r=Rn(e.jiti.esmResolve(i.input,{try:!0})??i.input),a=r.replace(st,""),u=on(r),c=Tn(u);let l=[];try{l=await In(r,{extensions:rt})}catch(d){P(e,`Cannot analyze ${r} for exports: ${d.toString()}`);return}const p=l.includes("default")||l.length===0,f=e.options.jiti.absoluteJitiPath?(...d)=>Wn(F(...d)):te;if(e.options.emitESM){const d=f(pe(s),await kt("jiti",{conditions:["node","import"],url:import.meta.url})),g=se(e,"esm"),h=`${a}.${g}`;Ce(`${s}.${ee(e,"esm")}`,c+[`import { createJiti } from "${d}";`,...o.map((y,m)=>`import plugin${m} from "${y}";`),"",`const jiti = createJiti(import.meta.url, ${n});`,"",`/** @type {import("${h}")} */`,`const _module = await jiti.import("${r}");`,...p?["export default _module?.default ?? _module;"]:[],...l.filter(y=>y!=="default").map((y,m)=>{if(dr.test(y))return`export const ${y} = _module.${y};`;const C=`__packem_export_${m}`,v=y.startsWith("'")&&y.endsWith("'")?`_module[${y}]`:`_module[${JSON.stringify(y)}]`;return`const ${C} = ${v};
|
|
4
|
+
var Ji=Object.defineProperty,No=k((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"s$a");const Ke=No(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),tt=No((e,t,o,n)=>{if(e==="module-sync")return"esm";if(n){const r=Ke(n);if(r)return r}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[i,...s]=t;return tt(i,s,o,n)},"inferExportType");var Bi=Object.defineProperty,zi=k((e,t)=>Bi(e,"name",{value:t,configurable:!0}),"x$1");const Ki=new Set(["browser","bun","default","deno","electron","import","module-sync","node","node-addons","require","types","workerd",...io,...ro]),ct=zi((e,t,o,n=[],i=[])=>{if(!e)return[];if(typeof e=="string"){const s=Ke(e);if(s&&s!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:s??t}]}if(typeof e=="object"){const s=Object.entries(e).filter(([a])=>!a.endsWith(".json"));let r=[];for(const[a,u]of s){const c=a.replace("./",""),l=i.some(p=>c===p||c.startsWith(`${p}/`));if(typeof u=="string"){let p={};Number.isInteger(+a)?p={exportKey:"*"}:a.startsWith("./")?p={exportKey:a.replace("./","")}:p={exportKey:a==="."?".":"*",subKey:a},r.push({...p,file:u,key:"exports",type:tt(a,n,t,u),...l&&{ignored:!0}})}else if(typeof u=="object"&&u!==void 0)for(const[p,f]of Object.entries(u)){if(o===!1&&p==="types")continue;const d=Number.isInteger(+a)?p:a;if(typeof f=="string")r.push({exportKey:d.replace("./",""),file:f,key:"exports",...Ki.has(p)?{subKey:p}:{},type:tt(p,n,t,f),...l&&{ignored:!0}});else{const g=d.replace("./",""),h=l||i.some(m=>g===m||g.startsWith(`${m}/`)),y=ct({[d]:f},t,o,[...n,p],i);h&&y.forEach(m=>{m.ignored=!0}),r=[...r,...y]}}}return r}return[]},"extractExportFilenames");var _i=Object.defineProperty,oe=k((e,t)=>_i(e,"name",{value:t,configurable:!0}),"R$2");const ot=new Map,nt=/\.[^./]+$/,Co=oe((e,t)=>{const o=e.match(/\.d\.[mc]?ts$/);if(o)return o[0];if(t)for(const n of Object.values(t)){const i=n.startsWith(".")?n:`.${n}`;if(e.endsWith(i))return i}return ao(e)},"getFullExtension"),Ui=oe(async e=>{try{return await jn.readdir(e,{withFileTypes:!0})}catch(t){const{code:o}=t;if(o==="ENOENT")return[];throw t}},"safeReaddir"),Mo=oe(async(e,t)=>{const o=await Ui(e);return(await Promise.all(o.map(async n=>{const i=$t.join(e,n.name);return n.isDirectory()?Mo(i,t):n.isFile()?$t.relative(t,i):[]}))).flat()},"getDirectoryFilesRecursive"),Li=oe(async e=>{let t=ot.get(e);return t||(t=Mo(e,e),ot.set(e,t)),t},"getDirectoryFiles"),St=oe((e,t,o)=>{const n=e.replace(nt,"");if(t==="*"){const a=n.split("/").filter(Boolean);return a.length===0?void 0:o&&o>1?a:[a[0]]}const i=t.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),s=new RegExp(`^${i}$`),r=n.match(s);return r?r.slice(1):void 0},"matchWildcardPattern"),de=oe((e,t)=>{let o=e;for(const n of t)o=o.replace("*",n);return o},"substituteWildcards"),Vi=oe((e,t)=>e.key==="exports"&&e.subKey===Oe?Oe:e.key==="exports"&&e.subKey===yt?yt:t,"getEnvironment"),Hi=oe(e=>{const t=e.replace(/^\.\/dist\//,"").replace(/^dist\//,"").replace(/\.[^./]+$/,"").split("/"),o=t.at(-1)||"",n=[".browser",".server",".development",".production",".node",".workerd"];for(const s of n)if(o.includes(s)){const r=o.replace(s,""),a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${r}`:r,pattern:s}}const i=o.split(".");if(i.length>2){const s=i.slice(0,-2).join("."),r=`.${i[i.length-2]}`,a=t.length>1?t.slice(0,-1).join("/"):"";return{baseName:a?`${a}/${s}`:s,pattern:r}}},"detectFilePattern"),qi=oe((e,t,o,n)=>{const i=`${t.replace(new RegExp(`^${n}/?`),"")}${o}`,s=i.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),r=new RegExp(String.raw`${s}\.([cm]?[tj]sx?|ts|js)$`),a=e.find(c=>{const l=c.replace(n,"").replace(/^\//,"");return r.test(l)});if(a)return a;const u=`${n}/${i}`;return e.find(c=>{const l=c.replace(/\.[^./]+$/,"");return l===u||l.endsWith(`/${i}`)})||void 0},"tryFindPatternFile"),he=oe((e,t,o,n,i,s,r,a)=>{const u=Vi(i,s.environment);let c=s.options.runtime;const l=i.subKey==="browser"||i.subKey?.includes("browser"),p=i.file.includes(".browser");if(l||p)c="browser";else{for(const w of io)if(i.file.includes(`.${w}.`)||i.subKey===w){c=w;break}(i.subKey==="node"||i.subKey==="workerd"||i.file.includes(".node")||i.file.includes(".workerd")||i.file.includes(".server"))&&(c="node")}const f=Co(i.file,s.options.outputExtensionMap),d=i.file.replace(f,""),g=s.options.outDir.replace(/^\.\//,""),h=d.replace(new RegExp(`^(./)?${g}/`),""),y=t.replace(/\.[^./]+$/,"").split("/").pop()||"",m=h.split("/").pop()||"",C=!t.includes(h)&&y!==m;let v=e.find(w=>w.input===t&&w.environment===u&&w.runtime===c&&w.fileAlias===(C?h:void 0));if(v===void 0?v=e[e.push({environment:u,exportKey:new Set([i.exportKey].filter(Boolean)),fileAlias:C?h:void 0,input:t,runtime:c})-1]:v.exportKey&&i.exportKey&&v.exportKey.add(i.exportKey),r&&(v.isGlob=!0),o&&(v.outDir=n),i.isExecutable)v.executable=!0,v.declaration=!1,i.type==="cjs"?v.cjs=!0:i.type==="esm"&&(v.esm=!0);else{const w=/\.d\.[mc]?ts$/.test(i.file),$=a.filter(b=>b.exportKey===i.exportKey),M=$.length>0&&$.every(b=>/\.d\.[mc]?ts$/.test(b.file));if(w&&s.options.declaration!==!1){v.declaration=s.options.declaration;const b=i.file.endsWith(".d.mts")?"d.mts":i.file.endsWith(".d.cts")?"d.cts":"d.ts";v.declarationExtensions??=new Set,v.declarationExtensions.add(b)}if(w||M){M&&s.options.declaration!==!1&&(v.declaration=s.options.declaration);const b=$.some(O=>/\.d\.mts$/.test(O.file)),j=$.some(O=>/\.d\.cts$/.test(O.file));if(b&&j?((s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible"),s.options.emitCJS=!0,s.options.emitESM=!0):j?(s.options.emitCJS=!0,(s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible")):b&&(s.options.emitESM=!0,(s.options.declaration===void 0||s.options.declaration==="node16")&&(s.options.declaration="compatible")),M){const O=a.filter(N=>/\.d\.[mc]?ts$/.test(N.file)),x=O.some(N=>/\.d\.mts$/.test(N.file)),E=O.some(N=>/\.d\.cts$/.test(N.file));$.every(N=>!N.subKey||N.subKey==="types")?(E&&(v.cjs=!0),x&&(v.esm=!0)):(E&&(v.declarationCjs=!0),x&&(v.declarationEsm=!0))}}else i.type==="cjs"?v.cjs=!0:i.type==="esm"&&(v.esm=!0)}C&&!v.fileAlias&&(v.fileAlias=h)},"createOrUpdateEntry");let Ot=!1;const Dt=oe(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Gi=oe(async(e,t,o)=>{const n=e.types||e.typings;ot.clear();const i=[];t.sort((d,g)=>d.split("/").length-g.split("/").length);const s=e.type==="module"?"esm":"cjs",r=o.options.declaration??"node16",a=ct(e.exports,s,r,[],o.options.ignoreExportKeys??[]).filter(d=>!d.ignored),u=new Set;for(const d of a){const g=a.filter(h=>h.exportKey===d.exportKey);if(g.length>0&&g.every(h=>/\.d\.[mc]?ts$/.test(h.file))&&!u.has(d.exportKey)){u.add(d.exportKey),g.some(m=>m.file.endsWith(".d.ts"));const h=g.some(m=>m.file.endsWith(".d.mts")),y=g.some(m=>m.file.endsWith(".d.cts"));h&&y?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):y?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):h&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0)}}o.options.declaration===void 0&&(o.options.declaration="node16");const c=a.some(d=>d.type==="esm"&&!/\.d\.mts$/.test(d.file)),l=a.some(d=>d.type==="cjs"&&!/\.d\.cts$/.test(d.file));c&&l?(o.options.emitESM=!0,o.options.emitCJS=!0):c?o.options.emitESM=!0:l?o.options.emitCJS=!0:s==="esm"?o.options.emitESM=!0:s==="cjs"&&(o.options.emitCJS=!0);const p=o.options.emitCJS&&o.options.emitESM;if(o.options.declaration==="node16"&&p&&(o.options.declaration="compatible"),e.bin){const d=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const g of d){const h=Ke(g);if(h&&h!==s)throw new Error(`Exported file "${g}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);a.push({file:g,isExecutable:!0,key:"bin",type:h??s})}}e.main&&a.push({file:e.main,key:"main",type:Ke(e.main)??s}),e.module&&a.push({file:e.module,key:"module",type:"esm"}),n&&(Dt(o),(o.options.declaration===void 0||o.options.declaration==="node16")&&p&&(o.options.declaration="compatible"),a.push({file:e.types??e.typings,key:"types"}));const f=[];if(!o.options.outputExtensionMap){const d=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".mjs")),g=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".cjs")),h=a.some(y=>!y.isExecutable&&!/\.d\.[mc]?ts$/.test(y.file)&&y.file.endsWith(".js"));d&&!g&&!h?o.options.outputExtensionMap={esm:"mjs"}:g&&!d&&!h&&(o.options.outputExtensionMap={cjs:"cjs"})}for await(const d of a){const g=/\.d\.[mc]?ts$/.test(d.file),h=Co(d.file,o.options.outputExtensionMap),y=[...st];if(o.options.outputExtensionMap)for(const x of Object.values(o.options.outputExtensionMap)){const E=x.startsWith(".")?x:`.${x}`;y.includes(E)||y.push(E)}if(!g&&h!==""&&!y.includes(h)||!g&&/\.(tsx?|cts|mts)$/.test(d.file))continue;let m=d.type;if(!m&&g){if(d.file.endsWith(".d.mts"))m="esm";else if(d.file.endsWith(".d.cts"))m="cjs";else if(d.file.endsWith(".d.ts")){const x=a.some(N=>N.subKey==="import"&&N.file.endsWith(".d.mts")),E=a.some(N=>N.subKey==="require"&&N.file.endsWith(".d.cts"));x&&E?m=void 0:m=o.pkg?.type==="module"?"esm":"cjs"}}if(/\.d\.[mc]?ts$/.test(d.file)||(o.options.emitCJS===void 0&&(m==="cjs"||d.type==="cjs")&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&(m==="esm"||d.type==="esm")&&(o.options.emitESM=!0)),o.options.declaration===void 0||o.options.declaration==="node16"){const x=o.options.emitCJS&&o.options.emitESM;o.options.declaration=x?"compatible":"node16"}let C=d.file;if(o.options.outputExtensionMap)for(const x of Object.values(o.options.outputExtensionMap)){const E=x.startsWith(".")?x:`.${x}`;if(d.file.endsWith(E)){C=d.file.slice(0,-E.length);break}}C===d.file&&(C=d.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$`),""));const v=C.endsWith("/");if(v&&["./","/"].includes(C))continue;const w=C.replace(new RegExp(`(./)?${o.options.outDir}`),o.options.sourceDir).replace("./",""),$=v?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?))$`,M="(?:^|/)";if((d.file.includes("/*")||C.includes("*"))&&d.key==="exports"){Ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Ot=!0);let x;d.exportKey?x=d.exportKey.startsWith("./")?d.exportKey.slice(2):d.exportKey:x=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(/^dist\//,"");const E=d.file,N=E.match(/\.\w+$/);if(E.includes("*")&&!N&&d.exportKey&&!d.subKey){const W=E.replace(/\*.*$/,"").replace(/^\.\//,""),F=x.replace(/\*.*$/,"").replace(/^\.\//,"");if(W!==F){const J=`package.json#exports["${d.exportKey==="."?".":`./${d.exportKey}`}"]`;i.push(`Wildcard pattern must include a file extension: ${E} at ${J}`);continue}}const V=o.options.sourceDir.replace(/^\.\//,""),_=R(o.options.rootDir,V),U=[],me=await Li(_),B=(E.match(/\*/g)||[]).length,ce=(x.match(/\*/g)||[]).length;for(const W of me){const F=St(W,x,B);if(F){if(B>ce&&B>1){if(F.length>=B){const A=F[0];if(F.every(S=>S===A)){const S=de(E,F.slice(0,B));S.includes("*")||U.push({input:R(_,W),output:S})}continue}const D=W.replace(nt,"").split("/").filter(Boolean);if(D.length>=B){const A=Math.floor(D.length/B),S=[];for(let z=0;z<B;z++){const Y=z*A,L=z===B-1?D.length:(z+1)*A;S.push(D.slice(Y,L).join("/"))}const I=S[0];if(S.every(z=>z===I)){const z=de(E,S);z.includes("*")||U.push({input:R(_,W),output:z})}}else if(D.length>0){const A=D[0];if(D.every(S=>S===A)){const S=new Array(B).fill(A),I=de(E,S);I.includes("*")||U.push({input:R(_,W),output:I})}}continue}if(F.length<B)continue;if(ce>0&&ce<B&&B>1&&F.length>1){const D=F[0];if(!F.every(A=>A===D))continue}const J=de(E,F);if(J.includes("*"))continue;U.push({input:R(_,W),output:J})}}if(U.length===0&&E.includes("*")){let W=(d.file.startsWith("./")?d.file.slice(2):d.file).replace(/^dist\//,"");W=W.replace(/\.\w+$/,""),(W.match(/\*/g)||[]).length;for(const F of me){const J=St(F,W,B);if(J){if(B>1&&ce<B){if(J.length>=B){const S=J[0];if(J.every(I=>I===S)){const I=de(E,J);I.includes("*")||U.push({input:R(_,F),output:I});continue}}const D=F.replace(nt,""),A=W.split("*");if(A.length>=2){const S=A.map(L=>L.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`));let I=`${S[0]}(.+)`;for(let L=1;L<S.length;L++)I+=S[L],L<S.length-1&&(I+=String.raw`\1`);const z=new RegExp(`^${I}$`),Y=D.match(z);if(Y){const L=Y[1],ge=de(E,new Array(B).fill(L));ge.includes("*")||U.push({input:R(_,F),output:ge})}}continue}if(J.length>=B){if(ce>0&&ce<B&&B>1&&J.length>1){const A=J[0];if(!J.every(S=>S===A))continue}const D=de(E,J);D.includes("*")||U.push({input:R(_,F),output:D})}}}}if(U.length===0){a.length>1||i.push(`Could not find entrypoints matching pattern \`${x}\` for output \`${E}\``);continue}const Z=a.filter(W=>W.exportKey===d.exportKey);if(Z.length>0&&Z.every(W=>/\.d\.[mc]?ts$/.test(W.file))){const W=Z.some(S=>S.file.endsWith(".d.ts")),F=Z.some(S=>S.file.endsWith(".d.mts")),J=Z.some(S=>S.file.endsWith(".d.cts"));F&&J?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):J?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):F&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0);const D=Z.find(S=>S.file.endsWith(".d.ts")),A=D||Z.find(S=>S.file.endsWith(".d.mts"))||Z.find(S=>S.file.endsWith(".d.cts"))||d;if(!(A===d||D&&d===D||!D&&A===d))continue;for(const{input:S,output:I}of U){let z=I;if(I.endsWith(".d.mts")||I.endsWith(".d.cts"))z=I.replace(/\.d\.[mc]ts$/,".d.ts");else if(!I.endsWith(".d.ts")){const L=I.replace(/\.d\.[mc]ts$/,".d.ts");W&&(z=L)}const Y={...A,file:z,subKey:"types",type:void 0};he(f,S,!1,C,Y,o,!0,a)}}else for(const{input:W,output:F}of U){const J=/\.d\.[mc]?ts$/.test(F);let D=d.type;J||(F.endsWith(".mjs")?D="esm":F.endsWith(".cjs")?D="cjs":F.endsWith(".js")&&!D&&(D=o.pkg?.type==="module"?"esm":"cjs"));const A={...d,file:F,...!J&&D&&{type:D}};he(f,W,!1,C,A,o,!0,a)}continue}const b=new RegExp(M+w.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);let j=t.find(x=>b.test(x));if(j===void 0){const x=o.options.sourceDir.replace(/^\.\//,""),E=R(o.options.rootDir,x),N=Hi(d.file);if(N){const V=qi(t,N.baseName,N.pattern,E);if(V)j=V;else{const _=N.baseName,U=new RegExp(M+_.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);j=t.find(me=>U.test(me))}}else{const V=w.replace(/^(.+?)\.[^.]*$/,"$1").replace(/\/$/,"");if(ro.has(d.subKey)){const _=new RegExp(M+V.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)+$);j=t.find(U=>_.test(U))}}}if(j===void 0){ue(R(o.options.rootDir,d.file))||i.push(`Could not find entrypoint for \`${d.file}\``);continue}ue(j)&&/\.[cm]?tsx?$/.test(j)&&Dt(o);const O=a.filter(x=>x.exportKey===d.exportKey);if(O.length>0&&O.every(x=>/\.d\.[mc]?ts$/.test(x.file))){O.some(V=>V.file.endsWith(".d.ts"));const x=O.some(V=>V.file.endsWith(".d.mts")),E=O.some(V=>V.file.endsWith(".d.cts"));x&&E?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0,o.options.emitESM=!0):E?((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitCJS=!0):x&&((o.options.declaration===void 0||o.options.declaration==="node16")&&(o.options.declaration="compatible"),o.options.emitESM=!0);const N={...d,subKey:"types",type:void 0};he(f,j,v,C,N,o,!1,a)}else{const x=mn(j.replace(at,""));ue(`${x}.cts`)&&ue(`${x}.mts`)?(he(f,`${x}.cts`,v,C,{...d,type:"cjs"},o,!1,a),he(f,`${x}.mts`,v,C,{...d,type:"esm"},o,!1,a)):he(f,j,v,C,d,o,!1,a)}}return{entries:f,warnings:i}},"inferEntries");var Yi=Object.defineProperty,Xi=k((e,t)=>Yi(e,"name",{value:t,configurable:!0}),"o$6");const Qi=Xi((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 Zi=Object.defineProperty,er=k((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"f$5");const tr={hooks:{"build:prepare":er(async function(e){if(e.options.unbundle){e.options.entries.length=0;const i=T(e.options.rootDir,e.options.sourceDir);if(!ue(i))throw new Error("No 'src' directory found. Please provide entries manually.");const s=ft(i,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[$e,/.*\/dist\/.*/]}).filter(r=>ae.test(r)&&!r.endsWith(".d.ts"));for(const r of s){const a=r.replace(`${i}/`,"").replace(ae,"").replaceAll("/","/");e.options.entries.push({input:r,name:a})}return}if(e.options.entries.length>0)return;const t=T(e.options.rootDir,e.options.sourceDir);if(!ue(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ft(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[$e,/.*\/dist\/.*/]});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};if(n.publishConfig&&(e.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(n.publishConfig).join(", ")}".`),e.logger.debug(n.publishConfig),n=Qi(n,e.options.declaration)),e.options.unbundle){e.logger.info("Unbundle mode detected, creating entries for all source files");const i=o.filter(s=>ae.test(s)&&!s.endsWith(".d.ts"));e.logger.info(`Found ${i.length} code files for unbundle mode`);for(const s of i){const r=s.replace(`${t}/`,"").replace(ae,"").replaceAll("/","/");e.logger.info(`Adding entry: ${r} -> ${s}`),e.options.entries.push({input:s,name:r})}}else{const i=await Gi(n,o,e);for(const s of i.warnings)e.logger.warn(s);e.options.entries.push(...i.entries)}if(e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",K(e.options.entries.map(i=>i.fileAlias?`${X(i.fileAlias)} => ${X(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:X(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),re([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var or=Object.defineProperty,nr=k((e,t)=>or(e,"name",{value:t,configurable:!0}),"e$5");const He=nr(e=>{const t=T(e,"package.json");if(!ue(t))throw new Error(`package.json not found at ${t}`);const o=mo(t,{resolveCatalogs:!0});return o.publishConfig&&Object.assign(o,o.publishConfig),{packageJson:o,packageJsonPath:t}},"loadPackageJson");var ir=Object.defineProperty,rr=k((e,t)=>ir(e,"name",{value:t,configurable:!0}),"a$c");const sr=rr(async(e,t,o,n)=>{let i;if(n){const s=T(e,n);if(!await le(s))throw new Error(`tsconfig.json not found at ${s}`);i={config:Dn(s),path:s},o.info("Using tsconfig settings at",s)}else if(oo(t,["typescript"]))try{i=await Pn(e),o.debug("Using tsconfig settings found at",i.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}return i},"loadTsconfig");var ar=Object.defineProperty,To=k((e,t)=>ar(e,"name",{value:t,configurable:!0}),"l$b");const Pt=To(async(e,t)=>{if(typeof e.name!="string"){let o=lt(e.input)?Q(t.options.rootDir,e.input):gn(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(at,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Cn(e.input)&&(e.input=R(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(e.declaration&&e.cjs===void 0&&e.esm===void 0||(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM))),e.outDir=R(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),Ao=To(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:et(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:et(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...n}=t,i=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")i.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const r of e.options.rollup.watch.exclude)typeof r=="string"&&i.push(r)}const s=go([n.input],{cwd:e.options.rootDir,dot:!1,ignore:i,onlyFiles:!0});if(s.length===0)throw new Nn(`No files found in the glob pattern: ${K(T(e.options.rootDir,n.input))}`);for(const r of s)e.options.entries.push({...n,input:R(e.options.rootDir,r)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries){if(t.runtime)continue;const o=t.exportKey&&[...t.exportKey].some(i=>i.includes("browser")||i==="browser"),n=t.fileAlias?.includes(".browser")??!1;if(o||n)t.runtime="browser";else if(t.exportKey){for(const i of t.exportKey)if(i==="node"||i==="workerd"||i.includes("node")||i.includes("workerd")){t.runtime="node";break}}!t.runtime&&t.fileAlias&&(t.fileAlias.includes(".server")||t.fileAlias.includes(".node")||t.fileAlias.includes(".workerd"))&&(t.runtime="node")}for(const t of e.options.entries)if(t.fileAlias){let o=t.fileAlias;for(;o.startsWith("./")||o.startsWith("../");)o=o.replace(/^\.\.?\//,"");t.name=o}for(const t of e.options.entries.filter(o=>!o.fileAlias))await Pt(t,e);for(const t of e.options.entries.filter(o=>o.fileAlias))await Pt(t,e),t.fileAlias=void 0},"prepareEntries");var lr=Object.defineProperty,pr=k((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$2");const qe=pr((e,t)=>{let o={};return e.name&&(o[e.name]=t.rootDir),o={...o,...t.alias},t.rollup.alias&&t.rollup.alias.entries&&(Array.isArray(t.rollup.alias.entries)?Object.assign(o,Object.fromEntries(t.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,t.rollup.alias.entries)),o},"resolveAliases");var cr=Object.defineProperty,ur=k((e,t)=>cr(e,"name",{value:t,configurable:!0}),"h$5");const dr=/^[_$a-z\u00A0-\uFFFF][\w$\u00A0-\uFFFF]*$/iu,fr=ur(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],n=JSON.stringify({...e.options.jiti,alias:{...qe(e.pkg,e.options),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},void 0,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?`[${t.map((i,s)=>{if(Array.isArray(i)){const[r,...a]=i;return o.push(r),`[${[`plugin${s}`,...a.map(u=>JSON.stringify(u))].join(", ")}]`}return o.push(i),`plugin${s}`}).join(",")}]`:"[]");for(const i of e.options.entries){const s=R(e.options.rootDir,e.options.outDir,i.name),r=Fn(e.jiti.esmResolve(i.input,{try:!0})??i.input),a=r.replace(at,""),u=on(r),c=Tn(u);let l=[];try{l=await In(r,{extensions:st})}catch(d){P(e,`Cannot analyze ${r} for exports: ${d.toString()}`);return}const p=l.includes("default")||l.length===0,f=e.options.jiti.absoluteJitiPath?(...d)=>Wn(R(...d)):Q;if(e.options.emitESM){const d=f(pe(s),await kt("jiti",{conditions:["node","import"],url:import.meta.url})),g=se(e,"esm"),h=`${a}.${g}`;Ce(`${s}.${te(e,"esm")}`,c+[`import { createJiti } from "${d}";`,...o.map((y,m)=>`import plugin${m} from "${y}";`),"",`const jiti = createJiti(import.meta.url, ${n});`,"",`/** @type {import("${h}")} */`,`const _module = await jiti.import("${r}");`,...p?["export default _module?.default ?? _module;"]:[],...l.filter(y=>y!=="default").map((y,m)=>{if(dr.test(y))return`export const ${y} = _module.${y};`;const C=`__packem_export_${m}`,v=y.startsWith("'")&&y.endsWith("'")?`_module[${y}]`:`_module[${JSON.stringify(y)}]`;return`const ${C} = ${v};
|
|
5
5
|
export { ${C} as ${JSON.stringify(y)} };`})].join(`
|
|
6
6
|
`)),e.options.declaration&&Ce(`${s}.${g}`,`export * from "${h}";
|
|
7
|
-
${p?`export { default } from "${h}";`:""}`)}if(e.options.emitCJS){const d=f(pe(s),await kt("jiti",{conditions:["node","require"],url:import.meta.url})),g=se(e,"cjs"),h=`${a}.${g}`;Ce(`${s}.${
|
|
7
|
+
${p?`export { default } from "${h}";`:""}`)}if(e.options.emitCJS){const d=f(pe(s),await kt("jiti",{conditions:["node","require"],url:import.meta.url})),g=se(e,"cjs"),h=`${a}.${g}`;Ce(`${s}.${te(e,"cjs")}`,c+[`const { createJiti } = require("${d}");`,...o.map((y,m)=>`const plugin${m} = require(${JSON.stringify(y)})`),"",`const jiti = createJiti(__filename, ${n});`,"",`/** @type {import("${h}")} */`,`module.exports = jiti("${r}")`].join(`
|
|
8
8
|
`)),e.options.declaration&&Ce(`${s}.${g}`,`export * from "${h}";
|
|
9
|
-
${p?`export { default } from "${h}";`:""}`)}c&&(await jt(`${s}.${ee(e,"cjs")}`),await jt(`${s}.${ee(e,"esm")}`))}await e.hooks.callHook("rollup:done",e)},"createStub");var mr=Object.defineProperty,ct=k((e,t)=>mr(e,"name",{value:t,configurable:!0}),"s$7");const nt=ct(e=>{const t=e.indexOf("/");if(t===-1)return[e,void 0];if(e[0]==="@"){const o=e.indexOf("/",t+1);return o===-1?[e,void 0]:[e.slice(0,o),e.slice(o+1)]}return[e.slice(0,t),e.slice(t+1)]},"parseSpecifier"),be=ct(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||at(e))},"isBareSpecifier"),Ae=ct((e,t=process.cwd())=>te(t,e).split("/").includes("node_modules"),"isFromNodeModules");var gr=Object.defineProperty,ne=k((e,t)=>gr(e,"name",{value:t,configurable:!0}),"f$4");const Nt=ne((e,t,o)=>e.reduce((n,i,s)=>(i instanceof RegExp?n.push(i):typeof i=="string"&&i.length>0?n.push(new RegExp(`^${i.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}$`)):o.warn(`Ignoring wrong entry type #${s} in '${t}' option: ${JSON.stringify(i)}`),n),[]),"getRegExps"),Ct=new Map,hr=ne((e,t)=>{Ct.has(e)||t.info({message:`Inlined implicit external "${K(e)}". If this is incorrect, add it to the "externals" option.`,prefix:"plugin:packem:externals"}),Ct.set(e,!0)},"logExternalMessage"),Mt=new Set(["node:sqlite","node:test"]),yr=/[\\:]/,br=ne(e=>e.length>0&&!yr.test(e),"isValidPackageName"),ut="@types/",Tt=ne(e=>{if(e.startsWith("@")){const[t,o]=e.split("/");return`${t}/types/${o}`}return`${ut}${e}`},"getAtTypesPackageName"),wr=ne(e=>{if(e.startsWith("@")){const t=e.split("/");if(t[1]==="types")return`@${t[0]}/${t.slice(2).join("/")}`}return e.replace(ut,"")},"getOriginalPackageName"),vr=["peerDependencies","dependencies","optionalDependencies"],Fo=ne((e,t)=>{const o=Jn.realpathSync.native(process.cwd()),{pkg:n}=e,i=new Set;for(const w of vr){const $=n[w];if($)for(const M of Object.keys($))M.startsWith(ut)?i.add(wr(M)):i.add(M)}const s=new Set(Object.keys(n.devDependencies||{})),r=e.options?.rollup?.resolveExternals??{},a=new Set(Nt([...e.options?.externals??[]],"include",e.logger)),u=new Set(Nt([...r.exclude??[]],"exclude",e.logger));if(t?.dtsResolve)if(t.dtsResolve===!0)u.add(/.*/);else for(const w of t.dtsResolve)typeof w=="string"?u.add(new RegExp(`^${w.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}(?:/.+)?$`)):u.add(w);const c=ne(w=>{const{dtsResolve:$}=t??{};return $?typeof $=="boolean"?$:$.some(M=>typeof M=="string"?w===M:M.test(w)):!1},"shouldResolveForDts"),l={...r.deps?n.dependencies??{}:void 0,...r.devDeps?n.devDependencies??{}:void 0,...r.peerDeps?n.peerDependencies??{}:void 0,...r.optDeps?n.optionalDependencies??{}:void 0},p=Object.keys(l);if(p.length>0&&a.add(new RegExp(`^(?:${p.join("|")})(?:/.+)?$`)),n?.peerDependenciesMeta)for(const[w,$]of Object.entries(n.peerDependenciesMeta))$&&typeof $=="object"&&"optional"in $&&$.optional&&a.add(new RegExp(`^${w}(?:/.+)?$`));const f=ne(w=>[...a].some($=>$.test(w)),"isIncluded"),d=ne(w=>[...u].some($=>$.test(w)),"isExcluded");let g=[];e.tsconfig&&(g=Object.entries(e.tsconfig.config.compilerOptions?.paths??{}).map(([w])=>w.endsWith("*")?new RegExp(`^${w.replace("*","(.*)")}$`):new RegExp(`^${w}$`)));const h=Ge(n,e.options),y=e.options?.sourceDir?new RegExp(String.raw`(?:^|/)${e.options.sourceDir.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/`):void 0,m=new Set,C=new Set,v=new Map;return{name:"packem:externals",options:ne(w=>{w.external=($,M)=>{if(v.has($))return v.get($);const b=xt($),j=M?xt(M):void 0;let O;if(Object.keys(h).length>0){const N=Mn(b,h);N!==b&&(O=N)}const x=O&&be(O)&&Et(O)?.name||be(b)&&Et(b)?.name||(be(b)?dn(b):""),E=x&&be(x)&&br(x)?x:"";if(E&&!Me(E)){e.usedDependencies.add(E);const N=!j||!Ae(j,e.options.rootDir),V=Object.keys(n.dependencies??{}).includes(E)||Object.keys(n.devDependencies??{}).includes(E)||Object.keys(n.peerDependencies??{}).includes(E)||Object.keys(n.optionalDependencies??{}).includes(E);N&&!V&&e.options.validation&&e.options.validation.dependencies!==!1&&e.options.validation.dependencies.hoisted!==!1&&!e.options.validation.dependencies.hoisted?.exclude.includes(E)&&e.hoistedDependencies.add(E)}for(const N of[b,O].filter(Boolean)){const V=n.name?N===n.name||N.startsWith(`${n.name}/`):!1;if(/^(?:\0|\.{1,2}\/)/.test(N)||at(N)||(y?.test(N)??!1)||V)return v.set($,!1),!1;if(Me(N)||Mt.has(N)){let _=r.builtins;return _===void 0&&j&&(_=f(j)&&!d(j)),v.set($,_),_}if(N[0]==="#"&&!N.startsWith("#/")||g.some(_=>_.test(N))||E&&c(E))return v.set($,!1),!1;if(f(N)&&!d(N))return v.set($,!0),!0}return e.implicitDependencies.add(b),hr(b,e.logger),v.set($,!1),!1}},"options"),resolveId:{filter:{id:ne(w=>!w.startsWith("\0"),"id")},async handler(w,$,{isEntry:M}){if(M)return;if(w[0]==="#"&&!w.startsWith("#/")&&n.imports)return $&&!Ae($,e.options.rootDir)?{external:!0,id:w}:void 0;if(Mt.has(w))return{external:!0,id:w,moduleSideEffects:!1};if(Me(w)){const j=w.replace(/^node:/,"");let O=j;return(r.builtinsPrefix==="add"||!Me(j))&&(O=`node:${j}`),{external:(r.builtins||f(w))&&!d(w),id:r.builtinsPrefix==="ignore"?w:O,moduleSideEffects:!1}}if(!be(w)||w.includes("?")||w.includes(" "))return;const[b]=nt(w);if(s.has(b)&&!i.has(b)){if(f(w)&&!d(w))return;if(t?.forTypes)return t.dtsResolve&&c(b)?void 0:{external:!0,id:w,moduleSideEffects:!1};const j=await this.resolve(w,$,{skipSelf:!0});if(!j)throw new Error(`Could not resolve "${w}" even though it's declared in package.json. Try re-installing node_modules.`);if(t?.forTypes){const O=Tt(b);i.has(O)&&!m.has(O)&&(m.add(O),e.logger.warn(`Recommendation: "${O}" is externalized but "${b}" is bundled (devDependencies). This may cause type mismatches for consumers. Consider moving "${b}" to dependencies or "${O}" to devDependencies.`))}return j}if(i.has(b)){if(t?.forTypes){const j=Tt(b);s.has(j)&&!m.has(j)&&(m.add(j),e.logger.warn(`Recommendation: "${j}" is bundled (devDependencies) but "${b}" is externalized. Place "${j}" in dependencies/peerDependencies as well so users don't have missing types.`))}return}if(!s.has(b)&&$&&!Ae($,o)&&!t?.skipUnlistedWarnings&&!C.has(b)&&(C.add(b),e.logger.warn(`"${b}" imported by "${$}" but not declared in package.json. Will be bundled to prevent failure at runtime.`)),t?.forTypes&&$&&Ae($,o))return{external:!0,id:w,moduleSideEffects:!1}},order:"pre"}}},"externalsPlugin");var $r=Object.defineProperty,Ue=k((e,t)=>$r(e,"name",{value:t,configurable:!0}),"l$a");const xr=Ue(async e=>{try{const n=await lt(e);if(n.isFile())return e;if(n.isDirectory()){const i=T(e,"index.js");if(await le(i))return i;const s=T(e,"index.json");if(await le(s))return s}}catch{}const t=`${e}.js`;if(await le(t))return t;const o=`${e}.json`;if(await le(o))return o},"tryResolveImplicit"),jr=Ue(async(e,t)=>{let o=e;const n=F("/");for(;o!==n&&o!==pe(o);){const i=T(o,"node_modules",t,"package.json");if(await le(i))return i;o=pe(o)}},"findPackageJson"),Ro=Ue(e=>{const t=new Map,o=new Map,n=new Set;e.pkg.dependencies&&Object.keys(e.pkg.dependencies).forEach(s=>n.add(s)),e.pkg.peerDependencies&&Object.keys(e.pkg.peerDependencies).forEach(s=>n.add(s)),e.pkg.optionalDependencies&&Object.keys(e.pkg.optionalDependencies).forEach(s=>n.add(s));const i=Ue(s=>n.has(s),"isExternalPackage");return{name:"packem:resolve-implicit-externals",async transform(s,r){if(r.includes("/node_modules/")||r.startsWith("\0"))return;const a=/\bfrom\s+['"`]([^'"`]+)['"`]/g,u=[];let c;for(;(c=a.exec(s))!==null;){const d=c[1];if(!d||!be(d))continue;const[g,h]=nt(d);if(h&&g&&i(g)){const y=c.index+c[0].indexOf(d);u.push({importId:d,quoteEnd:y+d.length,quoteStart:y})}}if(u.length===0)return;const l=pe(r),p=(await Promise.all(u.map(async d=>{const[g,h]=nt(d.importId);if(!h)return;const y=`${g}:${h}:${l}`,m=o.get(y);if(m!==void 0)return m?{...d,resolvedId:m}:void 0;const C=await jr(l,g);if(!C){o.set(y,void 0);return}let v=t.get(C);if(v===void 0)try{v=mo(C,{resolveCatalogs:!0}),t.set(C,v)}catch{t.set(C,void 0),o.set(y,void 0);return}if(!v){o.set(y,void 0);return}if(v.exports){o.set(y,void 0);return}const w=pe(C),$=T(w,h),M=await xr($);if(!M){o.set(y,void 0);return}const b=te(w,M),j=`${g}/${b}`;return o.set(y,j),{...d,resolvedId:j}}))).filter(d=>d!==void 0);if(p.length===0)return;const f=new $i(s);for(const{quoteEnd:d,quoteStart:g,resolvedId:h}of p)f.overwrite(g,d,h),this.debug(`[resolve-implicit-externals] Rewriting ${s.slice(g,d)} -> ${h} in ${r}`);return{code:f.toString(),map:f.generateMap({hires:!0})}}}},"resolveImplicitExternalsPlugin");var kr=Object.defineProperty,G=k((e,t)=>kr(e,"name",{value:t,configurable:!0}),"p$6");const Le=G(e=>!!e?.endsWith(".d"),"isDeclarationOnlyName"),At=G((e,t)=>t?o=>{if(!Le(o.name))return`${o.name}.${e()}`}:o=>{if(!Le(o.name))return De(o,e())},"createChunkFileNames"),Ft=G((e,t)=>t?o=>{const{name:n}=o;if(!Le(n))return`${n??"[name]"}.${e(o)}`}:o=>{const{name:n}=o;if(!Le(n))return fn(o,e(o))},"createEntryFileNames"),Er=G((e,t)=>{let o=`node${ze.node.split(".")[0]}`;if(t.pkg.engines?.node){const n=So(t.pkg.engines.node);n&&(o=`node${n.major}`)}if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");if(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"),t.options.rollup.esbuild.target){const n=ht(t.options.rollup.esbuild.target);t.options.runtime==="node"?t.options.rollup.esbuild.target=[...new Set([o,...n])]:t.options.runtime==="browser"&&(t.options.rollup.esbuild.target=[...new Set([...Te(t.options.browserTargets??[]),...n])])}else t.options.rollup.esbuild.target=t.options.runtime==="node"?[o]:Te(t.options.browserTargets??[]);return t.options.minify||(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because minify is disabled")),t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1,passes:2},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}if(e==="oxc"){if(!t.options.rollup.oxc)throw new Error("No oxc options found in your configuration.");if(t.options.rollup.oxc={...t.options.rollup.oxc,cwd:t.options.rootDir,jsx:typeof t.options.rollup.oxc.jsx=="string"?t.options.rollup.oxc.jsx:t.options.rollup.oxc.jsx?{...t.options.rollup.oxc.jsx,refresh:!1}:void 0,sourcemap:t.options.sourcemap,typescript:t.tsconfig?.config?{allowDeclareFields:!0,allowNamespaces:!0,declaration:void 0,jsxPragma:t.tsconfig.config.compilerOptions?.jsxFactory,jsxPragmaFrag:t.tsconfig.config.compilerOptions?.jsxFragmentFactory,onlyRemoveTypeImports:!0,rewriteImportExtensions:!1}:void 0},t.options.rollup.oxc.target){const n=ht(t.options.rollup.oxc.target);t.options.runtime==="node"?t.options.rollup.oxc.target=[...new Set([o,...n])]:t.options.runtime==="browser"&&(t.options.rollup.oxc.target=[...new Set([...Te(t.options.browserTargets??[]),...n])])}else t.options.rollup.oxc.target=t.options.runtime==="node"?[o]:Te(t.options.browserTargets??[]);return t.options.rollup.oxc}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Io=G(e=>{if(e.options.rollup.resolve&&e.options.experimental?.oxcResolve!==!0)return zn({...e.options.rollup.resolve});if(e.options.experimental?.oxcResolve&&e.options.rollup.experimental?.resolve)return ei(e.options.rollup.experimental.resolve,e.options.rootDir,e.logger,e.tsconfig?.path)},"createNodeResolver"),Wo=G((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT"){const o=new Error(`Failed to resolve the module "${e.exporter}" imported by "${K(te(F(),e.id))}"
|
|
9
|
+
${p?`export { default } from "${h}";`:""}`)}c&&(await jt(`${s}.${te(e,"cjs")}`),await jt(`${s}.${te(e,"esm")}`))}await e.hooks.callHook("rollup:done",e)},"createStub");var mr=Object.defineProperty,Ge=k((e,t)=>mr(e,"name",{value:t,configurable:!0}),"s$7");const it=Ge(e=>{const t=e.indexOf("/");if(t===-1)return[e,void 0];if(e[0]==="@"){const o=e.indexOf("/",t+1);return o===-1?[e,void 0]:[e.slice(0,o),e.slice(o+1)]}return[e.slice(0,t),e.slice(t+1)]},"parseSpecifier"),be=Ge(e=>{const t=e[0];return!(t==="."||t==="/"||t==="#"||lt(e))},"isBareSpecifier"),Ye=Ge((e,t=process.cwd())=>Q(t,e).split("/").includes("node_modules"),"isFromNodeModules"),gr=Ge((e,t=process.cwd())=>{const o=Q(t,e);return o.startsWith("..")?!0:o.split("/").includes("node_modules")},"isOutsideProject");var hr=Object.defineProperty,ne=k((e,t)=>hr(e,"name",{value:t,configurable:!0}),"f$4");const Nt=ne((e,t,o)=>e.reduce((n,i,s)=>(i instanceof RegExp?n.push(i):typeof i=="string"&&i.length>0?n.push(new RegExp(`^${i.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}$`)):o.warn(`Ignoring wrong entry type #${s} in '${t}' option: ${JSON.stringify(i)}`),n),[]),"getRegExps"),Ct=new Map,yr=ne((e,t)=>{Ct.has(e)||t.info({message:`Inlined implicit external "${K(e)}". If this is incorrect, add it to the "externals" option.`,prefix:"plugin:packem:externals"}),Ct.set(e,!0)},"logExternalMessage"),Mt=new Set(["node:sqlite","node:test"]),br=/[\\:]/,wr=ne(e=>e.length>0&&!br.test(e),"isValidPackageName"),ut="@types/",Tt=ne(e=>{if(e.startsWith("@")){const[t,o]=e.split("/");return`${t}/types/${o}`}return`${ut}${e}`},"getAtTypesPackageName"),vr=ne(e=>{if(e.startsWith("@")){const t=e.split("/");if(t[1]==="types")return`@${t[0]}/${t.slice(2).join("/")}`}return e.replace(ut,"")},"getOriginalPackageName"),$r=["peerDependencies","dependencies","optionalDependencies"],Ro=ne((e,t)=>{const o=Jn.realpathSync.native(process.cwd()),{pkg:n}=e,i=new Set;for(const w of $r){const $=n[w];if($)for(const M of Object.keys($))M.startsWith(ut)?i.add(vr(M)):i.add(M)}const s=new Set(Object.keys(n.devDependencies||{})),r=e.options?.rollup?.resolveExternals??{},a=new Set(Nt([...e.options?.externals??[]],"include",e.logger)),u=new Set(Nt([...r.exclude??[]],"exclude",e.logger));if(t?.dtsResolve)if(t.dtsResolve===!0)u.add(/.*/);else for(const w of t.dtsResolve)typeof w=="string"?u.add(new RegExp(`^${w.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}(?:/.+)?$`)):u.add(w);const c=ne(w=>{const{dtsResolve:$}=t??{};return $?typeof $=="boolean"?$:$.some(M=>typeof M=="string"?w===M:M.test(w)):!1},"shouldResolveForDts"),l={...r.deps?n.dependencies??{}:void 0,...r.devDeps?n.devDependencies??{}:void 0,...r.peerDeps?n.peerDependencies??{}:void 0,...r.optDeps?n.optionalDependencies??{}:void 0},p=Object.keys(l);if(p.length>0&&a.add(new RegExp(`^(?:${p.join("|")})(?:/.+)?$`)),n?.peerDependenciesMeta)for(const[w,$]of Object.entries(n.peerDependenciesMeta))$&&typeof $=="object"&&"optional"in $&&$.optional&&a.add(new RegExp(`^${w}(?:/.+)?$`));const f=ne(w=>[...a].some($=>$.test(w)),"isIncluded"),d=ne(w=>[...u].some($=>$.test(w)),"isExcluded");let g=[];e.tsconfig&&(g=Object.entries(e.tsconfig.config.compilerOptions?.paths??{}).map(([w])=>w.endsWith("*")?new RegExp(`^${w.replace("*","(.*)")}$`):new RegExp(`^${w}$`)));const h=qe(n,e.options),y=e.options?.sourceDir?new RegExp(String.raw`(?:^|/)${e.options.sourceDir.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/`):void 0,m=new Set,C=new Set,v=new Map;return{name:"packem:externals",options:ne(w=>{w.external=($,M)=>{if(v.has($))return v.get($);const b=xt($),j=M?xt(M):void 0;let O;if(Object.keys(h).length>0){const N=Mn(b,h);N!==b&&(O=N)}const x=O&&be(O)&&Et(O)?.name||be(b)&&Et(b)?.name||(be(b)?dn(b):""),E=x&&be(x)&&wr(x)?x:"";if(E&&!Me(E)){e.usedDependencies.add(E);const N=!j||!Ye(j,e.options.rootDir),V=Object.keys(n.dependencies??{}).includes(E)||Object.keys(n.devDependencies??{}).includes(E)||Object.keys(n.peerDependencies??{}).includes(E)||Object.keys(n.optionalDependencies??{}).includes(E);N&&!V&&e.options.validation&&e.options.validation.dependencies!==!1&&e.options.validation.dependencies.hoisted!==!1&&!e.options.validation.dependencies.hoisted?.exclude.includes(E)&&e.hoistedDependencies.add(E)}for(const N of[b,O].filter(Boolean)){const V=n.name?N===n.name||N.startsWith(`${n.name}/`):!1;if(/^(?:\0|\.{1,2}\/)/.test(N)||lt(N)||(y?.test(N)??!1)||V)return v.set($,!1),!1;if(Me(N)||Mt.has(N)){let _=r.builtins;return _===void 0&&j&&(_=f(j)&&!d(j)),v.set($,_),_}if(N[0]==="#"&&!N.startsWith("#/")||g.some(_=>_.test(N))||E&&c(E))return v.set($,!1),!1;if(f(N)&&!d(N))return v.set($,!0),!0}return e.implicitDependencies.add(b),yr(b,e.logger),v.set($,!1),!1}},"options"),resolveId:{filter:{id:ne(w=>!w.startsWith("\0"),"id")},async handler(w,$,M){if(M.isEntry)return;if(w[0]==="#"&&!w.startsWith("#/")&&n.imports)return $&&!Ye($,e.options.rootDir)?{external:!0,id:w}:void 0;if(Mt.has(w))return{external:!0,id:w,moduleSideEffects:!1};if(Me(w)){const j=w.replace(/^node:/,"");let O=j;return(r.builtinsPrefix==="add"||!Me(j))&&(O=`node:${j}`),{external:(r.builtins||f(w))&&!d(w),id:r.builtinsPrefix==="ignore"?w:O,moduleSideEffects:!1}}if(!be(w)||w.includes("?")||w.includes(" "))return;const[b]=it(w);if(s.has(b)&&!i.has(b)){if(f(w)&&!d(w))return;if(t?.forTypes)return t.dtsResolve&&c(b)?void 0:{external:!0,id:w,moduleSideEffects:!1};const j=await this.resolve(w,$,{skipSelf:!0,...M});if(!j)throw new Error(`Could not resolve "${w}" even though it's declared in package.json. Try re-installing node_modules.`);if(t?.forTypes){const O=Tt(b);i.has(O)&&!m.has(O)&&(m.add(O),e.logger.warn(`Recommendation: "${O}" is externalized but "${b}" is bundled (devDependencies). This may cause type mismatches for consumers. Consider moving "${b}" to dependencies or "${O}" to devDependencies.`))}return j}if(i.has(b)){if(t?.forTypes){const j=Tt(b);s.has(j)&&!m.has(j)&&(m.add(j),e.logger.warn(`Recommendation: "${j}" is bundled (devDependencies) but "${b}" is externalized. Place "${j}" in dependencies/peerDependencies as well so users don't have missing types.`))}return}if(!s.has(b)&&$&&!Ye($,o)&&!t?.skipUnlistedWarnings&&!C.has(b)&&(C.add(b),e.logger.warn(`"${b}" imported by "${$}" but not declared in package.json. Will be bundled to prevent failure at runtime.`)),t?.forTypes&&$&&gr($,o))return{external:!0,id:w,moduleSideEffects:!1}},order:"pre"}}},"externalsPlugin");var xr=Object.defineProperty,_e=k((e,t)=>xr(e,"name",{value:t,configurable:!0}),"l$a");const jr=_e(async e=>{try{const n=await pt(e);if(n.isFile())return e;if(n.isDirectory()){const i=T(e,"index.js");if(await le(i))return i;const s=T(e,"index.json");if(await le(s))return s}}catch{}const t=`${e}.js`;if(await le(t))return t;const o=`${e}.json`;if(await le(o))return o},"tryResolveImplicit"),kr=_e(async(e,t)=>{let o=e;const n=R("/");for(;o!==n&&o!==pe(o);){const i=T(o,"node_modules",t,"package.json");if(await le(i))return i;o=pe(o)}},"findPackageJson"),Fo=_e(e=>{const t=new Map,o=new Map,n=new Set;e.pkg.dependencies&&Object.keys(e.pkg.dependencies).forEach(s=>n.add(s)),e.pkg.peerDependencies&&Object.keys(e.pkg.peerDependencies).forEach(s=>n.add(s)),e.pkg.optionalDependencies&&Object.keys(e.pkg.optionalDependencies).forEach(s=>n.add(s));const i=_e(s=>n.has(s),"isExternalPackage");return{name:"packem:resolve-implicit-externals",async transform(s,r){if(r.includes("/node_modules/")||r.startsWith("\0"))return;const a=/\bfrom\s+['"`]([^'"`]+)['"`]/g,u=[];let c;for(;(c=a.exec(s))!==null;){const d=c[1];if(!d||!be(d))continue;const[g,h]=it(d);if(h&&g&&i(g)){const y=c.index+c[0].indexOf(d);u.push({importId:d,quoteEnd:y+d.length,quoteStart:y})}}if(u.length===0)return;const l=pe(r),p=(await Promise.all(u.map(async d=>{const[g,h]=it(d.importId);if(!h)return;const y=`${g}:${h}:${l}`,m=o.get(y);if(m!==void 0)return m?{...d,resolvedId:m}:void 0;const C=await kr(l,g);if(!C){o.set(y,void 0);return}let v=t.get(C);if(v===void 0)try{v=mo(C,{resolveCatalogs:!0}),t.set(C,v)}catch{t.set(C,void 0),o.set(y,void 0);return}if(!v){o.set(y,void 0);return}if(v.exports){o.set(y,void 0);return}const w=pe(C),$=T(w,h),M=await jr($);if(!M){o.set(y,void 0);return}const b=Q(w,M),j=`${g}/${b}`;return o.set(y,j),{...d,resolvedId:j}}))).filter(d=>d!==void 0);if(p.length===0)return;const f=new $i(s);for(const{quoteEnd:d,quoteStart:g,resolvedId:h}of p)f.overwrite(g,d,h),this.debug(`[resolve-implicit-externals] Rewriting ${s.slice(g,d)} -> ${h} in ${r}`);return{code:f.toString(),map:f.generateMap({hires:!0})}}}},"resolveImplicitExternalsPlugin");var Er=Object.defineProperty,G=k((e,t)=>Er(e,"name",{value:t,configurable:!0}),"p$6");const Ue=G(e=>!!e?.endsWith(".d"),"isDeclarationOnlyName"),At=G((e,t)=>t?o=>{if(!Ue(o.name))return`${o.name}.${e()}`}:o=>{if(!Ue(o.name))return De(o,e())},"createChunkFileNames"),Rt=G((e,t)=>t?o=>{const{name:n}=o;if(!Ue(n))return`${n??"[name]"}.${e(o)}`}:o=>{const{name:n}=o;if(!Ue(n))return fn(o,e(o))},"createEntryFileNames"),Sr=G((e,t)=>{let o=`node${Be.node.split(".")[0]}`;if(t.pkg.engines?.node){const n=So(t.pkg.engines.node);n&&(o=`node${n.major}`)}if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");if(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"),t.options.rollup.esbuild.target){const n=ht(t.options.rollup.esbuild.target);t.options.runtime==="node"?t.options.rollup.esbuild.target=[...new Set([o,...n])]:t.options.runtime==="browser"&&(t.options.rollup.esbuild.target=[...new Set([...Te(t.options.browserTargets??[]),...n])])}else t.options.rollup.esbuild.target=t.options.runtime==="node"?[o]:Te(t.options.browserTargets??[]);return t.options.minify||(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because minify is disabled")),t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1,passes:2},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}if(e==="oxc"){if(!t.options.rollup.oxc)throw new Error("No oxc options found in your configuration.");if(t.options.rollup.oxc={...t.options.rollup.oxc,cwd:t.options.rootDir,jsx:typeof t.options.rollup.oxc.jsx=="string"?t.options.rollup.oxc.jsx:t.options.rollup.oxc.jsx?{...t.options.rollup.oxc.jsx,refresh:!1}:void 0,sourcemap:t.options.sourcemap,typescript:t.tsconfig?.config?{allowDeclareFields:!0,allowNamespaces:!0,declaration:void 0,jsxPragma:t.tsconfig.config.compilerOptions?.jsxFactory,jsxPragmaFrag:t.tsconfig.config.compilerOptions?.jsxFragmentFactory,onlyRemoveTypeImports:!0,rewriteImportExtensions:!1}:void 0},t.options.rollup.oxc.target){const n=ht(t.options.rollup.oxc.target);t.options.runtime==="node"?t.options.rollup.oxc.target=[...new Set([o,...n])]:t.options.runtime==="browser"&&(t.options.rollup.oxc.target=[...new Set([...Te(t.options.browserTargets??[]),...n])])}else t.options.rollup.oxc.target=t.options.runtime==="node"?[o]:Te(t.options.browserTargets??[]);return t.options.rollup.oxc}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),Io=G(e=>{if(e.options.rollup.resolve&&e.options.experimental?.oxcResolve!==!0)return zn({...e.options.rollup.resolve});if(e.options.experimental?.oxcResolve&&e.options.rollup.experimental?.resolve)return ei(e.options.rollup.experimental.resolve,e.options.rootDir,e.logger,e.tsconfig?.path)},"createNodeResolver"),Wo=G((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT"){const o=new Error(`Failed to resolve the module "${e.exporter}" imported by "${K(Q(R(),e.id))}"
|
|
10
10
|
Is the module installed? Note:
|
|
11
11
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
12
|
-
↳ to depend on a module via import/require, install it to "dependencies".`);throw o.id=e.id,o}return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Jo=G((e,t)=>({input:Object.fromEntries(e.options.entries.map(o=>[o.name,
|
|
13
|
-
${n.stack}`),o==="warn"&&n.plugin==="node-resolve"&&i.includes("Could not resolve import")&&(e.options.rollup.resolve&&typeof e.options.rollup.resolve=="object"?e.options.rollup.resolve.unresolvedImportBehavior??"error":"error")==="error"){const s=new Error(i);throw n.id&&(s.id=n.id),s}switch(o){case"info":{e.logger.info({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")});return}case"warn":{e.logger.warn({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")});return}case"debug":e.logger.debug({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")})}},"onLog"),onwarn(o,n){Wo(o,e)||o.code||n(o)},preserveEntrySignatures:"strict",treeshake:{moduleSideEffects:!0,preset:"smallest"},watch:e.mode==="watch"?e.options.rollup.watch:!1}),"baseRollupOptions"),Bo=G(async(e,t)=>{const o=Ge(e.pkg,e.options),n=Io(e),i=e.options.unbundle||e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output?.preserveModulesRoot??e.options.sourceDir}:{manualChunks:Kn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1},[s,r,a]=so(e.options.rollup.plugins,"build"),u=e.tsconfig?.config.compilerOptions?.esModuleInterop;let c,l;return e.options.rollup.pure&&(c=_n({...e.options.rollup.pure,functions:["Object.defineProperty","Object.assign","Object.create","Object.freeze","Object.seal","Object.setPrototypeOf","Object.getOwnPropertyDescriptor","Object.getOwnPropertyDescriptors","Object.getPrototypeOf","Object.hasOwnProperty","Object.isExtensible","Object.isFrozen","Object.isSealed","Symbol","Symbol.for","Symbol.keyFor","Symbol.iterator","Symbol.asyncIterator","Symbol.hasInstance","Symbol.isConcatSpreadable","Symbol.species","Symbol.toPrimitive","Symbol.toStringTag","Proxy","Reflect.apply","Reflect.construct","Reflect.defineProperty","Reflect.deleteProperty","Reflect.get","Reflect.getOwnPropertyDescriptor","Reflect.getPrototypeOf","Reflect.has","Reflect.isExtensible","Reflect.ownKeys","Reflect.preventExtensions","Reflect.set","Reflect.setPrototypeOf","WeakMap","WeakSet","WeakRef","Array.from","Array.of","Array.isArray","Number.isFinite","Number.isInteger","Number.isNaN","Number.isSafeInteger","Number.parseFloat","Number.parseInt","String.fromCharCode","String.fromCodePoint","String.raw","Date.now","Date.parse","Date.UTC","Math.abs","Math.acos","Math.acosh","Math.asin","Math.asinh","Math.atan","Math.atan2","Math.atanh","Math.cbrt","Math.ceil","Math.clz32","Math.cos","Math.cosh","Math.exp","Math.expm1","Math.floor","Math.fround","Math.hypot","Math.imul","Math.log","Math.log10","Math.log1p","Math.log2","Math.max","Math.min","Math.pow","Math.random","Math.round","Math.sign","Math.sin","Math.sinh","Math.sqrt","Math.tan","Math.tanh","Math.trunc","JSON.parse","JSON.stringify","require.resolve","Buffer.from","Buffer.alloc","Buffer.allocUnsafe","Buffer.isBuffer",...e.options.rollup.pure?.functions??[]],sourcemap:e.options.sourcemap}),c.transform.order="pre",l=Un({constructors:["Proxy","WeakMap","WeakSet","WeakRef",...e.options.rollup.pure?.functions?.filter(p=>typeof p=="string"&&!p.includes("."))??[]],sourcemap:e.options.sourcemap})),{...Jo(e,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:At(()=>ee(e,"cjs"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),compact:e.options.minify,dir:F(e.options.rootDir,e.options.outDir),entryFileNames:Ft(p=>ee(e,"cjs"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),esModule:u??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...i},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:At(()=>ee(e,"esm"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),compact:e.options.minify,dir:F(e.options.rootDir,e.options.outDir),entryFileNames:Ft(p=>{if(e.options.unbundle||e.options.rollup.output?.preserveModules===!0)return"js";if(p.facadeModuleId?.endsWith(".mts")){const f=p.facadeModuleId.replace(/\.mts$/,".cts");if(ho(f))return"mjs"}return!e.options.emitCJS&&e.options.emitESM&&e.pkg.main?.endsWith(".cjs")?"mjs":ee(e,"esm")},e.options.unbundle||e.options.rollup.output?.preserveModules===!0),esModule:u??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...i}].filter(Boolean),plugins:[po(),ii(),q(bo(),t),Fo(e),jo(),e.tsconfig&&q(ko(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&q(Eo(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),Ro(e),e.options.rollup.replace&&(()=>{const p={sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:e.options.rollup.replace.values?{...e.options.rollup.replace.values}:{}};return wo(p)})(),e.options.rollup.alias&&vo({customResolver:n,...e.options.rollup.alias,entries:o}),...s,n,e.options.rollup.nativeModules&&ci(e.options.rollup.nativeModules),e.options.rollup.dataUri&&oi({...e.options.rollup.dataUri}),e.options.rollup.polyfillNode&&Ln({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ai({...e.options.rollup.json}),e.options.rollup.debarrel&&ni(e.options.rollup.debarrel,e.logger),Vn(),e.options.rollup.wasm&&Hn(e.options.rollup.wasm),e.options.rollup.url&&gi(e.options.rollup.url),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&q(await yi({dts:!!e.options.declaration,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.options.browserTargets,e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,o),t),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&(e.options.declaration||e.options.rollup.css.dts)&&bi(e.options.rollup.css,e.options.rootDir),e.options.rollup.raw&&q(di(e.options.rollup.raw),t),e.options.sourcemap&&mi(e.options.rollup.sourcemap),...r,e.options.rollup.minifyHTMLLiterals&&e.options.minify&&pi({...e.options.rollup.minifyHTMLLiterals,logger:e.logger}),e.options.rollup.requireCJS&&e.options.emitESM&&q(fi({...e.options.rollup.requireCJS,cwd:e.options.rootDir},e.logger),t),e.options.rollup.babel&&q(Zn({include:e.options.rollup.babel.include??/\.(?:m|c)?(?:j|t)sx?$/,...e.options.rollup.babel,root:e.options.rootDir,sourceMaps:e.options.rollup.babel.sourceMaps??e.options.sourcemap??!1}),t),l,c,q(e.options.transformer(Er(e.options.transformerName,e)),t),e.options.rollup.preserveDirectives&&ui({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),e.options.rollup.shebang&&An(e.options.entries.filter(p=>p.executable).map(p=>p.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&$o({...e.options.rollup.cjsInterop,logger:e.logger}),e.options.rollup.dynamicVars&&qn(),e.options.rollup.dynamicVars&&Gn(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&q(Yn({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&ri(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&q(li({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),...a,e.options.rollup.metafile&&Xn(),e.options.rollup.copy&&ti(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&xo({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.analyze&&e.options.rollup.visualizer!==!1&&Qn({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),preserveEntrySignatures:"strict"}},"getRollupOptions"),Sr=G(e=>{const t=e.options.rollup.dts?.resolve;if(t===!1)return!1;if(t===!0)return!0;const o=[...Object.keys(e.pkg.optionalDependencies??{})],n=e.pkg.peerDependencies??{};if(e.pkg.peerDependenciesMeta)for(const[a,u]of Object.entries(e.pkg.peerDependenciesMeta))u&&typeof u=="object"&&"optional"in u&&u.optional&&a in n&&o.push(a);if(e.options.rollup.resolveExternals?.devDeps!==!0)for(const a of Object.keys(e.pkg.devDependencies??{}))e.usedDependencies.has(a)&&!(a in n)&&o.push(a);if(o.length===0&&!t)return!1;const i=[...o,...t??[]],s=new Set,r=[];for(const a of i)typeof a=="string"?s.has(a)||(s.add(a),r.push(a)):r.push(a);return r},"computeDtsResolve"),Or=G(async(e,t)=>{const{dts:o}=await import("@visulima/rollup-plugin-dts"),n=e.options.rollup.dts??{};return o({...n,compilerOptions:{...n.compilerOptions,incremental:void 0,inlineSources:void 0,lib:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},emitDtsOnly:!0,resolve:t,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Dr=pn(Or),zo=G(async(e,t)=>{const o=Ge(e.pkg,e.options),n=Sr(e),i=Io(e),s=typeof n=="boolean"?String(n):n.map(l=>l instanceof RegExp?l.source:l).sort().join(","),r=`dts-plugin:${process.pid}${e.tsconfig.path}:${s}`,[a,u,c]=so(e.options.rollup.plugins,"dts");return{...Jo(e,"dts"),onwarn(l,p){Wo(l,e)||l.code!=="EMPTY_BUNDLE"&&p(l)},output:[e.options.emitCJS&&{chunkFileNames:G(l=>De(l,se(e,"cjs")),"chunkFileNames"),compact:e.options.minify,dir:F(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${se(e,"cjs")}`,format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:G(l=>De(l,se(e,"esm")),"chunkFileNames"),compact:e.options.minify,dir:F(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${se(e,"esm")}`,format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:G(l=>De(l,"d.mjs"),"chunkFileNames"),compact:e.options.minify,dir:F(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[po(),q(bo(),t),q(jo(),t),Fo(e,{dtsResolve:n,forTypes:!0,skipUnlistedWarnings:!0}),{load(l){if(!/\.(?:[cm]?jsx?|[cm]?tsx?|json)$/.test(l))return""},name:"packem:ignore-files"},e.tsconfig&&q(ko(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&q(Eo(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),Ro(e),e.options.rollup.replace&&(()=>{const l={sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:e.options.rollup.replace.values?{...e.options.rollup.replace.values}:{}};return wo(l)})(),e.options.rollup.alias&&vo({customResolver:i,...e.options.rollup.alias,entries:o}),...a,i,...u,...await Dr(r)(e,n),e.options.emitCJS&&si(),e.options.cjsInterop&&e.options.emitCJS&&$o({...e.options.rollup.cjsInterop,logger:e.logger}),e.options.rollup.patchTypes&&q(hi(e.options.rollup.patchTypes,e.logger),t),Fn(),...c,e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&xo({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Pr=Object.defineProperty,xe=k((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"l$9");const Ve="rollup-watch.json",Rt=xe(({context:e,doOnSuccessCleanup:t,fileCache:o,mode:n,runBuilder:i,runOnsuccess:s,useCache:r,watcher:a})=>{const u=`watcher:${n}`;a.on("change",async(c,{event:l})=>{await t?.(),e.logger.info({message:`${K(te(".",c))} was ${l}d`,prefix:u})}),a.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:u})}),a.on("event",async c=>{switch(c.code){case"BUNDLE_END":{await c.result.close(),r&&o.set(n==="bundle"?Ve:`dts-${Ve}`,c.result.cache),e.logger.raw(`
|
|
12
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);throw o.id=e.id,o}return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Jo=G((e,t)=>({input:Object.fromEntries(e.options.entries.map(o=>[o.name,R(e.options.rootDir,o.input)])),logLevel:e.options.debug?"debug":"info",onLog:G((o,n)=>{if(t==="dts"&&n.code==="EMPTY_BUNDLE")return;let i=n.message;if(n.stack&&(i=`${i}
|
|
13
|
+
${n.stack}`),o==="warn"&&n.plugin==="node-resolve"&&i.includes("Could not resolve import")&&(e.options.rollup.resolve&&typeof e.options.rollup.resolve=="object"?e.options.rollup.resolve.unresolvedImportBehavior??"error":"error")==="error"){const s=new Error(i);throw n.id&&(s.id=n.id),s}switch(o){case"info":{e.logger.info({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")});return}case"warn":{e.logger.warn({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")});return}case"debug":e.logger.debug({message:i,prefix:t+(n.plugin?`:plugin:${n.plugin}`:"")})}},"onLog"),onwarn(o,n){Wo(o,e)||o.code||n(o)},preserveEntrySignatures:"strict",treeshake:{moduleSideEffects:!0,preset:"smallest"},watch:e.mode==="watch"?e.options.rollup.watch:!1}),"baseRollupOptions"),Bo=G(async(e,t)=>{const o=qe(e.pkg,e.options),n=Io(e),i=e.options.unbundle||e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output?.preserveModulesRoot??e.options.sourceDir}:{manualChunks:Kn(e.dependencyGraphMap,e.buildEntries),preserveModules:!1},[s,r,a]=so(e.options.rollup.plugins,"build"),u=e.tsconfig?.config.compilerOptions?.esModuleInterop;let c,l;return e.options.rollup.pure&&(c=_n({...e.options.rollup.pure,functions:["Object.defineProperty","Object.assign","Object.create","Object.freeze","Object.seal","Object.setPrototypeOf","Object.getOwnPropertyDescriptor","Object.getOwnPropertyDescriptors","Object.getPrototypeOf","Object.hasOwnProperty","Object.isExtensible","Object.isFrozen","Object.isSealed","Symbol","Symbol.for","Symbol.keyFor","Symbol.iterator","Symbol.asyncIterator","Symbol.hasInstance","Symbol.isConcatSpreadable","Symbol.species","Symbol.toPrimitive","Symbol.toStringTag","Proxy","Reflect.apply","Reflect.construct","Reflect.defineProperty","Reflect.deleteProperty","Reflect.get","Reflect.getOwnPropertyDescriptor","Reflect.getPrototypeOf","Reflect.has","Reflect.isExtensible","Reflect.ownKeys","Reflect.preventExtensions","Reflect.set","Reflect.setPrototypeOf","WeakMap","WeakSet","WeakRef","Array.from","Array.of","Array.isArray","Number.isFinite","Number.isInteger","Number.isNaN","Number.isSafeInteger","Number.parseFloat","Number.parseInt","String.fromCharCode","String.fromCodePoint","String.raw","Date.now","Date.parse","Date.UTC","Math.abs","Math.acos","Math.acosh","Math.asin","Math.asinh","Math.atan","Math.atan2","Math.atanh","Math.cbrt","Math.ceil","Math.clz32","Math.cos","Math.cosh","Math.exp","Math.expm1","Math.floor","Math.fround","Math.hypot","Math.imul","Math.log","Math.log10","Math.log1p","Math.log2","Math.max","Math.min","Math.pow","Math.random","Math.round","Math.sign","Math.sin","Math.sinh","Math.sqrt","Math.tan","Math.tanh","Math.trunc","JSON.parse","JSON.stringify","require.resolve","Buffer.from","Buffer.alloc","Buffer.allocUnsafe","Buffer.isBuffer",...e.options.rollup.pure?.functions??[]],sourcemap:e.options.sourcemap}),c.transform.order="pre",l=Un({constructors:["Proxy","WeakMap","WeakSet","WeakRef",...e.options.rollup.pure?.functions?.filter(p=>typeof p=="string"&&!p.includes("."))??[]],sourcemap:e.options.sourcemap})),{...Jo(e,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:At(()=>te(e,"cjs"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),compact:e.options.minify,dir:R(e.options.rootDir,e.options.outDir),entryFileNames:Rt(p=>te(e,"cjs"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),esModule:u??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...i},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:At(()=>te(e,"esm"),e.options.unbundle||e.options.rollup.output?.preserveModules===!0),compact:e.options.minify,dir:R(e.options.rootDir,e.options.outDir),entryFileNames:Rt(p=>{if(e.options.unbundle||e.options.rollup.output?.preserveModules===!0)return"js";if(p.facadeModuleId?.endsWith(".mts")){const f=p.facadeModuleId.replace(/\.mts$/,".cts");if(ho(f))return"mjs"}return!e.options.emitCJS&&e.options.emitESM&&e.pkg.main?.endsWith(".cjs")?"mjs":te(e,"esm")},e.options.unbundle||e.options.rollup.output?.preserveModules===!0),esModule:u??"if-default-prop",exports:"auto",extend:!0,externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...i}].filter(Boolean),plugins:[po(),ii(),q(bo(),t),Ro(e),jo(),e.tsconfig&&q(ko(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&q(Eo(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),Fo(e),e.options.rollup.replace&&(()=>{const p={sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:e.options.rollup.replace.values?{...e.options.rollup.replace.values}:{}};return wo(p)})(),e.options.rollup.alias&&vo({customResolver:n,...e.options.rollup.alias,entries:o}),...s,n,e.options.rollup.nativeModules&&ci(e.options.rollup.nativeModules),e.options.rollup.dataUri&&oi({...e.options.rollup.dataUri}),e.options.rollup.polyfillNode&&Ln({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ai({...e.options.rollup.json}),e.options.rollup.debarrel&&ni(e.options.rollup.debarrel,e.logger),Vn(),e.options.rollup.wasm&&Hn(e.options.rollup.wasm),e.options.rollup.url&&gi(e.options.rollup.url),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&q(await yi({dts:!!e.options.declaration,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.options.browserTargets,e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,o),t),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&(e.options.declaration||e.options.rollup.css.dts)&&bi(e.options.rollup.css,e.options.rootDir),e.options.rollup.raw&&q(di(e.options.rollup.raw),t),e.options.sourcemap&&mi(e.options.rollup.sourcemap),...r,e.options.rollup.minifyHTMLLiterals&&e.options.minify&&pi({...e.options.rollup.minifyHTMLLiterals,logger:e.logger}),e.options.rollup.requireCJS&&e.options.emitESM&&q(fi({...e.options.rollup.requireCJS,cwd:e.options.rootDir},e.logger),t),e.options.rollup.babel&&q(Zn({include:e.options.rollup.babel.include??/\.(?:m|c)?(?:j|t)sx?$/,...e.options.rollup.babel,root:e.options.rootDir,sourceMaps:e.options.rollup.babel.sourceMaps??e.options.sourcemap??!1}),t),l,c,q(e.options.transformer(Sr(e.options.transformerName,e)),t),e.options.rollup.preserveDirectives&&ui({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),e.options.rollup.shebang&&An(e.options.entries.filter(p=>p.executable).map(p=>p.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&$o({...e.options.rollup.cjsInterop,logger:e.logger}),e.options.rollup.dynamicVars&&qn(),e.options.rollup.dynamicVars&&Gn(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&q(Yn({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&ri(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&q(li({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),...a,e.options.rollup.metafile&&Xn(),e.options.rollup.copy&&ti(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&xo({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.analyze&&e.options.rollup.visualizer!==!1&&Qn({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),preserveEntrySignatures:"strict"}},"getRollupOptions"),Or=G(e=>{const t=e.options.rollup.dts?.resolve;if(t===!1)return!1;if(t===!0)return!0;const o=[...Object.keys(e.pkg.optionalDependencies??{})],n=e.pkg.peerDependencies??{};if(e.pkg.peerDependenciesMeta)for(const[a,u]of Object.entries(e.pkg.peerDependenciesMeta))u&&typeof u=="object"&&"optional"in u&&u.optional&&a in n&&o.push(a);if(e.options.rollup.resolveExternals?.devDeps!==!0)for(const a of Object.keys(e.pkg.devDependencies??{}))e.usedDependencies.has(a)&&!(a in n)&&o.push(a);if(o.length===0&&!t)return!1;const i=[...o,...t??[]],s=new Set,r=[];for(const a of i)typeof a=="string"?s.has(a)||(s.add(a),r.push(a)):r.push(a);return r},"computeDtsResolve"),Dr=G(async(e,t)=>{const{dts:o}=await import("@visulima/rollup-plugin-dts"),n=e.options.rollup.dts??{};return o({...n,compilerOptions:{...n.compilerOptions,incremental:void 0,inlineSources:void 0,lib:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},emitDtsOnly:!0,resolve:t,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Pr=pn(Dr),zo=G(async(e,t)=>{const o=qe(e.pkg,e.options),n=Or(e),i=Io(e),s=typeof n=="boolean"?String(n):n.map(l=>l instanceof RegExp?l.source:l).sort().join(","),r=`dts-plugin:${process.pid}${e.tsconfig.path}:${s}`,[a,u,c]=so(e.options.rollup.plugins,"dts");return{...Jo(e,"dts"),onwarn(l,p){Wo(l,e)||l.code!=="EMPTY_BUNDLE"&&l.code!=="CIRCULAR_DEPENDENCY"&&p(l)},output:[e.options.emitCJS&&{chunkFileNames:G(l=>De(l,se(e,"cjs")),"chunkFileNames"),compact:e.options.minify,dir:R(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${se(e,"cjs")}`,format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:G(l=>De(l,se(e,"esm")),"chunkFileNames"),compact:e.options.minify,dir:R(e.options.rootDir,e.options.outDir),entryFileNames:`[name].${se(e,"esm")}`,format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:G(l=>De(l,"d.mjs"),"chunkFileNames"),compact:e.options.minify,dir:R(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[po(),q(bo(),t),q(jo(),t),Ro(e,{dtsResolve:n,forTypes:!0,skipUnlistedWarnings:!0}),{load(l){if(!/\.(?:[cm]?jsx?|[cm]?tsx?|json)$/.test(l))return""},name:"packem:ignore-files"},e.tsconfig&&q(ko(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&e.options.rollup.tsconfigPaths&&q(Eo(e.options.rootDir,e.tsconfig,e.logger,e.options.rollup.tsconfigPaths),t),Fo(e),e.options.rollup.replace&&(()=>{const l={sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:e.options.rollup.replace.values?{...e.options.rollup.replace.values}:{}};return wo(l)})(),e.options.rollup.alias&&vo({customResolver:i,...e.options.rollup.alias,entries:o}),...a,i,...u,...await Pr(r)(e,n),e.options.emitCJS&&si(),e.options.cjsInterop&&e.options.emitCJS&&$o({...e.options.rollup.cjsInterop,logger:e.logger}),e.options.rollup.patchTypes&&q(hi(e.options.rollup.patchTypes,e.logger),t),Rn(),...c,e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&xo({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Nr=Object.defineProperty,xe=k((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"l$9");const Le="rollup-watch.json",Ft=xe(({context:e,doOnSuccessCleanup:t,fileCache:o,mode:n,runBuilder:i,runOnsuccess:s,useCache:r,watcher:a})=>{const u=`watcher:${n}`;a.on("change",async(c,{event:l})=>{await t?.(),e.logger.info({message:`${K(Q(".",c))} was ${l}d`,prefix:u})}),a.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:u})}),a.on("event",async c=>{switch(c.code){case"BUNDLE_END":{await c.result.close(),r&&o.set(n==="bundle"?Le:`dts-${Le}`,c.result.cache),e.logger.raw(`
|
|
14
14
|
⚡️ Build run in ${c.duration}ms
|
|
15
15
|
|
|
16
|
-
`),await i?.(!0);break}case"BUNDLE_START":{e.logger.info({message:K("build started..."),prefix:u});break}case"END":{e.logger.success({message:"Rebuild finished",prefix:u}),await s?.();break}case"ERROR":{no(c.error),e.logger.error({context:[c.error],message:`Rebuild failed: ${c.error.message}`,prefix:u});break}}})},"watchHandler"),
|
|
17
|
-
└─ ${
|
|
16
|
+
`),await i?.(!0);break}case"BUNDLE_START":{e.logger.info({message:K("build started..."),prefix:u});break}case"END":{e.logger.success({message:"Rebuild finished",prefix:u}),await s?.();break}case"ERROR":{no(c.error),e.logger.error({context:[c.error],message:`Rebuild failed: ${c.error.message}`,prefix:u});break}}})},"watchHandler"),Cr=xe((e,t)=>{const o=[];Array.isArray(t.input)?o.push(...t.input):typeof t.input=="string"?o.push(t.input):o.push(...Object.keys(t.input??{}));let n="Starting watcher for entries:";for(const i of o)n+=re(`
|
|
17
|
+
└─ ${Q(process.cwd(),i)}`);e.logger.info(n)},"logInputs"),Mr=xe((e,t)=>{e.options.rollup.watch&&typeof t.watch=="object"&&t.watch.include===void 0&&(t.watch={...t.watch,...e.options.rollup.watch},t.watch.include=[T(e.options.sourceDir,"**","*"),"package.json","packem.config.*","tsconfig.json","tsconfig.*.json"],Array.isArray(e.options.rollup.watch.include)?t.watch.include=[...t.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&t.watch.include.push(e.options.rollup.watch.include),t.watch.chokidar={cwd:e.options.rootDir,...t.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...t.watch.chokidar?.ignored??[]]})},"configureWatchOptions"),Tr=xe(async(e,t,o,n,i)=>{let s=!0;e.options.rollup.css&&(s=!1);let r=[];const a=xe(async()=>{await Promise.all(r.map(p=>p.close())),r=[]},"closeWatchers"),u=xe(async()=>{const p=await Bo(e,t);if(await e.hooks.callHook("rollup:options",e,p),Object.keys(p.input).length===0)return;s&&(p.cache=t.get(Le)),Mr(e,p);const f=vt(p);if(await e.hooks.callHook("rollup:watch",e,f),Cr(e,p),Ft({context:e,doOnSuccessCleanup:i,fileCache:t,mode:"bundle",runBuilder:o,runOnsuccess:n,useCache:s,watcher:f}),r.push(f),e.options.declaration){const d=await zo(e,t);s&&(d.cache=t.get(`dts-${Le}`)),await e.hooks.callHook("rollup:dts:options",e,d);const g=vt(d);await e.hooks.callHook("rollup:watch",e,g),Ft({context:e,fileCache:t,mode:"types",useCache:s,watcher:g}),r.push(g)}},"startWatchers");await u();const c=T(e.options.rootDir,"package.json");let l;Bn(c,()=>{clearTimeout(l),l=setTimeout(async()=>{e.logger.info("package.json changed, restarting watchers...");try{await a();const{packageJson:p}=He(e.options.rootDir);e.pkg=p,e.options.entries.length=0,e.buildEntries.length=0,await e.hooks.callHook("build:prepare",e),await Ao(e),await u()}catch(p){e.logger.error({message:`Failed to restart watchers: ${p.message}`,prefix:"watcher"})}},100)})},"watch");var Ar=Object.defineProperty,Rr=k((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"e$3");const Fr=Rr(async e=>{if(e.options.clean){const t=[];for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).toSorted()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${Q(e.options.rootDir,o)}\``),await nn(o))}},"cleanDistributionDirectories");var Ir=Object.defineProperty,Wr=k((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"o$4");const Jr=Wr(()=>xi((e,t,o)=>{if(t==="hooks"&&typeof o=="object"&&o!==null&&!Array.isArray(o)){const n=typeof e[t]=="object"&&e[t]!==null&&!Array.isArray(e[t])?e[t]:{};return e[t]={...n,...o},!0}return!1}),"createDefuWithHooksMerger");var Br=Object.defineProperty,Ae=k((e,t)=>Br(e,"name",{value:t,configurable:!0}),"t$2");const zr=ki,Kr=Ae((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=Ae(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=Ae(()=>!1,"hasSideEffects");else{const i=o.map(s=>s.includes("/")?s:`**/${s}`);n=zr(i,void 0,{resolve:e})}else n=Ae(()=>{},"hasSideEffects");return n},"getPackageSideEffect");var _r=Object.defineProperty,ke=k((e,t)=>_r(e,"name",{value:t,configurable:!0}),"t$1");function Ko(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}k(Ko,"getDefaultExportFromCjs");ke(Ko,"getDefaultExportFromCjs");function Ur(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}k(Ur,"getDefaultExportFromNamespaceIfPresent");ke(Ur,"getDefaultExportFromNamespaceIfPresent");function Lr(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}k(Lr,"getDefaultExportFromNamespaceIfNotNamed");ke(Lr,"getDefaultExportFromNamespaceIfNotNamed");function Vr(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var o=ke(k(function n(){var i=!1;try{i=this instanceof n}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)},"a"),"a");o.prototype=t.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(o,n,i.get?i:{enumerable:!0,get:ke(function(){return e[n]},"get")})}),o}k(Vr,"getAugmentedNamespace");ke(Vr,"getAugmentedNamespace");var Xe,It;function Hr(){if(It)return Xe;It=1;var e=Object.defineProperty,t=k((u,c)=>e(u,"name",{value:c,configurable:!0}),"s"),o=Ei,n=o.spawn,i=o.exec;Xe=k(function(u,c,l){if(typeof c=="function"&&l===void 0&&(l=c,c=void 0),u=parseInt(u),Number.isNaN(u)){if(l)return l(new Error("pid must be a number"));throw new Error("pid must be a number")}var p={},f={};switch(p[u]=[],f[u]=1,process.platform){case"win32":i("taskkill /pid "+u+" /T /F",l);break;case"darwin":a(u,p,f,function(d){return n("pgrep",["-P",d])},function(){s(p,c,l)});break;default:a(u,p,f,function(d){return n("ps",["-o","pid","--no-headers","--ppid",d])},function(){s(p,c,l)});break}},"treeKill");function s(u,c,l){var p={};try{Object.keys(u).forEach(function(f){u[f].forEach(function(d){p[d]||(r(d,c),p[d]=1)}),p[f]||(r(f,c),p[f]=1)})}catch(f){if(l)return l(f);throw f}if(l)return l()}k(s,"killAll"),t(s,"killAll");function r(u,c){try{process.kill(parseInt(u,10),c)}catch(l){if(l.code!=="ESRCH")throw l}}k(r,"killPid"),t(r,"killPid");function a(u,c,l,p,f){var d=p(u),g="";d.stdout.on("data",function(m){var m=m.toString("ascii");g+=m});var h=t(function(y){if(delete l[u],y!=0){Object.keys(l).length==0&&f();return}g.match(/\d+/g).forEach(function(m){m=parseInt(m,10),c[u].push(m),c[m]=[],l[m]=1,a(m,c,l,p,f)})},"onClose");d.on("close",h)}return k(a,"buildProcessTree"),t(a,"buildProcessTree"),Xe}k(Hr,"requireTreeKill");var qr=Hr();const Gr=Ko(qr);var Yr=Object.defineProperty,_o=k((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"l$7");const Xr=_o(e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,"isTaskKillCmdProcessNotFoundError"),Qr=_o(async({pid:e,signal:t})=>await new Promise((o,n)=>{if(!Number.isInteger(e)||e<=0){n(new Error("Invalid process ID"));return}Gr(e,t,i=>{if(i&&!Xr(i)){n(i);return}o()})}),"killProcess");var Zr=Object.defineProperty,es=k((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"r$2");const Wt=es((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
18
18
|
`),e.logger.warn(`Build is done with some warnings:
|
|
19
19
|
|
|
20
20
|
${Array.from(e.warnings,o=>`- ${o}`).join(`
|
|
21
|
-
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var
|
|
22
|
-
`),t.info({message:`Removing ${r.name} file cache, the cache key is not used anymore.`,prefix:"file-cache"}),s=!1}}},"removeOldCacheFolders");var
|
|
23
|
-
`))},"warnLegacyCJS");var
|
|
24
|
-
`);let o="[";for(const n of t)n&&(o+=`${n},`);return o.at(-1)===","&&(o=o.slice(0,-1)),o+="]",o},"fixYarnStdout"),
|
|
25
|
-
`),!e.pkg){e.logger.warn({message:"attw is enabled but package.json is not found",prefix:"attw"});return}await ln(e.pkg,["@arethetypeswrong/core","package-manager-detector"],"devDependencies",{logger:{warn:Pe(v=>{e.logger.warn({message:v,prefix:"attw"})},"warn")}});let{level:i="warn",pm:s="auto",profile:r="strict",...a}=o.attw===!0?{}:o.attw;const u=performance.now();e.logger.debug({message:"Running attw check",prefix:"attw"});const c=await co(T(Do(),"packem-attw-"));let l;try{l=await import("@arethetypeswrong/core")}catch{e.logger.error({message:`ATTW check requires ${
|
|
26
|
-
`);const ge="OK (JSON)",Qo=z.isWildcard?"(wildcard)":`OK ${
|
|
21
|
+
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var ts=Object.defineProperty,os=k((e,t)=>ts(e,"name",{value:t,configurable:!0}),"n$4");const ns=os(async(e,t,o)=>{if(e&&await le(T(e,"keystore.json"))){const n=await to(T(e,"keystore.json"));let i=await kn(e,{withFileTypes:!0});i=i.filter(r=>r.isDirectory());let s=o;for(const r of i)if(!n[r.name]){try{await Ve(T(e,r.name),{force:!0,recursive:!0})}catch(a){t.error({message:`Failed to remove cache directory ${r.name}: ${a instanceof Error?a.message:String(a)}`,prefix:"file-cache"});continue}s&&t.raw(`
|
|
22
|
+
`),t.info({message:`Removing ${r.name} file cache, the cache key is not used anymore.`,prefix:"file-cache"}),s=!1}}},"removeOldCacheFolders");var is=Object.defineProperty,rs=k((e,t)=>is(e,"name",{value:t,configurable:!0}),"a$7");const ss=rs(e=>{if(e.options.runtime!=="node"||e.options.emitCJS!==!0)return;const t=[],o=e.pkg.engines?.node,n=o?So(o):null;n&&t.push(n.version);const i=bt(e.options.rollup.esbuild?.target??[]);for(const r of i)if(typeof r=="string"&&r.startsWith("node")){const a=Ie(r.slice(4));a&&t.push(a.version)}const s=bt(e.options.rollup.oxc?.target??[]);for(const r of s)if(typeof r=="string"&&r.startsWith("node")){const a=Ie(r.slice(4));a&&t.push(a.version)}if(t.length===0){const r=Ie(Be.node);r&&t.push(r.version)}t.some(r=>Oo(r,">=23.0.0 || >=22.12.0"))&&e.logger.warn(["We recommend using the ESM format instead of CommonJS.","The ESM format is compatible with modern platforms and runtimes, and most new libraries are now distributed only in ESM format.","Learn more at https://nodejs.org/en/learn/modules/publishing-a-package#how-did-we-get-here"].join(`
|
|
23
|
+
`))},"warnLegacyCJS");var as=Object.defineProperty,Pe=k((e,t)=>as(e,"name",{value:t,configurable:!0}),"w");const ls=Di(Si.exec);function Uo(e){const t=new Map;return(...o)=>{const n=o.toString();if(t.has(n))return t.get(n);const i=e(...o);return t.set(n,i),i}}k(Uo,"ye");Pe(Uo,"memo");const ps={bundler:"bundler",node10:"node10","node16-cjs":"node16 (from CJS)","node16-esm":"node16 (from ESM)"},cs={"":"",1:"(CJS)",99:"(ESM)"},Jt={CJSOnlyExportsDefault:Fe,CJSResolvesToESM:Se,FallbackCondition:Se,FalseCJS:ye,FalseESM:ye,FalseExportDefault:Fe,InternalResolutionError:ye,MissingExportEquals:Fe,NamedExports:Se,NoResolution:ye,UnexpectedModuleSyntax:ye,UntypedResolution:Se},us={esmOnly:["node10","node16-cjs"],node16:["node10"],strict:[]},ds=Pe(e=>{if(e.startsWith("{"))return e;const t=/\{\s*"name"/.exec(e)?.index;if(t!=null)return e.slice(t);const o=e.indexOf("{");return o!==-1?e.slice(o):e},"fixPnpmStdout"),fs=Pe(e=>{const t=e.split(`
|
|
24
|
+
`);let o="[";for(const n of t)n&&(o+=`${n},`);return o.at(-1)===","&&(o=o.slice(0,-1)),o+="]",o},"fixYarnStdout"),ms=Pe(async(e,t)=>{if(!e.options?.validation)return;const o=e.options.validation;if(!o.attw)return;const{packageJson:n}=He(e.options.rootDir);if(e.logger.log(n),e.pkg=n,t&&e.logger.raw(`
|
|
25
|
+
`),!e.pkg){e.logger.warn({message:"attw is enabled but package.json is not found",prefix:"attw"});return}await ln(e.pkg,["@arethetypeswrong/core","package-manager-detector"],"devDependencies",{logger:{warn:Pe(v=>{e.logger.warn({message:v,prefix:"attw"})},"warn")}});let{level:i="warn",pm:s="auto",profile:r="strict",...a}=o.attw===!0?{}:o.attw;const u=performance.now();e.logger.debug({message:"Running attw check",prefix:"attw"});const c=await co(T(Do(),"packem-attw-"));let l;try{l=await import("@arethetypeswrong/core")}catch{e.logger.error({message:`ATTW check requires ${Fe`@arethetypeswrong/core`} to be installed.`,prefix:"attw"});return}let p;switch(s){case"auto":{const{detect:v}=await import("package-manager-detector/detect"),w=await v({cwd:e.options.rootDir});if(w){if(w.name==="bun")throw new Error("Bun does not support --json on the pack command");p=w.name}break}case"bun":throw new Error("Bun does not support --json on the pack command");case"pnpm":{p="pnpm";break}case"yarn":{p="yarn";break}default:p="npm"}const{allResolutionKinds:f,getResolutionOption:d,groupProblemsByKind:g}=await import("@arethetypeswrong/core/utils"),{filterProblems:h,problemAffectsEntrypoint:y,problemAffectsResolutionKind:m,problemKindInfo:C}=await import("@arethetypeswrong/core/problems");try{let v=`--pack-destination ${c}`;p==="yarn"?v=`--out "${T(c,"package.tgz")}"`:p==="bun"&&(v=` --destination "${c}"`);let w=" --ignore-scripts";p==="yarn"?w="":p==="pnpm"&&(w=" --config.ignore-scripts=true");let{stdout:$}=await ls(`${p} pack --json ${v}${w}`,{cwd:e.options.rootDir,encoding:"utf8"});$=$.trim(),p==="pnpm"?$=ds($):p==="yarn"&&($=fs($));const M=JSON.parse($);if(!M?.filename)throw new Error(`Invalid npm pack output format: ${$}`);const b=M.filename,j=await En(b),O=l.createPackageFromTarballData(new Uint8Array(j)),x=await l.checkPackage(O,a),E=us[r];if(x.types!==!1&&x.problems.length>0){const N=f.filter(D=>!E.includes(D)),V=f.filter(D=>E.includes(D)),_=[...N,...V],U=Object.keys(x.entrypoints),me=U.map(D=>`"${D==="."?x.packageName:`${x.packageName}/${D.slice(2)}`}"`),B=U.map((D,A)=>{const S=x.problems.some(I=>y(I,D,x))?"redBright":"greenBright";return X[S](me[A])}),ce=Uo((D,A)=>{const S=E.includes(A)?"(ignored) ":"",I=g(h(x.problems,x,{entrypoint:D,resolutionKind:A})),z=x.entrypoints[D].resolutions[A],{resolution:Y}=z,L=Object.keys(I);if(L.length>0)return L.map(dt=>S+Jt[dt](C[dt].shortDescription)).join(`
|
|
26
|
+
`);const ge="OK (JSON)",Qo=z.isWildcard?"(wildcard)":`OK ${cs[x.programInfo[d(A)].moduleKinds?.[Y?.fileName??""]?.detectedKind||""]}`;return S+(Y?.isJson?ge:Qo)}),Z=Ni({style:{border:Ci}});Z.setHeaders(["",..._.map(D=>ps[D])]),B.forEach((D,A)=>{const[S,I,z,Y]=_.map(L=>U.map(ge=>ce(ge,L)));Z.addRow([D,S[A]??null,I[A]??null,z[A]??null,Y[A]??null])});const W=g(x.problems),F=Object.entries(W).map(([D,A])=>{const S=C[D],I=A.some(Y=>N.some(L=>m(Y,L,x))),z=`${`${S.description}${S.details?` Use \`-f json\` to see ${S.details}.`:""}`} ${S.docsUrl}`;return`${I?"":"(ignored per resolution) "}${Jt[D](z)}`}),J=`Are the types wrong problems found:
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${Z.toString()}
|
|
29
29
|
|
|
30
|
-
${
|
|
30
|
+
${F.join(`
|
|
31
31
|
|
|
32
|
-
`)}`;if(i==="error"){e.logger.error({message:J,prefix:"attw"}),ve.exitCode=1;return}e.logger.warn({message:J,prefix:"attw"})}else e.logger.success({message:Zt(`No Are the types wrong problems found ${eo`(${Math.round(performance.now()-u).toString()}ms)`}`),prefix:"attw"})}catch(v){e.logger.error({message:`ATTW check failed: ${v.toString()}`,prefix:"attw"}),e.logger.debug({message:"Found errors, setting exit code to 1",prefix:"attw"}),ve.exitCode=1}finally{await
|
|
33
|
-
- ${K(l)}${p.length>0?en` (did you mean ${p.map(f=>`"${f}"`).join(", ")}?)`:""}`}P(e,c)}},"validatePackageEntries");var ks=Object.defineProperty,Je=k((e,t)=>ks(e,"name",{value:t,configurable:!0}),"y$3");const Es=Je((e,t)=>{const o=e.options.validation;if(o.packageJson?.exports===!1)return;const n=new Set(["default","import","module-sync","node","node-addons","require"]),i=new Set(["browser","bun","deno","development","edge-light","electron","production","react-native","react-server","types","workerd"]),s=o.packageJson?.extraConditions||[],r=new Set(s),a=new Set([...i,...r,...n]),u=Je((c,l)=>{if(c!==null){if(typeof c=="string"){if(!c.startsWith("./")){P(e,`Invalid exports path "${c}" at ${l}. Export paths must start with "./"`);return}if(c.includes("../")){P(e,`Invalid exports path "${c}" at ${l}. Export paths should not contain "../" for security reasons`);return}const p=o.packageJson?.allowedExportExtensions||[],f=[...un,...p];if(Ze(c)){try{const d=c.startsWith("./")?F(e.options.rootDir,c.slice(2)):F(e.options.rootDir,c),g=go([d],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**","**/.git/**","**/dist/**"]});if(g.length===0)return;const h=g.filter(y=>!f.some(m=>y.endsWith(m)));h.length>0&&P(e,`Export path "${c}" at ${l} matches files with invalid extensions: ${h.join(", ")}. Valid extensions are: ${f.join(", ")}`)}catch(d){P(e,`Could not validate glob pattern "${c}" at ${l}: ${d instanceof Error?d.message:"Unknown error"}`)}return}f.some(d=>c.endsWith(d))||P(e,`Export path "${c}" at ${l} should have a valid file extension (${f.join(", ")})`);return}if(Array.isArray(c)){if(c.length===0){P(e,`Empty fallback array at ${l}. Fallback arrays should contain at least one entry`);return}c.forEach((p,f)=>{u(p,`${l}[${f}]`)});return}if(typeof c=="object"&&c!==null){const p=Object.keys(c);if(p.length===0){P(e,`Empty conditions object at ${l}. Conditional exports should define at least one condition`);return}const f=p.filter(g=>!a.has(g));if(f.length>0){const g=s.length>0,h=[...n].join(", ");g?P(e,`Unknown export conditions [${f.join(", ")}] at ${l}. Consider using standard conditions (${h}) or add custom conditions to 'validation.packageJson.extraConditions' in your packem config.`):P(e,`Unknown export conditions [${f.join(", ")}] at ${l}. Consider using standard conditions (${h}) or add custom conditions using the 'extraConditions' option in your validation config.`)}const d=p.filter(g=>n.has(g));if(d.length>1){const g=["node-addons","node","import","require","module-sync","default"],h=d,y=g.filter(m=>h.includes(m));JSON.stringify(h)!==JSON.stringify(y)&&P(e,`Incorrect condition order at ${l}. Standard conditions should be ordered: ${y.join(" > ")}`)}p.includes("import")&&p.includes("require"),p.includes("development")&&p.includes("production")&&P(e,`Conflicting conditions "development" and "production" at ${l}. These conditions are mutually exclusive`),p.forEach(g=>{u(c[g],`${l}.${g}`)});return}P(e,`Invalid exports value type at ${l}. Expected string, array, object, or null`)}},"validateExportsValue");Je(c=>{if(typeof c=="string"){u(c,"exports");return}if(Array.isArray(c)){c.forEach((l,p)=>{u(l,`exports[${p}]`)});return}if(typeof c=="object"&&c!==null){const l=Object.keys(c);if(l.length===0){P(e,"Empty exports object. Define at least one export entry");return}const p=l.filter(d=>d.startsWith(".")),f=l.filter(d=>!d.startsWith("."));if(p.length>0&&f.length>0){P(e,'Mixed subpaths and conditions in exports object. Use either subpaths (keys starting with ".") or conditions, not both');return}if(p.length>0){const d=p.filter(h=>h!=="."),g=e.pkg.bin!==void 0&&d.length<=1&&d.every(h=>h==="./package.json");!l.includes(".")&&!g&&P(e,'Missing main export ".". Subpaths exports should include a main export entry'),l.forEach(h=>{h.startsWith("./")||h==="."||h.startsWith(".")&&!h.startsWith("./")&&P(e,`Invalid subpath "${h}". Subpaths should start with "./" or be exactly "."`),h.includes("*")&&(h.match(/\*/g)||[]).length>1&&P(e,`Invalid subpath pattern "${h}". Only one "*" wildcard is allowed per subpath`),u(c[h],`exports["${h}"]`)})}else u(c,"exports");return}P(e,"Invalid exports field type. Expected string, array, or object")},"validateExportsObject")(t)},"validateExports"),Ss=Je(e=>{const t=e.options.validation,{pkg:o}=e,n=ee(e,"cjs"),i=ee(e,"esm");o.name===void 0&&t.packageJson?.name!==!1&&P(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t.packageJson?.files!==!1&&Array.isArray(o.files)&&!o.files.includes("*")&&(o.files.length===0?P(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(a=>a.includes(e.options.outDir))||P(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const s=o.type==="commonjs"||o.type===void 0,r=o.type==="module";if(s?(t.packageJson?.main!==!1&&(o.main===void 0&&P(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.endsWith(`.${i}`)&&P(e,`The 'main' field in your package.json should not use a '.${i}' extension for CommonJS modules.`)),t.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&P(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&P(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.endsWith(`.${n}`)&&P(e,`The 'module' field in your package.json should not use a '.${n}' extension for ES modules.`))):r&&(o.exports===void 0&&!e.options.emitCJS?t.packageJson?.exports!==!1&&P(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t.packageJson?.main!==!1&&o.main===void 0&&P(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t.packageJson?.module!==!1&&(o.module===void 0&&P(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.endsWith(`.${n}`)&&P(e,`The 'module' field should not use a '.${n}' extension for ES modules.`),o.module&&o.main&&o.module===o.main&&P(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t.packageJson?.exports!==!1&&o.exports===void 0&&P(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports!==void 0&&Es(e,o.exports),t.packageJson?.bin!==!1){const a=s?i:n;if(n!==i){if(typeof o.bin=="string"&&o.bin.endsWith(`.${a}`))P(e,`The 'bin' field in your package.json should not use a .${a} extension for ${s?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[u,c]of Object.entries(o.bin))c&&c.endsWith(`.${a}`)&&P(e,`The 'bin.${u}' field in your package.json should not use a .${a} extension for ${s?"CommonJS":"ES modules"} binaries.`)}}if(e.options.declaration){let a=!0;o.type==="module"&&(a=!!o.main?.endsWith(`.${n}`)),o.types===void 0&&o.typings===void 0&&a&&t.packageJson?.types!==!1&&P(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&a&&t.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&P(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}t.packageJson?.sideEffects!==!1&&o.sideEffects===void 0&&P(e,"The 'sideEffects' field is missing in your package.json. Consider adding this field to your package.json.")},"validatePackageFields");var Os=Object.defineProperty,Ds=k((e,t)=>Os(e,"name",{value:t,configurable:!0}),"o");const Ps=Ds(e=>{const{packageJson:t}=qe(e.options.rootDir);e.pkg=t,gs(e),bs(e),Ss(e),js(e)},"validator");var Ns=Object.defineProperty,Cs=k((e,t)=>Ns(e,"name",{value:t,configurable:!0}),"a$3");const Ms=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Ts=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","undefined","var","void","volatile","while","with","yield"]),_t=Cs(e=>{if(!Array.isArray(e)&&e!==void 0)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ms.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(Ts.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=F(o);if(!ue(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var As=Object.defineProperty,Fs=k((e,t)=>As(e,"name",{value:t,configurable:!0}),"p$4");const Rs=Fs((e,t)=>{const o=e.options.validation,{allowFail:n=!1,limit:i,limits:s={}}=o.bundleLimit??{};for(const[r,a]of Object.entries(s)){const u=typeof a=="string"?mt(a):a;if(!Number.isFinite(u)||u<=0){e.logger.debug({message:`Invalid limit for ${r}: ${a}`,prefix:"Validation: File Size"});continue}const c=e.buildEntries.find(l=>{const p=r.replace(new RegExp(`^.?/?${e.options.outDir}/?`),"");return l.path.endsWith(p)||Ti(r)(l.path)});if(!c?.size?.bytes){e.logger.debug({message:c?`Entry file has no size information: ${r}.`:`Entry file not found: ${r}, please check your configuration.`,prefix:"Validation: File Size"});continue}if(c.size.bytes>u){const l=`File size exceeds the limit: ${T(e.options.outDir,c.path)} (${H(c.size.bytes)} / ${H(u,{decimals:2})})`;n?(t&&e.logger.raw(`
|
|
32
|
+
`)}`;if(i==="error"){e.logger.error({message:J,prefix:"attw"}),ve.exitCode=1;return}e.logger.warn({message:J,prefix:"attw"})}else e.logger.success({message:Zt(`No Are the types wrong problems found ${eo`(${Math.round(performance.now()-u).toString()}ms)`}`),prefix:"attw"})}catch(v){e.logger.error({message:`ATTW check failed: ${v.toString()}`,prefix:"attw"}),e.logger.debug({message:"Found errors, setting exit code to 1",prefix:"attw"}),ve.exitCode=1}finally{await Ve(c,{force:!0,recursive:!0}).catch(()=>{})}},"attw");var gs=Object.defineProperty,Lo=k((e,t)=>gs(e,"name",{value:t,configurable:!0}),"n$3");const Bt=Lo(e=>Array.from(e,t=>Se(t)).join(", "),"joinWarnings"),hs=Lo(e=>{if(e.hoistedDependencies.size>0){const o=`These dependencies are shamefully hoisted: ${Bt(e.hoistedDependencies)}`;P(e,o)}let t=Object.keys(e.pkg.dependencies||{}).filter(o=>!e.usedDependencies.has(o));if(e.options?.validation&&e.options?.validation?.dependencies!==!1&&e.options?.validation?.dependencies?.unused!==!1&&(t=t.filter(o=>!e.options?.validation?.dependencies?.unused?.exclude.includes(o))),t.length>0){const o=`These dependencies are listed in package.json but not used: ${Bt(t)}`;P(e,o)}},"validateDependencies");var ys=Object.defineProperty,bs=k((e,t)=>ys(e,"name",{value:t,configurable:!0}),"o$2");const zt=">=18.0.0",ws=bs(e=>{const t=e.options.validation,{pkg:o}=e;if(t.packageJson?.engines===!1)return;const n=process.version,i=o.engines?.node;if(!i){P(e,`The 'engines.node' field is missing in your package.json. Consider adding "engines": { "node": "${zt}" } to specify Node.js version requirements.`);return}if(!wi(i)){P(e,`Invalid Node.js version range "${i}" in engines.node field. Please use a valid semver range like "${zt}".`);return}if(!Oo(n,i))throw new Error(`Node.js version mismatch: Current version ${n} does not satisfy the required range "${i}" specified in package.json engines.node field.`)},"validateEngines");var vs=Object.defineProperty,Vo=k((e,t)=>vs(e,"name",{value:t,configurable:!0}),"i$1");const $s=Vo((e,t)=>Mi(e,t)<=e.length/3||t.includes(e),"isSimilar"),xs=Vo((e,t)=>{const o=e.toLowerCase();return t.filter(n=>$s(n.toLowerCase(),o))},"findAlternatives");var js=Object.defineProperty,Kt=k((e,t)=>js(e,"name",{value:t,configurable:!0}),"o$1");const ks=Kt(e=>{const{options:t}=e,o=t.validation;if(o.packageJson?.exports===!1)return;let n=[];t.dtsOnly||o.packageJson?.bin===!1?n=[""]:typeof e.pkg.bin=="string"?n=[e.pkg.bin]:typeof e.pkg.bin=="object"&&(n=Object.values(e.pkg.bin));const i=e.pkg.type==="module"?"esm":"cjs",s=new Set([t.declaration&&o.packageJson?.types?e.pkg.types:"",t.declaration&&o.packageJson?.types?e.pkg.typings:"",...n,t.dtsOnly&&o.packageJson?.main===!1?"":e.pkg.main,t.dtsOnly&&o.packageJson?.module===!1?"":e.pkg.module,...o.packageJson?.exports?ct(e.pkg.exports,i,t.declaration,[],t.ignoreExportKeys).filter(c=>!c.ignored).map(c=>t.dtsOnly?c.subKey==="types"?c.file:void 0:c.file):[]].filter(Boolean).map(c=>c&&R(t.rootDir,c.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const c of s)c&&!c.includes("*")&&!ho(c)&&r.push(c.replace(`${t.rootDir}/`,""));const a=Kt(c=>Q(t.rootDir,R(t.outDir,c)),"rPath"),u=e.buildEntries.filter(c=>!c.chunk).map(c=>a(c.path));if(r.length>0){let c="Potential missing or wrong package.json files:";for(const l of r){const p=xs(l,u);c+=`
|
|
33
|
+
- ${K(l)}${p.length>0?en` (did you mean ${p.map(f=>`"${f}"`).join(", ")}?)`:""}`}P(e,c)}},"validatePackageEntries");var Es=Object.defineProperty,We=k((e,t)=>Es(e,"name",{value:t,configurable:!0}),"y$3");const Ss=We((e,t)=>{const o=e.options.validation;if(o.packageJson?.exports===!1)return;const n=new Set(["default","import","module-sync","node","node-addons","require"]),i=new Set(["browser","bun","deno","development","edge-light","electron","production","react-native","react-server","types","workerd"]),s=o.packageJson?.extraConditions||[],r=new Set(s),a=new Set([...i,...r,...n]),u=We((c,l)=>{if(c!==null){if(typeof c=="string"){if(!c.startsWith("./")){P(e,`Invalid exports path "${c}" at ${l}. Export paths must start with "./"`);return}if(c.includes("../")){P(e,`Invalid exports path "${c}" at ${l}. Export paths should not contain "../" for security reasons`);return}const p=o.packageJson?.allowedExportExtensions||[],f=[...un,...p];if(et(c)){try{const d=c.startsWith("./")?R(e.options.rootDir,c.slice(2)):R(e.options.rootDir,c),g=go([d],{cwd:e.options.rootDir,dot:!1,ignore:["**/node_modules/**","**/.git/**","**/dist/**"]});if(g.length===0)return;const h=g.filter(y=>!f.some(m=>y.endsWith(m)));h.length>0&&P(e,`Export path "${c}" at ${l} matches files with invalid extensions: ${h.join(", ")}. Valid extensions are: ${f.join(", ")}`)}catch(d){P(e,`Could not validate glob pattern "${c}" at ${l}: ${d instanceof Error?d.message:"Unknown error"}`)}return}f.some(d=>c.endsWith(d))||P(e,`Export path "${c}" at ${l} should have a valid file extension (${f.join(", ")})`);return}if(Array.isArray(c)){if(c.length===0){P(e,`Empty fallback array at ${l}. Fallback arrays should contain at least one entry`);return}c.forEach((p,f)=>{u(p,`${l}[${f}]`)});return}if(typeof c=="object"&&c!==null){const p=Object.keys(c);if(p.length===0){P(e,`Empty conditions object at ${l}. Conditional exports should define at least one condition`);return}const f=p.filter(g=>!a.has(g));if(f.length>0){const g=s.length>0,h=[...n].join(", ");g?P(e,`Unknown export conditions [${f.join(", ")}] at ${l}. Consider using standard conditions (${h}) or add custom conditions to 'validation.packageJson.extraConditions' in your packem config.`):P(e,`Unknown export conditions [${f.join(", ")}] at ${l}. Consider using standard conditions (${h}) or add custom conditions using the 'extraConditions' option in your validation config.`)}const d=p.filter(g=>n.has(g));if(d.length>1){const g=["node-addons","node","import","require","module-sync","default"],h=d,y=g.filter(m=>h.includes(m));JSON.stringify(h)!==JSON.stringify(y)&&P(e,`Incorrect condition order at ${l}. Standard conditions should be ordered: ${y.join(" > ")}`)}p.includes("import")&&p.includes("require"),p.includes("development")&&p.includes("production")&&P(e,`Conflicting conditions "development" and "production" at ${l}. These conditions are mutually exclusive`),p.forEach(g=>{u(c[g],`${l}.${g}`)});return}P(e,`Invalid exports value type at ${l}. Expected string, array, object, or null`)}},"validateExportsValue");We(c=>{if(typeof c=="string"){u(c,"exports");return}if(Array.isArray(c)){c.forEach((l,p)=>{u(l,`exports[${p}]`)});return}if(typeof c=="object"&&c!==null){const l=Object.keys(c);if(l.length===0){P(e,"Empty exports object. Define at least one export entry");return}const p=l.filter(d=>d.startsWith(".")),f=l.filter(d=>!d.startsWith("."));if(p.length>0&&f.length>0){P(e,'Mixed subpaths and conditions in exports object. Use either subpaths (keys starting with ".") or conditions, not both');return}if(p.length>0){const d=p.filter(h=>h!=="."),g=e.pkg.bin!==void 0&&d.length<=1&&d.every(h=>h==="./package.json");!l.includes(".")&&!g&&P(e,'Missing main export ".". Subpaths exports should include a main export entry'),l.forEach(h=>{h.startsWith("./")||h==="."||h.startsWith(".")&&!h.startsWith("./")&&P(e,`Invalid subpath "${h}". Subpaths should start with "./" or be exactly "."`),h.includes("*")&&(h.match(/\*/g)||[]).length>1&&P(e,`Invalid subpath pattern "${h}". Only one "*" wildcard is allowed per subpath`),u(c[h],`exports["${h}"]`)})}else u(c,"exports");return}P(e,"Invalid exports field type. Expected string, array, or object")},"validateExportsObject")(t)},"validateExports"),Os=We(e=>{const t=e.options.validation,{pkg:o}=e,n=te(e,"cjs"),i=te(e,"esm");o.name===void 0&&t.packageJson?.name!==!1&&P(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t.packageJson?.files!==!1&&Array.isArray(o.files)&&!o.files.includes("*")&&(o.files.length===0?P(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(a=>a.includes(e.options.outDir))||P(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const s=o.type==="commonjs"||o.type===void 0,r=o.type==="module";if(s?(t.packageJson?.main!==!1&&(o.main===void 0&&P(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.endsWith(`.${i}`)&&P(e,`The 'main' field in your package.json should not use a '.${i}' extension for CommonJS modules.`)),t.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&P(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&P(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.endsWith(`.${n}`)&&P(e,`The 'module' field in your package.json should not use a '.${n}' extension for ES modules.`))):r&&(o.exports===void 0&&!e.options.emitCJS?t.packageJson?.exports!==!1&&P(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t.packageJson?.main!==!1&&o.main===void 0&&P(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t.packageJson?.module!==!1&&(o.module===void 0&&P(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.endsWith(`.${n}`)&&P(e,`The 'module' field should not use a '.${n}' extension for ES modules.`),o.module&&o.main&&o.module===o.main&&P(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t.packageJson?.exports!==!1&&o.exports===void 0&&P(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports!==void 0&&Ss(e,o.exports),t.packageJson?.bin!==!1){const a=s?i:n;if(n!==i){if(typeof o.bin=="string"&&o.bin.endsWith(`.${a}`))P(e,`The 'bin' field in your package.json should not use a .${a} extension for ${s?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[u,c]of Object.entries(o.bin))c&&c.endsWith(`.${a}`)&&P(e,`The 'bin.${u}' field in your package.json should not use a .${a} extension for ${s?"CommonJS":"ES modules"} binaries.`)}}if(e.options.declaration){let a=!0;o.type==="module"&&(a=!!o.main?.endsWith(`.${n}`)),o.types===void 0&&o.typings===void 0&&a&&t.packageJson?.types!==!1&&P(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&a&&t.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&P(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}t.packageJson?.sideEffects!==!1&&o.sideEffects===void 0&&P(e,"The 'sideEffects' field is missing in your package.json. Consider adding this field to your package.json.")},"validatePackageFields");var Ds=Object.defineProperty,Ps=k((e,t)=>Ds(e,"name",{value:t,configurable:!0}),"o");const Ns=Ps(e=>{const{packageJson:t}=He(e.options.rootDir);e.pkg=t,hs(e),ws(e),Os(e),ks(e)},"validator");var Cs=Object.defineProperty,Ms=k((e,t)=>Cs(e,"name",{value:t,configurable:!0}),"a$3");const Ts=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,As=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","undefined","var","void","volatile","while","with","yield"]),_t=Ms(e=>{if(!Array.isArray(e)&&e!==void 0)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ts.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(As.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=R(o);if(!ue(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Rs=Object.defineProperty,Fs=k((e,t)=>Rs(e,"name",{value:t,configurable:!0}),"p$4");const Is=Fs((e,t)=>{const o=e.options.validation,{allowFail:n=!1,limit:i,limits:s={}}=o.bundleLimit??{};for(const[r,a]of Object.entries(s)){const u=typeof a=="string"?mt(a):a;if(!Number.isFinite(u)||u<=0){e.logger.debug({message:`Invalid limit for ${r}: ${a}`,prefix:"Validation: File Size"});continue}const c=e.buildEntries.find(l=>{const p=r.replace(new RegExp(`^.?/?${e.options.outDir}/?`),"");return l.path.endsWith(p)||Ti(r)(l.path)});if(!c?.size?.bytes){e.logger.debug({message:c?`Entry file has no size information: ${r}.`:`Entry file not found: ${r}, please check your configuration.`,prefix:"Validation: File Size"});continue}if(c.size.bytes>u){const l=`File size exceeds the limit: ${T(e.options.outDir,c.path)} (${H(c.size.bytes)} / ${H(u,{decimals:2})})`;n?(t&&e.logger.raw(`
|
|
34
34
|
`),e.logger.warn({message:l,prefix:"validation:file-size"})):P(e,l)}}if(i){const r=e.buildEntries.reduce((u,c)=>{const l=c.size?.bytes;return u+(typeof l=="number"?l:0)},0),a=typeof i=="string"?mt(i):i;if(!Number.isFinite(a)||a<=0){e.logger.debug({message:`Invalid total limit: ${i}`,prefix:"Validation: File Size"});return}if(r>a){const u=`Total file size exceeds the limit: ${H(r)} / ${H(a,{decimals:2})}`;n?(t&&Object.keys(s).length===0&&e.logger.raw(`
|
|
35
|
-
`),e.logger.warn({message:u,prefix:"validation:file-size"})):P(e,u)}}},"validateBundleSize");var
|
|
35
|
+
`),e.logger.warn({message:u,prefix:"validation:file-size"})):P(e,u)}}},"validateBundleSize");var Ws=Object.defineProperty,rt=k((e,t)=>Ws(e,"name",{value:t,configurable:!0}),"n$2");const Js=Pi("packem:exe"),Bs=/(?:^|,)packem:exe(?:,|$)/,zs=rt(()=>{const e=process.env.NODE_DEBUG;return e?Bs.test(e):!1},"isEnabled"),Ho=rt(()=>{const e=rt(((t,...o)=>{Js(t,...o)}),"debug");return Object.defineProperty(e,"enabled",{get:zs}),e},"createDebug");var Ks=Object.defineProperty,qo=k((e,t)=>Ks(e,"name",{value:t,configurable:!0}),"c$5");const _s=qo(()=>{const e=Oi();if(je==="darwin")return T(e,"Library/Caches/packem");if(je==="win32"){const o=process.env.LOCALAPPDATA;return o?T(o,"packem/Caches"):T(e,"AppData/Local/packem/Caches")}const t=process.env.XDG_CACHE_HOME;return t?T(t,"packem"):T(e,".cache/packem")},"getCacheDirectory"),Us=qo(e=>{const t=_s(),o=e.platform==="win"?"node.exe":"node";return T(t,"node",`v${e.nodeVersion}`,`${e.platform}-${e.arch}`,o)},"getCachedBinaryPath");var Ls=Object.defineProperty,Ne=k((e,t)=>Ls(e,"name",{value:t,configurable:!0}),"s$1");const Go=Ne(e=>e==="win"?"zip":e==="linux"?"tar.xz":"tar.gz","getArchiveExtension"),Vs=Ne(e=>{const{arch:t,nodeVersion:o,platform:n}=e,i=Go(n);return`https://nodejs.org/dist/v${o}/node-v${o}-${n}-${t}.${i}`},"getDownloadUrl"),Hs=Ne(e=>{const{arch:t,nodeVersion:o,platform:n}=e,i=`node-v${o}-${n}-${t}`;return n==="win"?`${i}/node.exe`:`${i}/bin/node`},"getBinaryPathInArchive"),Ut="https://nodejs.org/dist/index.json",qs=/^v/,Gs=Ne(async e=>{let t=e;if(t==="latest"||t==="latest-lts"){const n=await fetch(Ut);if(!n.ok)throw new Error(`Failed to fetch Node.js releases: HTTP ${String(n.status)} from ${Ut}`);const i=await n.json(),s=t==="latest";let r="";for(const a of i)if(s||a.lts!==!1){r=a.version;break}if(r==="")throw new Error(`No matching Node.js release found for "${t}".`);t=r.replace(qs,"")}const o=Wi(t);if(!o)throw new Error(`Invalid Node.js version: ${t}. Please provide a valid version string (e.g., "25.7.0").`);if(!Po(o,">=25.7.0"))throw new Error(`Node.js ${o} does not support SEA (Single Executable Applications). Required minimum version is 25.7.0. Please update the nodeVersion in your target configuration.`);return o},"resolveNodeVersion"),Ys=Ne(e=>`-${e.platform}-${e.arch}`,"getTargetSuffix");var Xs=Object.defineProperty,Yo=k((e,t)=>Xs(e,"name",{value:t,configurable:!0}),"d");const fe=Ho(),Qs=Yo(async(e,t,o)=>{const n=Hs(o),i=pe(t);if(fe("Extracting %s from archive to %s",n,i),o.platform==="win")await ze("tar",["-xf",e,"-C",i,"--strip-components=1",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0});else{const a=e.endsWith(".tar.xz")?"J":"z";await ze("tar",[`-x${a}f`,e,"-C",i,"--strip-components=2",n],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}const s=o.platform==="win"?"node.exe":"node",r=T(i,s);r!==t&&await Sn(r,t)},"extractBinary"),Zs=Yo(async(e,t)=>{fe("Resolving Node.js binary for target: %O",e);const o={...e,nodeVersion:await Gs(e.nodeVersion)},n=Us(o);if(fe("Cache path: %s",n),await le(n))return fe("Cache hit: %s",n),t.info(`Using cached Node.js ${o.nodeVersion} for ${o.platform}-${o.arch}`),n;const i=Vs(o);fe("Cache miss, downloading from: %s",i),t.info(`Downloading Node.js ${o.nodeVersion} for ${o.platform}-${o.arch}...`),t.info(` ${i}`),await uo(pe(n),{recursive:!0});const s=await fetch(i);if(!s.ok)throw new Error(`Failed to download Node.js binary: HTTP ${String(s.status)} from ${i}`);const r=Go(o.platform),a=`${n}.download.${r}`,u=Ii.from(await s.arrayBuffer());fe("Downloaded %d bytes, writing to: %s",u.length,a),await fo(a,u);try{await Qs(a,n,o),o.platform!=="win"&&await On(n,493),fe("Binary cached at: %s",n),t.info(`Cached Node.js binary at: ${n}`)}finally{await Ve(a,{force:!0})}return n},"resolveNodeBinary");var ea=Object.defineProperty,Ee=k((e,t)=>ea(e,"name",{value:t,configurable:!0}),"c$3");const we=Ho(),ta=/\.d\.[mc]?ts$/,oa=Ee(e=>({buildEntries:e.buildEntries,logger:e.logger,options:e.options,packageType:e.pkg.type}),"toExeBuildInput"),na=Ee(e=>{const{logger:t,options:o}=e;if(Be.bun||Be.deno)throw new Error("The `exe` option is not supported in Bun and Deno environments.");if(!Po(process.version,">=25.7.0"))throw new Error(`Node.js ${process.version} does not support \`exe\` option. Please upgrade to Node.js 25.7.0 or later.`);if(o.entries.length>1){const n=o.entries.map(i=>`- ${i.input}`).join(`
|
|
36
36
|
`);throw new Error(`The \`exe\` feature only supports a single entry point. Found ${String(o.entries.length)} entries:
|
|
37
|
-
${n}`)}o.declaration&&t.warn("Generating .d.ts files with the `exe` option is not recommended since they won't be included in the executable. Consider separating your library and executable targets if you need type declarations."),t.info("`exe` option is experimental and may change in future releases.")},"validateSea"),
|
|
38
|
-
codesign --sign - "${p}"`:`Automatic code signing is not supported on ${je}.`;a.warn(`Failed to code-sign the executable. ${h}`)}if(await le(p)){const h=await
|
|
37
|
+
${n}`)}o.declaration&&t.warn("Generating .d.ts files with the `exe` option is not recommended since they won't be included in the executable. Consider separating your library and executable targets if you need type declarations."),t.info("`exe` option is experimental and may change in future releases.")},"validateSea"),ia=Ee((e,t)=>e.endsWith(".cjs")?"commonjs":e.endsWith(".mjs")||t==="module"?"module":"commonjs","pickMainFormat"),Lt=je==="win32"?"win":je,Vt=Ee((e,t,o,n,i)=>{let s;return e.fileName?s=typeof e.fileName=="function"?e.fileName(t):e.fileName:s=hn(o,ao(o)),i&&(s+=i),n==="win"&&(s+=".exe"),s},"resolveOutputFileName"),Ht=Ee(async(e,t,o,n,i,s,r)=>{const{logger:a,options:u,packageType:c}=e,l=R(u.rootDir,t.outDir??"build");await uo(l,{recursive:!0});const p=T(l,i);we("Building SEA executable: %s -> %s",n,p);const f=performance.now(),d=await co(T(Do(),"packem-sea-"));try{const h={disableExperimentalSEAWarning:!0,...t.seaConfig,main:n,mainFormat:ia(o.path,c),output:p};r&&(h.executable=r);const y=T(d,"sea-config.json");await fo(y,JSON.stringify(h)),we("Wrote sea-config.json: %O -> %s",h,y),we("Running: %s --build-sea %s",process.execPath,y),await ze(process.execPath,["--build-sea",y],{nodeOptions:{stdio:["ignore","ignore","inherit"]},throwOnError:!0})}finally{we.enabled?we("Preserving temp directory for debugging: %s",d):await Ve(d,{force:!0,recursive:!0})}if(s==="darwin")try{await ze("codesign",["--sign","-",p],{nodeOptions:{stdio:"inherit"},throwOnError:!0})}catch{const h=je==="darwin"?`You can sign it manually using:
|
|
38
|
+
codesign --sign - "${p}"`:`Automatic code signing is not supported on ${je}.`;a.warn(`Failed to code-sign the executable. ${h}`)}if(await le(p)){const h=await pt(p),y=H(h.size,{decimals:2});a.info(`${X(Q(u.rootDir,p))} ${eo(y)}`)}const g=Math.round(performance.now()-f);a.success(`Built executable: ${ye(Q(u.rootDir,p))} ${re(`(${String(g)}ms)`)}`)},"buildSingleExe"),ra=Ee(async e=>{const t=oa(e),{buildEntries:o,logger:n,options:i}=t,s=i.exe;if(!s)return;const r=typeof s=="object"?s:{};na(t);const a=o.filter(p=>p.type==="entry"&&!ta.test(p.path));if(a.length===0)throw new Error("The `exe` feature requires a built entry, but no entry chunks were found.");if(a.length>1){const p=a.map(f=>`- ${f.path}`).join(`
|
|
39
39
|
`);throw new Error(`The \`exe\` feature only supports single-chunk outputs. Found ${String(a.length)} chunks:
|
|
40
|
-
${p}`)}const u=a[0],c=T(i.rootDir,i.outDir,u.path);we("Building executable with SEA for chunk: %s",u.path);const{targets:l}=r;if(l!==void 0&&l.length>0){r.seaConfig?.executable&&n.warn("`seaConfig.executable` is ignored when `targets` is specified.");for(const p of l){const f=await
|
|
40
|
+
${p}`)}const u=a[0],c=T(i.rootDir,i.outDir,u.path);we("Building executable with SEA for chunk: %s",u.path);const{targets:l}=r;if(l!==void 0&&l.length>0){r.seaConfig?.executable&&n.warn("`seaConfig.executable` is ignored when `targets` is specified.");for(const p of l){const f=await Zs(p,n),d=Ys(p),g=Vt(r,u,c,p.platform,d);await Ht(t,r,u,c,g,p.platform,f)}}else{const p=Vt(r,u,c,Lt);await Ht(t,r,u,c,p,Lt)}},"buildExe");var sa=Object.defineProperty,qt=k((e,t)=>sa(e,"name",{value:t,configurable:!0}),"t");const aa=qt(async(e,t)=>{if(e.length===0)return[];const o=t<=0||!Number.isFinite(t)?1/0:t,n=Array.from({length:e.length});let i=0;const s=qt(async()=>{for(;i<e.length;){const a=i;i+=1;const u=e[a];u&&(n[a]=await u())}},"runNext"),r=Array.from({length:Math.min(o,e.length)}).fill(s());return await Promise.all(r),n},"runWithConcurrency");var la=Object.defineProperty,pa=k((e,t)=>la(e,"name",{value:t,configurable:!0}),"m");const Gt="rollup-build.json",Qe="dependencies-cache.json",ca=pa(async(e,t,o)=>{const n=await Bo(e,t);if(await e.hooks.callHook("rollup:options",e,n),Object.keys(n.input).length===0)return;const i=e.options.validation&&e.options.validation.dependencies!==!1&&!!t.get(Qe,o),s=!e.options.validation||e.options.validation.dependencies===!1||i;if(s&&(n.cache=t.get(Gt,o),i)){const a=t.get(Qe,o);a&&(a.used?.forEach(u=>e.usedDependencies.add(u)),a.hoisted?.forEach(u=>e.hoistedDependencies.add(u)))}const r=await lo(n);try{s&&t.set(Gt,r.cache,o),e.options.validation&&e.options.validation.dependencies!==!1&&t.set(Qe,{hoisted:[...e.hoistedDependencies],used:[...e.usedDependencies]},o),await e.hooks.callHook("rollup:build",e,r);const a=new Map;for(const u of n.output){const{output:c}=await r.write(u),l=c.filter(f=>f.type==="chunk"&&f.isEntry);for(const f of l)e.buildEntries.push({chunks:f.imports.filter(d=>l.find(g=>g.fileName===d)),dynamicImports:f.dynamicImports,exports:f.exports,modules:Object.entries(f.modules).map(([d,g])=>({bytes:g.renderedLength,id:d})),path:f.fileName,size:{bytes:Buffer.byteLength(f.code,"utf8")},type:"entry"});const p=c.filter(f=>f.type==="asset");for(const f of p)a.has(f.fileName)||a.set(f.fileName,{path:f.fileName,size:{bytes:Buffer.byteLength(f.source,"utf8")},type:"asset"})}e.buildEntries.push(...a.values())}finally{await r.close()}},"build");var ua=Object.defineProperty,Je=k((e,t)=>ua(e,"name",{value:t,configurable:!0}),"r");const Yt="rollup-dts.json",Xt="__packem_skip__/",Qt=Je((e,t)=>{const o=new Set;if(t.options.emitCJS&&o.add(se(t,"cjs")),t.options.emitESM&&o.add(se(t,"esm")),(t.options.declaration===!0||t.options.declaration==="compatible")&&o.add("d.ts"),e.declarationExtensions)for(const n of e.declarationExtensions)o.add(n);return o},"resolveEntryExtensions"),da=Je(async(e,t,o)=>{const n=await zo(e,t);if(await e.hooks.callHook("rollup:dts:options",e,n),Object.keys(n.input).length===0)return;n.cache=t.get(Yt,o);const i=await lo(n);try{t.set(Yt,i.cache,o),await e.hooks.callHook("rollup:dts:build",e,i),e.logger.info({message:"Building declaration files...",prefix:"dts"});const s=new Map;for(const c of e.options.entries)c.name&&s.set(c.name,c);const r=new Set;for(const c of e.options.entries)for(const l of Qt(c,e))r.add(l);const a=R(e.options.rootDir,e.options.outDir),u={generateBundle(c,l){for(const p of Object.keys(l))p.startsWith(Xt)&&delete l[p]},name:"packem:filter-skip-chunks"};for(const c of r)await i.write({chunkFileNames:Je(l=>De(l,c),"chunkFileNames"),dir:a,entryFileNames:Je(l=>{const p=l.name?.endsWith(".d")?l.name.slice(0,-2):l.name,f=p?s.get(p):void 0;return f&&!Qt(f,e).has(c)?`${Xt}[name].${c}`:`[name].${c}`},"entryFileNames"),plugins:[u]});await e.hooks.callHook("rollup:dts:done",e)}finally{await i.close()}},"buildTypes");var fa=Object.defineProperty,ma=k((e,t)=>fa(e,"name",{value:t,configurable:!0}),"a");const ga=ma(async e=>await new Promise((t,o)=>{let n=0;const i=yo(e).pipe(Ai({params:{[Ri.BROTLI_PARAM_QUALITY]:11}}));i.on("error",o),i.on("data",s=>{n+=s.length}),i.on("end",()=>{t(n)})}),"brotliSize");var ha=Object.defineProperty,ya=k((e,t)=>ha(e,"name",{value:t,configurable:!0}),"K");const ba=ya((e,t,o,n)=>n!==void 0?e.reduce((i,s)=>{const r=String(s[t]??"undefined"),a=String(s[o]??"undefined"),u=String(s[n]??"undefined");return i[r]||(i[r]={}),i[r][a]||(i[r][a]={}),i[r][a][u]||(i[r][a][u]=[]),i[r][a][u].push(s),i},{}):e.reduce((i,s)=>{const r=String(s[t]??"undefined"),a=String(s[o]??"undefined");return i[r]||(i[r]={}),i[r][a]||(i[r][a]=[]),i[r][a].push(s),i},{}),"groupByKeys");var wa=Object.defineProperty,va=k((e,t)=>wa(e,"name",{value:t,configurable:!0}),"i");const $a=va(async e=>await new Promise((t,o)=>{let n=0;const i=yo(e).pipe(Fi({level:9}));i.on("error",o),i.on("data",s=>{n+=s.length}),i.on("end",()=>{t(n)})}),"gzipSize");var xa=Object.defineProperty,ie=k((e,t)=>xa(e,"name",{value:t,configurable:!0}),"h");const ja=2,ka=ie((e,t)=>{const o=ie(r=>Q(t.options.rootDir,R(t.options.outDir,r)),"rPath");let n=!1;const i=[],s=t.buildEntries.filter(r=>r.type==="entry");if(s.length>0){e.raw(`Entries:
|
|
41
41
|
`);for(const r of s){let a=r.size?.bytes??0,u=0;for(const l of r.chunks??[]){const p=t.buildEntries.find(f=>f.path.endsWith(l))?.size?.bytes??0;a+=p,u+=p}let c=` ${X(o(r.path))} (${[`total size: ${K(H(a,{decimals:2}))}`,r.size?.brotli&&`brotli size: ${K(H(r.size.brotli,{decimals:2}))}`,r.size?.gzip&&`gzip size: ${K(H(r.size.gzip,{decimals:2}))}`,u!==0&&`chunk size: ${K(H(u,{decimals:2}))}`].filter(Boolean).join(", ")})`;if(c+=r.exports?.length?`
|
|
42
42
|
exports: ${re(r.exports.join(", "))}`:"",r.chunks?.length&&(c+=`
|
|
43
43
|
${r.chunks.map(l=>{const p=t.buildEntries.find(f=>f.path===l)??{};return re(` └─ ${o(l)}${X(p.bytes?` (${H(p?.bytes,{decimals:2})})`:"")}`)}).join(`
|
|
@@ -47,7 +47,7 @@ ${r.dynamicImports.map(l=>re(` └─ ${o(l)}`)).join(`
|
|
|
47
47
|
`)}`),r.modules&&r.modules.length>0){const l=r.modules.filter(p=>p.id.includes("node_modules")).toSorted((p,f)=>(f.bytes||0)-(p.bytes||0)).map(p=>re(` 📦 ${o(p.id)}${X(p.bytes?` (${H(p.bytes,{decimals:2})})`:"")}`)).join(`
|
|
48
48
|
`);c+=l.length>0?`
|
|
49
49
|
inlined modules:
|
|
50
|
-
${l}`:""}if(t.options.declaration){const l=
|
|
50
|
+
${l}`:""}if(t.options.declaration){const l=te(t,"cjs"),p=te(t,"esm"),f=se(t,"cjs"),d=se(t,"esm");let g=r.path.replace(/\.js$/,".d.ts"),h="commonjs";r.path.endsWith(`.${l}`)?g=r.path.replace(new RegExp(String.raw`\.${l}$`),`.${f}`):r.path.endsWith(`.${p}`)&&(h="module",g=r.path.replace(new RegExp(String.raw`\.${p}$`),`.${d}`));const y=t.buildEntries.find(m=>m.path.endsWith(g));if(y){i.push(y.path);let m;g.includes(".d.ts")||(g=g.replace(/\.d\.[m|c]ts$/,".d.ts"),m=t.buildEntries.find(C=>C.path.endsWith(g))),m&&(i.push(m.path),h==="commonjs"?c+=`
|
|
51
51
|
types:
|
|
52
52
|
${[y,m].map(C=>`${re(" └─ ")+X(o(C.path))} (total size: ${K(H(C.size?.bytes??0,{decimals:2}))})`).join(`
|
|
53
53
|
`)}`:c+=`
|
|
@@ -57,32 +57,32 @@ ${[y,m].map(C=>`${re(" └─ ")+X(o(C.path))} (total size: ${K(H(C.size?.bytes
|
|
|
57
57
|
└─ `)+X(o(a.path))} (total size: ${K(H(a.size?.bytes??0,{decimals:2}))})`;r+=`
|
|
58
58
|
|
|
59
59
|
`,e.raw(r)}return n&&e.raw("Σ Total dist size (byte size):",K(H(t.buildEntries.reduce((r,a)=>r+(a.size?.bytes??0),0),{decimals:2})),`
|
|
60
|
-
`),n},"showSizeInformation"),
|
|
60
|
+
`),n},"showSizeInformation"),Ea=/\.d\.[mc]?ts$/,Sa=ie(e=>!!e?.endsWith(".d"),"isDeclarationOnlyEntry"),Ze=ie(e=>e.filter(t=>!Ea.test(t.input)),"filterDtsEntries"),Oa=ie((e,t)=>{const o=[];return e!=="undefined"&&o.push(`${K(e)} environment`),t!=="undefined"&&o.push(`${K(t)} runtime`),o.length>0?`Preparing build for ${o.join(" with ")}`:""},"createBuildLogMessage"),Da=ie((e,t)=>{const o={};return e!=="undefined"&&(o[["process","env","NODE_ENV"].join(".")]=JSON.stringify(e)),o[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(t==="edge-light"),Object.freeze(o)},"createReplaceValues"),Pa=ie((e,t)=>{const o=[];return e!=="undefined"&&o.push(e),t!=="undefined"&&o.push(t),o.length>0?`${o.join("/")}/`:""},"createSubDirectory"),Re=ie((e,t,o,n,i,s)=>({...e,options:{...e.options,emitCJS:t,emitESM:o,entries:n,minify:i,rollup:{...e.options.rollup,replace:e.options.rollup.replace?{...e.options.rollup.replace,values:e.options.rollup.replace.values?{...e.options.rollup.replace.values}:{...s}}:!1}}}),"createAdjustedContext"),Na=ie(async(e,t)=>{const o=ie(a=>{const u=a.name??a.fileAlias;if(!u)return"default";const c=[".browser",".server",".development",".node",".workerd"];for(const l of c)if(u.includes(l))return l.slice(1);return"default"},"getEntryType"),n=e.options.entries.map(a=>({...a,environment:String(a.environment??"undefined"),runtime:String(a.runtime??"undefined"),type:o(a)})),i=ba(n,"environment","runtime","type"),s=new Set,r=new Set;for(const[a,u]of Object.entries(i))for(const[c,l]of Object.entries(u))for(const[,p]of Object.entries(l)){const f={...e,environment:a==="undefined"?void 0:a,options:{...e.options,rollup:{...e.options.rollup,replace:e.options.rollup.replace?{...e.options.rollup.replace,values:{}}:e.options.rollup.replace}}};if(!e.options.dtsOnly&&(a!=="undefined"||c!=="undefined")){const b=Oa(a,c);b&&e.logger.info(b)}const d=c==="undefined"?void 0:c;f.options.runtime=d;try{await e.hooks.callHook("rollup:options",f,{})}catch(b){throw e.logger.error(`Error calling rollup:options hook: ${b}`),b}const g=f.options.rollup.replace?Da(a,c):{};if(f.options.rollup.replace){f.options.rollup.replace.values===void 0&&(f.options.rollup.replace.values={});const b=e.options.rollup.replace?{...e.options.rollup.replace.values}:{};Object.assign(f.options.rollup.replace.values,g,b)}else e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const h=f.options.rollup.replace&&f.options.rollup.replace.values||g,y=Pa(a,c);let m=f.options.minify??!1;a==="development"?m=!1:a==="production"&&(m=!0);const C=p.map(b=>{const{environment:j,runtime:O,...x}=b;return{...x,environment:j==="undefined"?void 0:j,runtime:O==="undefined"?void 0:O}}),v=[],w=[],$=[],M=[];for(const b of C){if(Sa(b.name)){b.declaration&&M.push(b);continue}b.cjs&&b.esm?v.push(b):b.cjs?$.push(b):b.esm?w.push(b):b.declaration&&M.push(b)}if(v.length>0){const b=Re(f,!0,!0,Ze(v),m,h);if(e.options.dtsOnly||s.add({context:b,fileCache:t,subDirectory:y}),e.options.declaration){const j=v.filter(O=>O.declaration);j.length>0&&r.add({context:{...b,options:{...b.options,entries:j}},fileCache:t,subDirectory:y})}}if(w.length>0){const b=Re(f,!1,!0,Ze(w),m,h);if(e.options.dtsOnly||s.add({context:b,fileCache:t,subDirectory:y}),e.options.declaration){const j=w.filter(O=>O.declaration);j.length>0&&r.add({context:{...b,options:{...b.options,entries:j}},fileCache:t,subDirectory:y})}}if($.length>0){const b=Re(f,!0,!1,Ze($),m,h);if(e.options.dtsOnly||s.add({context:b,fileCache:t,subDirectory:y}),e.options.declaration){const j=$.filter(O=>O.declaration);j.length>0&&r.add({context:{...b,options:{...b.options,entries:j}},fileCache:t,subDirectory:y})}}if(f.options.declaration&&M.length>0){const b=M.some(E=>E.declarationCjs),j=M.some(E=>E.declarationEsm),O=M.some(E=>E.declaration&&!E.declarationCjs&&!E.declarationEsm),x=Re(f,b||O,j,M,m,h);r.add({context:x,fileCache:t,subDirectory:y})}}return{builders:s,typeBuilders:r}},"prepareRollupConfig"),Ca=ie(async(e,t)=>{await e.hooks.callHook("build:before",e);const{builders:o,typeBuilders:n}=await Na(e,t);o.size>0&&await Promise.all(Array.from(o,async({context:i,fileCache:s,subDirectory:r})=>await ca(i,s,r))),n.size>0&&await aa(Array.from(n,({context:i,fileCache:s,subDirectory:r})=>()=>da(i,s,r)),ja),e.logger.success(Zt(e.options.name?`Build succeeded for ${e.options.name}`:"Build succeeded")),e.buildEntries=e.buildEntries.filter((i,s,r)=>r.findIndex(a=>a.path===i.path)===s);for await(const i of rn(T(e.options.rootDir,e.options.outDir),{includeDirs:!1,includeFiles:!0})){const s=T(e.options.rootDir,e.options.outDir);let r=e.buildEntries.find(u=>T(s,u.path)===i.path);r||(r={chunk:!0,path:i.path},e.buildEntries.push(r)),r.size===void 0&&(r.size={});const a=R(s,i.path);if(!r.size.bytes){const u=await pt(a);r.size.bytes=u.size}r.size.brotli||(r.size.brotli=await ga(a)),r.size.gzip||(r.size.gzip=await $a(a))}return e.options.exe&&await ra(e),await e.hooks.callHook("build:done",e),ka(e.logger,e)},"build");var Ma=Object.defineProperty,Xo=k((e,t)=>Ma(e,"name",{value:t,configurable:!0}),"c");const Ta=Xo(e=>Object.fromEntries(Object.entries(e).map(([t,o])=>{if(!o)return[t,{}];const n=Object.fromEntries(Object.entries(o).map(([i,s])=>Array.isArray(s)?[i,[...new Set(s)]]:[i,[]]));return[t,n]})),"uniqueNestedValues"),Aa=Xo(async(e,t,o,n,i,s)=>{if(s!=="*"&&vi(Ie(s))===void 0)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:packem:node10-compatibility"});const r={};for(const c of t)for(const l of c.exportKey)l.includes("/*")?r[l]=[`./${T(o,pe(c.name),"*.d.ts")}`]:r[l]=[...r[l]??[],`./${T(o,`${c.name}.d.ts`)}`];const a=T(n,"package.json"),u=await to(a);i==="file"&&Object.keys(r).length>0?(await sn(a,{...u,typesVersions:Ta({...u.typesVersions,[s]:r})},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:packem:node10-compatibility"})):Object.keys(r).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
|
|
61
61
|
|
|
62
62
|
${JSON.stringify({typesVersions:{"*":r}},void 0,4)}
|
|
63
|
-
`,prefix:"plugin:packem:node10-compatibility"})},"node10Compatibility");var
|
|
63
|
+
`,prefix:"plugin:packem:node10-compatibility"})},"node10Compatibility");var Ra=Object.defineProperty,ee=k((e,t)=>Ra(e,"name",{value:t,configurable:!0}),"l");const Fa=ee(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"),Ia=ee((e,t,o,n,i,s,r,a)=>{const u=Fa(r?.config.compilerOptions?.jsx),c=a.split("."),l=Jr()(tr,i,{alias:{},browserTargets:yn(),cjsInterop:!1,clean:!0,debug:n,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:n,interopDefault:!0},minify:o===Oe,name:(s.name??"").split("/").pop()??"default",outDir:r?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!0},css:{autoModules:!0,extensions:[".css",".pcss",".postcss",".sss"],namedExports:!0},dataUri:{srcset:!0},debarrel:{},dts:{compilerOptions:{baseUrl:r?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99}},dynamicVars:{errorWhenNoFilesFound:!0,exclude:$e,include:ae},esbuild:{charset:"utf8",supported:{"import-attributes":!0},jsx:u,jsxDev:r?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:r?.config.compilerOptions?.jsxFactory,jsxFragment:r?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:r?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:r?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:r?.config},experimental:{resolve:{aliasFields:[["browser"]],builtinModules:!1,conditionNames:["default","types","import","require","module-sync","node","node-addons","browser","esm2020","es2020","es2015"],extensionAlias:{".cjs":[".cts",".d.cts",".cjs"],".js":[".ts",".tsx",".d.ts",".js"],".jsx":[".tsx",".d.ts",".jsx"],".mjs":[".mts",".d.mts",".mjs"]},extensions:[".ts",".tsx",".d.ts",".js",".jsx",".json",".node"],mainFields:["types","typings","fesm2020","fesm2015","esm2020","es2020","main","module","browser","jsnext:main"]}},json:{preferConst:!1},license:{dependenciesTemplate:ee((g,h,y)=>`
|
|
64
64
|
# Licenses of bundled dependencies
|
|
65
65
|
The published ${y} artifact additionally contains code with the following licenses:
|
|
66
66
|
${g.length>0?`${g.join(", ")}
|
|
67
67
|
|
|
68
68
|
`:`
|
|
69
69
|
`}# Bundled dependencies:
|
|
70
|
-
${h}`,"dependenciesTemplate"),dtsTemplate:
|
|
70
|
+
${h}`,"dependenciesTemplate"),dtsTemplate:ee((g,h,y)=>`
|
|
71
71
|
# Licenses of bundled types
|
|
72
72
|
The published ${y} artifact additionally contains code with the following licenses:
|
|
73
73
|
${g.length>0?`${g.join(", ")}
|
|
74
74
|
|
|
75
75
|
`:`
|
|
76
76
|
`}# Bundled types:
|
|
77
|
-
${h}`,"dtsTemplate")},nativeModules:{},node10Compatibility:!1,output:{importAttributesKey:Number(c[0])>=22?"with":"assert"},oxc:{jsx:u==="preserve"?"preserve":{development:o!=="production",pragma:r?.config.compilerOptions?.jsxFactory,pragmaFrag:r?.config.compilerOptions?.jsxFragmentFactory,pure:!0,runtime:u==="transform"||u==="automatic"?"automatic":"classic",useBuiltIns:!0,useSpread:!0}},patchTypes:{},polyfillNode:{},preserveDirectives:{include:ae},preserveDynamicImports:!0,pure:{},raw:{exclude:$e,include:[/\.(md|txt|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:[o??"production","module-sync"],extensions:
|
|
77
|
+
${h}`,"dtsTemplate")},nativeModules:{},node10Compatibility:!1,output:{importAttributesKey:Number(c[0])>=22?"with":"assert"},oxc:{jsx:u==="preserve"?"preserve":{development:o!=="production",pragma:r?.config.compilerOptions?.jsxFactory,pragmaFrag:r?.config.compilerOptions?.jsxFragmentFactory,pure:!0,runtime:u==="transform"||u==="automatic"?"automatic":"classic",useBuiltIns:!0,useSpread:!0}},patchTypes:{},polyfillNode:{},preserveDirectives:{include:ae},preserveDynamicImports:!0,pure:{},raw:{exclude:$e,include:[/\.(md|txt|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:[o??"production","module-sync"],extensions:st,preferBuiltins:!1},resolveExternals:{builtins:!0,builtinsPrefix:"add",deps:!0,devDeps:!1,exclude:[],optDeps:!0,peerDeps:!0},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:$e,include:ae},sourcemap:{},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:r?.config.compilerOptions?.esModuleInterop===!1,include:ae,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===Oe,...r?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(r.config.compilerOptions.jsx)?{jsxFragmentPragma:r.config.compilerOptions.jsxFragmentFactory,jsxImportSource:r.config.compilerOptions.jsxImportSource,jsxPragma:r.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...r.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...r?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:ae,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!0,keepClassNames:!0,loose:!0,parser:{decorators:r?.config.compilerOptions?.experimentalDecorators,syntax:r?"typescript":"ecmascript",[r?"tsx":"jsx"]:!0},target:r?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:r?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:r?.config.compilerOptions?.experimentalDecorators,react:{development:o!==Oe,pragma:r?.config.compilerOptions?.jsxFactory,pragmaFrag:r?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:r?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:r?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Kr(t,s),preset:"recommended",propertyReadSideEffects:!0},tsconfigPaths:{resolveAbsolutePath:!1},url:{emitFiles:!0,fileName:"[hash][extname]",include:["**/*.svg","**/*.png","**/*.jp(e)?g","**/*.gif","**/*.webp"],limit:14*1024},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:$e}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,format:"inline",githubPages:!1,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:s.name??"unknown",pretty:!0,readme:"none",showConfig:n,tsconfig:r?.path},validation:{dependencies:{hoisted:{exclude:[]},unused:{exclude:[]}},packageJson:{bin:!0,dependencies:!0,exports:!0,files:!0,main:!0,module:!0,name:!0,types:!0,typesVersions:!0}}});l.runtime===void 0&&(e.warn("No runtime specified, defaulting to 'node'. This will change in packem v2 to 'browser', please add 'runtime: node' to your packem config or command call"),l.runtime="node");const p=new Map([...Object.entries(s.dependencies??{}),...Object.entries(s.devDependencies??{})]);if(l.transformer?.NAME===void 0)throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");l.transformerName=l.transformer.NAME;let f=l.transformerName;l.transformerName==="oxc"?f="oxc-transform":l.transformerName==="swc"&&(f="@swc/core");const d=p.get(f)??"0.0.0";if(e.info({message:`Using ${K("node ")}${a}`,prefix:"system"}),e.info({message:`Using ${K("rollup ")}${vn} with ${K(l.runtime)} build runtime`,prefix:"bundler"}),e.info({message:`Using ${K(l.transformerName)} ${d}`,prefix:"transformer"}),l.rollup.resolve&&(l.rollup.resolve.preferBuiltins=l.runtime==="node",l.rollup.resolve.preferBuiltins&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true"))),l.runtime==="node"&&(l.browserTargets=[]),l.runtime==="browser"&&(l.rollup.resolve&&l.rollup.resolve.browser===void 0&&(l.rollup.resolve.browser=!0),l.browserTargets&&l.browserTargets.length>0&&e.debug(`Using browser targets: ${l.browserTargets.join(", ")}`)),_t(l.alias),l.rollup.alias&&l.rollup.alias.entries&&_t(l.rollup.alias.entries),l.outputExtensionMap){let g;for(const[h,y]of Object.entries(l.outputExtensionMap)){if(!["cjs","esm"].includes(h))throw new Error(`Invalid output extension map: ${h} must be "cjs" or "esm"`);if(typeof y!="string")throw new TypeError(`Invalid output extension map: ${h} must be a string`);if(y.startsWith("."))throw new Error(`Invalid output extension map: ${h} must not start with a dot. Example: "cjs": "c.js", "esm": "m.js"`);if(g===void 0)g=y;else if(g===y)throw new Error(`Invalid output extension map: ${h} must be different from the other key`)}}return r?.config.compilerOptions?.declarationMap===!0&&(l.sourcemap=!0,e.info("Enabling sourcemap because declarationMap is enabled in tsconfig.json")),l},"generateOptions"),Wa=ee(async(e,t,o,n,i,s,r,a,u)=>{const c=s.hooks,l=Ia(e,t,n,i,s,r,a,u);an(T(l.rootDir,l.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hoistedDependencies:new Set,hooks:bn(),implicitDependencies:new Set,jiti:wn(l.rootDir,l.jiti),logger:e,mode:o,options:l,pkg:r,tsconfig:a,usedDependencies:new Set,warnings:new Set};if(c){const d=p.hooks._hooks?.get?.("rollup:options"),g=d?d.size:0;fetch("http://127.0.0.1:7242/ingest/e5ffe05e-4121-4b48-a3e5-edf81dc8035e",{body:JSON.stringify({data:{hasRollupOptionsHook:!!c?.["rollup:options"],hooksCountBefore:g,hooksKeys:Object.keys(c||{})},hypothesisId:"B",location:"index.ts:677",message:"Before addHooks",runId:"run1",sessionId:"debug-session",timestamp:Date.now()}),headers:{"Content-Type":"application/json"},method:"POST"}).catch(()=>{}),p.hooks.addHooks(c);const h=p.hooks._hooks?.get?.("rollup:options"),y=h?h.size:0;fetch("http://127.0.0.1:7242/ingest/e5ffe05e-4121-4b48-a3e5-edf81dc8035e",{body:JSON.stringify({data:{hooksAdded:y-g,hooksCountAfter:y,hooksCountBefore:g},hypothesisId:"B",location:"index.ts:683",message:"After addHooks",runId:"run1",sessionId:"debug-session",timestamp:Date.now()}),headers:{"Content-Type":"application/json"},method:"POST"}).catch(()=>{})}await p.hooks.callHook("build:prepare",p),p.options.emitESM===void 0&&p.logger.info("Emitting of ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting of CJS bundles, is disabled."),p.options.minify&&p.logger.info("Minification is enabled, the output will be minified"),p.options.json&&p.options.minify&&p.options.json.preferConst===void 0&&(p.options.json={...p.options.json,preferConst:!1}),ss(p);const f=oo(r,["typescript"]);if(p.options.declaration&&p.tsconfig===void 0&&f)throw new Error("Cannot build declaration files without a tsconfig.json");return f?p.options.declaration===!1&&p.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(p.options.declaration=!1,p.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),p.options.declaration&&p.logger.info(`Using typescript version: ${K(r.devDependencies?.typescript??r.dependencies?.typescript??"unknown")}`),p.options.declaration&&(r.dependencies?.typescript||r.devDependencies?.typescript)&&!p.tsconfig?.config.compilerOptions?.isolatedModules&&p.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
78
78
|
Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
|
|
79
|
-
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.`),await Ao(p),p},"createContext"),
|
|
80
|
-
${X("Entries:")}`});const C=
|
|
81
|
-
`),await m.hooks.callHook("builder:before",j,m);const x=Date.now(),E=
|
|
79
|
+
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.`),await Ao(p),p},"createContext"),Ja=ee(e=>{switch(e){case"build":return"Building";case"jit":return"Stubbing";case"watch":return"Watching";default:throw new Error(`Unknown mode: ${e}`)}},"getMode"),Ql=ee(async(e,t,o,n,i,s,r)=>{const a=ve.version.slice(1);n.wrapAll(),e=R(ve.cwd(),e),n.debug("Root directory:",e);const{packageJson:u,packageJsonPath:c}=He(e);n.debug("Using package.json found at",c);const l=await sr(e,u,n,r),p=tn("@visulima/packem",{cwd:e});let f=!1,d,g;const h=wt(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,nodeVersion:a,type:u.type,types:u.types}))+wt(JSON.stringify(s));p&&ji(h,p,n);const y=new cn(e,p,h,n);try{const m=await Wa(n,e,t,o,i,s,u,l,a);y.isEnabled=m.options.fileCache,m.logger.info(K(`${Ja(t)} ${m.options.name}`)),m.logger.debug({context:m.options.entries,message:`${X("Root dir:")} ${m.options.rootDir}
|
|
80
|
+
${X("Entries:")}`});const C=ee(async b=>{for await(const[j,O]of Object.entries(m.options.builder??{})){m.logger.raw(`
|
|
81
|
+
`),await m.hooks.callHook("builder:before",j,m);const x=Date.now(),E=ee(()=>gt(Math.floor(Date.now()-x)),"getBuilderDuration");await O(m,p,y,f),await m.hooks.callHook("builder:done",j,m),m.logger.raw(`
|
|
82
82
|
⚡️ ${j} run in ${E()}`),b&&m.logger.raw(`
|
|
83
83
|
|
|
84
|
-
`)}},"runBuilder"),v=
|
|
85
|
-
`);let b="console",j="*";m.options.node10Compatibility&&(b=m.options.node10Compatibility?.writeToPackageJson?"file":"console",j=m.options.node10Compatibility?.typeScriptVersion??"*"),await
|
|
84
|
+
`)}},"runBuilder"),v=ee(async()=>{if(d!==void 0)await Qr({pid:d.pid,signal:s.killSignal??"SIGTERM"});else if(g!==void 0)try{typeof g=="function"&&await g()}catch(b){throw new Error(`onSuccess function cleanup failed: ${b.message}`,{cause:b})}d=void 0,g=void 0},"doOnSuccessCleanup"),w=ee(async()=>{if(typeof m.options.onSuccess=="function")try{g=await m.options.onSuccess()}catch(b){throw new Error(`onSuccess function failed: ${b.message}`,{cause:b})}else if(typeof m.options.onSuccess=="string"){const b=m.options.onSuccessTimeout??3e4,j=d=xn(m.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:b}});await j;const{exitCode:O}=j;if(typeof O=="number"&&O!==0)throw new Error(`onSuccess script failed with exit code ${O}. Check the output above for details.`)}},"runOnsuccess"),$=Date.now(),M=ee(()=>gt(Math.floor(Date.now()-$)),"getDuration");if(t==="watch"){if(m.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem config.");await Tr(m,y,C,w,v),Wt(m,!1);return}if(await Fr(m),t==="jit")await fr(m),await m.hooks.callHook("build:done",m);else{if(f=await Ca(m,y),m.options.emitCJS&&m.options.declaration==="compatible"){f&&m.logger.raw(`
|
|
85
|
+
`);let b="console",j="*";m.options.node10Compatibility&&(b=m.options.node10Compatibility?.writeToPackageJson?"file":"console",j=m.options.node10Compatibility?.typeScriptVersion??"*"),await Aa(m.logger,m.options.entries,m.options.outDir,m.options.rootDir,b,j)}await m.hooks.callHook("validate:before",m),typeof m.options.validation=="object"&&(m.options.validation.packageJson&&Ns(m),m.options.validation.attw&&await ms(m,f),m.options.validation.bundleLimit&&Is(m,f)),await m.hooks.callHook("validate:done",m),Wt(m,f)}m.logger.raw(`
|
|
86
86
|
⚡️ Build run in ${M()}
|
|
87
87
|
`),await C(),await w(),ve.on("SIGINT",async()=>{await v()}),ve.on("SIGTERM",async()=>{await v()})}catch(m){throw n.raw(`
|
|
88
|
-
`),$n(m),no(m),m}finally{n.restoreAll(),await
|
|
88
|
+
`),$n(m),no(m),m}finally{n.restoreAll(),await ns(p,n,f)}},"packem");export{tr as $,Ql as S,Jr as c};
|
|
@@ -2,7 +2,7 @@ import { CheckPackageOptions } from '@arethetypeswrong/core';
|
|
|
2
2
|
import { PackemRollupOptions, TransformerFn, TransformerName } from '@visulima/packem-rollup';
|
|
3
3
|
import { InternalOXCTransformPluginConfig } from '@visulima/packem-rollup/oxc';
|
|
4
4
|
import { NativeModulesOptions } from '@visulima/packem-rollup/plugin/native-modules';
|
|
5
|
-
import {
|
|
5
|
+
import { Environment, Runtime, BuildContext, Format, BuildHooks, Mode } from '@visulima/packem-share/types';
|
|
6
6
|
import { FileCache } from '@visulima/packem-share/utils';
|
|
7
7
|
import { StyleOptions } from '@visulima/rollup-plugin-css';
|
|
8
8
|
import { JitiOptions } from 'jiti';
|
|
@@ -437,4 +437,4 @@ type ValidationOptions = {
|
|
|
437
437
|
typesVersions?: boolean;
|
|
438
438
|
};
|
|
439
439
|
};
|
|
440
|
-
export { BuildConfig as B, InternalBuildOptions as I, RollupBuildOptions as R,
|
|
440
|
+
export { BuildConfig as B, InternalBuildOptions as I, RollupBuildOptions as R, BuildEntry as a, BuildOptions as b, BuildConfigFunction as c, BuildPreset as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/packem",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.74",
|
|
4
4
|
"description": "A fast and modern bundler for Node.js and TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -179,12 +179,12 @@
|
|
|
179
179
|
"@visulima/fs": "5.0.0-alpha.12",
|
|
180
180
|
"@visulima/humanizer": "3.0.0-alpha.11",
|
|
181
181
|
"@visulima/package": "5.0.0-alpha.11",
|
|
182
|
-
"@visulima/packem-rollup": "1.0.0-alpha.
|
|
183
|
-
"@visulima/packem-share": "1.0.0-alpha.
|
|
182
|
+
"@visulima/packem-rollup": "1.0.0-alpha.61",
|
|
183
|
+
"@visulima/packem-share": "1.0.0-alpha.42",
|
|
184
184
|
"@visulima/pail": "4.0.0-alpha.11",
|
|
185
185
|
"@visulima/path": "3.0.0-alpha.10",
|
|
186
|
-
"@visulima/rollup-plugin-css": "1.0.0-alpha.
|
|
187
|
-
"@visulima/rollup-plugin-dts": "1.0.0-alpha.
|
|
186
|
+
"@visulima/rollup-plugin-css": "1.0.0-alpha.41",
|
|
187
|
+
"@visulima/rollup-plugin-dts": "1.0.0-alpha.22",
|
|
188
188
|
"@visulima/tabular": "4.0.0-alpha.11",
|
|
189
189
|
"@visulima/tsconfig": "3.0.0-alpha.11",
|
|
190
190
|
"browserslist": "4.28.2",
|