esbuild
esbuild copied to clipboard
Tell esbuild not to load tsconfig
esbuild will happily crawl my filesystem to find a tsconfig.json file, and then use its paths configuration to do file resolution. However, in my scenario (a monorepo built with Bazel), this behavior is too invasive and assumes too much.
I can think of two approaches to fix this behaviour:
- limit the filesystem crawling to what's under the current working directory;
- allow a way to turn this off via the tsconfig option (e.g., if I explicitly set it to undefined, then don't crawl for a tsconfig).
This is related to, but not quite the same as, #2386.
This is what the --tsconfig=
setting is for. You can use that to override the default one with one of your choosing: https://esbuild.github.io/api/#tsconfig
How do I specify that I don't want any tsconfig to be loaded?
I'm just giving esbuild JS sources, but because it loads a tsconfig, esbuild will use what's in paths
do to path resolution, and will try to load the corresponding TS sources. (That leaves the pnpm workspace and then it can't find deps for those sources - it's a whole can of worms).
I can get around that by updating the resolution extensions, but even then it's awkward for a few reasons (I'm using esbuild through remix, so I don't really have that kind of control without patching remix, and I could have other valid TS entry points). I also get warnings about the tsconfig which pollute the output.
It's used like this:
echo "{}" > empty-tsconfig.json
esbuild --bundle --tsconfig=empty-tsconfig.json
It doesn't seem ideal to provide configuration through the file system. Explicitly setting tsconfig
to undefined
would be better. I think if a raw tsconfig could be provided to build
it would also be better.
All this said, it still seems like undesirable behavior that esbuild will crawl above the working directory.
An upcoming change will allow you to pass --tsconfig-raw={}
to esbuild to further simplify passing esbuild a custom tsconfig.json
file.