Bundle tui3 into dist/ and run the bundle
Running the TypeScript sources makes Bun compile and keep hundreds of vendored modules, which cost 110-130 MB at startup. scripts/build.ts bundles bin.ts and OpenTUI's syntax-highlighting worker into dist/; bun install builds it, bun run build rebuilds it, and the tui3 bin runs it. bun run dev still runs the sources.
This commit is contained in:
1 parent
42189808f3
commit
f54ea6ad42
4 files changed
+28
-3
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
dist
|
||||||
@@ -8,10 +8,12 @@ Built with Bun and [OpenTUI](https://github.com/anomalyco/opentui) (React).
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone --recurse-submodules <this repo> && cd tui3
|
git clone --recurse-submodules <this repo> && cd tui3
|
||||||
bun install # also links the pinned T3 Code packages into node_modules
|
bun install # also links the pinned T3 Code packages into node_modules and builds dist/
|
||||||
bun link # optional: puts `tui3` on your PATH
|
bun link # optional: puts `tui3` on your PATH
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`tui3` runs the bundle in `dist/`, which uses over 100 MB less memory than the sources. After pulling changes, run `bun run build` (or `bun install`) to rebuild it; `bun run dev` runs the sources directly.
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
+3
-2
@@ -4,14 +4,15 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tui3": "./src/bin.ts"
|
"tui3": "./dist/bin.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run src/bin.ts",
|
"dev": "bun run src/bin.ts",
|
||||||
|
"build": "bun run scripts/build.ts",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"lint": "biome lint src test",
|
"lint": "biome lint src test",
|
||||||
"test": "bun test",
|
"test": "bun test",
|
||||||
"postinstall": "bun run scripts/link-vendor.ts"
|
"postinstall": "bun run scripts/link-vendor.ts && bun run scripts/build.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@opentui/core": "0.2.7",
|
"@opentui/core": "0.2.7",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// Bundles tui3 into dist/. Running the TypeScript sources makes Bun compile and keep
|
||||||
|
// hundreds of vendored modules at startup, which costs over 100 MB of memory.
|
||||||
|
import { rm } from "node:fs/promises";
|
||||||
|
import { join } from "node:path";
|
||||||
|
|
||||||
|
const root = join(import.meta.dir, "..");
|
||||||
|
const outdir = join(root, "dist");
|
||||||
|
await rm(outdir, { recursive: true, force: true });
|
||||||
|
|
||||||
|
const builds = [
|
||||||
|
join(root, "src/bin.ts"),
|
||||||
|
// OpenTUI starts its syntax highlighter from parser.worker.js beside the code that loads it.
|
||||||
|
join(root, "node_modules/@opentui/core/parser.worker.js"),
|
||||||
|
];
|
||||||
|
for (const entrypoint of builds) {
|
||||||
|
const result = await Bun.build({ entrypoints: [entrypoint], outdir, target: "bun", minify: true });
|
||||||
|
if (!result.success) {
|
||||||
|
for (const log of result.logs) console.error(log);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user