-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tell esbuild not to load tsconfig #2440
Comments
This is what the |
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 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. |
This patch addresses an issue[1] in which Remix looks for a tsconfig outside the root directory. We fix this behavior by looking for a tsconfig where it should be (in the rootDirectory itself) and passing its absolute path to `tsconfig-paths`. `tsconfig-paths` will then treat the given path as a tsconfig file path and won't crawl further. If no tsconfig file is found by us in our root directory, we simply won't call `tsconfig-paths` at all. Note that crawling up is `tsconfig-path`s intended behavior, but not Remix's. A secondary bug that causes this same issue is due to esbuild[2]. When no tsconfig is passed to esbuild, it will crawl the filesystem up looking for any tsconfig available and will load it. When tsconfig is explicitly set to `undefined`, it does the crawling anyways. Unfortunately, this is a fix that has to be done in `esbuild`, but a few alternatives to manage this unwanted behavior for now can be: 1. Create an empty tsconfig in the build directory and pass it to esbuild so it doesn't crawl outside rootDir; 2. Show a warning to let the user know why the crawling is happening. Fixes remix-run#3210 [1] remix-run#3210 [2] evanw/esbuild#2440 Signed-off-by: Juliana Oliveira <[email protected]>
It's used like this:
|
It doesn't seem ideal to provide configuration through the file system. Explicitly setting 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 |
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:
This is related to, but not quite the same as, #2386.
The text was updated successfully, but these errors were encountered: