@visulima/packem 2.0.0-alpha.93 → 2.0.0-alpha.95
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 +20 -0
- package/LICENSE.md +1211 -186
- package/dist/babel-runtime/packem_shared/transform-code-DtqOY-lW.js +1 -0
- package/dist/babel-runtime/plugins/babel/worker.js +1 -1
- package/dist/builder/typedoc/index.d.ts +1 -1
- package/dist/builder/typedoc/index.js +2 -2
- package/dist/cli/index.js +17 -17
- package/dist/config/index.d.ts +42 -42
- package/dist/config/preset/preact.d.ts +10 -10
- package/dist/config/preset/react.d.ts +45 -45
- package/dist/config/preset/solid.d.ts +75 -75
- package/dist/config/preset/svelte.d.ts +46 -46
- package/dist/config/preset/vue.d.ts +33 -33
- package/dist/index.d.ts +35 -35
- package/dist/index.js +61 -39
- package/dist/packem_shared/create-or-update-key-storage-BFOAEuWX.js +26 -0
- package/dist/packem_shared/default-BSbw_3ev.js +1 -0
- package/dist/packem_shared/index-BhmvQAG0.js +301 -0
- package/dist/packem_shared/oxcTransformPlugin-Dwvbw2jE-CI_T_eTp.js +168 -0
- package/dist/packem_shared/{types.d-BkLP91NJ.d.ts → types.d-CA4tXIce.d.ts} +178 -178
- package/dist/packem_shared/utils-DqCpIxDx.js +1 -0
- package/dist/rollup/plugins/oxc/oxc-transformer.js +1 -1
- package/package.json +16 -16
- package/dist/babel-runtime/packem_shared/transform-code-KNtowoK1.js +0 -1
- package/dist/packem_shared/create-or-update-key-storage-DHOKZmnD.js +0 -28
- package/dist/packem_shared/default-mHB0zin0.js +0 -1
- package/dist/packem_shared/index-DiAPKNwF.js +0 -249
- package/dist/packem_shared/oxcTransformPlugin-Dwvbw2jE-BsmmBg7q.js +0 -177
- package/dist/packem_shared/utils-Bsoe7qJG.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var u=(t,e)=>m(t,"name",{value:e,configurable:!0});import{transformAsync as g}from"@babel/core";var f=Object.defineProperty,p=u((t,e)=>f(t,"name",{value:e,configurable:!0}),"o");const d=/\.tsx?$/,y=/['"]use memo['"]/,x="babel-options",v="__packem_babel_missing_options__",A=p(t=>t.find(e=>e==="babel-plugin-react-compiler"||Array.isArray(e)&&e[0]==="babel-plugin-react-compiler"),"getReactCompilerPlugin"),b=p((t,e)=>{if(t.length===0)return;const s=A(t);if(!(!s||!Array.isArray(s))&&s[1]?.compilationMode==="annotation"&&!y.test(e)){const a=t.indexOf(s);a!==-1&&t.splice(a,1)}},"filterReactCompilerByAnnotation"),w=p(async(t,e,{filename:s,generatorOpts:a,sourceFileName:h,...r})=>{let n=[];r.plugins&&Array.isArray(r.plugins)&&(n=[...r.plugins]),n.length>0&&b(n,t);const o=[];(e.endsWith(".jsx")||e.endsWith(".tsx"))&&o.push("jsx"),d.test(e)&&o.push("typescript");const i=r.parserOpts?.plugins;i&&Array.isArray(i)&&o.unshift(...i);const c=[...new Set(o)],l=await g(t,{...r,filename:e,generatorOpts:a,parserOpts:{...r.parserOpts,allowAwaitOutsideFunction:!0,plugins:c.length>0?c:[],sourceType:"module"},plugins:n.length>0?n:[],sourceFileName:e});if(l?.code)return{code:l.code,map:l.map??void 0}},"transformCode");export{x as N,v as O,w as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var n=(r,o)=>s(r,"name",{value:o,configurable:!0});import i from"workerpool";import{
|
|
1
|
+
var s=Object.defineProperty;var n=(r,o)=>s(r,"name",{value:o,configurable:!0});import i from"workerpool";import{O as m,t as c}from"../../packem_shared/transform-code-DtqOY-lW.js";var p=Object.defineProperty,v=n((r,o)=>p(r,"name",{value:o,configurable:!0}),"t");const f=new Map,d=v(async(r,o,t,e)=>{e!==void 0&&f.set(t,e);const a=f.get(t);if(a===void 0)throw new Error(m);return c(r,o,a)},"transform");i.worker({transform:d});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildContext } from '@visulima/packem-share/types';
|
|
2
|
-
import { I as InternalBuildOptions } from "../../packem_shared/types.d-
|
|
2
|
+
import { I as InternalBuildOptions } from "../../packem_shared/types.d-CA4tXIce.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-plugins';
|
|
5
5
|
import '@visulima/packem-plugins/oxc';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
2
|
-
${i}`);if(!p){n.error({message:`Could not find the typedoc marker: <!-- ${t} --><!-- /${t} --> in ${r}`,prefix:"typedoc"});return}c!==p&&w(r,p.replaceAll(`<!-- _REPLACE_${t}`,`<!-- ${t}`).replaceAll(`<!-- _REPLACE_\\${t}`,"<!-- ${marker}"),{overwrite:!0})},
|
|
1
|
+
import{v as h,T as w,f as k,q as $}from"../../packem_shared/create-or-update-key-storage-BFOAEuWX.js";import{m}from"../../packem_shared/utils-DqCpIxDx.js";import{readdirSync as E}from"node:fs";import{replaceContentWithinMarker as j}from"@visulima/packem-share";import{Application as A}from"typedoc";const v=(e,o,t,r,n)=>{const s=E(e,{withFileTypes:!0}).filter(a=>a.isFile());let i="";for(const a of s)a.name==="README.md"&&o>1||(i+=h(m(e,a.name)).replaceAll(`<!-- ${t}`,`<!-- _REPLACE_${t}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${t}`));if(i==="")return;const c=h(r),p=j(c,t,`
|
|
2
|
+
${i}`);if(!p){n.error({message:`Could not find the typedoc marker: <!-- ${t} --><!-- /${t} --> in ${r}`,prefix:"typedoc"});return}c!==p&&w(r,p.replaceAll(`<!-- _REPLACE_${t}`,`<!-- ${t}`).replaceAll(`<!-- _REPLACE_\\${t}`,"<!-- ${marker}"),{overwrite:!0})},P=(e,o,t,r)=>{if(e==="inline"&&t===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(e!=="inline"&&typeof t=="string"&&r.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),e==="json"&&!o?.endsWith(".json"))throw new Error(o===void 0?"The `jsonFileName` option is required when using the `json` format.":"The `jsonFileName` option must end with `.json`.");e!=="json"&&typeof o=="string"&&r.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"})},C=async(e,o,t,r)=>{if(o.length===0)return;const{format:n,jsonFileName:s,marker:i,output:c,plugin:p,readmePath:a,...f}=e;P(n,s,a,r);const y=o.map(g=>g.input),u=p??[];u.push("typedoc-plugin-rename-defaults"),(n==="inline"||n==="markdown")&&u.push("typedoc-plugin-markdown");const l=await A.bootstrapWithPlugins({...f,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...f.compilerOptions},entryPoints:y,hideGenerator:!0,out:t,plugin:u,...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(n==="json")await l.generateJson(d,s);else if(n==="html")await l.generateDocs(d,t);else if(await l.generateOutputs(d),n==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");v(t,o.length,i,a,r)}}},T=e=>e.logger,L=async(e,o,t,r)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){const n=T(e);let s="unknown";e.pkg.dependencies?.typedoc?s=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(s=e.pkg.devDependencies.typedoc),o&&k("typedoc",o,n),r&&n.raw(`
|
|
3
3
|
`),n.info({message:`Using ${$("typedoc")} ${s} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let i=e.options.rootDir;e.options.typedoc.output?i=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?i=m(o,"typedoc"):e.options.typedoc.format!=="json"&&(i=m(i,"api-docs")),await C(e.options.typedoc,e.options.entries,i,n),await e.hooks.callHook("typedoc:done",e)}};export{L as default};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{
|
|
2
|
+
import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{d as A,y as q,m as ee,f as te,g as se,h as ae,j as ie,T as ne,l as R,v as re,n as oe,i as ce}from"../packem_shared/index-BhmvQAG0.js";import k,{cwd as N,exit as le}from"node:process";import{installPackage as h}from"@antfu/install-pkg";import{spinner as D,confirm as f,cancel as B,select as g,multiselect as G,intro as K,log as E,outro as z,isCancel as U}from"@clack/prompts";import{z as de,a as ue,q as pe,b as M,T as me,O as fe}from"../packem_shared/create-or-update-key-storage-BFOAEuWX.js";import{B as O,m as b}from"../packem_shared/utils-DqCpIxDx.js";import ge from"magic-string";import{exec as ye}from"tinyexec";import{PRODUCTION_ENV as W,DEVELOPMENT_ENV as we}from"@visulima/packem-share/constants";import{createJiti as be}from"jiti";import{writeFile as F,readFile as he}from"node:fs/promises";import{existsSync as V}from"node:fs";import{parseEnv as J}from"node:util";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
|
-
const _={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"]},ke=/defineConfig\s*\(\s*\{/,$e=/preset:\s*['"][^'"]+['"]/,Se=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],je=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],Pe=["solid-js"],Ee=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],De=["preact"],
|
|
4
|
+
const _={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"]},ke=/defineConfig\s*\(\s*\{/,$e=/preset:\s*['"][^'"]+['"]/,Se=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],je=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],Pe=["solid-js"],Ee=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],De=["preact"],Oe=["unplugin-vue"],Le=["vue"],Ie=["rollup-plugin-svelte"],Me=["svelte"],$=(t,e,a)=>t.includes(`preset: '${e}'`)||t.includes(`preset: "${e}"`)||t.includes(`preset: '${e}',`)||t.includes(`preset: "${e}",`)||t.includes(a)||t.includes(`@visulima/packem/config/preset/${e}`),S=(t,e)=>{const{logger:a,magic:s,packemConfig:i}=t,n=ke.exec(i);if(n?.index!==void 0){const r=n.index+n[0].length;if(i.includes("preset:")){const o=$e.exec(i);if(o)s.replace(o[0],`preset: '${e}'`);else throw a.warn(`A preset already exists in the config. Please manually set it to '${e}'.`),new Error("Preset exists but is not a string")}else s.appendLeft(r,`
|
|
5
5
|
preset: '${e}',`)}else if(i.includes("transformer:"))s.replace("transformer:",`preset: '${e}',
|
|
6
6
|
transformer:`);else{const r=i.indexOf("{");r!==-1&&s.appendLeft(r+1,`
|
|
7
|
-
preset: '${e}',`)}},
|
|
7
|
+
preset: '${e}',`)}},Ne=async t=>{try{return((await ye("git",["status","--porcelain"],{nodeOptions:{cwd:t,stdio:["pipe","pipe","pipe"]}})).stdout?.trim().length??0)>0}catch{return!1}},H=async t=>{const e=b(t,"package.json"),a=await q(e,{resolveCatalogs:!0});return!!(a.devDependencies?.typescript??a.dependencies?.typescript)},Be=async t=>{const e=await H(t),a=[...je],s=[...Ce];return e?s.push("@types/react","@types/react-dom"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/react","@types/react-dom"),{devPackages:s,packages:a}},C=async(t,e,a)=>{const{rootDirectory:s,spinner:i}=t;i.start("Installing packages"),await h(a,{cwd:s,dev:!1,silent:!0}),await h(e,{cwd:s,dev:!0,silent:!0}),i.stop("Installed packages")},Ve=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:i,rootDirectory:n,spinner:r,transformerReplaceKey:o,transformerSearchKey:c}=t;if(s.includes("typedoc: typedocBuilder")||s.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}i==="cjs"?a.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
|
8
8
|
`):a.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
|
|
9
9
|
`),s.includes("builder: {")?a.replace("builder: {",`builder: {
|
|
10
10
|
typedoc: typedocBuilder,
|
|
@@ -12,16 +12,16 @@ const _={less:["less"],lightningcss:["lightningcss"],"node-sass":["node-sass"],p
|
|
|
12
12
|
builder: {
|
|
13
13
|
typedoc: typedocBuilder,
|
|
14
14
|
},`),e.info("Adding typedoc dependencies..."),r.start("Installing packages"),await h(Se,{cwd:n,dev:!0,silent:!0}),r.stop("Installed packages"),e.success(`
|
|
15
|
-
Typedoc added!`)},
|
|
16
|
-
React preset added!`)},
|
|
15
|
+
Typedoc added!`)},Re=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"react","createReactPreset")){e.warn("React preset has already been added to the packem config.");return}S(t,"react");const{devPackages:s,packages:i}=await Be(t.rootDirectory);e.info("Adding React dependencies..."),await C(t,s,i),e.success(`
|
|
16
|
+
React preset added!`)},Te=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"solid","createSolidPreset")){e.warn("Solid preset has already been added to the packem config.");return}S(t,"solid"),e.info("Adding Solid dependencies..."),await C(t,xe,Pe),e.success(`
|
|
17
17
|
Solid preset added!`)},Ae=async t=>{const e=await H(t),a=[...De],s=[...Ee];return e?s.push("@types/preact"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/preact"),{devPackages:s,packages:a}},qe=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"preact","createPreactPreset")){e.warn("Preact preset has already been added to the packem config.");return}S(t,"preact");const{devPackages:s,packages:i}=await Ae(t.rootDirectory);e.info("Adding Preact dependencies..."),await C(t,s,i),e.success(`
|
|
18
|
-
Preact preset added!`)},Ge=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"vue","createVuePreset")){e.warn("Vue preset has already been added to the packem config.");return}S(t,"vue"),e.info("Adding Vue dependencies..."),await C(t,Le
|
|
19
|
-
Vue preset added!`)},Ke=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"svelte","createSveltePreset")){e.warn("Svelte preset has already been added to the packem config.");return}S(t,"svelte"),e.info("Adding Svelte dependencies..."),await C(t,Me
|
|
20
|
-
Svelte preset added!`)},
|
|
18
|
+
Preact preset added!`)},Ge=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"vue","createVuePreset")){e.warn("Vue preset has already been added to the packem config.");return}S(t,"vue"),e.info("Adding Vue dependencies..."),await C(t,Oe,Le),e.success(`
|
|
19
|
+
Vue preset added!`)},Ke=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"svelte","createSveltePreset")){e.warn("Svelte preset has already been added to the packem config.");return}S(t,"svelte"),e.info("Adding Svelte dependencies..."),await C(t,Ie,Me),e.success(`
|
|
20
|
+
Svelte preset added!`)},ze=async()=>{const t=[],e=await g({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(t.push(e),e!=="tailwindcss"){let a=await G({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(a.includes("sass")){const s=await g({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"}]});s!=="sass"&&(a=a.filter(i=>i!=="sass"),a.push(s))}t.push(...a)}return{cssLoaders:t,mainCssLoader:e}},Ue=async(t,e,a,s)=>{if(!await f({initialValue:!1,message:"Do you want to minify your css?"}))return;const i=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return a.includes("lightningcss")||s.push(i),e==="cjs"?t.prepend(`const ${i}Minifier = require("@visulima/packem/css/minifier/${i.toLowerCase()}");
|
|
21
21
|
`):t.prepend(`import ${i}Minifier from "@visulima/packem/css/minifier/${i.toLowerCase()}";
|
|
22
|
-
`),i},
|
|
22
|
+
`),i},We=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:i,transformerReplaceKey:n,transformerSearchKey:r}=t;if(s.includes("css: {")||s.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const{cssLoaders:o,mainCssLoader:c}=await ze(),l=[];for(const p of o)l.push(..._[p]);c!=="tailwindcss"&&o.push("sourceMap");for(const p of o){const d=p==="sass-embedded"||p==="node-sass"?"sass":p;i==="cjs"?a.prepend(`const ${d}Loader = require("@visulima/packem/css/loader/${d.toLowerCase()}");
|
|
23
23
|
`):a.prepend(`import ${d}Loader from "@visulima/packem/css/loader/${d.toLowerCase()}";
|
|
24
|
-
`)}const u=await
|
|
24
|
+
`)}const u=await Ue(a,i,o,l),m=o.map(p=>p==="sass-embedded"||p==="node-sass"?"sass":`${p}Loader`).join(", ");s.includes("rollup: {")?a.replace("rollup: {",`rollup: {
|
|
25
25
|
css: {${u?`
|
|
26
26
|
minifier: ${u}Minifier,`:""}
|
|
27
27
|
loaders: [${m}],
|
|
@@ -33,7 +33,7 @@ Svelte preset added!`)},Ue=async()=>{const t=[],e=await g({message:"Pick a css l
|
|
|
33
33
|
loaders: [${m}],
|
|
34
34
|
},
|
|
35
35
|
},`),t.spinner.start("Installing packages"),await h(l,{cwd:t.rootDirectory,dev:!0,silent:!0}),t.spinner.stop("Installed packages"),e.success(`
|
|
36
|
-
CSS loaders added!`)},
|
|
36
|
+
CSS loaders added!`)},Fe=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:async({argument:e,logger:a,options:s})=>{const i=a,n=D(),r=O(N(),typeof s.dir=="string"?s.dir:".");let o;try{o=await A(r,s.config)}catch{i.error("Could not find a packem config file, please run `packem init` first.");return}if(await Ne(r)&&!await f({initialValue:!1,message:"Git repository has uncommitted changes. Do you want to proceed?"})){B("Operation cancelled.");return}const c=await de(o,{buffer:!1}),l=c.includes("import")?"esm":"cjs",u=new ge(c),m=" transformer,",p=c.includes(" transformer,")?" transformer,":" transformer",d={logger:i,magic:u,packemConfig:c,packemConfigFormat:l,rootDirectory:r,spinner:n,transformerReplaceKey:m,transformerSearchKey:p};e.includes("typedoc")&&await Ve(d),e.includes("react")&&await Re(d),e.includes("solid")&&await Te(d),e.includes("preact")&&await qe(d),e.includes("vue")&&await Ge(d),e.includes("svelte")&&await Ke(d),e.includes("css")&&await We(d),await ue(o,u.toString(),{overwrite:!0})},name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},Je=(t,e)=>{if(t==="rolldown")return`// Generated by \`packem\` first-run setup. See https://packem.dev for full options.
|
|
37
37
|
import { defineConfig } from "@visulima/packem/config";
|
|
38
38
|
|
|
39
39
|
export default defineConfig({
|
|
@@ -49,10 +49,10 @@ export default defineConfig({
|
|
|
49
49
|
declaration: true,
|
|
50
50
|
transformer,
|
|
51
51
|
});
|
|
52
|
-
`},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"fast, native DTS",label:"rolldown",value:"rolldown"}]});if(
|
|
52
|
+
`},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"fast, native DTS",label:"rolldown",value:"rolldown"}]});if(U(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},He=async()=>{const t=await g({initialValue:"esbuild",message:"Which transformer do you want to use?",options:[{hint:"fast, widely used",label:"esbuild",value:"esbuild"},{hint:"fastest, Rust-based",label:"oxc",value:"oxc"},{hint:"TypeScript-aware, Rust-based",label:"swc",value:"swc"},{hint:"minimal, JS-based",label:"sucrase",value:"sucrase"}]});if(U(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},Xe=async(t,e)=>{if(t.length===0)return;const a=D();a.start(`Installing ${t.join(", ")}`);try{await h(t,{cwd:e,dev:!0,silent:!0}),a.stop(`Installed ${t.join(", ")}`)}catch(s){throw a.stop(`Failed to install ${t.join(", ")}`),s}},Ye=async t=>{if(await ee(t))return;if(!(process.stdout.isTTY&&!process.env.CI)){const n=await te(["rollup","esbuild"],t);throw new Error(`No packem.config found. Run packem in an interactive terminal to generate one, or install the defaults manually:
|
|
53
53
|
${n}
|
|
54
|
-
and create a packem.config.ts.`)}K(pe("Packem first-run setup")),E.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];a&&s.push(se[a]),await Xe(s,t);const i=b(t,"packem.config.ts");await
|
|
55
|
-
`)){const i=s.trim();if(!i||i.startsWith("#"))continue;const n=Qe.exec(i);if(n?.[1]){const r=n[1].trim();let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=(t,e,a,s)=>{const i=J(t),n=Object.keys(i).length,r={};for(const[c,l]of Object.entries(i))(!e||c.startsWith(e))&&(r[`process.env.${c}`]=JSON.stringify(l));const o=Object.keys(r).length;return n>0&&o===0&&e?s?.warn(`Loaded 0 of ${String(n)} variables from "${a}"; none matched the "${e}" prefix.`):s?.info(`Loaded ${String(o)} of ${String(n)} variables from "${a}"${e?` (prefix "${e}")`:""}.`),r},et=async(t,e,a="PACKEM_",s)=>{const i=
|
|
54
|
+
and create a packem.config.ts.`)}K(pe("Packem first-run setup")),E.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];a&&s.push(se[a]),await Xe(s,t);const i=b(t,"packem.config.ts");await F(i,Je(e,a),"utf8"),E.success(`Created ${i}`),z("Setup complete — continuing with build.")},Qe=/^([^#:=]+)=(.*)$/,T=(t,e="PACKEM_")=>{const a={};for(const s of t.split(`
|
|
55
|
+
`)){const i=s.trim();if(!i||i.startsWith("#"))continue;const n=Qe.exec(i);if(n?.[1]){const r=n[1].trim();let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=(t,e,a,s)=>{const i=J(t),n=Object.keys(i).length,r={};for(const[c,l]of Object.entries(i))(!e||c.startsWith(e))&&(r[`process.env.${c}`]=JSON.stringify(l));const o=Object.keys(r).length;return n>0&&o===0&&e?s?.warn(`Loaded 0 of ${String(n)} variables from "${a}"; none matched the "${e}" prefix.`):s?.info(`Loaded ${String(o)} of ${String(n)} variables from "${a}"${e?` (prefix "${e}")`:""}.`),r},et=async(t,e,a="PACKEM_",s)=>{const i=O(e,t);if(!V(i))return s?.warn(`Env file not found at "${i}"; no environment variables were loaded.`),{};const{readFile:n}=await import("node:fs/promises"),r=await n(i,"utf8");if(typeof J!="function")return T(r,a);try{return Ze(r,a,t,s)}catch{return T(r,a)}},tt=async(t,e,a,s,i)=>{const n=await A(e,i),r=await t.import(n,{default:!0})??{};return{config:typeof r=="function"?await r(a,s):r,path:n}},st=async(t,e)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:a}=await import("../config/preset/preact.js");t=a();break}case"react":{const{createReactPreset:a}=await import("../config/preset/react.js");t=a();break}case"solid":{const{createSolidPreset:a}=await import("../config/preset/solid.js");t=a();break}case"svelte":{const{createSveltePreset:a}=await import("../config/preset/svelte.js");t=a();break}case"vue":{const{createVuePreset:a}=await import("../config/preset/vue.js");t=a();break}default:typeof t=="string"&&(t=await e.import(t,{default:!0})||{})}return typeof t=="function"&&(t=t()),t},at=t=>t.watch?"watch":t.jit?"jit":"build",it=t=>{let e;const a={};if(t.env)for(const s of t.env)s.key==="NODE_ENV"?e=s.value:a[`process.env.${s.key}`]=JSON.stringify(s.value);return{cliEnvVariables:a,nodeEnvironment:e}},nt=(t,e)=>{if(e!==void 0)return e;if(t.production)return W;if(t.development)return we},rt=t=>{const e=[];if(t.external)for(const a of t.external)e.push(...a.split(","));return e},ot=t=>{t.addCommand({description:"Build the package using the resolved packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=at(s),{cliEnvVariables:n,nodeEnvironment:r}=it(s),o=nt(s,r),c=rt(s),l=O(N(),s.dir??".");await Ye(l);const u=be(l,{debug:s.debug}),{config:m,path:p}=await tt(u,l,o,i,s.config??void 0);e.debug("Using packem config found at",p);const d=s.envFile??m.envFile,x=s.envPrefix??m.envPrefix??"PACKEM_",w={};if(d){const y=await et(d,l,x,{info:v=>{e.info(v)},warn:v=>{e.warn(v)}});Object.assign(w,y)}Object.assign(w,n);const L=await st(m.preset??"none",u);s.minify&&s.sourcemap===void 0&&(s.sourcemap=!0);try{const y=ae()(m,ie,L,{analyze:s.analyze,bundler:s.bundler,cjsInterop:s.cjsInterop,clean:s.clean,dtsOnly:s.dtsOnly,externals:c,killSignal:s.killSignal,minify:s.minify??o===W,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,...Object.keys(w).length>0||Object.keys(n).length>0?{replace:{values:w}}:{},resolveExternals:s.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:s.runtime,sourcemap:s.metafile||s.analyze||s.sourcemap,unbundle:s.unbundle,validation:s.validation===!1?!1:{},...s.exe?{exe:!0}:{},...s.typedoc?{typedoc:{format:"html"}}:{}});s.validation===!1&&!m.validation&&(y.validation=!1),s.cache===!1&&(y.fileCache=!1),await ne(l,i,o,e,s.debug??!1,y,s.tsconfig??void 0)}catch(y){e.error(y),le(1)}},name:"build",options:[{description:"Specify the bundler to use (rollup or rolldown)",name:"bundler",type:e=>{if(e==="rollup"||e==="rolldown")return e;throw new Error("Invalid bundler. Use 'rollup' or 'rolldown'.")}},{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=>{const a=e.indexOf("=");return a===-1?{key:e,value:""}:{key:e.slice(0,a),value:e.slice(a+1)}}},{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:e=>{if(e==="SIGTERM"||e==="SIGKILL")return e;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")}},{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 (node, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean},{description:"Bundle the output into a standalone executable via Node.js SEA (requires Node.js >= 25.7.0, single entry)",name:"exe",type:Boolean}]})},X=t=>t==="sass-embedded"||t==="node-sass"?"sass":t,ct=(t,e)=>{fe(b(t,"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:e?["es2022","dom","dom.iterable"]:["es2022"]}})},lt=(t,e,a,s,i)=>{let n="";if(t)for(const r of e){const o=X(r);n+=i?`import ${o}Loader from "@visulima/packem/css/loader/${o.toLowerCase()}";
|
|
56
56
|
`:`const ${o}Loader = require("@visulima/packem/css/loader/${o.toLowerCase()}");
|
|
57
57
|
`}return s&&a&&(n+=i?`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
|
|
58
58
|
`:`const ${a}Minifier = require("@visulima/packem/css/minifier/${a.toLowerCase()}");
|
|
@@ -76,8 +76,8 @@ module.exports = defineConfig({
|
|
|
76
76
|
runtime: ${a},
|
|
77
77
|
transformer${i}
|
|
78
78
|
});
|
|
79
|
-
`,pt=t=>{const e=[];return t.dependencies&&e.push(...Object.keys(t.dependencies)),t.devDependencies&&e.push(...Object.keys(t.devDependencies)),e},mt=async(t,e,a,s)=>{if(t===void 0&&!e){const n=await f({message:"Do you want to install TypeScript?"});return n&&s.push("typescript@latest"),n}const i=a.devDependencies?.typescript??a.dependencies?.typescript??"unknown";return E.message(`TypeScript version ${i} is already installed`),t},ft=async(t,e,a)=>{let s=t;return e.includes("esbuild")?s="esbuild":e.includes("@swc/core")?s="swc":e.includes("sucrase")&&(s="sucrase"),s!==void 0?(E.message(`Transformer ${s} is already installed.`),s):(s=await g({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),s&&s!=="oxc"&&!e.includes(s)&&await f({message:`Do you want to install ${s}?`})&&a.push(s==="swc"?"@swc/core":s),s)},gt=async t=>{if(
|
|
80
|
-
`;return t?(e.info("[dry-run] package.json changes:"),e.info("Old content:"),console.info(a),e.info("New content:"),console.info(o)):(await
|
|
79
|
+
`,pt=t=>{const e=[];return t.dependencies&&e.push(...Object.keys(t.dependencies)),t.devDependencies&&e.push(...Object.keys(t.devDependencies)),e},mt=async(t,e,a,s)=>{if(t===void 0&&!e){const n=await f({message:"Do you want to install TypeScript?"});return n&&s.push("typescript@latest"),n}const i=a.devDependencies?.typescript??a.dependencies?.typescript??"unknown";return E.message(`TypeScript version ${i} is already installed`),t},ft=async(t,e,a)=>{let s=t;return e.includes("esbuild")?s="esbuild":e.includes("@swc/core")?s="swc":e.includes("sucrase")&&(s="sucrase"),s!==void 0?(E.message(`Transformer ${s} is already installed.`),s):(s=await g({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),s&&s!=="oxc"&&!e.includes(s)&&await f({message:`Do you want to install ${s}?`})&&a.push(s==="swc"?"@swc/core":s),s)},gt=async t=>{if(M(b(t,"tsconfig.json")))return;const e=await f({message:"Do you want to use generate a tsconfig.json?"}),a=await f({message:"Do you want to run your code in the DOM?"});if(e){const s=D();s.start("Generating tsconfig.json"),ct(t,!!a),s.stop("")}},yt=async t=>{if(!t.includes("sass"))return t;const e=await g({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"}]});return e==="sass"?t:[...t.filter(a=>a!=="sass"),e]},wt=async t=>{const e=[],a=await g({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});e.push(a);const s=await G({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1}),i=await yt(s);if(e.push(...i),await f({message:`Do you want to install "${e.join('", "')}"?`}))for(const n of e)t.push(..._[n]);return e.push("sourceMap"),e},bt=async(t,e)=>{const a=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return t.includes("lightningcss")||await f({message:`Do you want to install "${a}"?`})&&e.push(a),a},ht=t=>{t.addCommand({description:"Initialize packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=e;if(K("Welcome to packem setup"),M(b(s.dir??".","packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}const n=O(N(),s.dir??"."),r=b(n,"package.json");if(!M(r))throw new Error("No package.json found in the directory");const o=await q(r,{resolveCatalogs:!0}),c=pt(o),l=!!(o.devDependencies?.typescript??o.dependencies?.typescript),u=[];s.typescript=await mt(s.typescript,l,o,u),await gt(n),s.runtime??=await g({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]}),s.transformer=await ft(s.transformer,c,u),s.css??=await f({initialValue:!1,message:"Do you want to use css in your project?"});const m=s.css?await wt(u):[];s.cssMinifier??=await f({initialValue:!1,message:"Do you want to minify your css?"});const p=s.cssMinifier?await bt(m,u):void 0,d=s.css??!1,x=s.cssMinifier??!1,w=l||o.type==="module",L=dt(d,p,x,m),y=lt(d,m,p,x,w),v=ut(w,s.transformer??"",s.runtime??"",y,L),P=D(),I=l?"ts":"js";u.length>0&&(P.start("Installing packages"),await h(u,{cwd:n,dev:!0,silent:!0}),P.stop("Installed packages")),P.start(`Creating packem.config.${I}`),me(b(n,`packem.config.${I}`),v),P.stop(`Created packem.config.${I}`),z("Now you can run `packem build` to build your project")},name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:e=>{if(typeof e=="string"&&["esbuild","sucrase","swc"].includes(e))return e;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")}},{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:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}}]})},Y={bunchee:"@visulima/packem",tsup:"@visulima/packem","tsup-node":"@visulima/packem",unbuild:"@visulima/packem"},vt={dependencies:`^${R.version}`,devDependencies:`^${R.version}`,peerDependencies:"*"},kt=(t,e,a,s)=>{const i={};for(const n of Object.keys(t))n===e?i[a]=s??t[e]:i[n]=t[n];return i},$t=/\bunbuild\b/g,St=/\bbunchee\b/g,Ct=/\btsup(?:-node)?/g,jt=/\bbuild\b/g,xt=[{from:"tsup",rewrite:t=>t.replaceAll(Ct,"packem build").replaceAll(jt,"build")},{from:"unbuild",rewrite:t=>t.replaceAll($t,"packem build")},{from:"bunchee",rewrite:t=>t.replaceAll(St,"packem build")}],Pt=(t,e,a)=>{let s=e,i=!1;for(const n of Object.keys(Y))s.includes(n)&&(a.info(`Migrating \`${t}\` script from ${n} to packem`),i=!0,s=s.replaceAll(new RegExp(String.raw`\b${n}\b`,"g"),"packem").replaceAll(new RegExp(String.raw`\b${n}-node\b`,"g"),"packem"));for(const{from:n,rewrite:r}of xt)s.includes(n)&&(a.info(`Migrating \`${t}\` script from ${n} to packem`),i=!0,s=r(s));return i?s:void 0},Et=(t,e)=>{const a={...t};let s=!1;for(const i of Object.keys(a)){const n=Pt(i,a[i],e);n!==void 0&&(a[i]=n,s=!0)}return{found:s,scripts:a}},Dt=(t,e)=>{const a={...t};let s=!1;for(const[i,n]of Object.entries(vt)){let r=a[i];for(const[o,c]of Object.entries(Y))r?.[o]&&(e.info(`Migrating \`${i}\` from ${o} to ${c}.`),s=!0,r=kt(r,o,c,n),a[i]=r)}return{found:s,pkg:a}},Ot=(t,e)=>{const a=["tsup","unbuild","bunchee"];for(const s of a)t[s]&&e.info(`Found \`${s}\` config field in package.json. Consider moving to packem.config.ts`)},Lt=async(t,e)=>{if(!V("package.json"))return e.error("No package.json found"),!1;const a=await he("package.json","utf8"),s=JSON.parse(a),{found:i,pkg:n}=Dt(s,e);let r=i;if(n.scripts){const{found:c,scripts:l}=Et(n.scripts,e);c&&(n.scripts=l,r=!0)}if(Ot(n,e),!r)return e.info("No migratable bundler dependencies found in package.json"),!1;const o=`${JSON.stringify(n,void 0,a.includes(" ")?" ":2)}
|
|
80
|
+
`;return t?(e.info("[dry-run] package.json changes:"),e.info("Old content:"),console.info(a),e.info("New content:"),console.info(o)):(await F("package.json",o),e.success("Migrated `package.json`")),!0},It=["tsup.config.ts","tsup.config.cts","tsup.config.mts","tsup.config.js","tsup.config.cjs","tsup.config.mjs","tsup.config.json","build.config.ts","build.config.cts","build.config.mts","build.config.js","build.config.cjs","build.config.mjs","bunchee.config.ts","bunchee.config.cts","bunchee.config.mts","bunchee.config.js","bunchee.config.cjs","bunchee.config.mjs"],Mt=t=>{let e=!1;for(const a of It)V(a)&&(t.info(`Found config file \`${a}\`. Consider creating packem.config.ts instead.`),t.info("Manual migration required for config files. See https://www.visulima.com/docs/package/packem"),e=!0);return e||t.info("No bundler config files found"),e},Nt=async({cwd:t,dryRun:e,logger:a})=>{if(e)a.info("Dry run enabled. No changes will be made.");else{const i=ve({input:k.stdin,output:k.stdout});a.warn(`
|
|
81
81
|
|
|
82
82
|
Before proceeding, review the migration guide at https://www.visulima.com/docs/package/packem, as this process will modify your files.
|
|
83
|
-
Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const n=await i.question("Continue? (Y/n) ");if(i.close(),!(n.toLowerCase()==="y"||n==="")){a.error("Migration cancelled."),k.exitCode=1;return}}t&&k.chdir(t);let s=!1;await
|
|
83
|
+
Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const n=await i.question("Continue? (Y/n) ");if(i.close(),!(n.toLowerCase()==="y"||n==="")){a.error("Migration cancelled."),k.exitCode=1;return}}t&&k.chdir(t);let s=!1;await Lt(e,a)&&(s=!0),Mt(a)&&(s=!0),s?a.success("Migration completed. Remember to run install command with your package manager."):(a.error("No migration performed."),k.exitCode=1)},Bt=t=>{t.addCommand({description:"Migrate from other bundlers (tsup, unbuild, bunchee, etc.) to packem",execute:async({logger:e,options:a})=>{const s=a;await Nt({cwd:s.cwd,dryRun:s.dryRun,logger:e})},name:"migrate",options:[{defaultValue:".",description:"The directory to migrate",name:"cwd",type:String},{description:"Preview changes without applying them",name:"dry-run",type:Boolean}]})};try{require("node:module").enableCompileCache?.()}catch{}const j=Q("packem",{logger:Z({reporters:[new ce({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"}),packageName:oe,packageVersion:re});ht(j);ot(j);Fe(j);Bt(j);j.run({shouldExitProcess:!1});
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildConfig, a as BuildConfigFunction, b as BuildPreset } from "../packem_shared/types.d-
|
|
1
|
+
import { B as BuildConfig, a as BuildConfigFunction, b as BuildPreset } from "../packem_shared/types.d-CA4tXIce.js";
|
|
2
2
|
export type { BuildHooks } from '@visulima/packem-share/types';
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-plugins';
|
|
@@ -12,48 +12,48 @@ import 'jiti';
|
|
|
12
12
|
import 'rollup';
|
|
13
13
|
import 'typedoc';
|
|
14
14
|
/**
|
|
15
|
-
* Defines a build configuration for Packem.
|
|
16
|
-
* Supports both static configuration objects and dynamic configuration functions.
|
|
17
|
-
* @param config Static build configuration object or function returning configuration
|
|
18
|
-
* @returns The provided configuration
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Static configuration
|
|
22
|
-
* export default defineConfig({
|
|
23
|
-
* entries: ['./src/index.ts'],
|
|
24
|
-
* outDir: './dist'
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* // Dynamic configuration
|
|
28
|
-
* export default defineConfig((env, mode) => ({
|
|
29
|
-
* entries: ['./src/index.ts'],
|
|
30
|
-
* outDir: env === 'production' ? './dist' : './dev'
|
|
31
|
-
* }));
|
|
32
|
-
* ```
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
15
|
+
* Defines a build configuration for Packem.
|
|
16
|
+
* Supports both static configuration objects and dynamic configuration functions.
|
|
17
|
+
* @param config Static build configuration object or function returning configuration
|
|
18
|
+
* @returns The provided configuration
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Static configuration
|
|
22
|
+
* export default defineConfig({
|
|
23
|
+
* entries: ['./src/index.ts'],
|
|
24
|
+
* outDir: './dist'
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Dynamic configuration
|
|
28
|
+
* export default defineConfig((env, mode) => ({
|
|
29
|
+
* entries: ['./src/index.ts'],
|
|
30
|
+
* outDir: env === 'production' ? './dist' : './dev'
|
|
31
|
+
* }));
|
|
32
|
+
* ```
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
35
|
declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
|
|
36
36
|
/**
|
|
37
|
-
* Defines a build preset for Packem.
|
|
38
|
-
* Build presets provide reusable configuration templates that can be shared across projects.
|
|
39
|
-
* @param preset Build preset configuration
|
|
40
|
-
* @returns The provided preset configuration
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* export default definePreset({
|
|
44
|
-
* name: 'my-preset',
|
|
45
|
-
* defaults: {
|
|
46
|
-
* entries: ['./src/index.ts'],
|
|
47
|
-
* outDir: './dist'
|
|
48
|
-
* },
|
|
49
|
-
* hooks: {
|
|
50
|
-
* 'build:before': (context) => {
|
|
51
|
-
* // Custom build preparation logic
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* });
|
|
55
|
-
* ```
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
37
|
+
* Defines a build preset for Packem.
|
|
38
|
+
* Build presets provide reusable configuration templates that can be shared across projects.
|
|
39
|
+
* @param preset Build preset configuration
|
|
40
|
+
* @returns The provided preset configuration
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* export default definePreset({
|
|
44
|
+
* name: 'my-preset',
|
|
45
|
+
* defaults: {
|
|
46
|
+
* entries: ['./src/index.ts'],
|
|
47
|
+
* outDir: './dist'
|
|
48
|
+
* },
|
|
49
|
+
* hooks: {
|
|
50
|
+
* 'build:before': (context) => {
|
|
51
|
+
* // Custom build preparation logic
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
58
|
declare const definePreset: (preset: BuildPreset) => BuildPreset;
|
|
59
59
|
export { type BuildConfig, type BuildConfigFunction, type BuildPreset, defineConfig, definePreset };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BabelPluginConfig } from '@visulima/packem-plugins/babel';
|
|
2
|
-
import { B as BuildConfig } from "../../packem_shared/types.d-
|
|
2
|
+
import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-plugins';
|
|
5
5
|
import '@visulima/packem-plugins/oxc';
|
|
@@ -14,18 +14,18 @@ import 'rollup';
|
|
|
14
14
|
import 'typedoc';
|
|
15
15
|
interface PreactPresetOptions {
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* Enable Preact devtools in production builds
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
20
|
devtoolsInProd?: boolean;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
plugins?: BabelPluginConfig["plugins"]
|
|
22
|
+
* Custom Babel plugins to add
|
|
23
|
+
*/
|
|
24
|
+
plugins?: NonNullable<BabelPluginConfig["plugins"]>;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
presets?: BabelPluginConfig["presets"]
|
|
26
|
+
* Custom Babel presets to add
|
|
27
|
+
*/
|
|
28
|
+
presets?: NonNullable<BabelPluginConfig["presets"]>;
|
|
29
29
|
}
|
|
30
30
|
declare const createPreactPreset: (options?: PreactPresetOptions) => BuildConfig;
|
|
31
31
|
export { PreactPresetOptions, createPreactPreset };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BabelPluginConfig } from '@visulima/packem-plugins/babel';
|
|
2
|
-
import { B as BuildConfig } from "../../packem_shared/types.d-
|
|
2
|
+
import { B as BuildConfig } from "../../packem_shared/types.d-CA4tXIce.js";
|
|
3
3
|
import '@arethetypeswrong/core';
|
|
4
4
|
import '@visulima/packem-plugins';
|
|
5
5
|
import '@visulima/packem-plugins/oxc';
|
|
@@ -14,59 +14,59 @@ import 'rollup';
|
|
|
14
14
|
import 'typedoc';
|
|
15
15
|
interface ReactPresetOptions {
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
* Enable React Compiler optimization
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
20
|
compiler?: boolean | {
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
* React Compiler compilation mode
|
|
23
|
+
* @default "infer"
|
|
24
|
+
*/
|
|
25
25
|
compilationMode?: "infer" | "annotation";
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
* React Compiler panic threshold
|
|
28
|
+
* @default "critical_errors"
|
|
29
|
+
*/
|
|
30
30
|
panicThreshold?: "critical_errors" | "all_errors";
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
plugins?: BabelPluginConfig["plugins"]
|
|
33
|
+
* Custom Babel plugins to add
|
|
34
|
+
*/
|
|
35
|
+
plugins?: NonNullable<BabelPluginConfig["plugins"]>;
|
|
36
36
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
presets?: BabelPluginConfig["presets"]
|
|
37
|
+
* Custom Babel presets to add
|
|
38
|
+
*/
|
|
39
|
+
presets?: NonNullable<BabelPluginConfig["presets"]>;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* React preset for Packem. Configures Babel with React presets and optionally React Compiler.
|
|
43
|
-
* @description This preset configures Babel to run before your main transformer (esbuild/SWC/etc.).
|
|
44
|
-
* Babel handles JSX transformation, while TypeScript is handled by the transformer via parser plugins.
|
|
45
|
-
* This matches the approach used by `@vitejs/plugin-react`.
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Basic usage
|
|
49
|
-
* export default defineConfig({
|
|
50
|
-
* preset: "react"
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* // With React Compiler
|
|
54
|
-
* import { createReactPreset } from "@visulima/packem/config/preset/react";
|
|
55
|
-
* export default defineConfig({
|
|
56
|
-
* preset: createReactPreset({
|
|
57
|
-
* compiler: true
|
|
58
|
-
* })
|
|
59
|
-
* });
|
|
60
|
-
*
|
|
61
|
-
* // With custom options
|
|
62
|
-
* export default defineConfig({
|
|
63
|
-
* preset: createReactPreset({
|
|
64
|
-
* compiler: {
|
|
65
|
-
* compilationMode: "annotation"
|
|
66
|
-
* }
|
|
67
|
-
* })
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
42
|
+
* React preset for Packem. Configures Babel with React presets and optionally React Compiler.
|
|
43
|
+
* @description This preset configures Babel to run before your main transformer (esbuild/SWC/etc.).
|
|
44
|
+
* Babel handles JSX transformation, while TypeScript is handled by the transformer via parser plugins.
|
|
45
|
+
* This matches the approach used by `@vitejs/plugin-react`.
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Basic usage
|
|
49
|
+
* export default defineConfig({
|
|
50
|
+
* preset: "react"
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // With React Compiler
|
|
54
|
+
* import { createReactPreset } from "@visulima/packem/config/preset/react";
|
|
55
|
+
* export default defineConfig({
|
|
56
|
+
* preset: createReactPreset({
|
|
57
|
+
* compiler: true
|
|
58
|
+
* })
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // With custom options
|
|
62
|
+
* export default defineConfig({
|
|
63
|
+
* preset: createReactPreset({
|
|
64
|
+
* compiler: {
|
|
65
|
+
* compilationMode: "annotation"
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
71
|
declare const createReactPreset: (options?: ReactPresetOptions) => BuildConfig;
|
|
72
72
|
export { ReactPresetOptions, createReactPreset };
|