@visulima/packem 2.0.0-alpha.48 → 2.0.0-alpha.49
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,23 @@
|
|
|
1
|
+
## @visulima/packem [2.0.0-alpha.49](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.48...@visulima/packem@2.0.0-alpha.49) (2025-12-28)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **shared-module:** add cross-boundary shared module support and integration tests ([59c2635](https://github.com/visulima/packem/commit/59c2635e1e84132b7157f78f191b49b4e180b7b1))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* update package dependencies and improve configurations ([e942f98](https://github.com/visulima/packem/commit/e942f9833920f04e112daa232bbe7bdb3628e039))
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* standardize code formatting and improve readability ([2bc01d1](https://github.com/visulima/packem/commit/2bc01d1e1b266dceb6023e29d3211bc7415e4946))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.37
|
|
19
|
+
* **@visulima/rollup-plugin-css:** upgraded to 1.0.0-alpha.17
|
|
20
|
+
|
|
1
21
|
## @visulima/packem [2.0.0-alpha.48](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.47...@visulima/packem@2.0.0-alpha.48) (2025-12-28)
|
|
2
22
|
|
|
3
23
|
### Features
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Q=Object.defineProperty;var v=(t,s)=>Q(t,"name",{value:s,configurable:!0});import{createCerebro as Z}from"@visulima/cerebro";import ee from"@visulima/cerebro/logger/pail";import{SimpleReporter as se}from"@visulima/pail/reporter/simple";import j,{cwd as B,exit as te}from"node:process";import{installPackage as x}from"@antfu/install-pkg";import{confirm as b,select as h,multiselect as K,spinner as L,cancel as G,intro as ae,log as V,outro as ie}from"@clack/prompts";import{isAccessible as re,readFile as ne,writeFile as oe,isAccessibleSync as I,writeJsonSync as ce,writeFileSync as le}from"@visulima/fs";import{parsePackageJson as U}from"@visulima/package/package-json";import{join as S,resolve as T}from"@visulima/path";import de from"magic-string";import{exec as pe}from"tinyexec";import{t as A,E as ue}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as me}from"jiti";import{c as fe,w as ge,j as ye}from"../packem_shared/index-
|
|
2
|
+
var Q=Object.defineProperty;var v=(t,s)=>Q(t,"name",{value:s,configurable:!0});import{createCerebro as Z}from"@visulima/cerebro";import ee from"@visulima/cerebro/logger/pail";import{SimpleReporter as se}from"@visulima/pail/reporter/simple";import j,{cwd as B,exit as te}from"node:process";import{installPackage as x}from"@antfu/install-pkg";import{confirm as b,select as h,multiselect as K,spinner as L,cancel as G,intro as ae,log as V,outro as ie}from"@clack/prompts";import{isAccessible as re,readFile as ne,writeFile as oe,isAccessibleSync as I,writeJsonSync as ce,writeFileSync as le}from"@visulima/fs";import{parsePackageJson as U}from"@visulima/package/package-json";import{join as S,resolve as T}from"@visulima/path";import de from"magic-string";import{exec as pe}from"tinyexec";import{t as A,E as ue}from"../packem_shared/index-CUp9WuCG.js";import{createJiti as me}from"jiti";import{c as fe,w as ge,j as ye}from"../packem_shared/index-BtDoSJHb.js";import{existsSync as N}from"node:fs";import{parseEnv as R}from"node:util";import{readFile as be,writeFile as we}from"node:fs/promises";import{createInterface as ve}from"node:readline/promises";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
3
3
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
4
|
-
var he="@visulima/packem",z="2.0.0-alpha.
|
|
4
|
+
var he="@visulima/packem",z="2.0.0-alpha.48";const F={version:z};var ke=Object.defineProperty,Se=v((t,s)=>ke(t,"name",{value:s,configurable:!0}),"t");const W=Se(async(t,s="")=>{let e=s;if(!e){const a=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const r of a)if(await re(S(t,r))){e=`./${r}`;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"),_={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 $e=Object.defineProperty,y=v((t,s)=>$e(t,"name",{value:s,configurable:!0}),"r$1");const je=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],Pe=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],De=["solid-js"],Me=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],Oe=["preact"],Ee=["unplugin-vue"],Te=["vue"],Ie=["rollup-plugin-svelte"],Le=["svelte"],D=y((t,s,e)=>t.includes(`preset: '${s}'`)||t.includes(`preset: "${s}"`)||t.includes(`preset: '${s}',`)||t.includes(`preset: "${s}",`)||t.includes(e)||t.includes(`@visulima/packem/config/preset/${s}`),"checkPresetExists"),M=y((t,s)=>{const{logger:e,magic:a,packemConfig:r}=t,n=r.match(/defineConfig\s*\(\s*\{/);if(n&&n.index!==void 0){const o=n.index+n[0].length;if(r.includes("preset:")){const i=r.match(/preset:\s*['"]([^'"]+)['"]/);if(i)a.replace(i[0],`preset: '${s}'`);else throw e.warn(`A preset already exists in the config. Please manually set it to '${s}'.`),new Error("Preset exists but is not a string")}else a.appendLeft(o,`
|
|
5
5
|
preset: '${s}',`)}else if(r.includes("transformer:"))a.replace("transformer:",`preset: '${s}',
|
|
6
6
|
transformer:`);else{const o=r.indexOf("{");o!==-1&&a.appendLeft(o+1,`
|
|
7
7
|
preset: '${s}',`)}},"insertPreset"),Be=y(async t=>{try{return((await pe("git",["status","--porcelain"],{nodeOptions:{cwd:t,stdio:["pipe","pipe","pipe"]}})).stdout?.trim().length??0)>0}catch{return!1}},"checkGitDirty"),X=y(async t=>{const s=S(t,"package.json"),e=await U(s,{resolveCatalogs:!0});return!!(e.devDependencies?.typescript??e.dependencies?.typescript)},"checkTypeScriptInstalled"),Ne=y(async t=>{const s=await X(t),e=[...Pe],a=[...Ce];return s?a.push("@types/react","@types/react-dom"):await b({initialValue:!1,message:"Do you want to use TypeScript?"})&&a.push("typescript","@types/react","@types/react-dom"),{devPackages:a,packages:e}},"getReactTypeDependencies"),O=y(async(t,s,e)=>{const{rootDirectory:a,spinner:r}=t;r.start("Installing packages"),await x(e,{cwd:a,dev:!1,silent:!0}),await x(s,{cwd:a,dev:!0,silent:!0}),r.stop("Installed packages")},"installPackages"),Ve=y(async t=>{const{logger:s,magic:e,packemConfig:a,packemConfigFormat:r,rootDirectory:n,spinner:o,transformerReplaceKey:i,transformerSearchKey:l}=t;if(a.includes("typedoc: typedocBuilder")||a.includes("@visulima/packem/builder/typedoc")){s.warn("Typedoc has already been added to the packem config.");return}r==="cjs"?e.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
|
@@ -34,7 +34,7 @@ Svelte preset added!`)},"addSvelte"),Ge=y(async t=>{const{logger:s,magic:e,packe
|
|
|
34
34
|
},
|
|
35
35
|
},`),t.spinner.start("Installing packages"),await x(d,{cwd:t.rootDirectory,dev:!0,silent:!0}),t.spinner.stop("Installed packages"),s.success(`
|
|
36
36
|
CSS loaders added!`)},"addCss"),Ue=y(t=>{t.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:y(async({argument:s,logger:e,options:a})=>{const r=L(),n=T(B(),a.dir??".");let o;try{o=await W(n,a.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}if(await Be(n)&&!await b({initialValue:!1,message:"Git repository has uncommitted changes. Do you want to proceed?"})){G("Operation cancelled.");return}const i=await ne(o,{buffer:!1}),l=i.includes("import")?"esm":"cjs",d=new de(i),m=" transformer,",g=i.includes(" transformer,")?" transformer,":" transformer",f={logger:e,magic:d,packemConfig:i,packemConfigFilePath:o,packemConfigFormat:l,rootDirectory:n,spinner:r,transformerReplaceKey:m,transformerSearchKey:g};s.includes("typedoc")&&await Ve(f),s.includes("react")&&await Ae(f),s.includes("solid")&&await Re(f),s.includes("preact")&&await qe(f),s.includes("vue")&&await Je(f),s.includes("svelte")&&await Ke(f),s.includes("css")&&await Ge(f),await oe(o,d.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 ze=Object.defineProperty,H=v((t,s)=>ze(t,"name",{value:s,configurable:!0}),"a$2");const We=H(async(t,s,e="PACKEM_")=>{const a=T(s,t);if(!N(a))return{};const{readFile:r}=await import("node:fs/promises"),n=await r(a,"utf-8"),o={};if(typeof R=="function")try{const i=R(n);for(const[l,d]of Object.entries(i))(!e||l.startsWith(e))&&(o[`process.env.${l}`]=JSON.stringify(d))}catch{return q(n,e)}else return q(n,e);return o},"loadEnvFile"),q=H((t,s="PACKEM_")=>{const e={};for(const a of t.split(`
|
|
37
|
-
`)){const r=a.trim();if(!r||r.startsWith("#"))continue;const n=r.match(/^([^=:#]+)=(.*)$/);if(n&&n[1]&&n[2]!==void 0){const o=n[1].trim();let i=n[2].trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),(!s||o.startsWith(s))&&(e[`process.env.${o}`]=JSON.stringify(i))}}return e},"loadEnvFileManually");var _e=Object.defineProperty,Xe=v((t,s)=>_e(t,"name",{value:s,configurable:!0}),"e$2");const He=Xe(async(t,s,e,a,r)=>{const n=await W(s,r);let o=await t.import(n,{default:!0,try:!0})||{};return typeof o=="function"&&(o=await o(e,a)),{config:o,path:n}},"loadPackemConfig");var Ye=Object.defineProperty,Qe=v((t,s)=>Ye(t,"name",{value:s,configurable:!0}),"e$1");const Ze=Qe(async(t,s)=>{switch(t){case"none":return{};case"react":{const{createReactPreset:e}=await import("../config/preset/react.js");t=e();break}case"solid":{const{createSolidPreset:e}=await import("../config/preset/solid.js");t=e();break}case"svelte":{const{createSveltePreset:e}=await import("../config/preset/svelte.js");t=e();break}case"preact":{const{createPreactPreset:e}=await import("../config/preset/preact.js");t=e();break}case"vue":{const{createVuePreset:e}=await import("../config/preset/vue.js");t=e();break}default:typeof t=="string"&&(t=await s.import(t)||{})}return typeof t=="function"&&(t=t()),t},"loadPreset");var es=Object.defineProperty,C=v((t,s)=>es(t,"name",{value:s,configurable:!0}),"a$1");const ss=C(t=>{t.addCommand({description:"Demonstrate options required",execute:C(async({logger:s,options:e})=>{let a="build";e.watch?a="watch":e.jit&&(a="jit");let r;const n={};if(e.env)for(const c of e.env)c.key==="NODE_ENV"?r=c.value:n[`process.env.${c.key}`]=JSON.stringify(c.value);r===void 0&&(e.production?r=A:e.development&&(r=ue));const o=[];if(e.external)for(const c of e.external)o.push(c.split(","));const i=T(B(),e.dir??"."),l=me(i,{debug:e.debug}),{config:d,path:m}=await He(l,i,r,a,e.config??void 0);s.debug("Using packem config found at",m);const g=e.envFile??d.envFile,f=e.envPrefix??d.envPrefix??"PACKEM_",p={};if(g){const c=await We(g,i,f);Object.assign(p,c)}Object.assign(p,n);const w=await Ze(d.preset??"none",l);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{const c=fe()(d,ge,w,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:o,killSignal:e.killSignal,minify:e.minify===void 0?r===A:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...Object.keys(p).length>0||Object.keys(n).length>0?{replace:{values:p}}:{},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,unbundle:e.unbundle,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}});await ye(i,a,r,s,e.debug,c,e.tsconfig??void 0)}catch(c){s.error(c),te(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:C(s=>{const[e,a]=s.split("=");return{key:e,value:a}},"type")},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:C(s=>{if(s==="SIGTERM"||s==="SIGKILL")return s;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")},"type")},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:C(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean}]})},"createBuildCommand");var ts=Object.defineProperty,P=v((t,s)=>ts(t,"name",{value:s,configurable:!0}),"f");const as=P(t=>{t.addCommand({description:"Initialize packem configuration",execute:P(async({logger:s,options:e})=>{if(ae("Welcome to packem setup"),I(S(e.dir,"packem.config.mjs"))){s.info("Packem project already initialized, you can use `packem build` to build your project");return}const a=T(B(),e.dir??"."),r=S(a,"package.json");if(!I(r))throw new Error("No package.json found in the directory");const n=await U(r,{resolveCatalogs:!0}),o=[];n.dependencies&&o.push(...Object.keys(n.dependencies)),n.devDependencies&&o.push(...Object.keys(n.devDependencies));const i=!!(n.devDependencies?.typescript??n.dependencies?.typescript),l=[];if(e.typescript===void 0&&!i?(e.typescript=await b({message:"Do you want to install TypeScript?"}),e.typescript&&l.push("typescript@latest")):V.message(`TypeScript version ${n.devDependencies?.typescript??n.dependencies?.typescript} is already installed`),!I(S(a,"tsconfig.json"))){const c=await b({message:"Do you want to use generate a tsconfig.json?"}),u=await b({message:"Do you want to run your code in the DOM?"});if(c){const k=L();k.start("Generating tsconfig.json"),ce(S(a,"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:u?["es2022","dom","dom.iterable"]:["es2022"]}}),k.stop("")}}if(e.runtime===void 0&&(e.runtime=await h({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),o.includes("esbuild")?e.transformer="esbuild":o.includes("@swc/core")?e.transformer="swc":o.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await h({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"&&!o.includes(e.transformer)&&await b({message:`Do you want to install ${e.transformer}?`})&&l.push(e.transformer==="swc"?"@swc/core":e.transformer)):V.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await b({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({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:G("Invalid isolated declaration transformer")}c!==void 0&&!o.includes(c)&&await b({message:`Do you want to install ${c}?`})&&l.push(c)}e.css===void 0&&(e.css=await b({message:"Do you want to use css in your project?",initialValue:!1}));const d=[];if(e.css){const c=await h({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});d.push(c);let u=await K({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(u.includes("sass")){const k=await h({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"}]});k!=="sass"&&(u=u.filter(Y=>Y!=="sass"),u.push(k))}if(d.push(...u),await b({message:`Do you want to install "${d.join('", "')}"?`}))for(const k of d)l.push(..._[k]);d.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await b({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await h({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),d.includes("lightningcss")||await b({message:`Do you want to install "${m}"?`})&&l.push(m));let g="",f="";if(e.isolatedDeclarationTransformer&&(f+=`,
|
|
37
|
+
`)){const r=a.trim();if(!r||r.startsWith("#"))continue;const n=r.match(/^([^=:#]+)=(.*)$/);if(n&&n[1]&&n[2]!==void 0){const o=n[1].trim();let i=n[2].trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),(!s||o.startsWith(s))&&(e[`process.env.${o}`]=JSON.stringify(i))}}return e},"loadEnvFileManually");var _e=Object.defineProperty,Xe=v((t,s)=>_e(t,"name",{value:s,configurable:!0}),"e$2");const He=Xe(async(t,s,e,a,r)=>{const n=await W(s,r);let o=await t.import(n,{default:!0,try:!0})||{};return typeof o=="function"&&(o=await o(e,a)),{config:o,path:n}},"loadPackemConfig");var Ye=Object.defineProperty,Qe=v((t,s)=>Ye(t,"name",{value:s,configurable:!0}),"e$1");const Ze=Qe(async(t,s)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:e}=await import("../config/preset/preact.js");t=e();break}case"react":{const{createReactPreset:e}=await import("../config/preset/react.js");t=e();break}case"solid":{const{createSolidPreset:e}=await import("../config/preset/solid.js");t=e();break}case"svelte":{const{createSveltePreset:e}=await import("../config/preset/svelte.js");t=e();break}case"vue":{const{createVuePreset:e}=await import("../config/preset/vue.js");t=e();break}default:typeof t=="string"&&(t=await s.import(t)||{})}return typeof t=="function"&&(t=t()),t},"loadPreset");var es=Object.defineProperty,C=v((t,s)=>es(t,"name",{value:s,configurable:!0}),"a$1");const ss=C(t=>{t.addCommand({description:"Demonstrate options required",execute:C(async({logger:s,options:e})=>{let a="build";e.watch?a="watch":e.jit&&(a="jit");let r;const n={};if(e.env)for(const c of e.env)c.key==="NODE_ENV"?r=c.value:n[`process.env.${c.key}`]=JSON.stringify(c.value);r===void 0&&(e.production?r=A:e.development&&(r=ue));const o=[];if(e.external)for(const c of e.external)o.push(c.split(","));const i=T(B(),e.dir??"."),l=me(i,{debug:e.debug}),{config:d,path:m}=await He(l,i,r,a,e.config??void 0);s.debug("Using packem config found at",m);const g=e.envFile??d.envFile,f=e.envPrefix??d.envPrefix??"PACKEM_",p={};if(g){const c=await We(g,i,f);Object.assign(p,c)}Object.assign(p,n);const w=await Ze(d.preset??"none",l);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{const c=fe()(d,ge,w,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:o,killSignal:e.killSignal,minify:e.minify===void 0?r===A:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,...Object.keys(p).length>0||Object.keys(n).length>0?{replace:{values:p}}:{},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,unbundle:e.unbundle,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}});await ye(i,a,r,s,e.debug,c,e.tsconfig??void 0)}catch(c){s.error(c),te(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:C(s=>{const[e,a]=s.split("=");return{key:e,value:a}},"type")},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:C(s=>{if(s==="SIGTERM"||s==="SIGKILL")return s;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")},"type")},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:C(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean}]})},"createBuildCommand");var ts=Object.defineProperty,P=v((t,s)=>ts(t,"name",{value:s,configurable:!0}),"f");const as=P(t=>{t.addCommand({description:"Initialize packem configuration",execute:P(async({logger:s,options:e})=>{if(ae("Welcome to packem setup"),I(S(e.dir,"packem.config.mjs"))){s.info("Packem project already initialized, you can use `packem build` to build your project");return}const a=T(B(),e.dir??"."),r=S(a,"package.json");if(!I(r))throw new Error("No package.json found in the directory");const n=await U(r,{resolveCatalogs:!0}),o=[];n.dependencies&&o.push(...Object.keys(n.dependencies)),n.devDependencies&&o.push(...Object.keys(n.devDependencies));const i=!!(n.devDependencies?.typescript??n.dependencies?.typescript),l=[];if(e.typescript===void 0&&!i?(e.typescript=await b({message:"Do you want to install TypeScript?"}),e.typescript&&l.push("typescript@latest")):V.message(`TypeScript version ${n.devDependencies?.typescript??n.dependencies?.typescript} is already installed`),!I(S(a,"tsconfig.json"))){const c=await b({message:"Do you want to use generate a tsconfig.json?"}),u=await b({message:"Do you want to run your code in the DOM?"});if(c){const k=L();k.start("Generating tsconfig.json"),ce(S(a,"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:u?["es2022","dom","dom.iterable"]:["es2022"]}}),k.stop("")}}if(e.runtime===void 0&&(e.runtime=await h({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),o.includes("esbuild")?e.transformer="esbuild":o.includes("@swc/core")?e.transformer="swc":o.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await h({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"&&!o.includes(e.transformer)&&await b({message:`Do you want to install ${e.transformer}?`})&&l.push(e.transformer==="swc"?"@swc/core":e.transformer)):V.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await b({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await h({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:G("Invalid isolated declaration transformer")}c!==void 0&&!o.includes(c)&&await b({message:`Do you want to install ${c}?`})&&l.push(c)}e.css===void 0&&(e.css=await b({message:"Do you want to use css in your project?",initialValue:!1}));const d=[];if(e.css){const c=await h({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});d.push(c);let u=await K({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(u.includes("sass")){const k=await h({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"}]});k!=="sass"&&(u=u.filter(Y=>Y!=="sass"),u.push(k))}if(d.push(...u),await b({message:`Do you want to install "${d.join('", "')}"?`}))for(const k of d)l.push(..._[k]);d.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await b({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await h({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),d.includes("lightningcss")||await b({message:`Do you want to install "${m}"?`})&&l.push(m));let g="",f="";if(e.isolatedDeclarationTransformer&&(f+=`,
|
|
38
38
|
isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(f+=`,
|
|
39
39
|
rollup: {
|
|
40
40
|
css: {`),e.css){const c=d.map(u=>((u==="sass-embedded"||u==="node-sass")&&(u="sass"),`${u}Loader`)).join(", ");f+=`
|
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{j as g}from"./packem_shared/index-
|
|
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{j as g}from"./packem_shared/index-BtDoSJHb.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};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run async tasks with a concurrency limit to prevent memory overflow.
|
|
3
|
+
* Useful for limiting parallel rollup builds, especially DTS generation.
|
|
4
|
+
*/
|
|
5
|
+
declare const runWithConcurrency: <T>(tasks: (() => Promise<T>)[], limit: number) => Promise<T[]>;
|
|
6
|
+
export default runWithConcurrency;
|