I've run into similar issue recently, in my case I wanted to have 3 separate tsconfig in the same directory, with one being the "common base" and the other two being server/client separation. I tried running tstl with -p, but it seems tstl doesn't respect "extends" property in tsconfig for some reason.
Is this just me, or is this supposed to work? Nevermind, it seems to be working now (lol)
AI says:
Example TypeScriptToLua project with three tsconfig files in the same directory:
tsconfig.base.json: shared config
tsconfig.client.json: client‑side config
tsconfig.server.json: server‑side config
Each of the client/server configs extends the base config.
This is a very common setup for full-stack TypeScriptToLua monorepos or unified projects.
📁 Project Structure
my-tstl-project/
│
├── src/
│ ├── client/
│ │ └── main.ts
│ ├── server/
│ │ └── main.ts
│ └── shared/
│ └── utils.ts
│
├── tsconfig.base.json
├── tsconfig.client.json
├── tsconfig.server.json
└── package.json
🧩 1. Base Config - tsconfig.base.json
This contains all shared TSTL settings.
{
"compilerOptions": {
"strict": true,
"types": []
},
"tstl": {
"luaTarget": "5.4"
}
}
Notes:
tstl block contains TSTL‑specific options
- No
module or target as TSTL ignores those
🖥️ 2. Client Config - tsconfig.client.json
Client build extending the base config.
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/client"
},
"include": [
"src/client/**/*",
"src/shared/**/*"
],
"tstl": {
"luaTarget": "5.4"
}
}
🖧 3. Server Config - tsconfig.server.json
Server build extending the base config.
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/server"
},
"include": [
"src/server/**/*",
"src/shared/**/*"
],
"tstl": {
"luaTarget": "5.4"
}
}
🧪 Example Source Files
src/shared/utils.ts
export function greet(name: string) {
return "Hello, " + name + "!";
}
src/client/main.ts
import { greet } from "../shared/utils";
console.log(greet("Client"));
src/server/main.ts
import { greet } from "../shared/utils";
console.log(greet("Server"));
📦 package.json Example
{
"name": "multi-config-tstl-example",
"private": true,
"scripts": {
"build:client": "npx tstl -p tsconfig.client.json",
"build:server": "npx tstl -p tsconfig.server.json",
"build": "npm run build:client && npm run build:server"
},
"devDependencies": {
"typescript-to-lua": "^1.33.2",
"typescript": "^5.9.3"
}
}
🏁 Running the Build
Produces:
dist/
├── client/
│ └── main.lua
└── server/
└── main.lua