@tochii/build 2.0.3 → 2.1.0
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-U7SHXASE.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-CwdN3Nrj.d.mts → utils-CJIhwKYt.d.mts} +1 -0
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +51 -43
- package/dist/chunk-LBH52VOU.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 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},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,G=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},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(o){case".ts":case".js":P("esm");break;case".cjs":P("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(B.cyan("the config file has been created at:"),B.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,G as c};
|
package/dist/cli.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import{a as
|
2
|
+
import{a as c,c as J}from"./chunk-U7SHXASE.mjs";import r from"chalk";import d from"node:fs";import a from"node:path";import{spawn as M}from"node:child_process";import{Command as F}from"commander";var E={name:"tochibuild",version:"2.1.0",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",build:"tsx cli.ts --config tochibuild.config.ts --entry index.ts --entry cli.ts --entry utils.ts","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",tsx:"^4.19.4",typescript:"^5.8.3"},engines:{node:">=18.17.0"},files:["dist"]};var k=a.resolve(process.cwd(),"."),x=k.replace(/\\/g,"/").includes("packages/build"),g=x?void 0:a.join(k,"package.json"),U=g?d.existsSync(g):!1,A=g&&U?d.readFileSync(g,"utf-8"):void 0,f=A?JSON.parse(A):void 0;async function T(u){let R={node:"tsup-node"},v=process.cwd(),N=[...[".ts",".js",".cjs",".json"].map(s=>a.join(v,`tochibuild.config${s}`)),...[".ts",".js",".cjs",".json"].map(s=>a.join(v,`tsup.config${s}`))],w=f?.tochibuild,j=f?.tsup,C=!!Object.keys(w||{}).length||!!Object.keys(j||{}).length,p=N.find(s=>d.existsSync(s)),$=C||p,S=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(...s)=>O(s));S.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(s=>J.generateConfig(u,s,!1,!0)),S.parseAsync(process.argv);async function O(s){let[t]=s;return new Promise((D,l)=>{try{let h="node",e=[],m=t.includes("--config"),P=t.includes("--no-config"),b=m?t.findIndex(i=>i==="--config")+1:void 0;if(!m&&!P&&!$){if(t[0]==null||t[0]?.startsWith("-")){c.custom("error",`${r.red("No input files, try")} '${r.magenta(u)} ${r.gray("[...files]")}' ${r.red("instead")}`),l();return}e.push(...t)}else if(!m&&!P&&$)if(C){let i=w||j;t.filter(n=>n.startsWith("-")).forEach(n=>{let o=t.findIndex(V=>V===n),G=n.startsWith("--")?n.slice(2):n.slice(1);if(i[G]||(e.push(n),e[o+1]?.startsWith("-")))return;let I=e[o+1];I&&e.push(I)}),Object.entries(i).forEach(([n,o])=>{typeof o=="boolean"||o==="true"||o==="false"?o&&e.push(`--${n}`):typeof o=="string"&&e.push(`--${n}`,o)}),e.push("--no-config")}else if(p){let i=a.relative(k,p).replace(/\\/g,"/");c.log(`using existing configuration file: ${r.gray(i)}`),e.push("--config",i),e.push(...t)}else e.push(...t);else{if(b!=null&&b>=0){let i=t[b]||"unspecified";d.existsSync(i)||(c.error(void 0,`config file '${i}' does not exist`),c.info(`try running '${r.magenta(u)} ${r.blue("config")} ${r.gray("-h")}' to get help on how to generate a config file`),process.exit(1))}e.push(...t)}c.log(`running build${x||f?.name?` for ${r.magenta(x?u:f.name)}`:""}...`);let y=M(R[h],[...e],{stdio:"inherit",shell:!0,cwd:process.cwd(),env:process.env});y.on("exit",i=>{process.exit(i??1)}),process.on("SIGINT",()=>{l(),y.kill("SIGINT")}),process.on("SIGTERM",()=>{l(),y.kill("SIGTERM")}),D()}catch(h){l(h)}})}}T("@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-CJIhwKYt.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-U7SHXASE.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};
|
@@ -5,6 +5,7 @@ type BuildOptionsOverrideParam<RequiredKeys extends keyof Options> = (overrideOp
|
|
5
5
|
type BuildOptionsParams<RequiredKeys extends keyof Options> = BuildOptionsParam<RequiredKeys> | BuildOptionsOverrideParam<RequiredKeys>;
|
6
6
|
type ConfigResult<RequiredKeys extends keyof Options> = BuildOptionsParam<RequiredKeys> | BuildOptionsOverrideParam<RequiredKeys>;
|
7
7
|
declare class BuildUtils {
|
8
|
+
static defaultConfigOptions: Options;
|
8
9
|
/**
|
9
10
|
* Array of commonly ignored entries
|
10
11
|
*
|
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-CJIhwKYt.mjs';
|
2
|
+
export { b as BuildOptionsOverrideParam, a as BuildOptionsParam, c as BuildOptionsParams, C as ConfigResult } from './utils-CJIhwKYt.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-U7SHXASE.mjs";var e=o;export{r as BuildUtils,e as default};
|
package/package.json
CHANGED
@@ -1,43 +1,51 @@
|
|
1
|
-
{
|
2
|
-
"name": "@tochii/build",
|
3
|
-
"version": "2.0
|
4
|
-
"description": "An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",
|
5
|
-
"repository": "https://github.com/tochiResources/project/tree/main/packages/build.git",
|
6
|
-
"license": "MIT",
|
7
|
-
"keywords": [
|
8
|
-
"bundler",
|
9
|
-
"build",
|
10
|
-
"typescript",
|
11
|
-
"javascript",
|
12
|
-
"tsup",
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
"
|
23
|
-
"build
|
24
|
-
"build:
|
25
|
-
"
|
26
|
-
|
27
|
-
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
"
|
36
|
-
|
37
|
-
|
38
|
-
"
|
39
|
-
},
|
40
|
-
"
|
41
|
-
"
|
42
|
-
|
43
|
-
|
1
|
+
{
|
2
|
+
"name": "@tochii/build",
|
3
|
+
"version": "2.1.0",
|
4
|
+
"description": "An extremely fast JavaScript/Typescript and CSS bundler with minimal configuration.",
|
5
|
+
"repository": "https://github.com/tochiResources/project/tree/main/packages/build.git",
|
6
|
+
"license": "MIT",
|
7
|
+
"keywords": [
|
8
|
+
"bundler",
|
9
|
+
"build",
|
10
|
+
"typescript",
|
11
|
+
"javascript",
|
12
|
+
"tsup",
|
13
|
+
"esbuild",
|
14
|
+
"glob",
|
15
|
+
"cli",
|
16
|
+
"node",
|
17
|
+
"tochi",
|
18
|
+
"tochiResources"
|
19
|
+
],
|
20
|
+
"bin": "./dist/cli.mjs",
|
21
|
+
"scripts": {
|
22
|
+
"dev": "tsx cli.ts",
|
23
|
+
"build": "bun run build:root && bun run build:tochibuild",
|
24
|
+
"build:root": "tsx cli.ts --config ./tochibuild/tochibuild.config.ts --entry index.ts --entry cli.ts --entry utils.ts",
|
25
|
+
"build:tochibuild": "cd ./tochibuild && bun run build",
|
26
|
+
"build:release": "bun run build:release:root && bun run build:release:tochibuild",
|
27
|
+
"build:release:root": "bun run build:root && bun run release:root",
|
28
|
+
"build:release:tochibuild": "cd ./tochibuild && bun run build && bun run release",
|
29
|
+
"install:tochibuild": "cd ./tochibuild && bun install",
|
30
|
+
"release": "bun run release:root && bun run release:tochibuild",
|
31
|
+
"release:root": "bun publish --access public --no-private",
|
32
|
+
"release:tochibuild": "cd ./tochibuild && bun run release"
|
33
|
+
},
|
34
|
+
"dependencies": {
|
35
|
+
"chalk": "^5.4.1",
|
36
|
+
"commander": "^13.1.0",
|
37
|
+
"deepmerge": "^4.3.1",
|
38
|
+
"tsup": "8.4.0"
|
39
|
+
},
|
40
|
+
"devDependencies": {
|
41
|
+
"@types/node": "^22.15.17",
|
42
|
+
"tsx": "^4.19.4",
|
43
|
+
"typescript": "^5.8.3"
|
44
|
+
},
|
45
|
+
"engines": {
|
46
|
+
"node": ">=18.17.0"
|
47
|
+
},
|
48
|
+
"files": [
|
49
|
+
"dist"
|
50
|
+
]
|
51
|
+
}
|
package/dist/chunk-LBH52VOU.mjs
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import g from"chalk";import f from"fs";import h from"path";import a from"chalk";var u="tochibuild",c=a.cyan(u),y=class{static{this.log=(...e)=>{console.log(c,...e)}}static{this.debug=(...e)=>{console.debug(c,...e)}}static{this.info=(...e)=>{console.info(c,...e)}}static{this.warn=(...e)=>{console.warn(c,...[...e].map(t=>a.yellow(t)))}}static{this.error=(e,...t)=>{console.error(a.red(u),a.bgRed(...t),e?.stack?`
|
2
|
-
${a.gray(e.stack)}`:"")}}static{this.success=(...e)=>{console.log(a.green(u),...e)}}static{this.custom=(e,...t)=>{console.log(e(u),...t)}}},l=y;var d=class i{static{this.ignoredEntries=["!build","!dist","!node_modules","!**/*/node_modules","!*.d.ts","!**/*/*.d.ts","!tochibuild.*","!tsup.*","!**/*/tochibuild.*","!**/*/tsup.*"]}static{this.entriesCommon=["*.js","*.ts","**/*/*.js","**/*/*.ts"]}static{this.entriesIndex=["index.js","index.ts","**/*/index.js","**/*/index.ts"]}static{this.defaultEntriesIndex=[...i.entriesIndex,...i.ignoredEntries]}static{this.defaultEntriesCommon=[...i.entriesCommon,...i.ignoredEntries]}static{this.defaultOptions=e=>O(e,t=>({tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...t,entry:x(t.entry,"ignoredEntries")}))}static{this.defaultOptionsWithIndexEntries=e=>O(e,t=>({tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...t,entry:x(t.entry,"defaultEntriesIndex")}))}static{this.defaultOptionsWithCommonEntries=e=>O(e,t=>({tsconfig:"tsconfig.json",dts:!0,format:["esm"],minify:!0,...t,entry:x(t.entry,"defaultEntriesCommon")}))}static{this.generateConfig=$}},D=d;function O(i,e){let t=n=>Array.isArray(n)?n.map(r=>({...e(r),...r})):{...e(n),...n};if(typeof i=="function"){let n=i;async function r(s){let B=await n(s);return t(B)}return r}return t(i)}function x(i,e){if(Array.isArray(i))return[...d[e],...i];let t={};return d[e].forEach(n=>t[n]=n),{...i,...t}}function q(i){return h.isAbsolute(i||".")?i:h.resolve(process.cwd(),i)}function $(i,e,t,n){let r="";try{let s=e?.ext||".ts",b=`${e?.filename||"tochibuild.config"}${s}`;(e?.outDir?.length?e.outDir:["."]).forEach(m=>{r=q(m),f.existsSync(m)||f.mkdirSync(m,{recursive:!0});let p=h.join(r,b),C=f.existsSync(p);!e?.overwrite&&C&&(l.warn(`the config '${b}' file already exists for this project.`),n&&process.exit(1));let K=" ",o="",E={clean:!1,splitting:!0},P=R=>{o+=R==="esm"?`import build from '${i}';
|
3
|
-
|
4
|
-
`:`const build = require('${i}');
|
5
|
-
|
6
|
-
`,o+=R==="esm"?`export default build.defineConfigWithIndexEntries({
|
7
|
-
`:`module.exports = build.defineConfigWithIndexEntries({
|
8
|
-
`,Object.entries(E).forEach(([j,k])=>{o+=`${K}${j}: ${JSON.stringify(k)},
|
9
|
-
`}),o+=`});
|
10
|
-
`};switch(s){case".ts":case".js":P("esm");break;case".cjs":P("cjs");break;case".json":o+=`${JSON.stringify({...E,entry:d.defaultEntriesIndex},null,2)}
|
11
|
-
`;break;default:l.error(void 0,`unsupported extension: ${s}`),process.exit(1)}f.writeFileSync(p,o),l.custom(g.green,g.cyan("the config file has been created at:"),g.gray(p))})}catch(s){if(t)throw s;l.error(s,s.message?`failed to generate config file in ${r}: ${s.message}`:`failed to generate config file in ${r}`),n&&process.exit(1)}}export{l as a,d as b,D as c};
|