@visulima/packem 2.0.0-alpha.32 → 2.0.0-alpha.34
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 +21 -0
- package/LICENSE.md +5508 -9
- package/dist/builder/typedoc/generate-reference-documentation.d.ts +4 -0
- package/dist/builder/typedoc/index.d.ts +3 -29
- package/dist/cli/commands/add.d.ts +3 -0
- package/dist/cli/commands/build.d.ts +21 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/utils/css-loader-dependencies.d.ts +2 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +10 -10
- package/dist/config/index.d.ts +48 -31
- package/dist/config/preset/auto.d.ts +3 -0
- package/dist/config/preset/utils/infer-entries.d.ts +12 -0
- package/dist/config/preset/utils/overwrite-with-publish-config.d.ts +4 -0
- package/dist/config/utils/find-packem-file.d.ts +2 -0
- package/dist/config/utils/load-package-json.d.ts +6 -0
- package/dist/config/utils/load-packem-config.d.ts +7 -0
- package/dist/config/utils/load-preset.d.ts +4 -0
- package/dist/config/utils/load-tsconfig.d.ts +5 -0
- package/dist/config/utils/prepare-entries.d.ts +4 -0
- package/dist/index.d.ts +45 -35
- package/dist/index.js +1 -1
- package/dist/jit/create-stub.d.ts +4 -0
- package/dist/packem/build.d.ts +21 -0
- package/dist/packem/index.d.ts +25 -0
- package/dist/packem/node10-compatibility.d.ts +7 -0
- package/dist/packem/utils/brotli-size.d.ts +2 -0
- package/dist/packem/utils/group-by-keys.d.ts +3 -0
- package/dist/packem/utils/gzip-size.d.ts +2 -0
- package/dist/packem_shared/{index-8EL_RHKk.js → index-Dt7qUoo-.js} +63 -63
- package/dist/rollup/build-types.d.ts +5 -0
- package/dist/rollup/build.d.ts +5 -0
- package/dist/rollup/get-rollup-options.d.ts +5 -0
- package/dist/rollup/plugins/css/loaders/less.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/postcss.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/sass.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/sourcemap.d.ts +1 -9
- package/dist/rollup/plugins/css/loaders/stylus.d.ts +1 -1
- package/dist/rollup/plugins/css/loaders/tailwindcss.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/cssnano.d.ts +1 -1
- package/dist/rollup/plugins/css/minifiers/lightningcss.d.ts +1 -1
- package/dist/rollup/plugins/esbuild/index.d.ts +2 -26
- package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -27
- package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +2 -22
- package/dist/rollup/plugins/resolve-externals-plugin.d.ts +60 -0
- package/dist/rollup/plugins/sucrase/index.d.ts +2 -21
- package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -27
- package/dist/rollup/plugins/swc/swc-plugin.d.ts +2 -22
- package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -26
- package/dist/rollup/utils/resolve-aliases.d.ts +4 -0
- package/dist/rollup/watch.d.ts +5 -0
- package/dist/types.d.ts +328 -0
- package/dist/utils/clean-distribution-directories.d.ts +4 -0
- package/dist/utils/create-or-update-key-storage.d.ts +3 -0
- package/dist/utils/extract-export-filenames.d.ts +16 -0
- package/dist/utils/find-alternatives.d.ts +2 -0
- package/dist/utils/get-package-side-effect.d.ts +3 -0
- package/dist/utils/infer-export-type.d.ts +3 -0
- package/dist/utils/kill-process.d.ts +14 -0
- package/dist/utils/log-build-errors.d.ts +4 -0
- package/dist/utils/remove-old-cache-folders.d.ts +3 -0
- package/dist/utils/warn-legacy-cjs.d.ts +8 -0
- package/dist/validator/attw.d.ts +7 -0
- package/dist/validator/package-json/index.d.ts +4 -0
- package/dist/validator/package-json/validate-dependencies.d.ts +4 -0
- package/dist/validator/package-json/validate-engines.d.ts +4 -0
- package/dist/validator/package-json/validate-package-entries.d.ts +4 -0
- package/dist/validator/package-json/validate-package-fields.d.ts +4 -0
- package/dist/validator/validate-alias-entries.d.ts +3 -0
- package/dist/validator/validate-bundle-size.d.ts +4 -0
- package/package.json +8 -8
- package/dist/packem_shared/index-Cjp2s4rr.d.ts +0 -5106
- package/dist/packem_shared/types-0Eba14hg.d.ts +0 -175
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Pail } from "@visulima/pail";
|
|
2
|
+
import type { BuildEntry, TypeDocumentOptions } from "../../types.d.ts";
|
|
3
|
+
declare const generateReferenceDocumentation: (options: TypeDocumentOptions, entries: BuildEntry[], outputDirectory: string, logger: Pail) => Promise<void>;
|
|
4
|
+
export default generateReferenceDocumentation;
|
|
@@ -1,30 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '@rollup/plugin-alias';
|
|
4
|
-
import '@rollup/plugin-commonjs';
|
|
5
|
-
import '@rollup/plugin-json';
|
|
6
|
-
import '@rollup/plugin-node-resolve';
|
|
7
|
-
import '@rollup/plugin-replace';
|
|
8
|
-
import '@rollup/plugin-wasm';
|
|
9
|
-
import '@rollup/pluginutils';
|
|
10
|
-
import 'rollup';
|
|
11
|
-
import 'rollup-plugin-dts';
|
|
12
|
-
import 'rollup-plugin-polyfill-node';
|
|
13
|
-
import 'rollup-plugin-pure';
|
|
14
|
-
import 'rollup-plugin-visualizer';
|
|
15
|
-
import 'esbuild';
|
|
16
|
-
import '@visulima/package';
|
|
17
|
-
import '@visulima/colorize';
|
|
18
|
-
import 'magic-string';
|
|
19
|
-
import 'html-minifier-next';
|
|
20
|
-
import 'oxc-resolver';
|
|
21
|
-
import 'oxc-transform';
|
|
22
|
-
import 'sucrase';
|
|
23
|
-
import '@arethetypeswrong/core';
|
|
24
|
-
import '@visulima/rollup-plugin-css';
|
|
25
|
-
import 'jiti';
|
|
26
|
-
import 'typedoc';
|
|
27
|
-
|
|
1
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
2
|
+
import type { InternalBuildOptions } from "../../types.d.ts";
|
|
28
3
|
declare const builder: (context: BuildContext<InternalBuildOptions>, cachePath: string | undefined, _: never, logged: boolean) => Promise<void>;
|
|
29
|
-
|
|
30
|
-
export { builder as default };
|
|
4
|
+
export default builder;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Cli } from "@visulima/cerebro";
|
|
2
|
+
/**
|
|
3
|
+
* Creates and registers the build command with the CLI.
|
|
4
|
+
* Handles various build modes, environment variables, and build configurations.
|
|
5
|
+
* @param cli CLI instance to register the command with
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Usage from command line:
|
|
9
|
+
* // Build for production:
|
|
10
|
+
* // packem build --production
|
|
11
|
+
*
|
|
12
|
+
* // Watch mode with development environment:
|
|
13
|
+
* // packem build --watch --development
|
|
14
|
+
*
|
|
15
|
+
* // With custom environment variables:
|
|
16
|
+
* // packem build --env.API_URL=http://api.example.com
|
|
17
|
+
* ```
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare const createBuildCommand: (cli: Cli) => void;
|
|
21
|
+
export default createBuildCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var ae=Object.defineProperty;var k=(t,s)=>ae(t,"name",{value:s,configurable:!0});import re from"@visulima/cerebro";import{SimpleReporter as le}from"@visulima/pail/reporter";import{cwd as U,exit as ce}from"node:process";import{installPackage as q}from"@antfu/install-pkg";import{spinner as R,select as S,multiselect as Q,confirm as w,intro as pe,log as W,cancel as de,outro as ue}from"@clack/prompts";import{isAccessible as me,readFile as fe,writeFile as ye,isAccessibleSync as j,collectSync as ge,writeJsonSync as
|
|
2
|
+
var ae=Object.defineProperty;var k=(t,s)=>ae(t,"name",{value:s,configurable:!0});import re from"@visulima/cerebro";import{SimpleReporter as le}from"@visulima/pail/reporter";import{cwd as U,exit as ce}from"node:process";import{installPackage as q}from"@antfu/install-pkg";import{spinner as R,select as S,multiselect as Q,confirm as w,intro as pe,log as W,cancel as de,outro as ue}from"@clack/prompts";import{isAccessible as me,readFile as fe,writeFile as ye,isAccessibleSync as j,collectSync as ge,writeJsonSync as be,writeFileSync as ve}from"@visulima/fs";import{join as C,resolve as E,extname as ee,toNamespacedPath as we}from"@visulima/path";import he from"magic-string";import{t as O,E as G,e as $e,N as te,_ as ke,c as Se}from"../packem_shared/index-CUp9WuCG.js";import{defu as xe}from"defu";import{createJiti as je}from"jiti";import{cyan as Ce,bold as J,gray as De}from"@visulima/colorize";import{e as Ee,i as _,c as Pe,x as Ie}from"../packem_shared/index-Dt7qUoo-.js";import Me from"node:fs/promises";import X from"node:path/posix";import{parsePackageJson as Te}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
|
-
|
|
4
|
+
var Le="@visulima/packem",Be="2.0.0-alpha.33",Oe=Object.defineProperty,Ne=k((t,s)=>Oe(t,"name",{value:s,configurable:!0}),"t$2");const se=Ne(async(t,s="")=>{let e=s;if(!e){const r=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const a of r)if(await me(C(t,a))){e=`./${a}`;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(e))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return e},"findPackemFile"),oe={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 Ke=Object.defineProperty,H=k((t,s)=>Ke(t,"name",{value:s,configurable:!0}),"g");const Ae=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ve=H(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:H(async({argument:s,logger:e,options:r})=>{const a=R(),o=E(U(),r.dir??".");let p;try{p=await se(o,r.config)}catch{e.error("Could not find a packem config file, please run `packem init` first.");return}const u=await fe(p,{buffer:!1});let y="cjs";u.includes("import")&&(y="esm");const i=new he(u),m=" transformer,";let n=" transformer";if(u.includes(" transformer,")&&(n=" transformer,"),s.includes("typedoc")){if(u.includes("typedoc: typedocBuilder")||u.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}y==="cjs"?i.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
|
5
5
|
`):i.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
|
|
6
6
|
`),u.includes("builder: {")?i.replace("builder: {",`builder: {
|
|
7
7
|
typedoc: typedocBuilder,
|
|
@@ -9,23 +9,23 @@ const Le="@visulima/packem",Oe="2.0.0-alpha.31";var Be=Object.defineProperty,Ne=
|
|
|
9
9
|
builder: {
|
|
10
10
|
typedoc: typedocBuilder,
|
|
11
11
|
},`),e.info("Adding typedoc dependencies..."),a.start("Installing packages"),await q(Ae,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
|
|
12
|
-
Typedoc added!`)}if(s.includes("css")){if(u.includes("css: {")||u.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const c=[],g=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(c.push(g),g!=="tailwindcss"){let f=await Q({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(f.includes("sass")){const h=await S({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});h!=="sass"&&(f=f.filter(D=>D!=="sass"),f.push(h))}c.push(...f)}const
|
|
12
|
+
Typedoc added!`)}if(s.includes("css")){if(u.includes("css: {")||u.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const c=[],g=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(c.push(g),g!=="tailwindcss"){let f=await Q({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(f.includes("sass")){const h=await S({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});h!=="sass"&&(f=f.filter(D=>D!=="sass"),f.push(h))}c.push(...f)}const b=[];for(const f of c)b.push(...oe[f]);g!=="tailwindcss"&&c.push("sourceMap");for(let f of c)(f==="sass-embedded"||f==="node-sass")&&(f="sass"),y==="cjs"?i.prepend(`const ${f}Loader = require("@visulima/packem/css/loader/${f.toLowerCase()}");
|
|
13
13
|
`):i.prepend(`import ${f}Loader from "@visulima/packem/css/loader/${f.toLowerCase()}";
|
|
14
|
-
`);const d=await w({initialValue:!1,message:"Do you want to minify your css?"});let l;d&&(l=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),c.includes("lightningcss")||
|
|
14
|
+
`);const d=await w({initialValue:!1,message:"Do you want to minify your css?"});let l;d&&(l=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),c.includes("lightningcss")||b.push(l),y==="cjs"?i.prepend(`const ${l}Minifier = require("@visulima/packem/css/minifier/${l.toLowerCase()}");
|
|
15
15
|
`):i.prepend(`import ${l}Minifier from "@visulima/packem/css/minifier/${l.toLowerCase()}";
|
|
16
|
-
`));const
|
|
16
|
+
`));const v=c.map(f=>((f==="sass-embedded"||f==="node-sass")&&(f="sass"),`${f}Loader`)).join(", ");u.includes("rollup: {")?i.replace("rollup: {",`rollup: {
|
|
17
17
|
css: {${l?`
|
|
18
18
|
minifier: ${l}Minifier,`:""}
|
|
19
|
-
loaders: [${
|
|
19
|
+
loaders: [${v}],
|
|
20
20
|
},
|
|
21
21
|
`):i.replace(n,`${m}
|
|
22
22
|
rollup: {
|
|
23
23
|
css: {${l?`
|
|
24
24
|
minifier: ${l}Minifier,`:""}
|
|
25
|
-
loaders: [${
|
|
25
|
+
loaders: [${v}],
|
|
26
26
|
},
|
|
27
|
-
},`),a.start("Installing packages"),await q(
|
|
28
|
-
CSS loaders added!`)}await ye(p,i.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand");var Je=Object.defineProperty,qe=k((t,s)=>Je(t,"name",{value:s,configurable:!0}),"e$1");const Re=qe(async(t,s,e,r,a)=>{const o=await se(s,a);let p=await t.import(o,{default:!0,try:!0})||{};return typeof p=="function"&&(p=await p(e,r)),{config:p,path:o}},"loadPackemConfig");var Ge=Object.defineProperty,x=k((t,s)=>Ge(t,"name",{value:s,configurable:!0}),"u$1");const F=new Map,Fe=/\.[^./]+$/,Ue=x(async t=>{try{return await Me.readdir(t,{withFileTypes:!0})}catch(s){const{code:e}=s;if(e==="ENOENT")return[];throw s}},"safeReaddir"),ie=x(async(t,s)=>{const e=await Ue(t);return(await Promise.all(e.map(async r=>{const a=X.join(t,r.name);return r.isDirectory()?ie(a,s):r.isFile()?X.relative(s,a):[]}))).flat()},"getDirectoryFilesRecursive"),ze=x(async t=>{let s=F.get(t);return s||(s=ie(t,t),F.set(t,s)),s},"getDirectoryFiles"),We=x((t,s)=>{const e=t.replace(Fe,"");if(s==="*"){const p=e.split("/");return p.length>0?[p[0]]:null}const r=s.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),a=new RegExp(`^${r}$`),o=e.match(a);return o?o.slice(1):null},"matchWildcardPattern"),_e=x((t,s)=>{let e=t;for(const r of s)e=e.replace("*",r);return e},"substituteWildcards"),Xe=x((t,s)=>t.key==="exports"&&t.subKey===B?B:t.key==="exports"&&t.subKey===G?G:s,"getEnvironment"),O=x((t,s,e,r,a,o,p)=>{const u=Xe(a,o.environment);let y=o.options.runtime;for(const n of $e)if(a.file.includes(`.${n}.`)||a.subKey===n){y=n;break}let i=t.find(n=>n.input===s&&n.environment===u&&n.runtime===y);i===void 0?i=t[t.push({environment:u,exportKey:new Set([a.exportKey].filter(Boolean)),input:s,runtime:y})-1]:i.exportKey&&a.exportKey&&i.exportKey.add(a.exportKey),p&&(i.isGlob=!0),e&&(i.outDir=r),a.isExecutable?(i.executable=!0,i.declaration=!1,a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0)):(/\.d\.[mc]?ts$/.test(a.file)&&o.options.declaration!==!1&&(i.declaration=o.options.declaration),a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0));const m=a.file.replace(ee(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");te.has(a.subKey)&&!s.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Y=!1;const Z=x(t=>{if(t.pkg?.dependencies?.typescript===void 0&&t.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"),He=x(async(t,s,e)=>{const r=t.types||t.typings;F.clear();const a=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),o=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),p=[];s.sort((n,c)=>n.split("/").length-c.split("/").length);const u=t.type==="module"?"esm":"cjs";u==="esm"&&(e.options.emitESM=!0),u==="cjs"&&(e.options.emitCJS=!0);const y=e.options.emitCJS&&e.options.emitESM;e.options.declaration===void 0&&(e.options.declaration=y?"compatible":"node16");const i=Ee(t.exports,u,e.options.declaration,[],e.options.ignoreExportKeys).filter(n=>!n.ignored);if(t.bin){const n=(typeof t.bin=="string"?[t.bin]:Object.values(t.bin)).filter(Boolean);for(const c of n){const g=_(c);if(g&&g!==u)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${t.type??"commonjs"}".`);i.push({file:c,isExecutable:!0,key:"bin",type:g??u})}}t.main&&i.push({file:t.main,key:"main",type:_(t.main)??u}),t.module&&i.push({file:t.module,key:"module",type:"esm"}),r&&(Z(e),(e.options.declaration===void 0||e.options.declaration==="node16")&&y&&(e.options.declaration="compatible"),i.push({file:t.types??t.typings,key:"types"}));const m=[];for await(const n of i){const c=ee(n.file);if(c!==""&&!ke.includes(c))continue;if(e.options.emitCJS===void 0&&n.type==="cjs"&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.type==="esm"&&(e.options.emitESM=!0),e.options.declaration===void 0||e.options.declaration==="node16"){const $=e.options.emitCJS&&e.options.emitESM;e.options.declaration=$?"compatible":"node16"}const g=n.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+|${[`\\.${a}`,`\\.${o}`].join("|")})$`),""),v=g.endsWith("/");if(v&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),l="(?<=/|$)",b=v?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${a}`,`\\.${o}`].join("|")})$`;if((n.file.includes("/*")||g.includes("*"))&&n.key==="exports"){Y||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Y=!0);let $;n.exportKey?$=n.exportKey.startsWith("./")?n.exportKey.slice(2):n.exportKey:$=(n.file.startsWith("./")?n.file.slice(2):n.file).replace(/^dist\//,"");const M=n.file,K=e.options.sourceDir.replace(/^\.\//,""),z=E(e.options.rootDir,K),A=[],ne=await ze(z);for(const T of ne){const L=We(T,$);if(L){const V=_e(M,L);A.push({input:E(z,T),output:V})}}if(A.length===0){p.push(`Could not find entrypoints matching pattern \`${$}\` for output \`${M}\``);continue}for(const{input:T,output:L}of A){const V={...n,file:L};O(m,T,v,g,V,e,!0)}continue}const f=new RegExp(l+d+b);let h=s.find($=>f.test($));if(te.has(n.subKey)&&h===void 0){const $=d.replace(/^(.+?)\.[^.]*$/,"$1"),M=new RegExp(l+$+b);h=s.find(K=>M.test(K))}if(h===void 0){j(E(e.options.rootDir,n.file))||p.push(`Could not find entrypoint for \`${n.file}\``);continue}j(h)&&/\.[cm]?tsx?$/.test(h)&&Z(e);const D=we(h.replace(Se,""));j(`${D}.cts`)&&j(`${D}.mts`)?(O(m,`${D}.cts`,v,g,{...n,type:"cjs"},e,!1),O(m,`${D}.mts`,v,g,{...n,type:"esm"},e,!1)):O(m,h,v,g,n,e,!1)}return{entries:m,warnings:p}},"inferEntries");var Ye=Object.defineProperty,Ze=k((t,s)=>Ye(t,"name",{value:s,configurable:!0}),"o");const Qe=Ze((t,s)=>{const{publishConfig:e}=t;return e&&(e.bin&&(typeof e.bin=="object"||typeof e.bin=="string")&&(t.bin=e.bin),e.type&&typeof e.type=="string"&&e.type!==""&&(t.type=e.type),e.main&&typeof e.main=="string"&&e.main!==""&&(t.main=e.main),e.module&&typeof e.module=="string"&&e.module!==""&&(t.module=e.module),s===void 0&&e.types&&typeof e.types=="string"&&e.types!==""?t.types=e.types:s===void 0&&e.typings&&typeof e.typings=="string"&&e.typings!==""&&(t.typings=e.typings),e.exports&&typeof e.exports=="object"&&(t.exports=e.exports)),t},"overwriteWithPublishConfig");var et=Object.defineProperty,tt=k((t,s)=>et(t,"name",{value:s,configurable:!0}),"t$1");const st={hooks:{"build:prepare":tt(async function(t){if(t.options.entries.length>0)return;const s=C(t.options.rootDir,t.options.sourceDir);if(!j(s))throw new Error("No 'src' directory found. Please provide entries manually.");const e=ge(s,{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={...t.pkg};r.publishConfig&&(t.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(r.publishConfig).join(", ")}".`),t.logger.debug(r.publishConfig),r=Qe(r,t.options.declaration));const a=await He(r,e,t);for(const o of a.warnings)Pe(t,o);if(t.options.entries.push(...a.entries),t.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");t.logger.info("Automatically detected entries:",Ce(t.options.entries.map(o=>o.fileAlias?`${J(o.fileAlias)} => ${J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),De([t.options.emitESM&&"esm",t.options.emitCJS&&"cjs",t.options.declaration&&"dts"].filter(Boolean).map(o=>`[${o}]`).join(" ")))},"build:prepare")}};var ot=Object.defineProperty,it=k((t,s)=>ot(t,"name",{value:s,configurable:!0}),"t");const nt=it(async(t,s)=>{if(t==="auto")t=st;else{if(t==="none")return{};typeof t=="string"&&(t=await s.import(t)||{})}return typeof t=="function"&&(t=t()),t},"loadPreset");var at=Object.defineProperty,P=k((t,s)=>at(t,"name",{value:s,configurable:!0}),"r");const rt=P(t=>{t.addCommand({description:"Demonstrate options required",execute:P(async({logger:s,options:e})=>{let r="build";e.watch?r="watch":e.jit&&(r="jit");const a={};let o;if(e.env)for(const c of e.env)c.key==="NODE_ENV"?o=c.value:a[`process.env.${c.key}`]=JSON.stringify(c.value);o===void 0&&(e.production?o=B:e.development&&(o=G));const p=[];if(e.external)for(const c of e.external)p.push(c.split(","));const u=E(U(),e.dir??"."),y=je(u,{debug:e.debug}),{config:i,path:m}=await Re(y,u,o,r,e.config??void 0);s.debug("Using packem config found at",m);const n=await nt(i.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await Ie(u,r,o,s,e.debug,xe(i,n,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:p,killSignal:e.killSignal,minify:e.minify===void 0?o===B:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,replace:{values:a},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}}),e.tsconfig??void 0)}catch(c){s.error(c),ce(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:P(s=>{const[e,r]=s.split("=");return{key:e,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:P(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:P(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createBuildCommand");var lt=Object.defineProperty,I=k((t,s)=>lt(t,"name",{value:s,configurable:!0}),"f");const ct=I(t=>{t.addCommand({description:"Initialize packem configuration",execute:I(async({logger:s,options:e})=>{if(pe("Welcome to packem setup"),j(C(e.dir,"packem.config.mjs"))){s.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=E(U(),e.dir??"."),a=C(r,"package.json");if(!j(a))throw new Error("No package.json found in the directory");const o=await Te(a,{resolveCatalogs:!0}),p=[];o.dependencies&&p.push(...Object.keys(o.dependencies)),o.devDependencies&&p.push(...Object.keys(o.devDependencies));const u=!!(o.devDependencies?.typescript??o.dependencies?.typescript),y=[];if(e.typescript===void 0&&!u?(e.typescript=await w({message:"Do you want to install TypeScript?"}),e.typescript&&y.push("typescript@latest")):W.message(`TypeScript version ${o.devDependencies?.typescript??o.dependencies?.typescript} is already installed`),!j(C(r,"tsconfig.json"))){const d=await w({message:"Do you want to use generate a tsconfig.json?"}),l=await w({message:"Do you want to run your code in the DOM?"});if(d){const b=R();b.start("Generating tsconfig.json"),ve(C(r,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:l?["es2022","dom","dom.iterable"]:["es2022"]}}),b.stop("")}}if(e.runtime===void 0&&(e.runtime=await S({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),p.includes("esbuild")?e.transformer="esbuild":p.includes("@swc/core")?e.transformer="swc":p.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await S({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),e.transformer&&e.transformer!=="oxc"&&!p.includes(e.transformer)&&await w({message:`Do you want to install ${e.transformer}?`})&&y.push(e.transformer==="swc"?"@swc/core":e.transformer)):W.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await w({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await S({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:void 0}]}),e.isolatedDeclarationTransformer!==void 0)){let d;switch(e.isolatedDeclarationTransformer){case"oxc":{d="oxc-transform";break}case"swc":{d="@swc/core";break}case"typescript":{d="typescript";break}default:de("Invalid isolated declaration transformer")}d!==void 0&&!p.includes(d)&&await w({message:`Do you want to install ${d}?`})&&y.push(d)}e.css===void 0&&(e.css=await w({message:"Do you want to use css in your project?",initialValue:!1}));const i=[];if(e.css){const d=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});i.push(d);let l=await Q({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(l.includes("sass")){const b=await S({message:"Pick a sass loader",options:[{label:"Sass embedded",value:"sass-embedded",hint:"recommended"},{label:"Sass",value:"sass"},{label:"Node Sass",value:"node-sass",hint:"legacy"}]});b!=="sass"&&(l=l.filter(f=>f!=="sass"),l.push(b))}if(i.push(...l),await w({message:`Do you want to install "${i.join('", "')}"?`}))for(const b of i)y.push(...oe[b]);i.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await w({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),i.includes("lightningcss")||await w({message:`Do you want to install "${m}"?`})&&y.push(m));let n="",c="";if(e.isolatedDeclarationTransformer&&(c+=`,
|
|
27
|
+
},`),a.start("Installing packages"),await q(b,{cwd:o,dev:!0,silent:!0}),a.stop("Installed packages"),e.success(`
|
|
28
|
+
CSS loaders added!`)}await ye(p,i.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand");var Je=Object.defineProperty,qe=k((t,s)=>Je(t,"name",{value:s,configurable:!0}),"e$1");const Re=qe(async(t,s,e,r,a)=>{const o=await se(s,a);let p=await t.import(o,{default:!0,try:!0})||{};return typeof p=="function"&&(p=await p(e,r)),{config:p,path:o}},"loadPackemConfig");var Ge=Object.defineProperty,x=k((t,s)=>Ge(t,"name",{value:s,configurable:!0}),"u$1");const F=new Map,Fe=/\.[^./]+$/,Ue=x(async t=>{try{return await Me.readdir(t,{withFileTypes:!0})}catch(s){const{code:e}=s;if(e==="ENOENT")return[];throw s}},"safeReaddir"),ie=x(async(t,s)=>{const e=await Ue(t);return(await Promise.all(e.map(async r=>{const a=X.join(t,r.name);return r.isDirectory()?ie(a,s):r.isFile()?X.relative(s,a):[]}))).flat()},"getDirectoryFilesRecursive"),ze=x(async t=>{let s=F.get(t);return s||(s=ie(t,t),F.set(t,s)),s},"getDirectoryFiles"),We=x((t,s)=>{const e=t.replace(Fe,"");if(s==="*"){const p=e.split("/");return p.length>0?[p[0]]:null}const r=s.replaceAll(/[.+?^${}()|[\]\\]/g,String.raw`\$&`).replaceAll("*","(.*)"),a=new RegExp(`^${r}$`),o=e.match(a);return o?o.slice(1):null},"matchWildcardPattern"),_e=x((t,s)=>{let e=t;for(const r of s)e=e.replace("*",r);return e},"substituteWildcards"),Xe=x((t,s)=>t.key==="exports"&&t.subKey===O?O:t.key==="exports"&&t.subKey===G?G:s,"getEnvironment"),B=x((t,s,e,r,a,o,p)=>{const u=Xe(a,o.environment);let y=o.options.runtime;for(const n of $e)if(a.file.includes(`.${n}.`)||a.subKey===n){y=n;break}let i=t.find(n=>n.input===s&&n.environment===u&&n.runtime===y);i===void 0?i=t[t.push({environment:u,exportKey:new Set([a.exportKey].filter(Boolean)),input:s,runtime:y})-1]:i.exportKey&&a.exportKey&&i.exportKey.add(a.exportKey),p&&(i.isGlob=!0),e&&(i.outDir=r),a.isExecutable?(i.executable=!0,i.declaration=!1,a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0)):(/\.d\.[mc]?ts$/.test(a.file)&&o.options.declaration!==!1&&(i.declaration=o.options.declaration),a.type==="cjs"?i.cjs=!0:a.type==="esm"&&(i.esm=!0));const m=a.file.replace(ee(a.file),"").replace(new RegExp(`^./${o.options.outDir.replace(/^\.\//,"")}/`),"");te.has(a.subKey)&&!s.includes(m)&&(i.fileAlias=m)},"createOrUpdateEntry");let Y=!1;const Z=x(t=>{if(t.pkg?.dependencies?.typescript===void 0&&t.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"),He=x(async(t,s,e)=>{const r=t.types||t.typings;F.clear();const a=(e.options.outputExtensionMap?.cjs??"cjs").replaceAll(".",String.raw`\.`),o=(e.options.outputExtensionMap?.esm??"mjs").replaceAll(".",String.raw`\.`),p=[];s.sort((n,c)=>n.split("/").length-c.split("/").length);const u=t.type==="module"?"esm":"cjs";u==="esm"&&(e.options.emitESM=!0),u==="cjs"&&(e.options.emitCJS=!0);const y=e.options.emitCJS&&e.options.emitESM;e.options.declaration===void 0&&(e.options.declaration=y?"compatible":"node16");const i=Ee(t.exports,u,e.options.declaration,[],e.options.ignoreExportKeys).filter(n=>!n.ignored);if(t.bin){const n=(typeof t.bin=="string"?[t.bin]:Object.values(t.bin)).filter(Boolean);for(const c of n){const g=_(c);if(g&&g!==u)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${t.type??"commonjs"}".`);i.push({file:c,isExecutable:!0,key:"bin",type:g??u})}}t.main&&i.push({file:t.main,key:"main",type:_(t.main)??u}),t.module&&i.push({file:t.module,key:"module",type:"esm"}),r&&(Z(e),(e.options.declaration===void 0||e.options.declaration==="node16")&&y&&(e.options.declaration="compatible"),i.push({file:t.types??t.typings,key:"types"}));const m=[];for await(const n of i){const c=ee(n.file);if(c!==""&&!ke.includes(c))continue;if(e.options.emitCJS===void 0&&n.type==="cjs"&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.type==="esm"&&(e.options.emitESM=!0),e.options.declaration===void 0||e.options.declaration==="node16"){const $=e.options.emitCJS&&e.options.emitESM;e.options.declaration=$?"compatible":"node16"}const g=n.file.replace(new RegExp(String.raw`(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+|${[`\\.${a}`,`\\.${o}`].join("|")})$`),""),b=g.endsWith("/");if(b&&["./","/"].includes(g))continue;const d=g.replace(new RegExp(`(./)?${e.options.outDir}`),e.options.sourceDir).replace("./",""),l="(?<=/|$)",v=b?"":String.raw`(\.d\.[cm]?ts|(\.[cm]?[tj]sx?)|${[`\\.${a}`,`\\.${o}`].join("|")})$`;if((n.file.includes("/*")||g.includes("*"))&&n.key==="exports"){Y||(e.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Y=!0);let $;n.exportKey?$=n.exportKey.startsWith("./")?n.exportKey.slice(2):n.exportKey:$=(n.file.startsWith("./")?n.file.slice(2):n.file).replace(/^dist\//,"");const M=n.file,K=e.options.sourceDir.replace(/^\.\//,""),z=E(e.options.rootDir,K),A=[],ne=await ze(z);for(const T of ne){const L=We(T,$);if(L){const V=_e(M,L);A.push({input:E(z,T),output:V})}}if(A.length===0){p.push(`Could not find entrypoints matching pattern \`${$}\` for output \`${M}\``);continue}for(const{input:T,output:L}of A){const V={...n,file:L};B(m,T,b,g,V,e,!0)}continue}const f=new RegExp(l+d+v);let h=s.find($=>f.test($));if(te.has(n.subKey)&&h===void 0){const $=d.replace(/^(.+?)\.[^.]*$/,"$1"),M=new RegExp(l+$+v);h=s.find(K=>M.test(K))}if(h===void 0){j(E(e.options.rootDir,n.file))||p.push(`Could not find entrypoint for \`${n.file}\``);continue}j(h)&&/\.[cm]?tsx?$/.test(h)&&Z(e);const D=we(h.replace(Se,""));j(`${D}.cts`)&&j(`${D}.mts`)?(B(m,`${D}.cts`,b,g,{...n,type:"cjs"},e,!1),B(m,`${D}.mts`,b,g,{...n,type:"esm"},e,!1)):B(m,h,b,g,n,e,!1)}return{entries:m,warnings:p}},"inferEntries");var Ye=Object.defineProperty,Ze=k((t,s)=>Ye(t,"name",{value:s,configurable:!0}),"o");const Qe=Ze((t,s)=>{const{publishConfig:e}=t;return e&&(e.bin&&(typeof e.bin=="object"||typeof e.bin=="string")&&(t.bin=e.bin),e.type&&typeof e.type=="string"&&e.type!==""&&(t.type=e.type),e.main&&typeof e.main=="string"&&e.main!==""&&(t.main=e.main),e.module&&typeof e.module=="string"&&e.module!==""&&(t.module=e.module),s===void 0&&e.types&&typeof e.types=="string"&&e.types!==""?t.types=e.types:s===void 0&&e.typings&&typeof e.typings=="string"&&e.typings!==""&&(t.typings=e.typings),e.exports&&typeof e.exports=="object"&&(t.exports=e.exports)),t},"overwriteWithPublishConfig");var et=Object.defineProperty,tt=k((t,s)=>et(t,"name",{value:s,configurable:!0}),"t$1");const st={hooks:{"build:prepare":tt(async function(t){if(t.options.entries.length>0)return;const s=C(t.options.rootDir,t.options.sourceDir);if(!j(s))throw new Error("No 'src' directory found. Please provide entries manually.");const e=ge(s,{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={...t.pkg};r.publishConfig&&(t.logger.info(`Using publishConfig found in package.json, to override the default key-value pairs of "${Object.keys(r.publishConfig).join(", ")}".`),t.logger.debug(r.publishConfig),r=Qe(r,t.options.declaration));const a=await He(r,e,t);for(const o of a.warnings)Pe(t,o);if(t.options.entries.push(...a.entries),t.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");t.logger.info("Automatically detected entries:",Ce(t.options.entries.map(o=>o.fileAlias?`${J(o.fileAlias)} => ${J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))}`:J(o.input.replace(`${t.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),De([t.options.emitESM&&"esm",t.options.emitCJS&&"cjs",t.options.declaration&&"dts"].filter(Boolean).map(o=>`[${o}]`).join(" ")))},"build:prepare")}};var ot=Object.defineProperty,it=k((t,s)=>ot(t,"name",{value:s,configurable:!0}),"t");const nt=it(async(t,s)=>{if(t==="auto")t=st;else{if(t==="none")return{};typeof t=="string"&&(t=await s.import(t)||{})}return typeof t=="function"&&(t=t()),t},"loadPreset");var at=Object.defineProperty,P=k((t,s)=>at(t,"name",{value:s,configurable:!0}),"r");const rt=P(t=>{t.addCommand({description:"Demonstrate options required",execute:P(async({logger:s,options:e})=>{let r="build";e.watch?r="watch":e.jit&&(r="jit");const a={};let o;if(e.env)for(const c of e.env)c.key==="NODE_ENV"?o=c.value:a[`process.env.${c.key}`]=JSON.stringify(c.value);o===void 0&&(e.production?o=O:e.development&&(o=G));const p=[];if(e.external)for(const c of e.external)p.push(c.split(","));const u=E(U(),e.dir??"."),y=je(u,{debug:e.debug}),{config:i,path:m}=await Re(y,u,o,r,e.config??void 0);s.debug("Using packem config found at",m);const n=await nt(i.preset??"auto",y);e.minify&&e.sourcemap===void 0&&(e.sourcemap=!0);try{await Ie(u,r,o,s,e.debug,xe(i,n,{analyze:e.analyze,cjsInterop:e.cjsInterop,clean:e.clean,dtsOnly:e.dtsOnly,externals:p,killSignal:e.killSignal,minify:e.minify===void 0?o===O:e.minify,onSuccess:e.onSuccess,rollup:{esbuild:{target:e.target},license:{path:e.license},metafile:e.metafile,replace:{values:a},resolveExternals:e.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:e.runtime,sourcemap:e.metafile||e.analyze||e.sourcemap,unbundle:e.unbundle,validation:e.validation===!1?!1:{},...e.typedoc?{typedoc:{format:"html"}}:{}}),e.tsconfig??void 0)}catch(c){s.error(c),ce(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:P(s=>{const[e,r]=s.split("=");return{key:e,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:P(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:P(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 lt=Object.defineProperty,I=k((t,s)=>lt(t,"name",{value:s,configurable:!0}),"f");const ct=I(t=>{t.addCommand({description:"Initialize packem configuration",execute:I(async({logger:s,options:e})=>{if(pe("Welcome to packem setup"),j(C(e.dir,"packem.config.mjs"))){s.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=E(U(),e.dir??"."),a=C(r,"package.json");if(!j(a))throw new Error("No package.json found in the directory");const o=await Te(a,{resolveCatalogs:!0}),p=[];o.dependencies&&p.push(...Object.keys(o.dependencies)),o.devDependencies&&p.push(...Object.keys(o.devDependencies));const u=!!(o.devDependencies?.typescript??o.dependencies?.typescript),y=[];if(e.typescript===void 0&&!u?(e.typescript=await w({message:"Do you want to install TypeScript?"}),e.typescript&&y.push("typescript@latest")):W.message(`TypeScript version ${o.devDependencies?.typescript??o.dependencies?.typescript} is already installed`),!j(C(r,"tsconfig.json"))){const d=await w({message:"Do you want to use generate a tsconfig.json?"}),l=await w({message:"Do you want to run your code in the DOM?"});if(d){const v=R();v.start("Generating tsconfig.json"),be(C(r,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:l?["es2022","dom","dom.iterable"]:["es2022"]}}),v.stop("")}}if(e.runtime===void 0&&(e.runtime=await S({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]})),p.includes("esbuild")?e.transformer="esbuild":p.includes("@swc/core")?e.transformer="swc":p.includes("sucrase")&&(e.transformer="sucrase"),e.transformer===void 0?(e.transformer=await S({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),e.transformer&&e.transformer!=="oxc"&&!p.includes(e.transformer)&&await w({message:`Do you want to install ${e.transformer}?`})&&y.push(e.transformer==="swc"?"@swc/core":e.transformer)):W.message(`Transformer ${e.transformer} is already installed.`),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await w({message:"Do you want to use an isolated declaration types?",initialValue:!1})),e.isolatedDeclarationTransformer===void 0&&(e.isolatedDeclarationTransformer=await S({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:void 0}]}),e.isolatedDeclarationTransformer!==void 0)){let d;switch(e.isolatedDeclarationTransformer){case"oxc":{d="oxc-transform";break}case"swc":{d="@swc/core";break}case"typescript":{d="typescript";break}default:de("Invalid isolated declaration transformer")}d!==void 0&&!p.includes(d)&&await w({message:`Do you want to install ${d}?`})&&y.push(d)}e.css===void 0&&(e.css=await w({message:"Do you want to use css in your project?",initialValue:!1}));const i=[];if(e.css){const d=await S({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});i.push(d);let l=await Q({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(l.includes("sass")){const v=await S({message:"Pick a sass loader",options:[{label:"Sass embedded",value:"sass-embedded",hint:"recommended"},{label:"Sass",value:"sass"},{label:"Node Sass",value:"node-sass",hint:"legacy"}]});v!=="sass"&&(l=l.filter(f=>f!=="sass"),l.push(v))}if(i.push(...l),await w({message:`Do you want to install "${i.join('", "')}"?`}))for(const v of i)y.push(...oe[v]);i.push("sourceMap")}e.cssMinifier===void 0&&(e.cssMinifier=await w({message:"Do you want to minify your css?",initialValue:!1}));let m;e.cssMinifier&&(m=await S({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),i.includes("lightningcss")||await w({message:`Do you want to install "${m}"?`})&&y.push(m));let n="",c="";if(e.isolatedDeclarationTransformer&&(c+=`,
|
|
29
29
|
isolatedDeclarationTransformer`),(e.css||e.cssMinifier)&&(c+=`,
|
|
30
30
|
rollup: {
|
|
31
31
|
css: {`),e.css){const d=i.map(l=>((l==="sass-embedded"||l==="node-sass")&&(l="sass"),`${l}Loader`)).join(", ");c+=`
|
|
@@ -52,4 +52,4 @@ module.exports = defineConfig({
|
|
|
52
52
|
runtime: ${e.runtime},
|
|
53
53
|
transformer${c}
|
|
54
54
|
});
|
|
55
|
-
`}const g=R(),
|
|
55
|
+
`}const g=R(),b=u?"ts":"js";y.length>0&&(g.start("Installing packages"),await q(y,{cwd:r,dev:!0,silent:!0}),g.stop("Installed packages")),g.start(`Creating packem.config.${b}`),ve(C(r,`packem.config.${b}`),n),g.stop(`Created packem.config.${b}`),ue("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:I(s=>{if(typeof s=="string"&&["esbuild","sucrase","swc"].includes(s))return s;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:I(s=>{if(typeof s=="string"&&["none","oxc","swc","typescript"].includes(s))return s;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:I(s=>{if(s==="node"||s==="browser")return s;throw new Error("Invalid runtime. Use 'node' or 'browser'.")},"type")}]})},"createInitCommand");try{require("node:module")?.enableCompileCache?.()||require("v8-compile-cache")}catch{}const N=new re("packem",{logger:{reporters:[new le({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Le,packageVersion:Be});ct(N);rt(N);Ve(N);N.run({shouldExitProcess:!1});
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,31 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import type { BuildConfig, BuildConfigFunction, BuildPreset } from "../types.d.ts";
|
|
2
|
+
export type { BuildConfig, BuildConfigFunction, BuildPreset } from "../types.d.ts";
|
|
3
|
+
export type { BuildHooks } from "@visulima/packem-share/types";
|
|
4
|
+
/**
|
|
5
|
+
* Defines a build configuration for Packem.
|
|
6
|
+
* Supports both static configuration objects and dynamic configuration functions.
|
|
7
|
+
* @param config Static build configuration object or function returning configuration
|
|
8
|
+
* @returns The provided configuration
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Static configuration
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* entries: ['./src/index.ts'],
|
|
14
|
+
* outDir: './dist'
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Dynamic configuration
|
|
18
|
+
* export default defineConfig((env, mode) => ({
|
|
19
|
+
* entries: ['./src/index.ts'],
|
|
20
|
+
* outDir: env === 'production' ? './dist' : './dev'
|
|
21
|
+
* }));
|
|
22
|
+
* ```
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare const defineConfig: (config: BuildConfig | BuildConfigFunction) => BuildConfig | BuildConfigFunction;
|
|
26
|
+
/**
|
|
27
|
+
* Defines a build preset for Packem.
|
|
28
|
+
* Build presets provide reusable configuration templates that can be shared across projects.
|
|
29
|
+
* @param preset Build preset configuration
|
|
30
|
+
* @returns The provided preset configuration
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* export default definePreset({
|
|
34
|
+
* name: 'my-preset',
|
|
35
|
+
* defaults: {
|
|
36
|
+
* entries: ['./src/index.ts'],
|
|
37
|
+
* outDir: './dist'
|
|
38
|
+
* },
|
|
39
|
+
* hooks: {
|
|
40
|
+
* 'build:before': (context) => {
|
|
41
|
+
* // Custom build preparation logic
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* });
|
|
45
|
+
* ```
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export declare const definePreset: (preset: BuildPreset) => BuildPreset;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PackageJson } from "@visulima/package";
|
|
2
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
3
|
+
import type { InferEntriesResult, InternalBuildOptions } from "../../../types.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Infer entries from package files.
|
|
6
|
+
* @param packageJson
|
|
7
|
+
* @param sourceFiles A list of source files to use for inferring entries.
|
|
8
|
+
* @param context
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
declare const inferEntries: (packageJson: PackageJson, sourceFiles: string[], context: BuildContext<InternalBuildOptions>) => Promise<InferEntriesResult>;
|
|
12
|
+
export default inferEntries;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NormalizedPackageJson } from "@visulima/package";
|
|
2
|
+
import type { BuildConfig } from "../../../types.d.ts";
|
|
3
|
+
declare const overwriteWithPublishConfig: (packageJson: NormalizedPackageJson, declaration?: BuildConfig["declaration"]) => NormalizedPackageJson;
|
|
4
|
+
export default overwriteWithPublishConfig;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Jiti } from "jiti";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from "../../types.d.ts";
|
|
3
|
+
declare const loadPackemConfig: (jiti: Jiti, rootDirectory: string, environment: Environment, mode: Mode, configPath?: string) => Promise<{
|
|
4
|
+
config: BuildConfig;
|
|
5
|
+
path: string;
|
|
6
|
+
}>;
|
|
7
|
+
export default loadPackemConfig;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NormalizedPackageJson } from "@visulima/package";
|
|
2
|
+
import type { Pail } from "@visulima/pail";
|
|
3
|
+
import type { TsConfigResult } from "@visulima/tsconfig";
|
|
4
|
+
declare const loadTsconfig: (rootDirectory: string, packageJson: NormalizedPackageJson, logger: Pail, tsconfigPath?: string) => Promise<TsConfigResult | undefined>;
|
|
5
|
+
export default loadTsconfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,49 @@
|
|
|
1
|
-
import { ConstructorOptions } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import '@rollup/pluginutils';
|
|
17
|
-
import 'rollup';
|
|
18
|
-
import 'rollup-plugin-dts';
|
|
19
|
-
import 'rollup-plugin-polyfill-node';
|
|
20
|
-
import 'rollup-plugin-pure';
|
|
21
|
-
import 'rollup-plugin-visualizer';
|
|
22
|
-
import 'esbuild';
|
|
23
|
-
import '@visulima/package';
|
|
24
|
-
import '@visulima/colorize';
|
|
25
|
-
import 'magic-string';
|
|
26
|
-
import 'html-minifier-next';
|
|
27
|
-
import 'oxc-resolver';
|
|
28
|
-
import 'oxc-transform';
|
|
29
|
-
import 'sucrase';
|
|
30
|
-
|
|
31
|
-
interface PackemOptions extends BuildConfig {
|
|
1
|
+
import type { ConstructorOptions } from "@visulima/pail";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from "./types.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration options for Packem bundler.
|
|
5
|
+
* @interface PackemOptions
|
|
6
|
+
* @augments {BuildConfig}
|
|
7
|
+
*/
|
|
8
|
+
export interface PackemOptions extends BuildConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The environment to build for
|
|
11
|
+
* Determines the build environment configuration
|
|
12
|
+
* @default "production"
|
|
13
|
+
* @type {Environment}
|
|
14
|
+
* @memberof PackemOptions
|
|
15
|
+
*/
|
|
32
16
|
environment?: Environment;
|
|
17
|
+
/**
|
|
18
|
+
* Logger configuration options
|
|
19
|
+
* Used to customize the logging behavior and output format
|
|
20
|
+
* @type {ConstructorOptions<string, string>}
|
|
21
|
+
* @memberof PackemOptions
|
|
22
|
+
*/
|
|
33
23
|
logger?: ConstructorOptions<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* The mode to run Packem in
|
|
26
|
+
* Controls how the bundler processes and optimizes the code
|
|
27
|
+
* @default "build"
|
|
28
|
+
* @type {Mode}
|
|
29
|
+
* @memberof PackemOptions
|
|
30
|
+
*/
|
|
34
31
|
mode?: Mode;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Runs the Packem bundler with the specified options
|
|
35
|
+
* @param rootDirectory The root directory of the project to bundle
|
|
36
|
+
* @param options Configuration options for the bundler
|
|
37
|
+
* @returns Promise that resolves with the build result
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = await packem("./src", {
|
|
41
|
+
* mode: "build",
|
|
42
|
+
* environment: "production"
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const packem: (rootDirectory: string, options?: PackemOptions) => Promise<void>;
|
|
47
|
+
export type { BuildEntry, BuildOptions, RollupBuildOptions } from "./types.d.ts";
|
|
48
|
+
export type { IsolatedDeclarationsTransformer, TransformerFn, TransformerName } from "@visulima/packem-rollup";
|
|
49
|
+
export type { BuildContext, BuildContextBuildAssetAndChunk, BuildContextBuildEntry, BuildHooks, Environment, Mode, Runtime, } from "@visulima/packem-share/types";
|
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-
|
|
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-Dt7qUoo-.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,21 @@
|
|
|
1
|
+
import type { FileCache } from "@visulima/packem-share";
|
|
2
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
3
|
+
import type { InternalBuildOptions } from "../types.d.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Main build function that orchestrates the entire build process.
|
|
6
|
+
* Handles both JavaScript/TypeScript compilation and type definition generation.
|
|
7
|
+
* @param context Build context containing configuration and state
|
|
8
|
+
* @param fileCache Cache instance for file operations
|
|
9
|
+
* @returns Promise resolving to a boolean indicating build success
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const success = await build(BuildContext<InternalBuildOptions>, new FileCache());
|
|
13
|
+
* if (success) {
|
|
14
|
+
* console.log('Build completed successfully');
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
* @throws {Error} If the build process encounters critical errors
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare const build: (context: BuildContext<InternalBuildOptions>, fileCache: FileCache) => Promise<boolean>;
|
|
21
|
+
export default build;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Pail } from "@visulima/pail";
|
|
2
|
+
import type { BuildConfig, Environment, Mode } from '../types.d.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Main entry point for the Packem bundler.
|
|
5
|
+
* Handles the complete build process including configuration loading, validation,
|
|
6
|
+
* and execution of the build/watch process.
|
|
7
|
+
* @param rootDirectory Root directory of the project
|
|
8
|
+
* @param mode Build mode (build/watch)
|
|
9
|
+
* @param environment Build environment (development/production)
|
|
10
|
+
* @param logger Logger instance for output
|
|
11
|
+
* @param inputConfig User provided build configuration and options
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import packem from 'packem';
|
|
15
|
+
*
|
|
16
|
+
* await packem('/path/to/project', 'build', 'production', logger, {
|
|
17
|
+
* debug: true,
|
|
18
|
+
* configPath: './packem.config.js'
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
* @throws {Error} If configuration validation fails or build process encounters errors
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
declare const packem: (rootDirectory: string, mode: Mode, environment: Environment, logger: Pail, debug: boolean, config: BuildConfig, tsconfigPath?: string) => Promise<void>;
|
|
25
|
+
export default packem;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuildContext } from "@visulima/packem-share/types";
|
|
2
|
+
import type { InternalBuildOptions } from "../types.d.ts";
|
|
3
|
+
export type Node10CompatibilityOptions = {
|
|
4
|
+
typeScriptVersion?: string;
|
|
5
|
+
writeToPackageJson?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const node10Compatibility: (logger: BuildContext<InternalBuildOptions>["logger"], entries: BuildContext<InternalBuildOptions>["options"]["entries"], outDirectory: string, rootDirectory: string, mode: "console" | "file", typeScriptVersion: string) => Promise<void>;
|