@tochii/build 2.2.1 → 2.2.2
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/dist/chunk-UOBRZ36U.mjs +11 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{utils-CJIhwKYt.d.mts → utils-BMzAmbjm.d.mts} +11 -0
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-JBRJRSMC.mjs +0 -11
@@ -0,0 +1,11 @@
|
|
1
|
+
import B from"chalk";import y from"node:fs";import E from"node:path";import K from"deepmerge";import d from"chalk";var x="tochibuild",u=d.cyan(x),o=class{};o.custom=(e,...t)=>{console[e](u,...t)},o.log=(...e)=>{console.log(u,...e)},o.debug=(...e)=>{console.debug(u,...e)},o.info=(...e)=>{console.info(u,...e)},o.warn=(...e)=>{console.warn(u,...[...e].map(t=>d.yellow(t)))},o.error=(e,...t)=>{console.error(d.red(x),d.bgRed(...t),e?.stack?`
|
2
|
+
${d.gray(e.stack)}`:"")},o.success=(...e)=>{console.log(d.green(x),...e)};var f=o;var n=class n{};n.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},n.ignoredEntries=["!build/**","!dist/**","!node_modules/**","!**/build/**","!**/dist/**","!**/node_modules/**","!**/*.d.ts","!**/{tochibuild,tsup}.*"],n.entriesCommon=["**/*.{js,ts}"],n.entriesIndex=["**/index.{js,ts}"],n.defaultEntriesIndex=[...n.ignoredEntries,...n.entriesIndex],n.defaultEntriesCommon=[...n.ignoredEntries,...n.entriesCommon],n.defaultOptions=e=>h(e,t=>{let a=m(t.entry,"ignoredEntries");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithIndexEntries=e=>h(e,t=>{let a=m(t.entry,"defaultEntriesIndex");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithCommonEntries=e=>h(e,t=>{let a=m(t.entry,"defaultEntriesCommon");return{...n.defaultConfigOptions,...t,entry:a}}),n.generateConfig=I,n.ensureEntries=m;var l=n,G=l;function h(i,e){let t=s=>Array.isArray(s)?s.map(r=>K(e(r),s)):K(e(s),s);if(typeof i=="function"){let s=i;async function r(b){let p=await s(b);return t(p)}return r}return t(i)}function m(i,e){return Array.isArray(i)?Array.from(new Set([...l[e],...i])):i}function w(i){return E.isAbsolute(i||".")?i:E.resolve(process.cwd(),i)}function I(i,e,t,a){let s="";try{let r=e?.ext||".ts",p=`${e?.filename||"tochibuild.config"}${r}`;(e?.outDir?.length?e.outDir:["."]).forEach(O=>{s=w(O),y.existsSync(O)||y.mkdirSync(O,{recursive:!0});let g=E.join(s,p),k=y.existsSync(g);!e?.overwrite&&k&&(f.warn(`the config '${p}' file already exists for this project.`),a&&process.exit(1));let q=" ",c="",C={clean:!1,splitting:!0},P=R=>{c+=R==="esm"?`import build from '${i}';
|
3
|
+
|
4
|
+
`:`const build = require('${i}');
|
5
|
+
|
6
|
+
`,c+=R==="esm"?`export default build.defineConfigWithIndexEntries({
|
7
|
+
`:`module.exports = build.defineConfigWithIndexEntries({
|
8
|
+
`,Object.entries(C).forEach(([$,j])=>{c+=`${q}${$}: ${JSON.stringify(j)},
|
9
|
+
`}),c+=`});
|
10
|
+
`};switch(r){case".ts":case".js":P("esm");break;case".cjs":P("cjs");break;case".json":c+=`${JSON.stringify({...C,entry:l.defaultEntriesIndex},null,2)}
|
11
|
+
`;break;default:f.error(void 0,`unsupported extension: ${r}`),process.exit(1)}y.writeFileSync(g,c),f.success(B.cyan("the config file has been created at:"),B.gray(g))})}catch(r){if(t)throw r;f.error(r,r.message?`failed to generate config file in ${s}: ${r.message}`:`failed to generate config file in ${s}`),a&&process.exit(1)}}export{f as a,l as b,G as c};
|
package/dist/cli.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import{a,c as J}from"./chunk-
|
2
|
+
import{a,c as J}from"./chunk-UOBRZ36U.mjs";import r from"chalk";import d from"node:fs";import c from"node:path";import{fileURLToPath as M}from"node:url";import{spawn as U}from"node:child_process";import{Command as F}from"commander";var E={name:"tochibuild",version:"2.2.2",description:"An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",repository:"https://github.com/tochiResources/project/tree/main/packages/build/tochibuild.git",license:"MIT",keywords:["bundler","build","typescript","javascript","tsup","esbuild","glob","cli","node","tochi","tochiResources"],bin:"./dist/cli.mjs",scripts:{dev:"tsx cli.ts",copybundler:"copyfiles ./tsup@8.4.0/* ./dist",build:"tsx cli.ts && bun run copybundler","build:release":"bun run build && bun run release",release:"bun publish --access public --no-private"},dependencies:{chalk:"^5.4.1",commander:"^13.1.0",deepmerge:"^4.3.1",tsup:"8.4.0"},devDependencies:{"@types/node":"^22.15.17",copyfiles:"^2.4.1",tsx:"^4.19.4",typescript:"^5.8.3"},engines:{node:">=18.17.0"},files:["dist"]};var L=M(import.meta.url),B=c.dirname(L),k=c.resolve(process.cwd(),"."),x=k.replace(/\\/g,"/").includes("packages/build"),p=x?void 0:c.join(k,"package.json"),_=p?d.existsSync(p):!1,T=p&&_?d.readFileSync(p,"utf-8"):void 0,f=T?JSON.parse(T):void 0;async function A(l){let R={node:c.join(B,"tsup@8.4.0/cli-node.js")},j=process.cwd(),N=[...[".ts",".js",".cjs",".json"].map(n=>c.join(j,`tochibuild.config${n}`)),...[".ts",".js",".cjs",".json"].map(n=>c.join(j,`tsup.config${n}`))],v=f?.tochibuild,w=f?.tsup,C=!!Object.keys(v||{}).length||!!Object.keys(w||{}).length,g=N.find(n=>d.existsSync(n)),$=C||g,P=new F("tochibuild").name("tochibuild <command>").description("bundle a Node.js project powered by tsup (https://tsup.egoist.dev)").allowUnknownOption(!0).version(E.version).argument("[args...]","arguments to pass to tsup").action(async(...n)=>O(n));P.command("config").description("generate config files").option("--ext <string>","the file extension to use excluding the file extension (defaults to .ts)",".ts").option("-f, --filename <string>","the file name to use (defaults to tochibuild.config)","tochibuild.config").option("-o, --overwrite","whether or not to overwrite the config file if it already exists (defaults to false)",!1).option("--outDir <string...>","the absolute/relative output directory paths to create the config files in (defaults to the working directory)").action(n=>J.generateConfig(l,n,!1,!0)),P.parseAsync(process.argv);async function O(n){let[i]=n;return new Promise((D,u)=>{try{let h="node",e=[],m=i.includes("--config"),S=i.includes("--no-config"),b=m?i.findIndex(t=>t==="--config")+1:void 0;if(!m&&!S&&!$){if(i[0]==null||i[0]?.startsWith("-")){a.custom("error",`${r.red("No input files, try")} '${r.magenta(l)} ${r.gray("[...files]")}' ${r.red("instead")}`),u();return}e.push(...i)}else if(!m&&!S&&$)if(C){let t=v||w;i.filter(s=>s.startsWith("-")).forEach(s=>{let o=i.findIndex(V=>V===s),G=s.startsWith("--")?s.slice(2):s.slice(1);if(t[G]||(e.push(s),e[o+1]?.startsWith("-")))return;let I=e[o+1];I&&e.push(I)}),Object.entries(t).forEach(([s,o])=>{typeof o=="boolean"||o==="true"||o==="false"?o&&e.push(`--${s}`):typeof o=="string"&&e.push(`--${s}`,o)}),e.push("--no-config")}else if(g){let t=c.relative(k,g).replace(/\\/g,"/");a.log(`using existing configuration file: ${r.gray(t)}`),e.push("--config",t),e.push(...i)}else e.push(...i);else{if(b!=null&&b>=0){let t=i[b]||"unspecified";d.existsSync(t)||(a.error(void 0,`config file '${t}' does not exist`),a.info(`try running '${r.magenta(l)} ${r.blue("config")} ${r.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}e.push(...i)}a.log(`running build${x||f?.name?` for ${r.magenta(x?l:f.name)}`:""}...`);let y=U("node",[R[h],...e],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});y.on("exit",t=>{process.exit(t??1)}),process.on("SIGINT",()=>{u(),y.kill("SIGINT")}),process.on("SIGTERM",()=>{u(),y.kill("SIGTERM")}),D()}catch(h){u(h)}})}}A("@tochii/build");
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as tsup from 'tsup';
|
2
|
-
import { B as BuildUtils$1, c as BuildOptionsParams } from './utils-
|
2
|
+
import { B as BuildUtils$1, c as BuildOptionsParams } from './utils-BMzAmbjm.mjs';
|
3
3
|
|
4
4
|
type DefineConfigOptions = BuildOptionsParams<'entry' | 'clean' | 'splitting'>;
|
5
5
|
type DefineConfigOptionsIndexEntries = BuildOptionsParams<'clean' | 'splitting'>;
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{c as n}from"./chunk-
|
1
|
+
import{c as n}from"./chunk-UOBRZ36U.mjs";import{defineConfig as t}from"tsup";var l=n,e={utils:n,defineConfig:o,defineConfigWithIndexEntries:r,defineConfigWithCommonEntries:f};function o(i){return t(n.defaultOptions(i))}function r(i){return t(n.defaultOptionsWithIndexEntries(i))}function f(i){return t(n.defaultOptionsWithCommonEntries(i))}var a=e;export{l as BuildUtils,a as default,o as defineConfig,f as defineConfigWithCommonEntries,r as defineConfigWithIndexEntries};
|
@@ -78,8 +78,19 @@ declare class BuildUtils {
|
|
78
78
|
* @returns {void}
|
79
79
|
*/
|
80
80
|
static generateConfig: typeof generateConfig;
|
81
|
+
/**
|
82
|
+
* Ensures that the passed entries includes the certain ones
|
83
|
+
*
|
84
|
+
* NOTE: only works for string arrays (otherwise will return the same entry) and will not overwrite or duplicate the entries
|
85
|
+
*
|
86
|
+
* @param entry the entries to check
|
87
|
+
* @param type the type of entries to ensure
|
88
|
+
* @memberof BuildUtils
|
89
|
+
*/
|
90
|
+
static ensureEntries: typeof ensureEntries;
|
81
91
|
}
|
82
92
|
|
93
|
+
declare function ensureEntries(entry: Options['entry'], type: 'ignoredEntries' | 'entriesIndex' | 'entriesCommon' | 'defaultEntriesIndex' | 'defaultEntriesCommon'): Options['entry'];
|
83
94
|
declare function generateConfig(module: '@tochii/build' | 'tochibuild', options?: GenerateConfigOptions, throwErr?: boolean, cli?: boolean): void;
|
84
95
|
|
85
96
|
export { BuildUtils as B, type ConfigResult as C, type BuildOptionsParam as a, type BuildOptionsOverrideParam as b, type BuildOptionsParams as c };
|
package/dist/utils.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { B as BuildUtils } from './utils-
|
2
|
-
export { b as BuildOptionsOverrideParam, a as BuildOptionsParam, c as BuildOptionsParams, C as ConfigResult } from './utils-
|
1
|
+
import { B as BuildUtils } from './utils-BMzAmbjm.mjs';
|
2
|
+
export { b as BuildOptionsOverrideParam, a as BuildOptionsParam, c as BuildOptionsParams, C as ConfigResult } from './utils-BMzAmbjm.mjs';
|
3
3
|
import 'tsup';
|
4
4
|
|
5
5
|
|
package/dist/utils.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{b as r,c as o}from"./chunk-
|
1
|
+
import{b as r,c as o}from"./chunk-UOBRZ36U.mjs";var e=o;export{r as BuildUtils,e as default};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tochii/build",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.2",
|
4
4
|
"description": "An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",
|
5
5
|
"repository": "https://github.com/tochiResources/project/tree/main/packages/build.git",
|
6
6
|
"license": "MIT",
|
package/dist/chunk-JBRJRSMC.mjs
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import R from"chalk";import y from"node:fs";import E from"node:path";import K from"deepmerge";import d from"chalk";var g="tochibuild",u=d.cyan(g),o=class{};o.custom=(e,...t)=>{console[e](u,...t)},o.log=(...e)=>{console.log(u,...e)},o.debug=(...e)=>{console.debug(u,...e)},o.info=(...e)=>{console.info(u,...e)},o.warn=(...e)=>{console.warn(u,...[...e].map(t=>d.yellow(t)))},o.error=(e,...t)=>{console.error(d.red(g),d.bgRed(...t),e?.stack?`
|
2
|
-
${d.gray(e.stack)}`:"")},o.success=(...e)=>{console.log(d.green(g),...e)};var l=o;var n=class n{};n.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0},n.ignoredEntries=["!build/**","!dist/**","!node_modules/**","!**/build/**","!**/dist/**","!**/node_modules/**","!**/*.d.ts","!**/{tochibuild,tsup}.*"],n.entriesCommon=["**/*.{js,ts}"],n.entriesIndex=["**/index.{js,ts}"],n.defaultEntriesIndex=[...n.ignoredEntries,...n.entriesIndex],n.defaultEntriesCommon=[...n.ignoredEntries,...n.entriesCommon],n.defaultOptions=e=>x(e,t=>{let a=h(t.entry,"ignoredEntries");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithIndexEntries=e=>x(e,t=>{let a=h(t.entry,"defaultEntriesIndex");return{...n.defaultConfigOptions,...t,entry:a}}),n.defaultOptionsWithCommonEntries=e=>x(e,t=>{let a=h(t.entry,"defaultEntriesCommon");return{...n.defaultConfigOptions,...t,entry:a}}),n.generateConfig=I;var f=n,G=f;function x(i,e){let t=s=>Array.isArray(s)?s.map(r=>K(e(r),s)):K(e(s),s);if(typeof i=="function"){let s=i;async function r(b){let p=await s(b);return t(p)}return r}return t(i)}function h(i,e){return Array.isArray(i)?[...f[e],...i]:i}function w(i){return E.isAbsolute(i||".")?i:E.resolve(process.cwd(),i)}function I(i,e,t,a){let s="";try{let r=e?.ext||".ts",p=`${e?.filename||"tochibuild.config"}${r}`;(e?.outDir?.length?e.outDir:["."]).forEach(m=>{s=w(m),y.existsSync(m)||y.mkdirSync(m,{recursive:!0});let O=E.join(s,p),k=y.existsSync(O);!e?.overwrite&&k&&(l.warn(`the config '${p}' file already exists for this project.`),a&&process.exit(1));let q=" ",c="",C={clean:!1,splitting:!0},P=B=>{c+=B==="esm"?`import build from '${i}';
|
3
|
-
|
4
|
-
`:`const build = require('${i}');
|
5
|
-
|
6
|
-
`,c+=B==="esm"?`export default build.defineConfigWithIndexEntries({
|
7
|
-
`:`module.exports = build.defineConfigWithIndexEntries({
|
8
|
-
`,Object.entries(C).forEach(([$,j])=>{c+=`${q}${$}: ${JSON.stringify(j)},
|
9
|
-
`}),c+=`});
|
10
|
-
`};switch(r){case".ts":case".js":P("esm");break;case".cjs":P("cjs");break;case".json":c+=`${JSON.stringify({...C,entry:f.defaultEntriesIndex},null,2)}
|
11
|
-
`;break;default:l.error(void 0,`unsupported extension: ${r}`),process.exit(1)}y.writeFileSync(O,c),l.success(R.cyan("the config file has been created at:"),R.gray(O))})}catch(r){if(t)throw r;l.error(r,r.message?`failed to generate config file in ${s}: ${r.message}`:`failed to generate config file in ${s}`),a&&process.exit(1)}}export{l as a,f as b,G as c};
|