@visulima/packem 2.0.0-alpha.22 → 2.0.0-alpha.23

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,14 @@
1
+ ## @visulima/packem [2.0.0-alpha.23](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.22...@visulima/packem@2.0.0-alpha.23) (2025-10-02)
2
+
3
+ ### Bug Fixes
4
+
5
+ * update dependencies and versions across multiple packages ([a0d209d](https://github.com/visulima/packem/commit/a0d209d847b1feb171850994a64591ab7d26f8cb))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.18
11
+
1
12
  ## @visulima/packem [2.0.0-alpha.22](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.21...@visulima/packem@2.0.0-alpha.22) (2025-09-30)
2
13
 
3
14
  ### Features
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
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 be}from"jiti";import{cyan as ve,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-C56sx504.js";import{parsePackageJson as Se}from"@visulima/package/package-json";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
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-D1mgDFnu.js";import{parsePackageJson as Se}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.21";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");
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.22";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
5
  `):o.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
6
6
  `),f.includes("builder: {")?o.replace("builder: {",`builder: {
7
7
  typedoc: typedocBuilder,
@@ -9,9 +9,9 @@ const _=globalThis.process.getBuiltinModule("module").createRequire(import.meta.
9
9
  builder: {
10
10
  typedoc: typedocBuilder,
11
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=[],b=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(b),b!=="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 v=[];for(const m of l)v.push(...H[m]);b!=="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()}");
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
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")||v.push(a),y==="cjs"?o.prepend(`const ${a}Minifier = require("@visulima/packem/css/minifier/${a.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
15
  `):o.prepend(`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
16
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
17
  css: {${a?`
@@ -24,8 +24,8 @@ Typedoc added!`)}if(t.includes("css")){if(f.includes("css: {")||f.includes("@vis
24
24
  minifier: ${a}Minifier,`:""}
25
25
  loaders: [${g}],
26
26
  },
27
- },`),n.start("Installing packages"),await N(v,{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 b=p.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),v="(?<=/|$)",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(v+b.replace("*","(.*)")+c),L=b.replace(/^(.+?)\.[^.]*$/,"$1"),Y=new RegExp(v+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(v+b+c);let g=t.find(h=>a.test(h));if(V.has(o.subKey)&&g===void 0){const h=b.replace(/^(.+?)\.[^.]*$/,"$1"),j=new RegExp(v+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:",ve(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=be(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=Se(n),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+=`,
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
29
  isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(l+=`,
30
30
  rollup: {
31
31
  css: {`),e.css){const c=o.map(a=>((a==="sass-embedded"||a==="node-sass")&&(a="sass"),`${a}Loader`)).join(", ");l+=`
@@ -52,4 +52,4 @@ module.exports = defineConfig({
52
52
  runtime: ${e.runtime},
53
53
  transformer${l}
54
54
  });
55
- `}const b=K(),v=f?"ts":"js";y.length>0&&(b.start("Installing packages"),await N(y,{cwd:r,dev:!0,silent:!0}),b.stop("Installed packages")),b.start(`Creating packem.config.${v}`),pe(x(r,`packem.config.${v}`),p),b.stop(`Created packem.config.${v}`),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 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});
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-C56sx504.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-D1mgDFnu.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};