@tochii/build 2.2.0 → 2.2.1
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-JBRJRSMC.mjs +11 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-EOPXFG45.mjs +0 -11
@@ -0,0 +1,11 @@
|
|
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};
|
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-JBRJRSMC.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.1",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.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{c as n}from"./chunk-
|
1
|
+
import{c as n}from"./chunk-JBRJRSMC.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};
|
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-JBRJRSMC.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.1",
|
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-EOPXFG45.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",l=d.cyan(g),a=class{};a.custom=(e,...t)=>{console[e](l,...t)},a.log=(...e)=>{console.log(l,...e)},a.debug=(...e)=>{console.debug(l,...e)},a.info=(...e)=>{console.info(l,...e)},a.warn=(...e)=>{console.warn(l,...[...e].map(t=>d.yellow(t)))},a.error=(e,...t)=>{console.error(d.red(g),d.bgRed(...t),e?.stack?`
|
2
|
-
${d.gray(e.stack)}`:"")},a.success=(...e)=>{console.log(d.green(g),...e)};var f=a;var n=class n{};n.defaultConfigOptions={tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,skipNodeModulesBundle:!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 r=h(t.entry,"ignoredEntries");return{...n.defaultConfigOptions,...t,entry:r}}),n.defaultOptionsWithIndexEntries=e=>x(e,t=>{let r=h(t.entry,"defaultEntriesIndex");return{...n.defaultConfigOptions,...t,entry:r}}),n.defaultOptionsWithCommonEntries=e=>x(e,t=>{let r=h(t.entry,"defaultEntriesCommon");return{...n.defaultConfigOptions,...t,entry:r}}),n.generateConfig=I;var u=n,M=u;function x(i,e){let t=s=>Array.isArray(s)?s.map(o=>K(e(o),s)):K(e(s),s);if(typeof i=="function"){let s=i;async function o(b){let p=await s(b);return t(p)}return o}return t(i)}function h(i,e){if(Array.isArray(i))return[...u[e],...i];let t={};return u[e].forEach(r=>t[r]=r),{...i,...t}}function w(i){return E.isAbsolute(i||".")?i:E.resolve(process.cwd(),i)}function I(i,e,t,r){let s="";try{let o=e?.ext||".ts",p=`${e?.filename||"tochibuild.config"}${o}`;(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&&(f.warn(`the config '${p}' file already exists for this project.`),r&&process.exit(1));let q=" ",c="",C={clean:!1,splitting:!0},B=P=>{c+=P==="esm"?`import build from '${i}';
|
3
|
-
|
4
|
-
`:`const build = require('${i}');
|
5
|
-
|
6
|
-
`,c+=P==="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(o){case".ts":case".js":B("esm");break;case".cjs":B("cjs");break;case".json":c+=`${JSON.stringify({...C,entry:u.defaultEntriesIndex},null,2)}
|
11
|
-
`;break;default:f.error(void 0,`unsupported extension: ${o}`),process.exit(1)}y.writeFileSync(O,c),f.success(R.cyan("the config file has been created at:"),R.gray(O))})}catch(o){if(t)throw o;f.error(o,o.message?`failed to generate config file in ${s}: ${o.message}`:`failed to generate config file in ${s}`),r&&process.exit(1)}}export{f as a,u as b,M as c};
|