justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
880 stars 63 forks source link

Does not work properly with tsconfig.json with extends #230

Open amosbastian opened 1 week ago

amosbastian commented 1 week ago

I have this tsconfig.build.json

{
  "extends": ["./tsconfig.json", "@workspace/tsconfig/build.json"],
}

when I run tsc-alias -p tsconfig.build.json it says 0 files were affected

If I do tsc --showConfig -p tsconfig.build.json > tsconfig.build.resolved.json and run tsc-alias -p tsconfig.build.resolved.json it says 44 files were affected.

mkvlrn commented 1 week ago

@amosbastian Just by having this issue open you solved my problem! Been using esbuild + tsc-alias for a while now, and when I started extending a tsconfig things broke and I had no idea where.

It's a quick workaround and it really doesn't impact build time.

// create full temp config because tsc-alias doesn't like extended configs
// https://github.com/justkey007/tsc-alias/issues/230
await execAsync("tsc --showConfig > tsconfig.temp.json");

// replace aliases
await replaceTscAliasPaths({ outDir, configFile: "tsconfig.temp.json" });

// clean up
await fs.rm("tsconfig.temp.json");

So yeah, thanks! 🍺