-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Build fails if there's a broken tsconfig.json file outside the project #3210
Comments
@F3n67u 👋🏼 |
I think yes. tsconfig-paths will walk to parent directory until to root to find a tsconfig.json. if the found tsconfig.json is not valid, then error will throw when parse the invalid json config. I think error message could be improved. |
Can we tell it to stop searching when reaching the remix app root? |
I don't think there is any problem with EDIT: This is causing lot of test to fail on running async function createBrowserBuild(
config: RemixConfig,
options: BuildOptions & { incremental?: boolean }
): Promise<esbuild.BuildResult> {
...
...
...
return esbuild.build({
...
tsconfig: `${config.rootDirectory}/tsconfig.json`, // Setting tsconfig explicitly
});
} function createServerBuild(
config: RemixConfig,
options: Required<BuildOptions> & { incremental?: boolean },
assetsManifestPromiseRef: AssetsManifestPromiseRef
): Promise<esbuild.BuildResult> {
...
...
...
return esbuild
.build({
...
tsconfig: `${config.rootDirectory}/tsconfig.json`,
})
.then(...);
} |
@machour I am wrong a lot. after some debugging, I found it's not a problem with
the log result shows |
Looking at the error message, it seems to be an error in our own |
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]>
Closed by #3936 |
What version of Remix are you using?
latest
Steps to Reproduce
Expected Behavior
The build should work fine, and the tsconfig.json file outside my project should be ignored
Actual Behavior
🍺 ~/my-remix-app npm run dev
Watching Remix app in development mode...
✘ [ERROR] Unexpected end of file
Build failed with 1 error:
../tsconfig.json:1:0: ERROR: Unexpected end of file
The text was updated successfully, but these errors were encountered: