@visulima/packem 2.0.0-alpha.97 → 2.0.0-alpha.99

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.
@@ -1,5 +1,5 @@
1
1
  import { BuildContext } from '@visulima/packem-share/types';
2
- import { I as InternalBuildOptions } from "../../packem_shared/types.d-CA4tXIce.js";
2
+ import { I as InternalBuildOptions } from "../../packem_shared/types.d-BRQSr_g5.js";
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/packem-plugins';
5
5
  import '@visulima/packem-plugins/oxc';
@@ -11,5 +11,6 @@ import '@visulima/rollup-plugin-css';
11
11
  import 'jiti';
12
12
  import 'rollup';
13
13
  import 'typedoc';
14
+ import '@visulima/pail';
14
15
  declare const builder: (context: BuildContext<InternalBuildOptions>, cachePath: string | undefined, _: never, logged: boolean) => Promise<void>;
15
16
  export { builder as default };
@@ -1,3 +1,3 @@
1
- import{f as w,q as k}from"../../packem_shared/create-or-update-key-storage-DbvoG0IR.js";import{v as h,m,T as $}from"../../packem_shared/index-KXVG6Tyr.js";import{readdirSync as E}from"node:fs";import{replaceContentWithinMarker as j}from"@visulima/packem-share";import{Application as A}from"typedoc";const v=(e,o,t,r,n)=>{const s=E(e,{withFileTypes:!0}).filter(a=>a.isFile());let i="";for(const a of s)a.name==="README.md"&&o>1||(i+=h(m(e,a.name)).replaceAll(`<!-- ${t}`,`<!-- _REPLACE_${t}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${t}`));if(i==="")return;const c=h(r),p=j(c,t,`
1
+ import{f as w,q as k}from"../../packem_shared/create-or-update-key-storage-D8_VJrpX.js";import{v as h,m,T as $}from"../../packem_shared/index-KXVG6Tyr.js";import{readdirSync as E}from"node:fs";import{replaceContentWithinMarker as j}from"@visulima/packem-share";import{Application as A}from"typedoc";const v=(e,o,t,r,n)=>{const s=E(e,{withFileTypes:!0}).filter(a=>a.isFile());let i="";for(const a of s)a.name==="README.md"&&o>1||(i+=h(m(e,a.name)).replaceAll(`<!-- ${t}`,`<!-- _REPLACE_${t}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${t}`));if(i==="")return;const c=h(r),p=j(c,t,`
2
2
  ${i}`);if(!p){n.error({message:`Could not find the typedoc marker: <!-- ${t} --><!-- /${t} --> in ${r}`,prefix:"typedoc"});return}c!==p&&$(r,p.replaceAll(`<!-- _REPLACE_${t}`,`<!-- ${t}`).replaceAll(`<!-- _REPLACE_\\${t}`,"<!-- ${marker}"),{overwrite:!0})},P=(e,o,t,r)=>{if(e==="inline"&&t===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(e!=="inline"&&typeof t=="string"&&r.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),e==="json"&&!o?.endsWith(".json"))throw new Error(o===void 0?"The `jsonFileName` option is required when using the `json` format.":"The `jsonFileName` option must end with `.json`.");e!=="json"&&typeof o=="string"&&r.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"})},C=async(e,o,t,r)=>{if(o.length===0)return;const{format:n,jsonFileName:s,marker:i,output:c,plugin:p,readmePath:a,...f}=e;P(n,s,a,r);const y=o.map(g=>g.input),u=p??[];u.push("typedoc-plugin-rename-defaults"),(n==="inline"||n==="markdown")&&u.push("typedoc-plugin-markdown");const l=await A.bootstrapWithPlugins({...f,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...f.compilerOptions},entryPoints:y,hideGenerator:!0,out:t,plugin:u,...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(n==="json")await l.generateJson(d,s);else if(n==="html")await l.generateDocs(d,t);else if(await l.generateOutputs(d),n==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");v(t,o.length,i,a,r)}}},T=e=>e.logger,L=async(e,o,t,r)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){const n=T(e);let s="unknown";e.pkg.dependencies?.typedoc?s=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(s=e.pkg.devDependencies.typedoc),o&&w("typedoc",o,n),r&&n.raw(`
3
3
  `),n.info({message:`Using ${k("typedoc")} ${s} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let i=e.options.rootDir;e.options.typedoc.output?i=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?i=m(o,"typedoc"):e.options.typedoc.format!=="json"&&(i=m(i,"api-docs")),await C(e.options.typedoc,e.options.entries,i,n),await e.hooks.callHook("typedoc:done",e)}};export{L as default};
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{d as A,m as ee,f as te,g as se,h as ae,j as ie,T as ne,l as R,v as re,n as oe,i as ce}from"../packem_shared/index-CkgyzW1Y.js";import k,{cwd as N,exit as le}from"node:process";import{installPackage as h}from"@antfu/install-pkg";import{spinner as D,confirm as f,cancel as B,select as g,multiselect as q,intro as G,log as E,outro as K,isCancel as z}from"@clack/prompts";import{B as O,z as de,q as ue,m as b,f as M,T as pe,O as me}from"../packem_shared/index-KXVG6Tyr.js";import{y as U}from"../packem_shared/oxcTransformPlugin-B5ATuMoi-DwCO2qaH.js";import fe from"magic-string";import{exec as ge}from"tinyexec";import{PRODUCTION_ENV as W,DEVELOPMENT_ENV as ye}from"@visulima/packem-share/constants";import{createJiti as we}from"jiti";import{writeFile as F,readFile as be}from"node:fs/promises";import{q as he}from"../packem_shared/create-or-update-key-storage-DbvoG0IR.js";import{existsSync as V}from"node:fs";import{parseEnv as J}from"node:util";import{createInterface as ve}from"node:readline/promises";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{SimpleReporter as ee}from"@visulima/pail/reporter/simple";import{a as A,m as te,b as se,c as ae,d as ie,B as ne,T as re,f as R,v as oe,n as ce}from"../packem_shared/index-CVQ-yDKD.js";import k,{cwd as N,exit as le}from"node:process";import{installPackage as h}from"@antfu/install-pkg";import{spinner as D,confirm as f,cancel as B,select as g,multiselect as q,intro as G,log as E,outro as K,isCancel as z}from"@clack/prompts";import{B as O,z as de,q as ue,m as b,f as M,T as pe,O as me}from"../packem_shared/index-KXVG6Tyr.js";import{y as U}from"../packem_shared/oxcTransformPlugin-B5ATuMoi-DwCO2qaH.js";import fe from"magic-string";import{exec as ge}from"tinyexec";import{PRODUCTION_ENV as W,DEVELOPMENT_ENV as ye}from"@visulima/packem-share/constants";import{createJiti as we}from"jiti";import{writeFile as F,readFile as be}from"node:fs/promises";import{q as he}from"../packem_shared/create-or-update-key-storage-D8_VJrpX.js";import{existsSync as V}from"node:fs";import{parseEnv as J}from"node:util";import{createInterface as ve}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
4
  const _={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"]},ke=/defineConfig\s*\(\s*\{/,$e=/preset:\s*['"][^'"]+['"]/,Se=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],je=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],Pe=["solid-js"],Ee=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],De=["preact"],Oe=["unplugin-vue"],Le=["vue"],Ie=["rollup-plugin-svelte"],Me=["svelte"],$=(t,e,a)=>t.includes(`preset: '${e}'`)||t.includes(`preset: "${e}"`)||t.includes(`preset: '${e}',`)||t.includes(`preset: "${e}",`)||t.includes(a)||t.includes(`@visulima/packem/config/preset/${e}`),S=(t,e)=>{const{logger:a,magic:s,packemConfig:i}=t,n=ke.exec(i);if(n?.index!==void 0){const r=n.index+n[0].length;if(i.includes("preset:")){const o=$e.exec(i);if(o)s.replace(o[0],`preset: '${e}'`);else throw a.warn(`A preset already exists in the config. Please manually set it to '${e}'.`),new Error("Preset exists but is not a string")}else s.appendLeft(r,`
5
5
  preset: '${e}',`)}else if(i.includes("transformer:"))s.replace("transformer:",`preset: '${e}',
@@ -49,10 +49,10 @@ export default defineConfig({
49
49
  declaration: true,
50
50
  transformer,
51
51
  });
52
- `},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"fast, native DTS",label:"rolldown",value:"rolldown"}]});if(z(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},He=async()=>{const t=await g({initialValue:"esbuild",message:"Which transformer do you want to use?",options:[{hint:"fast, widely used",label:"esbuild",value:"esbuild"},{hint:"fastest, Rust-based",label:"oxc",value:"oxc"},{hint:"TypeScript-aware, Rust-based",label:"swc",value:"swc"},{hint:"minimal, JS-based",label:"sucrase",value:"sucrase"}]});if(z(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},Xe=async(t,e)=>{if(t.length===0)return;const a=D();a.start(`Installing ${t.join(", ")}`);try{await h(t,{cwd:e,dev:!0,silent:!0}),a.stop(`Installed ${t.join(", ")}`)}catch(s){throw a.stop(`Failed to install ${t.join(", ")}`),s}},Ye=async t=>{if(await ee(t))return;if(!(process.stdout.isTTY&&!process.env.CI)){const n=await te(["rollup","esbuild"],t);throw new Error(`No packem.config found. Run packem in an interactive terminal to generate one, or install the defaults manually:
52
+ `},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"fast, native DTS",label:"rolldown",value:"rolldown"}]});if(z(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},He=async()=>{const t=await g({initialValue:"esbuild",message:"Which transformer do you want to use?",options:[{hint:"fast, widely used",label:"esbuild",value:"esbuild"},{hint:"fastest, Rust-based",label:"oxc",value:"oxc"},{hint:"TypeScript-aware, Rust-based",label:"swc",value:"swc"},{hint:"minimal, JS-based",label:"sucrase",value:"sucrase"}]});if(z(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},Xe=async(t,e)=>{if(t.length===0)return;const a=D();a.start(`Installing ${t.join(", ")}`);try{await h(t,{cwd:e,dev:!0,silent:!0}),a.stop(`Installed ${t.join(", ")}`)}catch(s){throw a.stop(`Failed to install ${t.join(", ")}`),s}},Ye=async t=>{if(await te(t))return;if(!(process.stdout.isTTY&&!process.env.CI)){const n=await se(["rollup","esbuild"],t);throw new Error(`No packem.config found. Run packem in an interactive terminal to generate one, or install the defaults manually:
53
53
  ${n}
54
- and create a packem.config.ts.`)}G(he("Packem first-run setup")),E.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];a&&s.push(se[a]),await Xe(s,t);const i=b(t,"packem.config.ts");await F(i,Je(e,a),"utf8"),E.success(`Created ${i}`),K("Setup complete — continuing with build.")},Qe=/^([^#:=]+)=(.*)$/,T=(t,e="PACKEM_")=>{const a={};for(const s of t.split(`
55
- `)){const i=s.trim();if(!i||i.startsWith("#"))continue;const n=Qe.exec(i);if(n?.[1]){const r=n[1].trim();let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=(t,e,a,s)=>{const i=J(t),n=Object.keys(i).length,r={};for(const[c,l]of Object.entries(i))(!e||c.startsWith(e))&&(r[`process.env.${c}`]=JSON.stringify(l));const o=Object.keys(r).length;return n>0&&o===0&&e?s?.warn(`Loaded 0 of ${String(n)} variables from "${a}"; none matched the "${e}" prefix.`):s?.info(`Loaded ${String(o)} of ${String(n)} variables from "${a}"${e?` (prefix "${e}")`:""}.`),r},et=async(t,e,a="PACKEM_",s)=>{const i=O(e,t);if(!V(i))return s?.warn(`Env file not found at "${i}"; no environment variables were loaded.`),{};const{readFile:n}=await import("node:fs/promises"),r=await n(i,"utf8");if(typeof J!="function")return T(r,a);try{return Ze(r,a,t,s)}catch{return T(r,a)}},tt=async(t,e,a,s,i)=>{const n=await A(e,i),r=await t.import(n,{default:!0})??{};return{config:typeof r=="function"?await r(a,s):r,path:n}},st=async(t,e)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:a}=await import("../config/preset/preact.js");t=a();break}case"react":{const{createReactPreset:a}=await import("../config/preset/react.js");t=a();break}case"solid":{const{createSolidPreset:a}=await import("../config/preset/solid.js");t=a();break}case"svelte":{const{createSveltePreset:a}=await import("../config/preset/svelte.js");t=a();break}case"vue":{const{createVuePreset:a}=await import("../config/preset/vue.js");t=a();break}default:typeof t=="string"&&(t=await e.import(t,{default:!0})||{})}return typeof t=="function"&&(t=t()),t},at=t=>t.watch?"watch":t.jit?"jit":"build",it=t=>{let e;const a={};if(t.env)for(const s of t.env)s.key==="NODE_ENV"?e=s.value:a[`process.env.${s.key}`]=JSON.stringify(s.value);return{cliEnvVariables:a,nodeEnvironment:e}},nt=(t,e)=>{if(e!==void 0)return e;if(t.production)return W;if(t.development)return ye},rt=t=>{const e=[];if(t.external)for(const a of t.external)e.push(...a.split(","));return e},ot=t=>{t.addCommand({description:"Build the package using the resolved packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=at(s),{cliEnvVariables:n,nodeEnvironment:r}=it(s),o=nt(s,r),c=rt(s),l=O(N(),s.dir??".");await Ye(l);const u=we(l,{debug:s.debug}),{config:m,path:p}=await tt(u,l,o,i,s.config??void 0);e.debug("Using packem config found at",p);const d=s.envFile??m.envFile,x=s.envPrefix??m.envPrefix??"PACKEM_",w={};if(d){const y=await et(d,l,x,{info:v=>{e.info(v)},warn:v=>{e.warn(v)}});Object.assign(w,y)}Object.assign(w,n);const L=await st(m.preset??"none",u);s.minify&&s.sourcemap===void 0&&(s.sourcemap=!0);try{const y=ae()(m,ie,L,{analyze:s.analyze,bundler:s.bundler,cjsInterop:s.cjsInterop,clean:s.clean,dtsOnly:s.dtsOnly,externals:c,killSignal:s.killSignal,minify:s.minify??o===W,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,...Object.keys(w).length>0||Object.keys(n).length>0?{replace:{values:w}}:{},resolveExternals:s.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:s.runtime,sourcemap:s.metafile||s.analyze||s.sourcemap,unbundle:s.unbundle,validation:s.validation===!1?!1:{},...s.exe?{exe:!0}:{},...s.typedoc?{typedoc:{format:"html"}}:{}});s.validation===!1&&!m.validation&&(y.validation=!1),s.cache===!1&&(y.fileCache=!1),await ne(l,i,o,e,s.debug??!1,y,s.tsconfig??void 0)}catch(y){e.error(y),le(1)}},name:"build",options:[{description:"Specify the bundler to use (rollup or rolldown)",name:"bundler",type:e=>{if(e==="rollup"||e==="rolldown")return e;throw new Error("Invalid bundler. Use 'rollup' or 'rolldown'.")}},{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:e=>{const a=e.indexOf("=");return a===-1?{key:e,value:""}:{key:e.slice(0,a),value:e.slice(a+1)}}},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:e=>{if(e==="SIGTERM"||e==="SIGKILL")return e;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")}},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (node, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean},{description:"Bundle the output into a standalone executable via Node.js SEA (requires Node.js >= 25.7.0, single entry)",name:"exe",type:Boolean}]})},X=t=>t==="sass-embedded"||t==="node-sass"?"sass":t,ct=(t,e)=>{me(b(t,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:e?["es2022","dom","dom.iterable"]:["es2022"]}})},lt=(t,e,a,s,i)=>{let n="";if(t)for(const r of e){const o=X(r);n+=i?`import ${o}Loader from "@visulima/packem/css/loader/${o.toLowerCase()}";
54
+ and create a packem.config.ts.`)}G(he("Packem first-run setup")),E.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];a&&s.push(ae[a]),await Xe(s,t);const i=b(t,"packem.config.ts");await F(i,Je(e,a),"utf8"),E.success(`Created ${i}`),K("Setup complete — continuing with build.")},Qe=/^([^#:=]+)=(.*)$/,T=(t,e="PACKEM_")=>{const a={};for(const s of t.split(`
55
+ `)){const i=s.trim();if(!i||i.startsWith("#"))continue;const n=Qe.exec(i);if(n?.[1]){const r=n[1].trim();let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=(t,e,a,s)=>{const i=J(t),n=Object.keys(i).length,r={};for(const[c,l]of Object.entries(i))(!e||c.startsWith(e))&&(r[`process.env.${c}`]=JSON.stringify(l));const o=Object.keys(r).length;return n>0&&o===0&&e?s?.warn(`Loaded 0 of ${String(n)} variables from "${a}"; none matched the "${e}" prefix.`):s?.info(`Loaded ${String(o)} of ${String(n)} variables from "${a}"${e?` (prefix "${e}")`:""}.`),r},et=async(t,e,a="PACKEM_",s)=>{const i=O(e,t);if(!V(i))return s?.warn(`Env file not found at "${i}"; no environment variables were loaded.`),{};const{readFile:n}=await import("node:fs/promises"),r=await n(i,"utf8");if(typeof J!="function")return T(r,a);try{return Ze(r,a,t,s)}catch{return T(r,a)}},tt=async(t,e,a,s,i)=>{const n=await A(e,i),r=await t.import(n,{default:!0})??{};return{config:typeof r=="function"?await r(a,s):r,path:n}},st=async(t,e)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:a}=await import("../config/preset/preact.js");t=a();break}case"react":{const{createReactPreset:a}=await import("../config/preset/react.js");t=a();break}case"solid":{const{createSolidPreset:a}=await import("../config/preset/solid.js");t=a();break}case"svelte":{const{createSveltePreset:a}=await import("../config/preset/svelte.js");t=a();break}case"vue":{const{createVuePreset:a}=await import("../config/preset/vue.js");t=a();break}default:typeof t=="string"&&(t=await e.import(t,{default:!0})||{})}return typeof t=="function"&&(t=t()),t},at=t=>t.watch?"watch":t.jit?"jit":"build",it=t=>{let e;const a={};if(t.env)for(const s of t.env)s.key==="NODE_ENV"?e=s.value:a[`process.env.${s.key}`]=JSON.stringify(s.value);return{cliEnvVariables:a,nodeEnvironment:e}},nt=(t,e)=>{if(e!==void 0)return e;if(t.production)return W;if(t.development)return ye},rt=t=>{const e=[];if(t.external)for(const a of t.external)e.push(...a.split(","));return e},ot=t=>{t.addCommand({description:"Build the package using the resolved packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=at(s),{cliEnvVariables:n,nodeEnvironment:r}=it(s),o=nt(s,r),c=rt(s),l=O(N(),s.dir??".");await Ye(l);const u=we(l,{debug:s.debug}),{config:m,path:p}=await tt(u,l,o,i,s.config??void 0);e.debug("Using packem config found at",p);const d=s.envFile??m.envFile,x=s.envPrefix??m.envPrefix??"PACKEM_",w={};if(d){const y=await et(d,l,x,{info:v=>{e.info(v)},warn:v=>{e.warn(v)}});Object.assign(w,y)}Object.assign(w,n);const L=await st(m.preset??"none",u);s.minify&&s.sourcemap===void 0&&(s.sourcemap=!0);try{const y=ie()(m,ne,L,{analyze:s.analyze,bundler:s.bundler,cjsInterop:s.cjsInterop,clean:s.clean,dtsOnly:s.dtsOnly,externals:c,killSignal:s.killSignal,minify:s.minify??o===W,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,...Object.keys(w).length>0||Object.keys(n).length>0?{replace:{values:w}}:{},resolveExternals:s.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:s.runtime,sourcemap:s.metafile||s.analyze||s.sourcemap,unbundle:s.unbundle,validation:s.validation===!1?!1:{},...s.exe?{exe:!0}:{},...s.typedoc?{typedoc:{format:"html"}}:{}});s.validation===!1&&!m.validation&&(y.validation=!1),s.cache===!1&&(y.fileCache=!1),await re(l,i,o,e,s.debug??!1,y,s.tsconfig??void 0)}catch(y){e.error(y),le(1)}},name:"build",options:[{description:"Specify the bundler to use (rollup or rolldown)",name:"bundler",type:e=>{if(e==="rollup"||e==="rolldown")return e;throw new Error("Invalid bundler. Use 'rollup' or 'rolldown'.")}},{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:e=>{const a=e.indexOf("=");return a===-1?{key:e,value:""}:{key:e.slice(0,a),value:e.slice(a+1)}}},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:e=>{if(e==="SIGTERM"||e==="SIGKILL")return e;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")}},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (node, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean},{description:"Bundle the output into a standalone executable via Node.js SEA (requires Node.js >= 25.7.0, single entry)",name:"exe",type:Boolean}]})},X=t=>t==="sass-embedded"||t==="node-sass"?"sass":t,ct=(t,e)=>{me(b(t,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:e?["es2022","dom","dom.iterable"]:["es2022"]}})},lt=(t,e,a,s,i)=>{let n="";if(t)for(const r of e){const o=X(r);n+=i?`import ${o}Loader from "@visulima/packem/css/loader/${o.toLowerCase()}";
56
56
  `:`const ${o}Loader = require("@visulima/packem/css/loader/${o.toLowerCase()}");
57
57
  `}return s&&a&&(n+=i?`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
58
58
  `:`const ${a}Minifier = require("@visulima/packem/css/minifier/${a.toLowerCase()}");
@@ -80,4 +80,4 @@ module.exports = defineConfig({
80
80
  `;return t?(e.info("[dry-run] package.json changes:"),e.info("Old content:"),console.info(a),e.info("New content:"),console.info(o)):(await F("package.json",o),e.success("Migrated `package.json`")),!0},It=["tsup.config.ts","tsup.config.cts","tsup.config.mts","tsup.config.js","tsup.config.cjs","tsup.config.mjs","tsup.config.json","build.config.ts","build.config.cts","build.config.mts","build.config.js","build.config.cjs","build.config.mjs","bunchee.config.ts","bunchee.config.cts","bunchee.config.mts","bunchee.config.js","bunchee.config.cjs","bunchee.config.mjs"],Mt=t=>{let e=!1;for(const a of It)V(a)&&(t.info(`Found config file \`${a}\`. Consider creating packem.config.ts instead.`),t.info("Manual migration required for config files. See https://www.visulima.com/docs/package/packem"),e=!0);return e||t.info("No bundler config files found"),e},Nt=async({cwd:t,dryRun:e,logger:a})=>{if(e)a.info("Dry run enabled. No changes will be made.");else{const i=ve({input:k.stdin,output:k.stdout});a.warn(`
81
81
 
82
82
  Before proceeding, review the migration guide at https://www.visulima.com/docs/package/packem, as this process will modify your files.
83
- Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const n=await i.question("Continue? (Y/n) ");if(i.close(),!(n.toLowerCase()==="y"||n==="")){a.error("Migration cancelled."),k.exitCode=1;return}}t&&k.chdir(t);let s=!1;await Lt(e,a)&&(s=!0),Mt(a)&&(s=!0),s?a.success("Migration completed. Remember to run install command with your package manager."):(a.error("No migration performed."),k.exitCode=1)},Bt=t=>{t.addCommand({description:"Migrate from other bundlers (tsup, unbuild, bunchee, etc.) to packem",execute:async({logger:e,options:a})=>{const s=a;await Nt({cwd:s.cwd,dryRun:s.dryRun,logger:e})},name:"migrate",options:[{defaultValue:".",description:"The directory to migrate",name:"cwd",type:String},{description:"Preview changes without applying them",name:"dry-run",type:Boolean}]})};try{require("node:module").enableCompileCache?.()}catch{}const j=Q("packem",{logger:Z({reporters:[new ce({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"}),packageName:oe,packageVersion:re});ht(j);ot(j);Fe(j);Bt(j);j.run({shouldExitProcess:!1});
83
+ Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const n=await i.question("Continue? (Y/n) ");if(i.close(),!(n.toLowerCase()==="y"||n==="")){a.error("Migration cancelled."),k.exitCode=1;return}}t&&k.chdir(t);let s=!1;await Lt(e,a)&&(s=!0),Mt(a)&&(s=!0),s?a.success("Migration completed. Remember to run install command with your package manager."):(a.error("No migration performed."),k.exitCode=1)},Bt=t=>{t.addCommand({description:"Migrate from other bundlers (tsup, unbuild, bunchee, etc.) to packem",execute:async({logger:e,options:a})=>{const s=a;await Nt({cwd:s.cwd,dryRun:s.dryRun,logger:e})},name:"migrate",options:[{defaultValue:".",description:"The directory to migrate",name:"cwd",type:String},{description:"Preview changes without applying them",name:"dry-run",type:Boolean}]})};try{require("node:module").enableCompileCache?.()}catch{}const j=Q("packem",{logger:Z({reporters:[new ee({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"}),packageName:ce,packageVersion:oe});ht(j);ot(j);Fe(j);Bt(j);j.run({shouldExitProcess:!1});
@@ -1,4 +1,4 @@
1
- import { B as BuildConfig, a as BuildConfigFunction, b as BuildPreset } from "../packem_shared/types.d-CA4tXIce.js";
1
+ import { B as BuildConfig, a as BuildConfigFunction, b as BuildPreset } from "../packem_shared/types.d-BRQSr_g5.js";
2
2
  export type { BuildHooks } from '@visulima/packem-share/types';
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/packem-plugins';
@@ -11,6 +11,7 @@ import '@visulima/rollup-plugin-css';
11
11
  import 'jiti';
12
12
  import 'rollup';
13
13
  import 'typedoc';
14
+ import '@visulima/pail';
14
15
  /**
15
16
  * Defines a build configuration for Packem.
16
17
  * Supports both static configuration objects and dynamic configuration functions.
@@ -1,5 +1,5 @@
1
1
  import { BabelPluginConfig } from '@visulima/packem-plugins/babel';
2
- import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
2
+ import { B as BuildConfig } from "../../packem_shared/types.d-BRQSr_g5.js";
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/packem-plugins';
5
5
  import '@visulima/packem-plugins/oxc';
@@ -12,6 +12,7 @@ import '@visulima/rollup-plugin-css';
12
12
  import 'jiti';
13
13
  import 'rollup';
14
14
  import 'typedoc';
15
+ import '@visulima/pail';
15
16
  interface PreactPresetOptions {
16
17
  /**
17
18
  * Enable Preact devtools in production builds
@@ -1,5 +1,5 @@
1
1
  import { BabelPluginConfig } from '@visulima/packem-plugins/babel';
2
- import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
2
+ import { B as BuildConfig } from "../../packem_shared/types.d-BRQSr_g5.js";
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/packem-plugins';
5
5
  import '@visulima/packem-plugins/oxc';
@@ -12,6 +12,7 @@ import '@visulima/rollup-plugin-css';
12
12
  import 'jiti';
13
13
  import 'rollup';
14
14
  import 'typedoc';
15
+ import '@visulima/pail';
15
16
  interface ReactPresetOptions {
16
17
  /**
17
18
  * Enable React Compiler optimization
@@ -1,5 +1,5 @@
1
1
  import { BabelPluginConfig } from '@visulima/packem-plugins/babel';
2
- import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
2
+ import { B as BuildConfig } from "../../packem_shared/types.d-BRQSr_g5.js";
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/packem-plugins';
5
5
  import '@visulima/packem-plugins/oxc';
@@ -12,6 +12,7 @@ import '@visulima/rollup-plugin-css';
12
12
  import 'jiti';
13
13
  import 'rollup';
14
14
  import 'typedoc';
15
+ import '@visulima/pail';
15
16
  interface SolidPresetOptions {
16
17
  /**
17
18
  * Pass any additional babel transform options. They will be merged with
@@ -1,4 +1,4 @@
1
- import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
1
+ import { B as BuildConfig } from "../../packem_shared/types.d-BRQSr_g5.js";
2
2
  import '@arethetypeswrong/core';
3
3
  import '@visulima/packem-plugins';
4
4
  import '@visulima/packem-plugins/oxc';
@@ -11,6 +11,7 @@ import '@visulima/rollup-plugin-css';
11
11
  import 'jiti';
12
12
  import 'rollup';
13
13
  import 'typedoc';
14
+ import '@visulima/pail';
14
15
  interface SveltePresetOptions {
15
16
  /**
16
17
  * Svelte plugin options
@@ -1,4 +1,4 @@
1
- import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
1
+ import { B as BuildConfig } from "../../packem_shared/types.d-BRQSr_g5.js";
2
2
  import '@arethetypeswrong/core';
3
3
  import '@visulima/packem-plugins';
4
4
  import '@visulima/packem-plugins/oxc';
@@ -11,6 +11,7 @@ import '@visulima/rollup-plugin-css';
11
11
  import 'jiti';
12
12
  import 'rollup';
13
13
  import 'typedoc';
14
+ import '@visulima/pail';
14
15
  interface VuePresetOptions {
15
16
  /**
16
17
  * Vue plugin options
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-CA4tXIce.js";
3
- export type { c as BuildEntry, d as BuildOptions, R as RollupBuildOptions } from "./packem_shared/types.d-CA4tXIce.js";
2
+ import { B as BuildConfig } from "./packem_shared/types.d-BRQSr_g5.js";
3
+ export type { c as BuildEntry, d as BuildOptions, R as RollupBuildOptions } from "./packem_shared/types.d-BRQSr_g5.js";
4
4
  export type { TransformerFn, TransformerName } from '@visulima/packem-plugins';
5
5
  import { Environment, Mode } from '@visulima/packem-share/types';
6
6
  export type { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Mode, Runtime } from '@visulima/packem-share/types';