@visulima/packem 2.0.0-alpha.24 → 2.0.0-alpha.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## @visulima/packem [2.0.0-alpha.26](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.25...@visulima/packem@2.0.0-alpha.26) (2025-10-08)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update dependencies and improve minification options ([25b69b5](https://github.com/visulima/packem/commit/25b69b50f7631655303a417e61f3a37e2aa3c017))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.21
11
+
12
+ ## @visulima/packem [2.0.0-alpha.25](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.24...@visulima/packem@2.0.0-alpha.25) (2025-10-08)
13
+
14
+ ### Bug Fixes
15
+
16
+ * enhance package-json-exports and preserve-directives tests ([c3b58f2](https://github.com/visulima/packem/commit/c3b58f251ea9ed3d8747a967b6f53fd4c1773509))
17
+
18
+ ### Miscellaneous Chores
19
+
20
+ * update dependencies and add minify-html-literals plugin ([e20007d](https://github.com/visulima/packem/commit/e20007ddf3cbb80c34c323ed37164baaf6f9a649))
21
+ * update dependencies and improve package validation tests ([b4fd83b](https://github.com/visulima/packem/commit/b4fd83bf3f5749d53c1c01eaf10d61f88530d9f4))
22
+
23
+ ### Tests
24
+
25
+ * enhance infer-entries and package validation tests ([42624c1](https://github.com/visulima/packem/commit/42624c1b14f937e4365222753ace3f4b4b0d9b3c))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.20
31
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.13
32
+ * **@visulima/rollup-plugin-css:** upgraded to 1.0.0-alpha.7
33
+
1
34
  ## @visulima/packem [2.0.0-alpha.24](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.23...@visulima/packem@2.0.0-alpha.24) (2025-10-07)
2
35
 
3
36
  ### Bug Fixes
@@ -1,5 +1,5 @@
1
- import { B as BuildContext } from '../../packem_shared/index-DrmPUIt8.js';
2
- import { I as InternalBuildOptions } from '../../packem_shared/types-Hhg8-okS.js';
1
+ import { B as BuildContext } from '../../packem_shared/index-B4tRN_2r.js';
2
+ import { I as InternalBuildOptions } from '../../packem_shared/types-CjNosz_D.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
package/dist/cli/index.js CHANGED
@@ -1,55 +1,55 @@
1
1
  #!/usr/bin/env node
2
- var Q=Object.defineProperty;var k=(s,t)=>Q(s,"name",{value:t,configurable:!0});import Z from"@visulima/cerebro";import{SimpleReporter as ee}from"@visulima/pail/reporter";import{installPackage as N}from"@antfu/install-pkg";import{spinner as K,select as $,multiselect as F,confirm as w,intro as te,log as R,cancel as oe,outro as ie}from"@clack/prompts";import{isAccessible as ne,readFile as ae,writeFile as re,isAccessibleSync as S,collectSync as le,writeJsonSync as ce,writeFileSync as pe}from"@visulima/fs";import{join as x,resolve as T,extname as W,toNamespacedPath as de}from"@visulima/path";import{t as I,E as q,e as me,N as V,_ as fe,c as ye}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as ve}from"jiti";import{cyan as be,bold as O,gray as we}from"@visulima/colorize";import{e as he,i as G,c as ke,x as $e}from"../packem_shared/index-DQUk9_13.js";import{parsePackageJson as Se}from"@visulima/package/package-json";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
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-KjC11dSQ.js";import{parsePackageJson as Be}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 _=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{cwd:A,exit:se}=globalThis.process,ue=_("magic-string"),{defu:ge}=_("defu"),xe="@visulima/packem",je="2.0.0-alpha.23";var Ce=Object.defineProperty,Ee=k((s,t)=>Ce(s,"name",{value:t,configurable:!0}),"t$2");const X=Ee(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 n of r)if(await ne(x(s,n))){e=`./${n}`;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"),H={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 De=Object.defineProperty,J=k((s,t)=>De(s,"name",{value:t,configurable:!0}),"g");const Pe=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ie=J(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:J(async({argument:t,logger:e,options:r})=>{const n=K(),i=T(A(),r.dir??".");let d;try{d=await X(i,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const f=await ae(d,{buffer:!1});let y="cjs";f.includes("import")&&(y="esm");const o=new ue(f),u=" transformer,";let p=" transformer";if(f.includes(" transformer,")&&(p=" transformer,"),t.includes("typedoc")){if(f.includes("typedoc: typedocBuilder")||f.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}y==="cjs"?o.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
5
- `):o.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
6
- `),f.includes("builder: {")?o.replace("builder: {",`builder: {
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.25";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");
5
+ `):i.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
6
+ `),u.includes("builder: {")?i.replace("builder: {",`builder: {
7
7
  typedoc: typedocBuilder,
8
- `):o.replace(p,`${u}
8
+ `):i.replace(n,`${m}
9
9
  builder: {
10
10
  typedoc: typedocBuilder,
11
- },`),e.info("Adding typedoc dependencies..."),n.start("Installing packages"),await N(Pe,{cwd:i,dev:!0,silent:!0}),n.stop("Installed packages"),e.success(`
12
- Typedoc added!`)}if(t.includes("css")){if(f.includes("css: {")||f.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const l=[],v=await $({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(v),v!=="tailwindcss"){let m=await F({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(m.includes("sass")){const h=await $({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"&&(m=m.filter(j=>j!=="sass"),m.push(h))}l.push(...m)}const b=[];for(const m of l)b.push(...H[m]);v!=="tailwindcss"&&l.push("sourceMap");for(let m of l)(m==="sass-embedded"||m==="node-sass")&&(m="sass"),y==="cjs"?o.prepend(`const ${m}Loader = require("@visulima/packem/css/loader/${m.toLowerCase()}");
13
- `):o.prepend(`import ${m}Loader from "@visulima/packem/css/loader/${m.toLowerCase()}";
14
- `);const c=await w({initialValue:!1,message:"Do you want to minify your css?"});let a;c&&(a=await $({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),l.includes("lightningcss")||b.push(a),y==="cjs"?o.prepend(`const ${a}Minifier = require("@visulima/packem/css/minifier/${a.toLowerCase()}");
15
- `):o.prepend(`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
16
- `));const g=l.map(m=>((m==="sass-embedded"||m==="node-sass")&&(m="sass"),`${m}Loader`)).join(", ");f.includes("rollup: {")?o.replace("rollup: {",`rollup: {
17
- css: {${a?`
18
- minifier: ${a}Minifier,`:""}
19
- loaders: [${g}],
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()}");
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,`:""}
19
+ loaders: [${v}],
20
20
  },
21
- `):o.replace(p,`${u}
21
+ `):i.replace(n,`${m}
22
22
  rollup: {
23
- css: {${a?`
24
- minifier: ${a}Minifier,`:""}
25
- loaders: [${g}],
23
+ css: {${l?`
24
+ minifier: ${l}Minifier,`:""}
25
+ loaders: [${v}],
26
26
  },
27
- },`),n.start("Installing packages"),await N(b,{cwd:i,dev:!0,silent:!0}),n.stop("Installed packages"),e.success(`
28
- CSS loaders added!`)}await re(d,o.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 Te=Object.defineProperty,Me=k((s,t)=>Te(s,"name",{value:t,configurable:!0}),"e$1");const Be=Me(async(s,t,e,r,n)=>{const i=await X(t,n);let d=await s.import(i,{default:!0,try:!0})||{};return typeof d=="function"&&(d=await d(e,r)),{config:d,path:i}},"loadPackemConfig");var Le=Object.defineProperty,M=k((s,t)=>Le(s,"name",{value:t,configurable:!0}),"E$1");const Oe=M((s,t)=>s.key==="exports"&&s.subKey===I?I:s.key==="exports"&&s.subKey===q?q:t,"getEnvironment"),P=M((s,t,e,r,n,i,d)=>{const f=Oe(n,i.environment);let y=i.options.runtime;for(const p of me)if(n.file.includes(`.${p}.`)||n.subKey===p){y=p;break}let o=s.find(p=>p.input===t&&p.environment===f&&p.runtime===y);o===void 0?o=s[s.push({environment:f,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:y})-1]:o.exportKey&&n.exportKey&&o.exportKey.add(n.exportKey),d&&(o.isGlob=!0),e&&(o.outDir=r),n.isExecutable?(o.executable=!0,o.declaration=!1,n.type==="cjs"?o.cjs=!0:n.type==="esm"&&(o.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(o.declaration=i.options.declaration),n.type==="cjs"?o.cjs=!0:n.type==="esm"&&(o.esm=!0));const u=n.file.replace(W(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");V.has(n.subKey)&&!t.includes(u)&&(o.fileAlias=u)},"createOrUpdateEntry");let U=!1;const z=M(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"),Ne=M((s,t,e)=>{const r=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),n=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),i=[];t.sort((o,u)=>o.split("/").length-u.split("/").length);const d=s.type==="module"?"esm":"cjs";d==="esm"&&(e.options.emitESM=!0),d==="cjs"&&(e.options.emitCJS=!0);const f=he(s.exports,d,e.options.declaration,[],e.options.ignoreExportKeys).filter(o=>!o.ignored);if(s.bin){const o=(typeof s.bin=="string"?[s.bin]:Object.values(s.bin)).filter(Boolean);for(const u of o){const p=G(u);if(p&&p!==d)throw new Error(`Exported file "${u}" has an extension that does not match the package.json type "${s.type??"commonjs"}".`);f.push({file:u,isExecutable:!0,key:"bin",type:p??d})}}s.main&&f.push({file:s.main,key:"main",type:G(s.main)??d}),s.module&&f.push({file:s.module,key:"module",type:"esm"}),(s.types||s.typings)&&(z(e),e.options.declaration===void 0&&(e.options.declaration="compatible"),f.push({file:s.types??s.typings,key:"types"}));const y=[];for(const o of f){const u=W(o.file);if(u!==""&&!fe.includes(u))continue;e.options.declaration===void 0&&(o.key==="types"||o.subKey==="types")&&(e.options.declaration=o.file.includes(".d.ts")?"compatible":!0),e.options.emitCJS===void 0&&o.type==="cjs"&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&o.type==="esm"&&(e.options.emitESM=!0);const p=o.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+|${[`\\.${r}`,`\\.${n}`].join("|")})$`),""),l=p.endsWith("/");if(l&&["./","/"].includes(p))continue;const v=p.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),b="(?<=/|$)",c=l?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${r}`,`\\.${n}`].join("|")})$`;if(o.file.includes("/*")&&o.key==="exports"){U||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),U=!0);const h=[],j=new RegExp(b+v.replace("*","(.*)")+c),L=v.replace(/^(.+?)\.[^.]*$/,"$1"),Y=new RegExp(b+L.replace("*","(.*)")+c);for(const C of t)(j.test(C)||V.has(o.subKey)&&Y.test(C))&&h.push(C);if(h.length===0){i.push(`Could not find entrypoint for \`${o.file}\``);continue}for(const C of h)P(y,C,l,p,o,e,!0);continue}const a=new RegExp(b+v+c);let g=t.find(h=>a.test(h));if(V.has(o.subKey)&&g===void 0){const h=v.replace(/^(.+?)\.[^.]*$/,"$1"),j=new RegExp(b+h+c);g=t.find(L=>j.test(L))}if(g===void 0){S(T(e.options.rootDir,o.file))||i.push(`Could not find entrypoint for \`${o.file}\``);continue}S(g)&&/\.[cm]?tsx?$/.test(g)&&z(e);const m=de(g.replace(ye,""));S(`${m}.cts`)&&S(`${m}.mts`)?(P(y,`${m}.cts`,l,p,{...o,type:"cjs"},e,!1),P(y,`${m}.mts`,l,p,{...o,type:"esm"},e,!1)):P(y,g,l,p,o,e,!1)}return e.options.emitESM&&!e.options.emitCJS&&e.options.declaration===void 0&&(e.options.declaration="node16"),{entries:y,warnings:i}},"inferEntries");var Ke=Object.defineProperty,qe=k((s,t)=>Ke(s,"name",{value:t,configurable:!0}),"o");const Ve=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 Ae=Object.defineProperty,Re=k((s,t)=>Ae(s,"name",{value:t,configurable:!0}),"t$1");const Ge={hooks:{"build:prepare":Re(function(s){if(s.options.entries.length>0)return;const t=x(s.options.rootDir,s.options.sourceDir);if(!S(t))throw new Error("No 'src' directory found. Please provide entries manually.");const e=le(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=Ve(r,s.options.declaration));const n=Ne(r,e,s);for(const i of n.warnings)ke(s,i);if(s.options.entries.push(...n.entries),s.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");s.logger.info("Automatically detected entries:",be(s.options.entries.map(i=>i.fileAlias?`${O(i.fileAlias)} => ${O(i.input.replace(`${s.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:O(i.input.replace(`${s.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),we([s.options.emitESM&&"esm",s.options.emitCJS&&"cjs",s.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Je=Object.defineProperty,Ue=k((s,t)=>Je(s,"name",{value:t,configurable:!0}),"t");const ze=Ue(async(s,t)=>{if(s==="auto")s=Ge;else{if(s==="none")return{};typeof s=="string"&&(s=await t.import(s)||{})}return typeof s=="function"&&(s=s()),s},"loadPreset");var _e=Object.defineProperty,E=k((s,t)=>_e(s,"name",{value:t,configurable:!0}),"r");const Fe=E(s=>{s.addCommand({description:"Demonstrate options required",execute:E(async({logger:t,options:e})=>{let r="build";e.watch?r="watch":e.jit&&(r="jit");const n={};let i;if(e.env)for(const l of e.env)l.key==="NODE_ENV"?i=l.value:n[`process.env.${l.key}`]=JSON.stringify(l.value);i===void 0&&(e.production?i=I:e.development&&(i=q));const d=[];if(e.external)for(const l of e.external)d.push(l.split(","));const f=T(A(),e.dir??"."),y=ve(f,{debug:e.debug}),{config:o,path:u}=await Be(y,f,i,r,e.config??void 0);t.debug("Using packem config found at",u);const p=await ze(o.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await $e(f,r,i,t,e.debug,ge(o,p,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:d,killSignal:e.killSignal,minify:e.minify===void 0?i===I:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,replace:{values:n},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),se(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:E(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:E(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:E(t=>{if(t==="node"||t==="browser")return t;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var We=Object.defineProperty,D=k((s,t)=>We(s,"name",{value:t,configurable:!0}),"f");const Xe=D(s=>{s.addCommand({description:"Initialize packem configuration",execute:D(async({logger:t,options:e})=>{if(te("Welcome to packem setup"),S(x(e.dir,"packem.config.mjs"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=T(A(),e.dir??"."),n=x(r,"package.json");if(!S(n))throw new Error("No package.json found in the directory");const i=await Se(n,{resolveCatalogs:!0}),d=[];i.dependencies&&d.push(...Object.keys(i.dependencies)),i.devDependencies&&d.push(...Object.keys(i.devDependencies));const f=!!(i.devDependencies?.typescript??i.dependencies?.typescript),y=[];if(e.typescript===void 0&&!f?(e.typescript=await w({message:"Do you want to install TypeScript?"}),e.typescript&&y.push("typescript@latest")):R.message(`TypeScript version ${i.devDependencies?.typescript??i.dependencies?.typescript} is already installed`),!S(x(r,"tsconfig.json"))){const c=await w({message:"Do you want to use generate a tsconfig.json?"}),a=await w({message:"Do you want to run your code in the DOM?"});if(c){const g=K();g.start("Generating tsconfig.json"),ce(x(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:a?["es2022","dom","dom.iterable"]:["es2022"]}}),g.stop("")}}if(e.runtime===void 0&&(e.runtime=await $({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),d.includes("esbuild")?e.transformer="esbuild":d.includes("@swc/core")?e.transformer="swc":d.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await $({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"&&!d.includes(e.transformer)&&await w({message:`Do you want to install ${e.transformer}?`})&&y.push(e.transformer==="swc"?"@swc/core":e.transformer)):R.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 $({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 c;switch(e.isolatedDeclarationTransformer){case"oxc":{c="oxc-transform";break}case"swc":{c="@swc/core";break}case"typescript":{c="typescript";break}default:oe("Invalid isolated declaration transformer")}c!==void 0&&!d.includes(c)&&await w({message:`Do you want to install ${c}?`})&&y.push(c)}e.css===void 0&&(e.css=await w({message:"Do you want to use css in your project?",initialValue:!1}));const o=[];if(e.css){const c=await $({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});o.push(c);let a=await F({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(a.includes("sass")){const g=await $({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"}]});g!=="sass"&&(a=a.filter(m=>m!=="sass"),a.push(g))}if(o.push(...a),await w({message:`Do you want to install "${o.join('", "')}"?`}))for(const g of o)y.push(...H[g]);o.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await w({message:"Do you want to minify your css?",initialValue:!1}));let u;e.cssMinifier&&(u=await $({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),o.includes("lightningcss")||await w({message:`Do you want to install "${u}"?`})&&y.push(u));let p="",l="";if(e.isolatedDeclarationTransformer&&(l+=`,
29
- isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(l+=`,
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+=`,
30
30
  rollup: {
31
- css: {`),e.css){const c=o.map(a=>((a==="sass-embedded"||a==="node-sass")&&(a="sass"),`${a}Loader`)).join(", ");l+=`
32
- loaders: [${c}],`}if(e.cssMinifier&&u&&(l+=`
33
- minifier: ${u}Minifier,`),(e.css||e.cssMinifier)&&(l+=`
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+=`
34
34
  }
35
- }`),f||i.type==="module"){let c="";if(e.isolatedDeclarationTransformer&&(c+=`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}";
36
- `),e.css)for(let a of o)(a==="sass-embedded"||a==="node-sass")&&(a="sass"),c+=`import ${a}Loader from "@visulima/packem/css/loader/${a.toLowerCase()}";
37
- `;e.cssMinifier&&u&&(c+=`import ${u}Minifier from "@visulima/packem/css/minifier/${u.toLowerCase()}";
38
- `),p=`import { defineConfig } from "@visulima/packem/config";
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()}";
37
+ `;e.cssMinifier&&m&&(d+=`import ${m}Minifier from "@visulima/packem/css/minifier/${m.toLowerCase()}";
38
+ `),n=`import { defineConfig } from "@visulima/packem/config";
39
39
  import transformer from "@visulima/packem/transformer/${e.transformer}";
40
- ${c}
40
+ ${d}
41
41
  export default defineConfig({
42
42
  runtime: "${e.runtime}",
43
- transformer${l}
43
+ transformer${c}
44
44
  });
45
- `}else{let c="";if(e.isolatedDeclarationTransformer&&(c+=`const isolatedDeclarationTransformer = require("@visulima/packem/dts/isolated/transformer/${e.isolatedDeclarationTransformer}");
46
- `),e.css)for(let a of o)(a==="sass-embedded"||a==="node-sass")&&(a="sass"),c+=`const ${a}Loader = require("@visulima/packem/css/loader/${a.toLowerCase()}");
47
- `;e.cssMinifier&&u&&(c+=`const ${u}Minifier = require("@visulima/packem/css/minifier/${u.toLowerCase()}");
48
- `),p=`const { defineConfig } = require("@visulima/packem/config");
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()}");
47
+ `;e.cssMinifier&&m&&(d+=`const ${m}Minifier = require("@visulima/packem/css/minifier/${m.toLowerCase()}");
48
+ `),n=`const { defineConfig } = require("@visulima/packem/config");
49
49
  const transformer = require("@visulima/packem/transformer/${e.transformer}");
50
- ${c}
50
+ ${d}
51
51
  module.exports = defineConfig({
52
52
  runtime: ${e.runtime},
53
- transformer${l}
53
+ transformer${c}
54
54
  });
55
- `}const v=K(),b=f?"ts":"js";y.length>0&&(v.start("Installing packages"),await N(y,{cwd:r,dev:!0,silent:!0}),v.stop("Installed packages")),v.start(`Creating packem.config.${b}`),pe(x(r,`packem.config.${b}`),p),v.stop(`Created packem.config.${b}`),ie("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:D(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:D(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:D(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 B=new Z("packem",{logger:{reporters:[new ee({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:xe,packageVersion:je});Xe(B);Fe(B);Ie(B);B.run({shouldExitProcess:!1});
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});
@@ -1,5 +1,5 @@
1
- import { B as BuildConfig, c as BuildConfigFunction, d as BuildPreset } from '../packem_shared/types-Hhg8-okS.js';
2
- export { d as BuildHooks } from '../packem_shared/index-DrmPUIt8.js';
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';
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-Hhg8-okS.js';
3
- export { a as BuildEntry, b as BuildOptions, R as RollupBuildOptions } from './packem_shared/types-Hhg8-okS.js';
4
- import { E as Environment, M as Mode } from './packem_shared/index-DrmPUIt8.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-DrmPUIt8.js';
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';
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-DQUk9_13.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-KjC11dSQ.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};