@visulima/packem 2.0.0-alpha.31 → 2.0.0-alpha.32

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/builder/typedoc/index.d.ts +2 -2
  3. package/dist/builder/typedoc/index.js +3 -3
  4. package/dist/cli/index.js +8 -8
  5. package/dist/config/index.d.ts +2 -2
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.js +1 -1
  8. package/dist/packem_shared/{default-Bv0h8ASu.js → default-B2EOH52z.js} +1 -1
  9. package/dist/packem_shared/default-B_dUKZ_J.js +1 -0
  10. package/dist/packem_shared/{default-CTOd1a5W.js → default-Dego_fiC.js} +1 -1
  11. package/dist/packem_shared/{default-BY_XZBkt.js → default-E4TiWfSK.js} +1 -1
  12. package/dist/packem_shared/esbuildPlugin-DpLtQGuZ-Bny-e486.js +3 -0
  13. package/dist/packem_shared/index-8EL_RHKk.js +173 -0
  14. package/dist/packem_shared/{index-D09qw6EP.d.ts → index-Cjp2s4rr.d.ts} +2 -4
  15. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js +3 -0
  16. package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL-D14z9S9i.js +1 -0
  17. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-3AmQC7y7.js +6 -0
  18. package/dist/packem_shared/{types-B5hAMUkV.d.ts → types-0Eba14hg.d.ts} +1 -1
  19. package/dist/rollup/plugins/esbuild/index.d.ts +2 -2
  20. package/dist/rollup/plugins/esbuild/index.js +1 -1
  21. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -1
  22. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +1 -1
  23. package/dist/rollup/plugins/sucrase/index.d.ts +1 -1
  24. package/dist/rollup/plugins/sucrase/index.js +1 -1
  25. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -1
  26. package/dist/rollup/plugins/swc/swc-plugin.d.ts +1 -1
  27. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -1
  28. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  29. package/package.json +2 -2
  30. package/dist/packem_shared/default-CAKCVA5N.js +0 -1
  31. package/dist/packem_shared/esbuildPlugin-DpLtQGuZ-DlbvGoD-.js +0 -3
  32. package/dist/packem_shared/index-CMiSObms.js +0 -178
  33. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-CfOpxpsh.js +0 -3
  34. package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL-VBndJ7ld.js +0 -1
  35. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-D4oir4A1.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## @visulima/packem [2.0.0-alpha.32](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.31...@visulima/packem@2.0.0-alpha.32) (2025-10-28)
2
+
3
+ ### Features
4
+
5
+ * enhance require-cjs-transformer with multi-entry point support ([6f0a824](https://github.com/visulima/packem/commit/6f0a824fe982bc9dc18e0e19fd9de55754ac37b3))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.25
11
+
1
12
  ## @visulima/packem [2.0.0-alpha.31](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.30...@visulima/packem@2.0.0-alpha.31) (2025-10-28)
2
13
 
3
14
  ### Bug Fixes
@@ -1,5 +1,5 @@
1
- import { B as BuildContext } from '../../packem_shared/index-D09qw6EP.js';
2
- import { I as InternalBuildOptions } from '../../packem_shared/types-B5hAMUkV.js';
1
+ import { B as BuildContext } from '../../packem_shared/index-Cjp2s4rr.js';
2
+ import { I as InternalBuildOptions } from '../../packem_shared/types-0Eba14hg.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -1,3 +1,3 @@
1
- var v=Object.defineProperty;var f=(e,o)=>v(e,"name",{value:o,configurable:!0});import{createRequire as E}from"node:module";import{cyan as P}from"@visulima/colorize";import{join as y}from"@visulima/path";import{p as A,d as T}from"../../packem_shared/create-or-update-key-storage-GwAIWW7R.js";import{readFileSync as j,writeFileSync as R}from"@visulima/fs";import{Application as C}from"typedoc";const $=E(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=f(e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[o,r]=l.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return l.getBuiltinModule(e)}return $(e)},"__cjs_getBuiltinModule"),{readdirSync:F}=b("node:fs");var q=Object.defineProperty,D=f((e,o)=>q(e,"name",{value:o,configurable:!0}),"w");const M=D(async(e,o,r,a)=>{if(o.length===0)return;const{format:t,jsonFileName:n,marker:i,output:N,plugin:k,readmePath:p,...w}=e;if(t==="inline"&&p===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(t!=="inline"&&typeof p=="string"&&a.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),t==="json"){if(n===void 0)throw new Error("The `jsonFileName` option is required when using the `json` format.");if(!n.endsWith(".json"))throw new Error("The `jsonFileName` option must end with `.json`.")}t!=="json"&&typeof n=="string"&&a.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"});const _=o.map(g=>g.input),m=k??[];m.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&m.push("typedoc-plugin-markdown");const d=await C.bootstrapWithPlugins({...w,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...w.compilerOptions},entryPoints:_,hideGenerator:!0,out:r,plugin:m,...t==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),c=await d.convert();if(c){if(t==="json")await d.generateJson(c,n);else if(t==="html")await d.generateDocs(c,r);else if(await d.generateOutputs(c),t==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const g=F(r,{withFileTypes:!0}).filter(s=>s.isFile());let h="";for(const s of g)s.name==="README.md"&&o.length>1||(h+=j(y(r,s.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(h!==""){const s=j(p),u=A(s,i,`
2
- ${h}`);if(!u){a.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${p}`,prefix:"typedoc"});return}if(s===u)return;u&&R(p,u.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}}},"generateReferenceDocumentation");var x=Object.defineProperty,L=f((e,o)=>x(e,"name",{value:o,configurable:!0}),"r");const G=L(async(e,o,r,a)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){let t="unknown";e.pkg.dependencies?.typedoc?t=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(t=e.pkg.devDependencies.typedoc),o&&T("typedoc",o,e.logger,!0),a&&e.logger.raw(`
3
- `),e.logger.info({message:`Using ${P("typedoc")} ${t} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let n=e.options.rootDir;e.options.typedoc.output?n=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?n=y(o,"typedoc"):e.options.typedoc.format!=="json"&&(n=y(n,"api-docs")),await M(e.options.typedoc,e.options.entries,n,e.logger),await e.hooks.callHook("typedoc:done",e)}},"builder");export{G as default};
1
+ var j=Object.defineProperty;var g=(e,o)=>j(e,"name",{value:o,configurable:!0});import{cyan as v}from"@visulima/colorize";import{join as h}from"@visulima/path";import{p as $,d as P}from"../../packem_shared/create-or-update-key-storage-GwAIWW7R.js";import{readdirSync as A}from"node:fs";import{readFileSync as w,writeFileSync as F}from"@visulima/fs";import{Application as b}from"typedoc";var T=Object.defineProperty,_=g((e,o)=>T(e,"name",{value:o,configurable:!0}),"w");const C=_(async(e,o,a,s)=>{if(o.length===0)return;const{format:t,jsonFileName:n,marker:i,output:x,plugin:k,readmePath:p,...y}=e;if(t==="inline"&&p===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(t!=="inline"&&typeof p=="string"&&s.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),t==="json"){if(n===void 0)throw new Error("The `jsonFileName` option is required when using the `json` format.");if(!n.endsWith(".json"))throw new Error("The `jsonFileName` option must end with `.json`.")}t!=="json"&&typeof n=="string"&&s.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"});const E=o.map(m=>m.input),u=k??[];u.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&u.push("typedoc-plugin-markdown");const l=await b.bootstrapWithPlugins({...y,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...y.compilerOptions},entryPoints:E,hideGenerator:!0,out:a,plugin:u,...t==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(t==="json")await l.generateJson(d,n);else if(t==="html")await l.generateDocs(d,a);else if(await l.generateOutputs(d),t==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const m=A(a,{withFileTypes:!0}).filter(r=>r.isFile());let f="";for(const r of m)r.name==="README.md"&&o.length>1||(f+=w(h(a,r.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(f!==""){const r=w(p),c=$(r,i,`
2
+ ${f}`);if(!c){s.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${p}`,prefix:"typedoc"});return}if(r===c)return;c&&F(p,c.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}}},"generateReferenceDocumentation");var R=Object.defineProperty,D=g((e,o)=>R(e,"name",{value:o,configurable:!0}),"r");const B=D(async(e,o,a,s)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){let t="unknown";e.pkg.dependencies?.typedoc?t=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(t=e.pkg.devDependencies.typedoc),o&&P("typedoc",o,e.logger,!0),s&&e.logger.raw(`
3
+ `),e.logger.info({message:`Using ${v("typedoc")} ${t} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let n=e.options.rootDir;e.options.typedoc.output?n=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?n=h(o,"typedoc"):e.options.typedoc.format!=="json"&&(n=h(n,"api-docs")),await C(e.options.typedoc,e.options.entries,n,e.logger),await e.hooks.callHook("typedoc:done",e)}},"builder");export{B as default};
package/dist/cli/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- var ce=Object.defineProperty;var w=(s,t)=>ce(s,"name",{value:t,configurable:!0});import{createRequire as pe}from"node:module";import de from"@visulima/cerebro";import{SimpleReporter as ue}from"@visulima/pail/reporter";import{installPackage as _}from"@antfu/install-pkg";import{spinner as J,select as S,multiselect as te,confirm as h,intro as fe,log as X,cancel as ye,outro as ge}from"@clack/prompts";import{isAccessible as ve,readFile as be,writeFile as we,isAccessibleSync as x,collectSync as he,writeJsonSync as $e,writeFileSync as ke}from"@visulima/fs";import{join as C,resolve as P,extname as oe,toNamespacedPath as Se}from"@visulima/path";import{t as N,E as G,e as xe,N as ie,_ as Ce,c as De}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as Pe}from"jiti";import{cyan as Te,bold as V,gray as Me}from"@visulima/colorize";import{e as Ie,i as H,c as Be,x as Le}from"../packem_shared/index-CMiSObms.js";import{parsePackageJson as Ne}from"@visulima/package/package-json";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ var ae=Object.defineProperty;var k=(t,s)=>ae(t,"name",{value:s,configurable:!0});import re from"@visulima/cerebro";import{SimpleReporter as le}from"@visulima/pail/reporter";import{cwd as U,exit as ce}from"node:process";import{installPackage as q}from"@antfu/install-pkg";import{spinner as R,select as S,multiselect as Q,confirm as w,intro as pe,log as W,cancel as de,outro as ue}from"@clack/prompts";import{isAccessible as me,readFile as fe,writeFile as ye,isAccessibleSync as j,collectSync as ge,writeJsonSync as ve,writeFileSync as be}from"@visulima/fs";import{join as C,resolve as E,extname as ee,toNamespacedPath as we}from"@visulima/path";import he from"magic-string";import{t as B,E as G,e as $e,N as te,_ as ke,c as Se}from"../packem_shared/index-CUp9WuCG.js";import{defu as xe}from"defu";import{createJiti as je}from"jiti";import{cyan as Ce,bold as J,gray as De}from"@visulima/colorize";import{e as Ee,i as _,c as Pe,x as Ie}from"../packem_shared/index-8EL_RHKk.js";import Me from"node:fs/promises";import X from"node:path/posix";import{parsePackageJson as Te}from"@visulima/package/package-json";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
3
  const require = __cjs_mod__.createRequire(import.meta.url);
4
- const U=pe(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=w(s=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,e]=E.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return E.getBuiltinModule(s)}return U(s)},"__cjs_getBuiltinModule"),{cwd:z,exit:me}=E,je=U("magic-string"),{defu:Ee}=U("defu"),Oe=se("node:fs/promises"),Y=se("node:path/posix"),Ke="@visulima/packem",qe="2.0.0-alpha.30";var Ae=Object.defineProperty,Re=w((s,t)=>Ae(s,"name",{value:t,configurable:!0}),"t$2");const ne=Re(async(s,t="")=>{let e=t;if(!e){const r=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const a of r)if(await ve(C(s,a))){e=`./${a}`;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(e))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return e},"findPackemFile"),ae={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 Ve=Object.defineProperty,Z=w((s,t)=>Ve(s,"name",{value:t,configurable:!0}),"g");const _e=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Je=Z(s=>{s.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:Z(async({argument:t,logger:e,options:r})=>{const a=J(),o=P(z(),r.dir??".");let p;try{p=await ne(o,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const u=await be(p,{buffer:!1});let y="cjs";u.includes("import")&&(y="esm");const i=new je(u),m=" transformer,";let n=" transformer";if(u.includes(" transformer,")&&(n=" transformer,"),t.includes("typedoc")){if(u.includes("typedoc: typedocBuilder")||u.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}y==="cjs"?i.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
4
+ const Le="@visulima/packem",Oe="2.0.0-alpha.31";var Be=Object.defineProperty,Ne=k((t,s)=>Be(t,"name",{value:s,configurable:!0}),"t$2");const se=Ne(async(t,s="")=>{let e=s;if(!e){const r=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const a of r)if(await me(C(t,a))){e=`./${a}`;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(e))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return e},"findPackemFile"),oe={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 Ke=Object.defineProperty,H=k((t,s)=>Ke(t,"name",{value:s,configurable:!0}),"g");const Ae=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ve=H(t=>{t.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:H(async({argument:s,logger:e,options:r})=>{const a=R(),o=E(U(),r.dir??".");let p;try{p=await se(o,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const u=await fe(p,{buffer:!1});let y="cjs";u.includes("import")&&(y="esm");const i=new he(u),m=" transformer,";let n=" transformer";if(u.includes(" transformer,")&&(n=" transformer,"),s.includes("typedoc")){if(u.includes("typedoc: typedocBuilder")||u.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}y==="cjs"?i.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
5
5
  `):i.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
6
6
  `),u.includes("builder: {")?i.replace("builder: {",`builder: {
7
7
  typedoc: typedocBuilder,
8
8
  `):i.replace(n,`${m}
9
9
  builder: {
10
10
  typedoc: typedocBuilder,
11
- },`),e.info("Adding typedoc dependencies..."),a.start("Installing packages"),await _(_e,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
12
- Typedoc added!`)}if(t.includes("css")){if(u.includes("css: {")||u.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const c=[],g=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(c.push(g),g!=="tailwindcss"){let f=await te({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(f.includes("sass")){const $=await S({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});$!=="sass"&&(f=f.filter(D=>D!=="sass"),f.push($))}c.push(...f)}const v=[];for(const f of c)v.push(...ae[f]);g!=="tailwindcss"&&c.push("sourceMap");for(let f of c)(f==="sass-embedded"||f==="node-sass")&&(f="sass"),y==="cjs"?i.prepend(`const ${f}Loader = require("@visulima/packem/css/loader/${f.toLowerCase()}");
11
+ },`),e.info("Adding typedoc dependencies..."),a.start("Installing packages"),await q(Ae,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
12
+ Typedoc added!`)}if(s.includes("css")){if(u.includes("css: {")||u.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const c=[],g=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(c.push(g),g!=="tailwindcss"){let f=await Q({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(f.includes("sass")){const h=await S({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});h!=="sass"&&(f=f.filter(D=>D!=="sass"),f.push(h))}c.push(...f)}const v=[];for(const f of c)v.push(...oe[f]);g!=="tailwindcss"&&c.push("sourceMap");for(let f of c)(f==="sass-embedded"||f==="node-sass")&&(f="sass"),y==="cjs"?i.prepend(`const ${f}Loader = require("@visulima/packem/css/loader/${f.toLowerCase()}");
13
13
  `):i.prepend(`import ${f}Loader from "@visulima/packem/css/loader/${f.toLowerCase()}";
14
- `);const d=await h({initialValue:!1,message:"Do you want to minify your css?"});let l;d&&(l=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),c.includes("lightningcss")||v.push(l),y==="cjs"?i.prepend(`const ${l}Minifier = require("@visulima/packem/css/minifier/${l.toLowerCase()}");
14
+ `);const d=await w({initialValue:!1,message:"Do you want to minify your css?"});let l;d&&(l=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),c.includes("lightningcss")||v.push(l),y==="cjs"?i.prepend(`const ${l}Minifier = require("@visulima/packem/css/minifier/${l.toLowerCase()}");
15
15
  `):i.prepend(`import ${l}Minifier from "@visulima/packem/css/minifier/${l.toLowerCase()}";
16
16
  `));const b=c.map(f=>((f==="sass-embedded"||f==="node-sass")&&(f="sass"),`${f}Loader`)).join(", ");u.includes("rollup: {")?i.replace("rollup: {",`rollup: {
17
17
  css: {${l?`
@@ -24,8 +24,8 @@ Typedoc added!`)}if(t.includes("css")){if(u.includes("css: {")||u.includes("@vis
24
24
  minifier: ${l}Minifier,`:""}
25
25
  loaders: [${b}],
26
26
  },
27
- },`),a.start("Installing packages"),await _(v,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
28
- CSS loaders added!`)}await we(p,i.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand");var Ge=Object.defineProperty,Fe=w((s,t)=>Ge(s,"name",{value:t,configurable:!0}),"e$1");const Ue=Fe(async(s,t,e,r,a)=>{const o=await ne(t,a);let p=await s.import(o,{default:!0,try:!0})||{};return typeof p=="function"&&(p=await p(e,r)),{config:p,path:o}},"loadPackemConfig");var ze=Object.defineProperty,j=w((s,t)=>ze(s,"name",{value:t,configurable:!0}),"u$1");const F=new Map,We=/\.[^./]+$/,Xe=j(async s=>{try{return await Oe.readdir(s,{withFileTypes:!0})}catch(t){const{code:e}=t;if(e==="ENOENT")return[];throw t}},"safeReaddir"),re=j(async(s,t)=>{const e=await Xe(s);return(await Promise.all(e.map(async r=>{const a=Y.join(s,r.name);return r.isDirectory()?re(a,t):r.isFile()?Y.relative(t,a):[]}))).flat()},"getDirectoryFilesRecursive"),He=j(async s=>{let t=F.get(s);return t||(t=re(s,s),F.set(s,t)),t},"getDirectoryFiles"),Ye=j((s,t)=>{const e=s.replace(We,"");if(t==="*"){const p=e.split("/");return p.length>0?[p[0]]:null}const r=t.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),a=new RegExp(`^${r}$`),o=e.match(a);return o?o.slice(1):null},"matchWildcardPattern"),Ze=j((s,t)=>{let e=s;for(const r of t)e=e.replace("*",r);return e},"substituteWildcards"),Qe=j((s,t)=>s.key==="exports"&&s.subKey===N?N:s.key==="exports"&&s.subKey===G?G:t,"getEnvironment"),O=j((s,t,e,r,a,o,p)=>{const u=Qe(a,o.environment);let y=o.options.runtime;for(const n of xe)if(a.file.includes(`.${n}.`)||a.subKey===n){y=n;break}let i=s.find(n=>n.input===t&&n.environment===u&&n.runtime===y);i===void 0?i=s[s.push({environment:u,exportKey:new Set([a.exportKey].filter(Boolean)),input:t,runtime:y})-1]:i.exportKey&&a.exportKey&&i.exportKey.add(a.exportKey),p&&(i.isGlob=!0),e&&(i.outDir=r),a.isExecutable?(i.executable=!0,i.declaration=!1,a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0)):(/\.d\.[mc]?ts$/.test(a.file)&&o.options.declaration!==!1&&(i.declaration=o.options.declaration),a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0));const m=a.file.replace(oe(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");ie.has(a.subKey)&&!t.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Q=!1;const ee=j(s=>{if(s.pkg?.dependencies?.typescript===void 0&&s.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"),es=j(async(s,t,e)=>{const r=s.types||s.typings;F.clear();const a=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),o=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),p=[];t.sort((n,c)=>n.split("/").length-c.split("/").length);const u=s.type==="module"?"esm":"cjs";u==="esm"&&(e.options.emitESM=!0),u==="cjs"&&(e.options.emitCJS=!0);const y=e.options.emitCJS&&e.options.emitESM;e.options.declaration===void 0&&(e.options.declaration=y?"compatible":"node16");const i=Ie(s.exports,u,e.options.declaration,[],e.options.ignoreExportKeys).filter(n=>!n.ignored);if(s.bin){const n=(typeof s.bin=="string"?[s.bin]:Object.values(s.bin)).filter(Boolean);for(const c of n){const g=H(c);if(g&&g!==u)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${s.type??"commonjs"}".`);i.push({file:c,isExecutable:!0,key:"bin",type:g??u})}}s.main&&i.push({file:s.main,key:"main",type:H(s.main)??u}),s.module&&i.push({file:s.module,key:"module",type:"esm"}),r&&(ee(e),(e.options.declaration===void 0||e.options.declaration==="node16")&&y&&(e.options.declaration="compatible"),i.push({file:s.types??s.typings,key:"types"}));const m=[];for await(const n of i){const c=oe(n.file);if(c!==""&&!Ce.includes(c))continue;if(e.options.emitCJS===void 0&&n.type==="cjs"&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.type==="esm"&&(e.options.emitESM=!0),e.options.declaration===void 0||e.options.declaration==="node16"){const k=e.options.emitCJS&&e.options.emitESM;e.options.declaration=k?"compatible":"node16"}const g=n.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+|${[`\\.${a}`,`\\.${o}`].join("|")})$`),""),v=g.endsWith("/");if(v&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),l="(?<=/|$)",b=v?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${a}`,`\\.${o}`].join("|")})$`;if((n.file.includes("/*")||g.includes("*"))&&n.key==="exports"){Q||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Q=!0);let k;n.exportKey?k=n.exportKey.startsWith("./")?n.exportKey.slice(2):n.exportKey:k=(n.file.startsWith("./")?n.file.slice(2):n.file).replace(/^dist\//,"");const I=n.file,q=e.options.sourceDir.replace(/^\.\//,""),W=P(e.options.rootDir,q),A=[],le=await He(W);for(const B of le){const L=Ye(B,k);if(L){const R=Ze(I,L);A.push({input:P(W,B),output:R})}}if(A.length===0){p.push(`Could not find entrypoints matching pattern \`${k}\` for output \`${I}\``);continue}for(const{input:B,output:L}of A){const R={...n,file:L};O(m,B,v,g,R,e,!0)}continue}const f=new RegExp(l+d+b);let $=t.find(k=>f.test(k));if(ie.has(n.subKey)&&$===void 0){const k=d.replace(/^(.+?)\.[^.]*$/,"$1"),I=new RegExp(l+k+b);$=t.find(q=>I.test(q))}if($===void 0){x(P(e.options.rootDir,n.file))||p.push(`Could not find entrypoint for \`${n.file}\``);continue}x($)&&/\.[cm]?tsx?$/.test($)&&ee(e);const D=Se($.replace(De,""));x(`${D}.cts`)&&x(`${D}.mts`)?(O(m,`${D}.cts`,v,g,{...n,type:"cjs"},e,!1),O(m,`${D}.mts`,v,g,{...n,type:"esm"},e,!1)):O(m,$,v,g,n,e,!1)}return{entries:m,warnings:p}},"inferEntries");var ss=Object.defineProperty,ts=w((s,t)=>ss(s,"name",{value:t,configurable:!0}),"o");const os=ts((s,t)=>{const{publishConfig:e}=s;return e&&(e.bin&&(typeof e.bin=="object"||typeof e.bin=="string")&&(s.bin=e.bin),e.type&&typeof e.type=="string"&&e.type!==""&&(s.type=e.type),e.main&&typeof e.main=="string"&&e.main!==""&&(s.main=e.main),e.module&&typeof e.module=="string"&&e.module!==""&&(s.module=e.module),t===void 0&&e.types&&typeof e.types=="string"&&e.types!==""?s.types=e.types:t===void 0&&e.typings&&typeof e.typings=="string"&&e.typings!==""&&(s.typings=e.typings),e.exports&&typeof e.exports=="object"&&(s.exports=e.exports)),s},"overwriteWithPublishConfig");var is=Object.defineProperty,ns=w((s,t)=>is(s,"name",{value:t,configurable:!0}),"t$1");const as={hooks:{"build:prepare":ns(async function(s){if(s.options.entries.length>0)return;const t=C(s.options.rootDir,s.options.sourceDir);if(!x(t))throw new Error("No 'src' directory found. Please provide entries manually.");const e=he(t,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[/.*\/node_modules\/.*/,/.*\/dist\/.*/]});if(e.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...s.pkg};r.publishConfig&&(s.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(r.publishConfig).join(", ")}".`),s.logger.debug(r.publishConfig),r=os(r,s.options.declaration));const a=await es(r,e,s);for(const o of a.warnings)Be(s,o);if(s.options.entries.push(...a.entries),s.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");s.logger.info("Automatically detected entries:",Te(s.options.entries.map(o=>o.fileAlias?`${V(o.fileAlias)} => ${V(o.input.replace(`${s.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:V(o.input.replace(`${s.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),Me([s.options.emitESM&&"esm",s.options.emitCJS&&"cjs",s.options.declaration&&"dts"].filter(Boolean).map(o=>`[${o}]`).join(" ")))},"build:prepare")}};var rs=Object.defineProperty,ls=w((s,t)=>rs(s,"name",{value:t,configurable:!0}),"t");const cs=ls(async(s,t)=>{if(s==="auto")s=as;else{if(s==="none")return{};typeof s=="string"&&(s=await t.import(s)||{})}return typeof s=="function"&&(s=s()),s},"loadPreset");var ps=Object.defineProperty,T=w((s,t)=>ps(s,"name",{value:t,configurable:!0}),"r");const ds=T(s=>{s.addCommand({description:"Demonstrate options required",execute:T(async({logger:t,options:e})=>{let r="build";e.watch?r="watch":e.jit&&(r="jit");const a={};let o;if(e.env)for(const c of e.env)c.key==="NODE_ENV"?o=c.value:a[`process.env.${c.key}`]=JSON.stringify(c.value);o===void 0&&(e.production?o=N:e.development&&(o=G));const p=[];if(e.external)for(const c of e.external)p.push(c.split(","));const u=P(z(),e.dir??"."),y=Pe(u,{debug:e.debug}),{config:i,path:m}=await Ue(y,u,o,r,e.config??void 0);t.debug("Using packem config found at",m);const n=await cs(i.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await Le(u,r,o,t,e.debug,Ee(i,n,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:p,killSignal:e.killSignal,minify:e.minify===void 0?o===N:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,replace:{values:a},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}}),e.tsconfig??void 0)}catch(c){t.error(c),me(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{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:T(t=>{const[e,r]=t.split("=");return{key:e,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{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:T(t=>{if(t==="SIGTERM"||t==="SIGKILL")return t;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")},"type")},{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 (nodejs, browser).",name:"runtime",type:T(t=>{if(t==="node"||t==="browser")return t;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var us=Object.defineProperty,M=w((s,t)=>us(s,"name",{value:t,configurable:!0}),"f");const ms=M(s=>{s.addCommand({description:"Initialize packem configuration",execute:M(async({logger:t,options:e})=>{if(fe("Welcome to packem setup"),x(C(e.dir,"packem.config.mjs"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=P(z(),e.dir??"."),a=C(r,"package.json");if(!x(a))throw new Error("No package.json found in the directory");const o=await Ne(a,{resolveCatalogs:!0}),p=[];o.dependencies&&p.push(...Object.keys(o.dependencies)),o.devDependencies&&p.push(...Object.keys(o.devDependencies));const u=!!(o.devDependencies?.typescript??o.dependencies?.typescript),y=[];if(e.typescript===void 0&&!u?(e.typescript=await h({message:"Do you want to install TypeScript?"}),e.typescript&&y.push("typescript@latest")):X.message(`TypeScript version ${o.devDependencies?.typescript??o.dependencies?.typescript} is already installed`),!x(C(r,"tsconfig.json"))){const d=await h({message:"Do you want to use generate a tsconfig.json?"}),l=await h({message:"Do you want to run your code in the DOM?"});if(d){const b=J();b.start("Generating tsconfig.json"),$e(C(r,"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:l?["es2022","dom","dom.iterable"]:["es2022"]}}),b.stop("")}}if(e.runtime===void 0&&(e.runtime=await S({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),p.includes("esbuild")?e.transformer="esbuild":p.includes("@swc/core")?e.transformer="swc":p.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await S({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),e.transformer&&e.transformer!=="oxc"&&!p.includes(e.transformer)&&await h({message:`Do you want to install ${e.transformer}?`})&&y.push(e.transformer==="swc"?"@swc/core":e.transformer)):X.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await S({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:void 0}]}),e.isolatedDeclarationTransformer!==void 0)){let d;switch(e.isolatedDeclarationTransformer){case"oxc":{d="oxc-transform";break}case"swc":{d="@swc/core";break}case"typescript":{d="typescript";break}default:ye("Invalid isolated declaration transformer")}d!==void 0&&!p.includes(d)&&await h({message:`Do you want to install ${d}?`})&&y.push(d)}e.css===void 0&&(e.css=await h({message:"Do you want to use css in your project?",initialValue:!1}));const i=[];if(e.css){const d=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});i.push(d);let l=await te({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(l.includes("sass")){const b=await S({message:"Pick a sass loader",options:[{label:"Sass embedded",value:"sass-embedded",hint:"recommended"},{label:"Sass",value:"sass"},{label:"Node Sass",value:"node-sass",hint:"legacy"}]});b!=="sass"&&(l=l.filter(f=>f!=="sass"),l.push(b))}if(i.push(...l),await h({message:`Do you want to install "${i.join('", "')}"?`}))for(const b of i)y.push(...ae[b]);i.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await h({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),i.includes("lightningcss")||await h({message:`Do you want to install "${m}"?`})&&y.push(m));let n="",c="";if(e.isolatedDeclarationTransformer&&(c+=`,
27
+ },`),a.start("Installing packages"),await q(v,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
28
+ CSS loaders added!`)}await ye(p,i.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand");var Je=Object.defineProperty,qe=k((t,s)=>Je(t,"name",{value:s,configurable:!0}),"e$1");const Re=qe(async(t,s,e,r,a)=>{const o=await se(s,a);let p=await t.import(o,{default:!0,try:!0})||{};return typeof p=="function"&&(p=await p(e,r)),{config:p,path:o}},"loadPackemConfig");var Ge=Object.defineProperty,x=k((t,s)=>Ge(t,"name",{value:s,configurable:!0}),"u$1");const F=new Map,Fe=/\.[^./]+$/,Ue=x(async t=>{try{return await Me.readdir(t,{withFileTypes:!0})}catch(s){const{code:e}=s;if(e==="ENOENT")return[];throw s}},"safeReaddir"),ie=x(async(t,s)=>{const e=await Ue(t);return(await Promise.all(e.map(async r=>{const a=X.join(t,r.name);return r.isDirectory()?ie(a,s):r.isFile()?X.relative(s,a):[]}))).flat()},"getDirectoryFilesRecursive"),ze=x(async t=>{let s=F.get(t);return s||(s=ie(t,t),F.set(t,s)),s},"getDirectoryFiles"),We=x((t,s)=>{const e=t.replace(Fe,"");if(s==="*"){const p=e.split("/");return p.length>0?[p[0]]:null}const r=s.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),a=new RegExp(`^${r}$`),o=e.match(a);return o?o.slice(1):null},"matchWildcardPattern"),_e=x((t,s)=>{let e=t;for(const r of s)e=e.replace("*",r);return e},"substituteWildcards"),Xe=x((t,s)=>t.key==="exports"&&t.subKey===B?B:t.key==="exports"&&t.subKey===G?G:s,"getEnvironment"),O=x((t,s,e,r,a,o,p)=>{const u=Xe(a,o.environment);let y=o.options.runtime;for(const n of $e)if(a.file.includes(`.${n}.`)||a.subKey===n){y=n;break}let i=t.find(n=>n.input===s&&n.environment===u&&n.runtime===y);i===void 0?i=t[t.push({environment:u,exportKey:new Set([a.exportKey].filter(Boolean)),input:s,runtime:y})-1]:i.exportKey&&a.exportKey&&i.exportKey.add(a.exportKey),p&&(i.isGlob=!0),e&&(i.outDir=r),a.isExecutable?(i.executable=!0,i.declaration=!1,a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0)):(/\.d\.[mc]?ts$/.test(a.file)&&o.options.declaration!==!1&&(i.declaration=o.options.declaration),a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0));const m=a.file.replace(ee(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");te.has(a.subKey)&&!s.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Y=!1;const Z=x(t=>{if(t.pkg?.dependencies?.typescript===void 0&&t.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"),He=x(async(t,s,e)=>{const r=t.types||t.typings;F.clear();const a=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),o=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),p=[];s.sort((n,c)=>n.split("/").length-c.split("/").length);const u=t.type==="module"?"esm":"cjs";u==="esm"&&(e.options.emitESM=!0),u==="cjs"&&(e.options.emitCJS=!0);const y=e.options.emitCJS&&e.options.emitESM;e.options.declaration===void 0&&(e.options.declaration=y?"compatible":"node16");const i=Ee(t.exports,u,e.options.declaration,[],e.options.ignoreExportKeys).filter(n=>!n.ignored);if(t.bin){const n=(typeof t.bin=="string"?[t.bin]:Object.values(t.bin)).filter(Boolean);for(const c of n){const g=_(c);if(g&&g!==u)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${t.type??"commonjs"}".`);i.push({file:c,isExecutable:!0,key:"bin",type:g??u})}}t.main&&i.push({file:t.main,key:"main",type:_(t.main)??u}),t.module&&i.push({file:t.module,key:"module",type:"esm"}),r&&(Z(e),(e.options.declaration===void 0||e.options.declaration==="node16")&&y&&(e.options.declaration="compatible"),i.push({file:t.types??t.typings,key:"types"}));const m=[];for await(const n of i){const c=ee(n.file);if(c!==""&&!ke.includes(c))continue;if(e.options.emitCJS===void 0&&n.type==="cjs"&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.type==="esm"&&(e.options.emitESM=!0),e.options.declaration===void 0||e.options.declaration==="node16"){const $=e.options.emitCJS&&e.options.emitESM;e.options.declaration=$?"compatible":"node16"}const g=n.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+|${[`\\.${a}`,`\\.${o}`].join("|")})$`),""),v=g.endsWith("/");if(v&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),l="(?<=/|$)",b=v?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${a}`,`\\.${o}`].join("|")})$`;if((n.file.includes("/*")||g.includes("*"))&&n.key==="exports"){Y||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Y=!0);let $;n.exportKey?$=n.exportKey.startsWith("./")?n.exportKey.slice(2):n.exportKey:$=(n.file.startsWith("./")?n.file.slice(2):n.file).replace(/^dist\//,"");const M=n.file,K=e.options.sourceDir.replace(/^\.\//,""),z=E(e.options.rootDir,K),A=[],ne=await ze(z);for(const T of ne){const L=We(T,$);if(L){const V=_e(M,L);A.push({input:E(z,T),output:V})}}if(A.length===0){p.push(`Could not find entrypoints matching pattern \`${$}\` for output \`${M}\``);continue}for(const{input:T,output:L}of A){const V={...n,file:L};O(m,T,v,g,V,e,!0)}continue}const f=new RegExp(l+d+b);let h=s.find($=>f.test($));if(te.has(n.subKey)&&h===void 0){const $=d.replace(/^(.+?)\.[^.]*$/,"$1"),M=new RegExp(l+$+b);h=s.find(K=>M.test(K))}if(h===void 0){j(E(e.options.rootDir,n.file))||p.push(`Could not find entrypoint for \`${n.file}\``);continue}j(h)&&/\.[cm]?tsx?$/.test(h)&&Z(e);const D=we(h.replace(Se,""));j(`${D}.cts`)&&j(`${D}.mts`)?(O(m,`${D}.cts`,v,g,{...n,type:"cjs"},e,!1),O(m,`${D}.mts`,v,g,{...n,type:"esm"},e,!1)):O(m,h,v,g,n,e,!1)}return{entries:m,warnings:p}},"inferEntries");var Ye=Object.defineProperty,Ze=k((t,s)=>Ye(t,"name",{value:s,configurable:!0}),"o");const Qe=Ze((t,s)=>{const{publishConfig:e}=t;return e&&(e.bin&&(typeof e.bin=="object"||typeof e.bin=="string")&&(t.bin=e.bin),e.type&&typeof e.type=="string"&&e.type!==""&&(t.type=e.type),e.main&&typeof e.main=="string"&&e.main!==""&&(t.main=e.main),e.module&&typeof e.module=="string"&&e.module!==""&&(t.module=e.module),s===void 0&&e.types&&typeof e.types=="string"&&e.types!==""?t.types=e.types:s===void 0&&e.typings&&typeof e.typings=="string"&&e.typings!==""&&(t.typings=e.typings),e.exports&&typeof e.exports=="object"&&(t.exports=e.exports)),t},"overwriteWithPublishConfig");var et=Object.defineProperty,tt=k((t,s)=>et(t,"name",{value:s,configurable:!0}),"t$1");const st={hooks:{"build:prepare":tt(async function(t){if(t.options.entries.length>0)return;const s=C(t.options.rootDir,t.options.sourceDir);if(!j(s))throw new Error("No 'src' directory found. Please provide entries manually.");const e=ge(s,{extensions:[],includeDirs:!1,includeSymlinks:!1,skip:[/.*\/node_modules\/.*/,/.*\/dist\/.*/]});if(e.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let r={...t.pkg};r.publishConfig&&(t.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(r.publishConfig).join(", ")}".`),t.logger.debug(r.publishConfig),r=Qe(r,t.options.declaration));const a=await He(r,e,t);for(const o of a.warnings)Pe(t,o);if(t.options.entries.push(...a.entries),t.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");t.logger.info("Automatically detected entries:",Ce(t.options.entries.map(o=>o.fileAlias?`${J(o.fileAlias)} => ${J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),De([t.options.emitESM&&"esm",t.options.emitCJS&&"cjs",t.options.declaration&&"dts"].filter(Boolean).map(o=>`[${o}]`).join(" ")))},"build:prepare")}};var ot=Object.defineProperty,it=k((t,s)=>ot(t,"name",{value:s,configurable:!0}),"t");const nt=it(async(t,s)=>{if(t==="auto")t=st;else{if(t==="none")return{};typeof t=="string"&&(t=await s.import(t)||{})}return typeof t=="function"&&(t=t()),t},"loadPreset");var at=Object.defineProperty,P=k((t,s)=>at(t,"name",{value:s,configurable:!0}),"r");const rt=P(t=>{t.addCommand({description:"Demonstrate options required",execute:P(async({logger:s,options:e})=>{let r="build";e.watch?r="watch":e.jit&&(r="jit");const a={};let o;if(e.env)for(const c of e.env)c.key==="NODE_ENV"?o=c.value:a[`process.env.${c.key}`]=JSON.stringify(c.value);o===void 0&&(e.production?o=B:e.development&&(o=G));const p=[];if(e.external)for(const c of e.external)p.push(c.split(","));const u=E(U(),e.dir??"."),y=je(u,{debug:e.debug}),{config:i,path:m}=await Re(y,u,o,r,e.config??void 0);s.debug("Using packem config found at",m);const n=await nt(i.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await Ie(u,r,o,s,e.debug,xe(i,n,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:p,killSignal:e.killSignal,minify:e.minify===void 0?o===B:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,replace:{values:a},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}}),e.tsconfig??void 0)}catch(c){s.error(c),ce(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{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:P(s=>{const[e,r]=s.split("=");return{key:e,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{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:P(s=>{if(s==="SIGTERM"||s==="SIGKILL")return s;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")},"type")},{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 (nodejs, browser).",name:"runtime",type:P(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var lt=Object.defineProperty,I=k((t,s)=>lt(t,"name",{value:s,configurable:!0}),"f");const ct=I(t=>{t.addCommand({description:"Initialize packem configuration",execute:I(async({logger:s,options:e})=>{if(pe("Welcome to packem setup"),j(C(e.dir,"packem.config.mjs"))){s.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=E(U(),e.dir??"."),a=C(r,"package.json");if(!j(a))throw new Error("No package.json found in the directory");const o=await Te(a,{resolveCatalogs:!0}),p=[];o.dependencies&&p.push(...Object.keys(o.dependencies)),o.devDependencies&&p.push(...Object.keys(o.devDependencies));const u=!!(o.devDependencies?.typescript??o.dependencies?.typescript),y=[];if(e.typescript===void 0&&!u?(e.typescript=await w({message:"Do you want to install TypeScript?"}),e.typescript&&y.push("typescript@latest")):W.message(`TypeScript version ${o.devDependencies?.typescript??o.dependencies?.typescript} is already installed`),!j(C(r,"tsconfig.json"))){const d=await w({message:"Do you want to use generate a tsconfig.json?"}),l=await w({message:"Do you want to run your code in the DOM?"});if(d){const b=R();b.start("Generating tsconfig.json"),ve(C(r,"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:l?["es2022","dom","dom.iterable"]:["es2022"]}}),b.stop("")}}if(e.runtime===void 0&&(e.runtime=await S({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),p.includes("esbuild")?e.transformer="esbuild":p.includes("@swc/core")?e.transformer="swc":p.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await S({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),e.transformer&&e.transformer!=="oxc"&&!p.includes(e.transformer)&&await w({message:`Do you want to install ${e.transformer}?`})&&y.push(e.transformer==="swc"?"@swc/core":e.transformer)):W.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await w({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await S({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:void 0}]}),e.isolatedDeclarationTransformer!==void 0)){let d;switch(e.isolatedDeclarationTransformer){case"oxc":{d="oxc-transform";break}case"swc":{d="@swc/core";break}case"typescript":{d="typescript";break}default:de("Invalid isolated declaration transformer")}d!==void 0&&!p.includes(d)&&await w({message:`Do you want to install ${d}?`})&&y.push(d)}e.css===void 0&&(e.css=await w({message:"Do you want to use css in your project?",initialValue:!1}));const i=[];if(e.css){const d=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});i.push(d);let l=await Q({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(l.includes("sass")){const b=await S({message:"Pick a sass loader",options:[{label:"Sass embedded",value:"sass-embedded",hint:"recommended"},{label:"Sass",value:"sass"},{label:"Node Sass",value:"node-sass",hint:"legacy"}]});b!=="sass"&&(l=l.filter(f=>f!=="sass"),l.push(b))}if(i.push(...l),await w({message:`Do you want to install "${i.join('", "')}"?`}))for(const b of i)y.push(...oe[b]);i.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await w({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),i.includes("lightningcss")||await w({message:`Do you want to install "${m}"?`})&&y.push(m));let n="",c="";if(e.isolatedDeclarationTransformer&&(c+=`,
29
29
  isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(c+=`,
30
30
  rollup: {
31
31
  css: {`),e.css){const d=i.map(l=>((l==="sass-embedded"||l==="node-sass")&&(l="sass"),`${l}Loader`)).join(", ");c+=`
@@ -52,4 +52,4 @@ module.exports = defineConfig({
52
52
  runtime: ${e.runtime},
53
53
  transformer${c}
54
54
  });
55
- `}const g=J(),v=u?"ts":"js";y.length>0&&(g.start("Installing packages"),await _(y,{cwd:r,dev:!0,silent:!0}),g.stop("Installed packages")),g.start(`Creating packem.config.${v}`),ke(C(r,`packem.config.${v}`),n),g.stop(`Created packem.config.${v}`),ge("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:M(t=>{if(typeof t=="string"&&["esbuild","sucrase","swc"].includes(t))return t;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")},"type")},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:M(t=>{if(typeof t=="string"&&["none","oxc","swc","typescript"].includes(t))return t;throw new Error("Invalid isolated declaration isolated declaration, please choose one of 'none', 'oxc', 'swc' or 'typescript'")},"type")},{description:"Use CSS",name:"css",type:Boolean},{description:"Use CSS minifier",name:"css-minifier",type:Boolean},{Description:"Use TypeScript",name:"typescript",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:M(t=>{if(t==="node"||t==="browser")return t;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createInitCommand");try{require("node:module")?.enableCompileCache?.()||require("v8-compile-cache")}catch{}const K=new de("packem",{logger:{reporters:[new ue({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Ke,packageVersion:qe});ms(K);ds(K);Je(K);K.run({shouldExitProcess:!1});
55
+ `}const g=R(),v=u?"ts":"js";y.length>0&&(g.start("Installing packages"),await q(y,{cwd:r,dev:!0,silent:!0}),g.stop("Installed packages")),g.start(`Creating packem.config.${v}`),be(C(r,`packem.config.${v}`),n),g.stop(`Created packem.config.${v}`),ue("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:I(s=>{if(typeof s=="string"&&["esbuild","sucrase","swc"].includes(s))return s;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")},"type")},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:I(s=>{if(typeof s=="string"&&["none","oxc","swc","typescript"].includes(s))return s;throw new Error("Invalid isolated declaration isolated declaration, please choose one of 'none', 'oxc', 'swc' or 'typescript'")},"type")},{description:"Use CSS",name:"css",type:Boolean},{description:"Use CSS minifier",name:"css-minifier",type:Boolean},{Description:"Use TypeScript",name:"typescript",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:I(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createInitCommand");try{require("node:module")?.enableCompileCache?.()||require("v8-compile-cache")}catch{}const N=new re("packem",{logger:{reporters:[new le({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Le,packageVersion:Oe});ct(N);rt(N);Ve(N);N.run({shouldExitProcess:!1});
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-B5hAMUkV.js';
2
- export { d as BuildHooks } from '../packem_shared/index-D09qw6EP.js';
1
+ import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-0Eba14hg.js';
2
+ export { d as BuildHooks } from '../packem_shared/index-Cjp2s4rr.js';
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/rollup-plugin-css';
5
5
  import 'jiti';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ConstructorOptions } from '@visulima/pail';
2
- import { B as BuildConfig } from './packem_shared/types-B5hAMUkV.js';
3
- export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-B5hAMUkV.js';
4
- import { E as Environment, M as Mode } from './packem_shared/index-D09qw6EP.js';
5
- export { B as BuildContext, b as BuildContextBuildAssetAndChunk, c as BuildContextBuildEntry, d as BuildHooks, I as IsolatedDeclarationsTransformer, R as Runtime, T as TransformerFn, a as TransformerName } from './packem_shared/index-D09qw6EP.js';
2
+ import { B as BuildConfig } from './packem_shared/types-0Eba14hg.js';
3
+ export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-0Eba14hg.js';
4
+ import { E as Environment, M as Mode } from './packem_shared/index-Cjp2s4rr.js';
5
+ export { B as BuildContext, b as BuildContextBuildAssetAndChunk, c as BuildContextBuildEntry, d as BuildHooks, I as IsolatedDeclarationsTransformer, R as Runtime, T as TransformerFn, a as TransformerName } from './packem_shared/index-Cjp2s4rr.js';
6
6
  import '@arethetypeswrong/core';
7
7
  import '@visulima/rollup-plugin-css';
8
8
  import 'jiti';
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";import{x as g}from"./packem_shared/index-CMiSObms.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
+ 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";import{x as g}from"./packem_shared/index-8EL_RHKk.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 +1 @@
1
- import{d as a}from"./isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js";import{z as s}from"./oxcResolvePlugin-Ccef6pyL-VBndJ7ld.js";import{n as x}from"./oxcTransformPlugin-DfVQouIB-Cpfv95eA.js";export{a as isolatedDeclarationsOxcTransformer,s as oxcResolvePlugin,x as oxcTransformPlugin};
1
+ import{d as a}from"./isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js";import{z as s}from"./oxcResolvePlugin-Ccef6pyL-D14z9S9i.js";import{n as x}from"./oxcTransformPlugin-DfVQouIB-Cpfv95eA.js";export{a as isolatedDeclarationsOxcTransformer,s as oxcResolvePlugin,x as oxcTransformPlugin};
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var n=(e,r)=>m(e,"name",{value:r,configurable:!0});import{createFilter as f}from"@rollup/pluginutils";import{f as l}from"./index-CUp9WuCG.js";import{transform as p}from"sucrase";var d=Object.defineProperty,v=n((e,r)=>d(e,"name",{value:r,configurable:!0}),"n"),b=Object.defineProperty,P=v((e,r)=>b(e,"name",{value:r,configurable:!0}),"a"),g=Object.defineProperty,y=P((e,r)=>g(e,"name",{value:r,configurable:!0}),"n");const o=y(({exclude:e,include:r,...t})=>{const c=f(r,e??l);return{name:"packem:sucrase",async transform(u,a){if(!c(a))return;const{code:s,sourceMap:i}=p(u,{...t,filePath:a,sourceMapOptions:{compiledFilename:a}});return{code:s,map:i}}}},"sucraseTransformPlugin");o.NAME="sucrase";const F=o;export{F as sucrasePlugin};
@@ -1 +1 @@
1
- import{v as r}from"./isolatedDeclarationsTypescriptTransformer-DkuEkofo-CfOpxpsh.js";import{B as o,B as p,N as t,D as a,i as c}from"./resolveTypescriptMjsCtsPlugin-DcZrZTmM-D4oir4A1.js";export{r as isolatedDeclarationsTypescriptTransformer,o as patchTypescriptTypes,p as patchTypescriptTypesPlugin,t as resolveTsconfigPathsPlugin,a as resolveTsconfigRootDirectoriesPlugin,c as resolveTypescriptMjsCtsPlugin};
1
+ import{v as r}from"./isolatedDeclarationsTypescriptTransformer-DkuEkofo-Cwe3ODMG.js";import{B as o,B as p,N as t,D as a,i as c}from"./resolveTypescriptMjsCtsPlugin-DcZrZTmM-3AmQC7y7.js";export{r as isolatedDeclarationsTypescriptTransformer,o as patchTypescriptTypes,p as patchTypescriptTypesPlugin,t as resolveTsconfigPathsPlugin,a as resolveTsconfigRootDirectoriesPlugin,c as resolveTypescriptMjsCtsPlugin};
@@ -1 +1 @@
1
- import{b as r}from"./browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js";import{z as e}from"./esbuildPlugin-DpLtQGuZ-DlbvGoD-.js";export{r as browserslistToEsbuild,e as esbuildPlugin};
1
+ import{b as r}from"./browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js";import{z as e}from"./esbuildPlugin-DpLtQGuZ-Bny-e486.js";export{r as browserslistToEsbuild,e as esbuildPlugin};
@@ -0,0 +1,3 @@
1
+ var x=Object.defineProperty;var v=(e,r)=>x(e,"name",{value:r,configurable:!0});import{createFilter as O}from"@rollup/pluginutils";import{a as k}from"./index-CUp9WuCG.js";import{extname as M,join as P}from"@visulima/path";import{transform as y,formatMessages as $,build as A}from"esbuild";import{findCacheDirSync as E}from"@visulima/find-cache-dir";import{readFileSync as S}from"@visulima/fs";import*as W from"rs-module-lexer";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ var C=Object.defineProperty,F=v((e,r)=>C(e,"name",{value:r,configurable:!0}),"h"),I=Object.defineProperty,f=F((e,r)=>I(e,"name",{value:r,configurable:!0}),"u"),R=Object.defineProperty,q=f((e,r)=>R(e,"name",{value:r,configurable:!0}),"n$1");const w=q(async(e,r)=>{r.length>0&&(await $(r,{color:!0,kind:"warning"})).forEach(s=>e.warn(s))},"warn");var L=Object.defineProperty,D=f((e,r)=>L(e,"name",{value:r,configurable:!0}),"t");const N=D(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),T=D(({sourceMap:e=!0,...r})=>async function(s,n,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=N(i.format),c=await y(s,{format:t,loader:"js",sourcemap:e,...r});if(await w(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var B=Object.defineProperty,j=f((e,r)=>B(e,"name",{value:r,configurable:!0}),"n");const h=j(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:G}=W,H=j(async e=>{const r=E("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await A({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",async setup(n){n.onResolve({filter:/.*/},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await n.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),n.onLoad({filter:/.*/,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,p=S(t),{output:g}=await G({input:[{code:p,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${h(t)}'`:`module.exports = require('${h(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const s=new Map;for(const n of e.include)s.set(n,{file:P(r,`${n}.js`)});return{cacheDir:r,optimized:s}},"optimizeDeps");var U=Object.defineProperty,J=f((e,r)=>U(e,"name",{value:r,configurable:!0}),"g");const K=J(({exclude:e,include:r,loaders:s,logger:n,optimizeDeps:i,sourceMap:t,...c})=>{const p=k;if(s!==void 0)for(let[o,a]of Object.entries(s)){const l=o.startsWith(".")?o:`.${o}`;typeof a=="string"?p[l]=a:a||delete p[l]}const g=Object.keys(p),z=new RegExp(`\\.(${g.map(o=>o.slice(1)).join("|")})$`),_=O(r??z,e);let u,b=process.cwd();return{async buildStart(){!i||u||(u=await H({cwd:b,sourceMap:t??!1,...i}),n.debug("optimized %O",u.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:T({...c,sourceMap:t}),async resolveId(o){if(u?.optimized.has(o)){const a=u.optimized.get(o);if(a)return n.debug("resolved %s to %s",o,a.file),a.file}},async transform(o,a){if(!_(a)||u?.optimized.has(a))return;const l=M(a),d=p[l];if(n.debug("transforming %s with %s loader",a,d),!d)return;const m=await y(o,{format:["base64","binary","dataurl","text","json"].includes(d)?"esm":void 0,loader:d,sourcefile:a.replace(/\.[cm]ts/,".ts"),sourcemap:t,...c});if(await w(this,m.warnings),m.code)return{code:m.code,map:m.map||void 0}}}},"esbuildTransformer");K.NAME="esbuild";export{K as z};