build: migrate to commonjs and add node single executable app support
- Switch module type to commonjs in package.json - Update esbuild target to node22 and remove explicit ESM format flag - Add `bin` script for building a native binary using `node --build-sea` - Introduce sea-config.json with code cache enabled for faster startup
This commit is contained in:
parent
cd3749b07e
commit
d98ddb3ca7
3 changed files with 16 additions and 6 deletions
5
index.ts
5
index.ts
|
|
@ -77,4 +77,7 @@ async function main() {
|
||||||
await renderer.renderStats(totalUsage);
|
await renderer.renderStats(totalUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
await main();
|
main().catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
|
||||||
11
package.json
11
package.json
|
|
@ -1,18 +1,19 @@
|
||||||
{
|
{
|
||||||
"name": "lmc",
|
"name": "lmc",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"main": "dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
"private": true,
|
"private": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"lmc": "dist/index.js",
|
"lmc": "dist/index.js"
|
||||||
"ttsc": "dist/tts.js"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tsx index.ts",
|
"dev": "tsx index.ts",
|
||||||
"prod": "node dist/index.js",
|
"prod": "node dist/index.js",
|
||||||
"check": "biome check --write && pnpm run tc",
|
"check": "biome check --write && pnpm run tc",
|
||||||
"build": "pnpm run check && pnpm run bundle",
|
"build": "pnpm run check && pnpm run bundle && pnpm run bin",
|
||||||
"bundle": "esbuild index.ts --bundle --outdir=dist --platform=node --target=node18 --format=esm --packages=external",
|
"bundle": "esbuild index.ts --bundle --outdir=dist --platform=node --target=node22",
|
||||||
|
"bin": "node --build-sea sea-config.json",
|
||||||
"tc": "tsc --noEmit --incremental"
|
"tc": "tsc --noEmit --incremental"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
6
sea-config.json
Normal file
6
sea-config.json
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"output": "dist/lmc",
|
||||||
|
"useCodeCache": true,
|
||||||
|
"disableExperimentalSEAWarning": true
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue