@visulima/packem 2.0.0-alpha.27 → 2.0.0-alpha.29

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 +23 -0
  2. package/README.md +1 -1
  3. package/dist/builder/typedoc/index.d.ts +4 -2
  4. package/dist/builder/typedoc/index.js +3 -3
  5. package/dist/cli/index.js +22 -22
  6. package/dist/config/index.d.ts +4 -2
  7. package/dist/index.d.ts +6 -4
  8. package/dist/index.js +1 -1
  9. package/dist/packem_shared/{default-Gd-5cD57.js → default-BGHvCOQE.js} +1 -1
  10. package/dist/packem_shared/default-BM-KR0tJ.js +1 -0
  11. package/dist/packem_shared/{default-Jms1t_Ru.js → default-D78T-lZt.js} +1 -1
  12. package/dist/packem_shared/{default-BOtIzYpr.js → default-DwVph-yx.js} +1 -1
  13. package/dist/packem_shared/esbuildPlugin-BrFhdKJk-BzTGlVjw.js +3 -0
  14. package/dist/packem_shared/{index-CFqWYreU.js → index-8sc8c1Ye.js} +87 -74
  15. package/dist/packem_shared/{index-B4tRN_2r.d.ts → index-BYO428ZM.d.ts} +93 -5
  16. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-CAV3IRk9.js +3 -0
  17. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-D88S5wUe.js +1 -0
  18. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-C40Ff4h5.js +6 -0
  19. package/dist/packem_shared/{types-CjNosz_D.d.ts → types-BXtpQcRr.d.ts} +1 -1
  20. package/dist/rollup/plugins/esbuild/index.d.ts +4 -2
  21. package/dist/rollup/plugins/esbuild/index.js +1 -1
  22. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +3 -1
  23. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +3 -1
  24. package/dist/rollup/plugins/sucrase/index.d.ts +3 -1
  25. package/dist/rollup/plugins/sucrase/index.js +1 -1
  26. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +9 -2
  27. package/dist/rollup/plugins/swc/swc-plugin.d.ts +4 -8
  28. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +3 -1
  29. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  30. package/package.json +12 -12
  31. package/dist/packem_shared/default-BSK7122E.js +0 -1
  32. package/dist/packem_shared/esbuildPlugin-BrFhdKJk-ByenQxgl.js +0 -3
  33. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-OpINP11F.js +0 -3
  34. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-Dnnq2zke.js +0 -1
  35. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-CKlu5gDZ.js +0 -6
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## @visulima/packem [2.0.0-alpha.29](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.28...@visulima/packem@2.0.0-alpha.29) (2025-10-12)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update readme ([3b5467f](https://github.com/visulima/packem/commit/3b5467f8ba57e39495582a8914d970fe455c70e8))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * add .cursorignore and update package.json for isolated transformers ([750e101](https://github.com/visulima/packem/commit/750e101a6d5b88f0b9a6c5952ee1223c825eb2ad))
10
+ * update pnpm workspace and package configurations ([feacec9](https://github.com/visulima/packem/commit/feacec93d1b0cefb8ea5d2b730fc1c6918925826))
11
+ * update TypeScript SDK path and adjust package dependencies ([b3a3661](https://github.com/visulima/packem/commit/b3a3661299bcb2343a0da19dddebb43678575750))
12
+
13
+ ## @visulima/packem [2.0.0-alpha.28](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.27...@visulima/packem@2.0.0-alpha.28) (2025-10-11)
14
+
15
+ ### Bug Fixes
16
+
17
+ * update dependencies and improve require CJS transformer ([a8d4fb7](https://github.com/visulima/packem/commit/a8d4fb7f35a313fd22c123b4b6487a346eb66e0a))
18
+
19
+
20
+ ### Dependencies
21
+
22
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.22
23
+
1
24
  ## @visulima/packem [2.0.0-alpha.27](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.26...@visulima/packem@2.0.0-alpha.27) (2025-10-08)
2
25
 
3
26
  ### Bug Fixes
package/README.md CHANGED
@@ -53,7 +53,7 @@ It uses the `exports` configuration in `package.json` and recognizes entry file
53
53
  - ✅ Supports react server and client components
54
54
  - ✅ Supports shared modules
55
55
  - ✅ Supports dynamic import
56
- - ✅ Supports `tsconfig.json` paths and `package.json` imports resolution
56
+ - ✅ Supports `tsconfig.json` paths and `package.json`, `package.yml`, `package.yaml` and `package.json5` imports resolution
57
57
  - ✅ ESM ⇄ CJS interoperability
58
58
  - ✅ Supports isolated declaration types (experimental) (Typescript version 5.5 or higher)
59
59
  - ✅ Supports wasm [WebAssembly modules](http://webassembly.org)
@@ -1,5 +1,5 @@
1
- import { B as BuildContext } from '../../packem_shared/index-B4tRN_2r.js';
2
- import { I as InternalBuildOptions } from '../../packem_shared/types-CjNosz_D.js';
1
+ import { B as BuildContext } from '../../packem_shared/index-BYO428ZM.js';
2
+ import { I as InternalBuildOptions } from '../../packem_shared/types-BXtpQcRr.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1,3 +1,3 @@
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{readFileSync as w,writeFileSync as b}from"@visulima/fs";import{Application as F}from"typedoc";const{readdirSync:A}=globalThis.process.getBuiltinModule("node:fs");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(f=>f.input),u=k??[];u.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&u.push("typedoc-plugin-markdown");const l=await F.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 f=A(a,{withFileTypes:!0}).filter(r=>r.isFile());let m="";for(const r of f)r.name==="README.md"&&o.length>1||(m+=w(h(a,r.name)).replaceAll(`<!-- ${i}`,`<!-- _REPLACE_${i}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${i}`));if(m!==""){const r=w(p),c=$(r,i,`
2
- ${m}`);if(!c){s.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${p}`,prefix:"typedoc"});return}if(r===c)return;c&&b(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};
1
+ var _=Object.defineProperty;var u=(e,o)=>_(e,"name",{value:o,configurable:!0});import{createRequire as v}from"node:module";import{cyan as b}from"@visulima/colorize";import{join as h}from"@visulima/path";import{p as P,d as A}from"../../packem_shared/create-or-update-key-storage-GwAIWW7R.js";import{readFileSync as w,writeFileSync as F}from"@visulima/fs";import{Application as R}from"typedoc";const E=v(import.meta.url),$=u(e=>{if(process.versions?.node){const[o,i]=process.versions.node.split(".").map(Number);if(o>22||o===22&&i>=3||o===20&&i>=16)return process.getBuiltinModule(e)}return E(e)},"__cjs_getBuiltinModule"),B=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{readdirSync:T}=$("node:fs");var C=Object.defineProperty,q=u((e,o)=>C(e,"name",{value:o,configurable:!0}),"w");const D=q(async(e,o,i,a)=>{if(o.length===0)return;const{format:t,jsonFileName:n,marker:r,output:L,plugin:j,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"&&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 k=o.map(m=>m.input),f=j??[];f.push("typedoc-plugin-rename-defaults"),(t==="inline"||t==="markdown")&&f.push("typedoc-plugin-markdown");const l=await R.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:k,hideGenerator:!0,out:i,plugin:f,...t==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),c=await l.convert();if(c){if(t==="json")await l.generateJson(c,n);else if(t==="html")await l.generateDocs(c,i);else if(await l.generateOutputs(c),t==="inline"){if(r===void 0)throw new Error("The `marker` option is required when using the `inline` format.");const m=T(i,{withFileTypes:!0}).filter(s=>s.isFile());let g="";for(const s of m)s.name==="README.md"&&o.length>1||(g+=w(h(i,s.name)).replaceAll(`<!-- ${r}`,`<!-- _REPLACE_${r}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${r}`));if(g!==""){const s=w(p),d=P(s,r,`
2
+ ${g}`);if(!d){a.error({message:`Could not find the typedoc marker: <!-- ${r} --><!-- /${r} --> in ${p}`,prefix:"typedoc"});return}if(s===d)return;d&&F(p,d.replaceAll(`<!-- _REPLACE_${r}`,`<!-- ${r}`).replaceAll(`<!-- _REPLACE_\\${r}`,"<!-- ${marker}"),{overwrite:!0})}}}},"generateReferenceDocumentation");var M=Object.defineProperty,x=u((e,o)=>M(e,"name",{value:o,configurable:!0}),"r");const G=x(async(e,o,i,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&&A("typedoc",o,e.logger,!0),a&&e.logger.raw(`
3
+ `),e.logger.info({message:`Using ${b("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 D(e.options.typedoc,e.options.entries,n,e.logger),await e.hooks.callHook("typedoc:done",e)}},"builder");export{G as default};
package/dist/cli/index.js CHANGED
@@ -1,55 +1,55 @@
1
1
  #!/usr/bin/env node
2
- var re=Object.defineProperty;var k=(s,t)=>re(s,"name",{value:t,configurable:!0});import le from"@visulima/cerebro";import{SimpleReporter as ce}from"@visulima/pail/reporter";import{installPackage as J}from"@antfu/install-pkg";import{spinner as R,select as S,multiselect as ee,confirm as w,intro as de,log as W,cancel as ue,outro as me}from"@clack/prompts";import{isAccessible as fe,readFile as ye,writeFile as ge,isAccessibleSync as j,collectSync as be,writeJsonSync as ve,writeFileSync as we}from"@visulima/fs";import{join as C,resolve as E,extname as se,toNamespacedPath as he}from"@visulima/path";import{t as O,E as G,e as ke,N as te,_ as Se,c as xe}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as Ce}from"jiti";import{cyan as De,bold as V,gray as Ee}from"@visulima/colorize";import{e as Pe,i as _,c as Te,x as Me}from"../packem_shared/index-CFqWYreU.js";import{parsePackageJson as Be}from"@visulima/package/package-json";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ var ce=Object.defineProperty;var w=(s,t)=>ce(s,"name",{value:t,configurable:!0});import{createRequire as le}from"node:module";import de from"@visulima/cerebro";import{SimpleReporter as ue}from"@visulima/pail/reporter";import{installPackage as V}from"@antfu/install-pkg";import{spinner as _,select as S,multiselect as se,confirm as h,intro as fe,log as W,cancel as ye,outro as ge}from"@clack/prompts";import{isAccessible as be,readFile as ve,writeFile as we,isAccessibleSync as x,collectSync as he,writeJsonSync as $e,writeFileSync as ke}from"@visulima/fs";import{join as C,resolve as E,extname as te,toNamespacedPath as Se}from"@visulima/path";import{t as O,E as J,e as xe,N as oe,_ as Ce,c as De}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as Pe}from"jiti";import{cyan as Te,bold as R,gray as Me}from"@visulima/colorize";import{e as Ie,i as X,c as Be,x as Le}from"../packem_shared/index-8sc8c1Ye.js";import{parsePackageJson as Ne}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 Q=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{cwd:U,exit:pe}=globalThis.process,$e=Q("magic-string"),{defu:je}=Q("defu"),Ie=globalThis.process.getBuiltinModule("node:fs/promises"),X=globalThis.process.getBuiltinModule("node:path/posix"),Le="@visulima/packem",Oe="2.0.0-alpha.26";var Ne=Object.defineProperty,Ke=k((s,t)=>Ne(s,"name",{value:t,configurable:!0}),"t$2");const oe=Ke(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 fe(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"),ie={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 Ae=Object.defineProperty,H=k((s,t)=>Ae(s,"name",{value:t,configurable:!0}),"g");const qe=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ve=H(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:H(async({argument:t,logger:e,options:r})=>{const a=R(),o=E(U(),r.dir??".");let p;try{p=await oe(o,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const u=await ye(p,{buffer:!1});let y="cjs";u.includes("import")&&(y="esm");const i=new $e(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 F=le(import.meta.url),ee=w(s=>{if(process.versions?.node){const[t,e]=process.versions.node.split(".").map(Number);if(t>22||t===22&&e>=3||t===20&&e>=16)return process.getBuiltinModule(s)}return F(s)},"__cjs_getBuiltinModule"),pe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{cwd:U,exit:me}=pe,je=F("magic-string"),{defu:Ee}=F("defu"),Oe=ee("node:fs/promises"),H=ee("node:path/posix"),Ke="@visulima/packem",qe="2.0.0-alpha.28";var Ae=Object.defineProperty,Re=w((s,t)=>Ae(s,"name",{value:t,configurable:!0}),"t$2");const ie=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 be(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"),ne={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,Y=w((s,t)=>Ve(s,"name",{value:t,configurable:!0}),"g");const _e=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Je=Y(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:Y(async({argument:t,logger:e,options:r})=>{const a=_(),o=E(U(),r.dir??".");let p;try{p=await ie(o,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const u=await ve(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");
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 J(qe,{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 ee({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 b=[];for(const f of c)b.push(...ie[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 V(_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 l=[],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(l.push(g),g!=="tailwindcss"){let f=await se({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($))}l.push(...f)}const b=[];for(const f of l)b.push(...ne[f]);g!=="tailwindcss"&&l.push("sourceMap");for(let f of l)(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 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")||b.push(l),y==="cjs"?i.prepend(`const ${l}Minifier = require("@visulima/packem/css/minifier/${l.toLowerCase()}");
15
- `):i.prepend(`import ${l}Minifier from "@visulima/packem/css/minifier/${l.toLowerCase()}";
16
- `));const v=c.map(f=>((f==="sass-embedded"||f==="node-sass")&&(f="sass"),`${f}Loader`)).join(", ");u.includes("rollup: {")?i.replace("rollup: {",`rollup: {
17
- css: {${l?`
18
- minifier: ${l}Minifier,`:""}
14
+ `);const d=await h({initialValue:!1,message:"Do you want to minify your css?"});let c;d&&(c=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),l.includes("lightningcss")||b.push(c),y==="cjs"?i.prepend(`const ${c}Minifier = require("@visulima/packem/css/minifier/${c.toLowerCase()}");
15
+ `):i.prepend(`import ${c}Minifier from "@visulima/packem/css/minifier/${c.toLowerCase()}";
16
+ `));const v=l.map(f=>((f==="sass-embedded"||f==="node-sass")&&(f="sass"),`${f}Loader`)).join(", ");u.includes("rollup: {")?i.replace("rollup: {",`rollup: {
17
+ css: {${c?`
18
+ minifier: ${c}Minifier,`:""}
19
19
  loaders: [${v}],
20
20
  },
21
21
  `):i.replace(n,`${m}
22
22
  rollup: {
23
- css: {${l?`
24
- minifier: ${l}Minifier,`:""}
23
+ css: {${c?`
24
+ minifier: ${c}Minifier,`:""}
25
25
  loaders: [${v}],
26
26
  },
27
- },`),a.start("Installing packages"),await J(b,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
28
- CSS loaders added!`)}await ge(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,Re=k((s,t)=>Je(s,"name",{value:t,configurable:!0}),"e$1");const Ge=Re(async(s,t,e,r,a)=>{const o=await oe(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 Fe=Object.defineProperty,x=k((s,t)=>Fe(s,"name",{value:t,configurable:!0}),"u$1");const F=new Map,Ue=/\.[^./]+$/,ze=x(async s=>{try{return await Ie.readdir(s,{withFileTypes:!0})}catch(t){const{code:e}=t;if(e==="ENOENT")return[];throw t}},"safeReaddir"),ne=x(async(s,t)=>{const e=await ze(s);return(await Promise.all(e.map(async r=>{const a=X.join(s,r.name);return r.isDirectory()?ne(a,t):r.isFile()?X.relative(t,a):[]}))).flat()},"getDirectoryFilesRecursive"),We=x(async s=>{let t=F.get(s);return t||(t=ne(s,s),F.set(s,t)),t},"getDirectoryFiles"),_e=x((s,t)=>{const e=s.replace(Ue,"");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"),Xe=x((s,t)=>{let e=s;for(const r of t)e=e.replace("*",r);return e},"substituteWildcards"),He=x((s,t)=>s.key==="exports"&&s.subKey===O?O:s.key==="exports"&&s.subKey===G?G:t,"getEnvironment"),L=x((s,t,e,r,a,o,p)=>{const u=He(a,o.environment);let y=o.options.runtime;for(const n of ke)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(se(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");te.has(a.subKey)&&!t.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Y=!1;const Z=x(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"),Ye=x(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=Pe(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=_(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:_(s.main)??u}),s.module&&i.push({file:s.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:s.types??s.typings,key:"types"}));const m=[];for await(const n of i){const c=se(n.file);if(c!==""&&!Se.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("|")})$`),""),b=g.endsWith("/");if(b&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),l="(?<=/|$)",v=b?"":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=[],ae=await We(z);for(const I of ae){const B=_e(I,$);if(B){const q=Xe(M,B);A.push({input:E(z,I),output:q})}}if(A.length===0){p.push(`Could not find entrypoints matching pattern \`${$}\` for output \`${M}\``);continue}for(const{input:I,output:B}of A){const q={...n,file:B};L(m,I,b,g,q,e,!0)}continue}const f=new RegExp(l+d+v);let h=t.find($=>f.test($));if(te.has(n.subKey)&&h===void 0){const $=d.replace(/^(.+?)\.[^.]*$/,"$1"),M=new RegExp(l+$+v);h=t.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=he(h.replace(xe,""));j(`${D}.cts`)&&j(`${D}.mts`)?(L(m,`${D}.cts`,b,g,{...n,type:"cjs"},e,!1),L(m,`${D}.mts`,b,g,{...n,type:"esm"},e,!1)):L(m,h,b,g,n,e,!1)}return{entries:m,warnings:p}},"inferEntries");var Ze=Object.defineProperty,Qe=k((s,t)=>Ze(s,"name",{value:t,configurable:!0}),"o");const es=Qe((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 ss=Object.defineProperty,ts=k((s,t)=>ss(s,"name",{value:t,configurable:!0}),"t$1");const os={hooks:{"build:prepare":ts(async function(s){if(s.options.entries.length>0)return;const t=C(s.options.rootDir,s.options.sourceDir);if(!j(t))throw new Error("No 'src' directory found. Please provide entries manually.");const e=be(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=es(r,s.options.declaration));const a=await Ye(r,e,s);for(const o of a.warnings)Te(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:",De(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(", ")),Ee([s.options.emitESM&&"esm",s.options.emitCJS&&"cjs",s.options.declaration&&"dts"].filter(Boolean).map(o=>`[${o}]`).join(" ")))},"build:prepare")}};var is=Object.defineProperty,ns=k((s,t)=>is(s,"name",{value:t,configurable:!0}),"t");const as=ns(async(s,t)=>{if(s==="auto")s=os;else{if(s==="none")return{};typeof s=="string"&&(s=await t.import(s)||{})}return typeof s=="function"&&(s=s()),s},"loadPreset");var rs=Object.defineProperty,P=k((s,t)=>rs(s,"name",{value:t,configurable:!0}),"r");const ls=P(s=>{s.addCommand({description:"Demonstrate options required",execute:P(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=O: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=Ce(u,{debug:e.debug}),{config:i,path:m}=await Ge(y,u,o,r,e.config??void 0);t.debug("Using packem config found at",m);const n=await as(i.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await Me(u,r,o,t,e.debug,je(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===O: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),pe(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(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:P(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:P(t=>{if(t==="node"||t==="browser")return t;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var cs=Object.defineProperty,T=k((s,t)=>cs(s,"name",{value:t,configurable:!0}),"f");const ps=T(s=>{s.addCommand({description:"Initialize packem configuration",execute:T(async({logger:t,options:e})=>{if(de("Welcome to packem setup"),j(C(e.dir,"packem.config.mjs"))){t.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 Be(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 v=R();v.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"]}}),v.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:ue("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 ee({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(l.includes("sass")){const v=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"}]});v!=="sass"&&(l=l.filter(f=>f!=="sass"),l.push(v))}if(i.push(...l),await w({message:`Do you want to install "${i.join('", "')}"?`}))for(const v of i)y.push(...ie[v]);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
- isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(c+=`,
27
+ },`),a.start("Installing packages"),await V(b,{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 ie(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 G=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"),ae=j(async(s,t)=>{const e=await Xe(s);return(await Promise.all(e.map(async r=>{const a=H.join(s,r.name);return r.isDirectory()?ae(a,t):r.isFile()?H.relative(t,a):[]}))).flat()},"getDirectoryFilesRecursive"),He=j(async s=>{let t=G.get(s);return t||(t=ae(s,s),G.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===O?O:s.key==="exports"&&s.subKey===J?J:t,"getEnvironment"),L=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(te(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");oe.has(a.subKey)&&!t.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Z=!1;const Q=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;G.clear();const a=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),o=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),p=[];t.sort((n,l)=>n.split("/").length-l.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 l of n){const g=X(l);if(g&&g!==u)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${s.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:g??u})}}s.main&&i.push({file:s.main,key:"main",type:X(s.main)??u}),s.module&&i.push({file:s.module,key:"module",type:"esm"}),r&&(Q(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 l=te(n.file);if(l!==""&&!Ce.includes(l))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("|")})$`),""),b=g.endsWith("/");if(b&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),c="(?<=/|$)",v=b?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${a}`,`\\.${o}`].join("|")})$`;if((n.file.includes("/*")||g.includes("*"))&&n.key==="exports"){Z||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Z=!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 M=n.file,K=e.options.sourceDir.replace(/^\.\//,""),z=E(e.options.rootDir,K),q=[],re=await He(z);for(const I of re){const B=Ye(I,k);if(B){const A=Ze(M,B);q.push({input:E(z,I),output:A})}}if(q.length===0){p.push(`Could not find entrypoints matching pattern \`${k}\` for output \`${M}\``);continue}for(const{input:I,output:B}of q){const A={...n,file:B};L(m,I,b,g,A,e,!0)}continue}const f=new RegExp(c+d+v);let $=t.find(k=>f.test(k));if(oe.has(n.subKey)&&$===void 0){const k=d.replace(/^(.+?)\.[^.]*$/,"$1"),M=new RegExp(c+k+v);$=t.find(K=>M.test(K))}if($===void 0){x(E(e.options.rootDir,n.file))||p.push(`Could not find entrypoint for \`${n.file}\``);continue}x($)&&/\.[cm]?tsx?$/.test($)&&Q(e);const D=Se($.replace(De,""));x(`${D}.cts`)&&x(`${D}.mts`)?(L(m,`${D}.cts`,b,g,{...n,type:"cjs"},e,!1),L(m,`${D}.mts`,b,g,{...n,type:"esm"},e,!1)):L(m,$,b,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?`${R(o.fileAlias)} => ${R(o.input.replace(`${s.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:R(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,cs=w((s,t)=>rs(s,"name",{value:t,configurable:!0}),"t");const ls=cs(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,P=w((s,t)=>ps(s,"name",{value:t,configurable:!0}),"r");const ds=P(s=>{s.addCommand({description:"Demonstrate options required",execute:P(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 l of e.env)l.key==="NODE_ENV"?o=l.value:a[`process.env.${l.key}`]=JSON.stringify(l.value);o===void 0&&(e.production?o=O:e.development&&(o=J));const p=[];if(e.external)for(const l of e.external)p.push(l.split(","));const u=E(U(),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 ls(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===O: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(l){t.error(l),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:P(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:P(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:P(t=>{if(t==="node"||t==="browser")return t;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var us=Object.defineProperty,T=w((s,t)=>us(s,"name",{value:t,configurable:!0}),"f");const ms=T(s=>{s.addCommand({description:"Initialize packem configuration",execute:T(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=E(U(),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")):W.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?"}),c=await h({message:"Do you want to run your code in the DOM?"});if(d){const v=_();v.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:c?["es2022","dom","dom.iterable"]:["es2022"]}}),v.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)):W.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 c=await se({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(c.includes("sass")){const v=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"}]});v!=="sass"&&(c=c.filter(f=>f!=="sass"),c.push(v))}if(i.push(...c),await h({message:`Do you want to install "${i.join('", "')}"?`}))for(const v of i)y.push(...ne[v]);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="",l="";if(e.isolatedDeclarationTransformer&&(l+=`,
29
+ isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(l+=`,
30
30
  rollup: {
31
- css: {`),e.css){const d=i.map(l=>((l==="sass-embedded"||l==="node-sass")&&(l="sass"),`${l}Loader`)).join(", ");c+=`
32
- loaders: [${d}],`}if(e.cssMinifier&&m&&(c+=`
33
- minifier: ${m}Minifier,`),(e.css||e.cssMinifier)&&(c+=`
31
+ css: {`),e.css){const d=i.map(c=>((c==="sass-embedded"||c==="node-sass")&&(c="sass"),`${c}Loader`)).join(", ");l+=`
32
+ loaders: [${d}],`}if(e.cssMinifier&&m&&(l+=`
33
+ minifier: ${m}Minifier,`),(e.css||e.cssMinifier)&&(l+=`
34
34
  }
35
35
  }`),u||o.type==="module"){let d="";if(e.isolatedDeclarationTransformer&&(d+=`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
36
- `),e.css)for(let l of i)(l==="sass-embedded"||l==="node-sass")&&(l="sass"),d+=`import ${l}Loader from "@visulima/packem/css/loader/${l.toLowerCase()}";
36
+ `),e.css)for(let c of i)(c==="sass-embedded"||c==="node-sass")&&(c="sass"),d+=`import ${c}Loader from "@visulima/packem/css/loader/${c.toLowerCase()}";
37
37
  `;e.cssMinifier&&m&&(d+=`import ${m}Minifier from "@visulima/packem/css/minifier/${m.toLowerCase()}";
38
38
  `),n=`import { defineConfig } from "@visulima/packem/config";
39
39
  import transformer from "@visulima/packem/transformer/${e.transformer}";
40
40
  ${d}
41
41
  export default defineConfig({
42
42
  runtime: "${e.runtime}",
43
- transformer${c}
43
+ transformer${l}
44
44
  });
45
45
  `}else{let d="";if(e.isolatedDeclarationTransformer&&(d+=`const isolatedDeclarationTransformer = require("@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}");
46
- `),e.css)for(let l of i)(l==="sass-embedded"||l==="node-sass")&&(l="sass"),d+=`const ${l}Loader = require("@visulima/packem/css/loader/${l.toLowerCase()}");
46
+ `),e.css)for(let c of i)(c==="sass-embedded"||c==="node-sass")&&(c="sass"),d+=`const ${c}Loader = require("@visulima/packem/css/loader/${c.toLowerCase()}");
47
47
  `;e.cssMinifier&&m&&(d+=`const ${m}Minifier = require("@visulima/packem/css/minifier/${m.toLowerCase()}");
48
48
  `),n=`const { defineConfig } = require("@visulima/packem/config");
49
49
  const transformer = require("@visulima/packem/transformer/${e.transformer}");
50
50
  ${d}
51
51
  module.exports = defineConfig({
52
52
  runtime: ${e.runtime},
53
- transformer${c}
53
+ transformer${l}
54
54
  });
55
- `}const g=R(),b=u?"ts":"js";y.length>0&&(g.start("Installing packages"),await J(y,{cwd:r,dev:!0,silent:!0}),g.stop("Installed packages")),g.start(`Creating packem.config.${b}`),we(C(r,`packem.config.${b}`),n),g.stop(`Created packem.config.${b}`),me("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:T(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:T(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:T(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 N=new le("packem",{logger:{reporters:[new ce({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Le,packageVersion:Oe});ps(N);ls(N);Ve(N);N.run({shouldExitProcess:!1});
55
+ `}const g=_(),b=u?"ts":"js";y.length>0&&(g.start("Installing packages"),await V(y,{cwd:r,dev:!0,silent:!0}),g.stop("Installed packages")),g.start(`Creating packem.config.${b}`),ke(C(r,`packem.config.${b}`),n),g.stop(`Created packem.config.${b}`),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:T(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:T(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:T(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 N=new de("packem",{logger:{reporters:[new ue({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Ke,packageVersion:qe});ms(N);ds(N);Je(N);N.run({shouldExitProcess:!1});
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-CjNosz_D.js';
2
- export { d as BuildHooks } from '../packem_shared/index-B4tRN_2r.js';
1
+ import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-BXtpQcRr.js';
2
+ export { d as BuildHooks } from '../packem_shared/index-BYO428ZM.js';
3
3
  import '@arethetypeswrong/core';
4
4
  import '@visulima/rollup-plugin-css';
5
5
  import 'jiti';
@@ -16,6 +16,8 @@ import 'rollup-plugin-dts';
16
16
  import 'rollup-plugin-polyfill-node';
17
17
  import 'rollup-plugin-pure';
18
18
  import 'rollup-plugin-visualizer';
19
+ import 'magic-string';
20
+ import 'html-minifier-next';
19
21
  import 'esbuild';
20
22
  import '@visulima/package';
21
23
  import '@visulima/colorize';
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-CjNosz_D.js';
3
- export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-CjNosz_D.js';
4
- import { E as Environment, M as Mode } from './packem_shared/index-B4tRN_2r.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-B4tRN_2r.js';
2
+ import { B as BuildConfig } from './packem_shared/types-BXtpQcRr.js';
3
+ export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-BXtpQcRr.js';
4
+ import { E as Environment, M as Mode } from './packem_shared/index-BYO428ZM.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-BYO428ZM.js';
6
6
  import '@arethetypeswrong/core';
7
7
  import '@visulima/rollup-plugin-css';
8
8
  import 'jiti';
@@ -19,6 +19,8 @@ import 'rollup-plugin-dts';
19
19
  import 'rollup-plugin-polyfill-node';
20
20
  import 'rollup-plugin-pure';
21
21
  import 'rollup-plugin-visualizer';
22
+ import 'magic-string';
23
+ import 'html-minifier-next';
22
24
  import 'esbuild';
23
25
  import '@visulima/package';
24
26
  import '@visulima/colorize';
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-CFqWYreU.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-8sc8c1Ye.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{b as r}from"./browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js";import{z as e}from"./esbuildPlugin-BrFhdKJk-ByenQxgl.js";export{r as browserslistToEsbuild,e as esbuildPlugin};
1
+ import{b as r}from"./browserslistToEsbuild-C0IWmbNe-C6xPL1oW.js";import{z as e}from"./esbuildPlugin-BrFhdKJk-BzTGlVjw.js";export{r as browserslistToEsbuild,e as esbuildPlugin};
@@ -0,0 +1 @@
1
+ var l=Object.defineProperty;var o=(e,r)=>l(e,"name",{value:r,configurable:!0});import{createRequire as f}from"node:module";import{createFilter as m}from"@rollup/pluginutils";import{f as d}from"./index-CUp9WuCG.js";const p=f(import.meta.url);const O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transform:b}=p("sucrase");var _=Object.defineProperty,g=o((e,r)=>_(e,"name",{value:r,configurable:!0}),"n"),v=Object.defineProperty,j=g((e,r)=>v(e,"name",{value:r,configurable:!0}),"a"),P=Object.defineProperty,y=j((e,r)=>P(e,"name",{value:r,configurable:!0}),"n");const n=y(({exclude:e,include:r,...t})=>{const c=m(r,e??d);return{name:"packem:sucrase",async transform(a,s){if(!c(s))return;const{code:i,sourceMap:u}=b(a,{...t,filePath:s,sourceMapOptions:{compiledFilename:s}});return{code:i,map:u}}}},"sucraseTransformPlugin");n.NAME="sucrase";const x=n;export{x as sucrasePlugin};
@@ -1 +1 @@
1
- import{v as r}from"./isolatedDeclarationsTypescriptTransformer-DkuEkofo-OpINP11F.js";import{B as o,B as p,N as t,D as a,i as c}from"./resolveTypescriptMjsCtsPlugin-DcZrZTmM-CKlu5gDZ.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-CAV3IRk9.js";import{B as o,B as p,N as t,D as a,i as c}from"./resolveTypescriptMjsCtsPlugin-DcZrZTmM-C40Ff4h5.js";export{r as isolatedDeclarationsTypescriptTransformer,o as patchTypescriptTypes,p as patchTypescriptTypesPlugin,t as resolveTsconfigPathsPlugin,a as resolveTsconfigRootDirectoriesPlugin,c as resolveTypescriptMjsCtsPlugin};
@@ -1 +1 @@
1
- import{d as a}from"./isolatedDeclarationsOxcTransformer-WbfE6cGu-NeZOx2Y7.js";import{z as s}from"./oxcResolvePlugin-BJpi-eSG-Dnnq2zke.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-BJpi-eSG-D88S5wUe.js";import{n as x}from"./oxcTransformPlugin-DfVQouIB-Cpfv95eA.js";export{a as isolatedDeclarationsOxcTransformer,s as oxcResolvePlugin,x as oxcTransformPlugin};
@@ -0,0 +1,3 @@
1
+ var k=Object.defineProperty;var v=(e,r)=>k(e,"name",{value:r,configurable:!0});import{createRequire as M}from"node:module";import{createFilter as P}from"@rollup/pluginutils";import{a as A}from"./index-CUp9WuCG.js";import{extname as $,join as q}from"@visulima/path";import{findCacheDirSync as T}from"@visulima/find-cache-dir";import{readFileSync as S}from"@visulima/fs";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const _=M(import.meta.url);const ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transform:w,formatMessages:E,build:R}=_("esbuild"),h=_("rs-module-lexer"),W={...h,default:h};var B=Object.defineProperty,C=v((e,r)=>B(e,"name",{value:r,configurable:!0}),"h"),F=Object.defineProperty,f=C((e,r)=>F(e,"name",{value:r,configurable:!0}),"u"),I=Object.defineProperty,N=f((e,r)=>I(e,"name",{value:r,configurable:!0}),"n$1");const j=N(async(e,r)=>{r.length>0&&(await E(r,{color:!0,kind:"warning"})).forEach(a=>e.warn(a))},"warn");var L=Object.defineProperty,D=f((e,r)=>L(e,"name",{value:r,configurable:!0}),"t");const G=D(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),H=D(({sourceMap:e=!0,...r})=>async function(a,n,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=G(i.format),c=await w(a,{format:t,loader:"js",sourcemap:e,...r});if(await j(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var U=Object.defineProperty,z=f((e,r)=>U(e,"name",{value:r,configurable:!0}),"n");const y=z(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:J}=W,K=z(async e=>{const r=T("@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 R({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,u=S(t),{output:g}=await J({input:[{code:u,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${y(t)}'`:`module.exports = require('${y(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const a=new Map;for(const n of e.include)a.set(n,{file:q(r,`${n}.js`)});return{cacheDir:r,optimized:a}},"optimizeDeps");var Q=Object.defineProperty,V=f((e,r)=>Q(e,"name",{value:r,configurable:!0}),"g");const X=V(({exclude:e,include:r,loaders:a,logger:n,optimizeDeps:i,sourceMap:t,...c})=>{const u=A;if(a!==void 0)for(let[o,s]of Object.entries(a)){const p=o.startsWith(".")?o:`.${o}`;typeof s=="string"?u[p]=s:s||delete u[p]}const g=Object.keys(u),x=new RegExp(`\\.(${g.map(o=>o.slice(1)).join("|")})$`),O=P(r??x,e);let l,b=process.cwd();return{async buildStart(){!i||l||(l=await K({cwd:b,sourceMap:t??!1,...i}),n.debug("optimized %O",l.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:H({...c,sourceMap:t}),async resolveId(o){if(l?.optimized.has(o)){const s=l.optimized.get(o);if(s)return n.debug("resolved %s to %s",o,s.file),s.file}},async transform(o,s){if(!O(s)||l?.optimized.has(s))return;const p=$(s),d=u[p];if(n.debug("transforming %s with %s loader",s,d),!d)return;const m=await w(o,{format:["base64","binary","dataurl","text","json"].includes(d)?"esm":void 0,loader:d,sourcefile:s.replace(/\.[cm]ts/,".ts"),sourcemap:t,...c});if(await j(this,m.warnings),m.code)return{code:m.code,map:m.map||void 0}}}},"esbuildTransformer");X.NAME="esbuild";export{X as z};