Skip to content
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

custom tsconfig location appears to be silently ignored when it's outside of the source folder ancestry #467

Open
4 of 6 tasks
moredip opened this issue Jan 30, 2024 · 2 comments
Labels
bug Something isn't working pending triage

Comments

@moredip
Copy link

moredip commented Jan 30, 2024

Acknowledgements

  • I searched existing issues before opening this one to avoid duplicates
  • I understand this is not a place for seek help, but to report a bug
  • I understand that the bug must be proven first with a minimal reproduction
  • I will be polite, respectful, and considerate of people's time and effort

Minimal reproduction URL

https://stackblitz.com/edit/node-49eqfc?file=README.md

Version

4.7.0

Node.js version

18.18.0

Package manager

pnpm

Operating system

Linux

Problem & Expected behavior

TL;DR

If I give tsx a tsconfig path that's a direct ancestor of the source directory then it is used as expected, but if I give it a tsconfig that's in a sibling directory then it appears to be silently ignored.

Details

I'm trying to use tsx to dynamically import jsx rendered using nano-jsx rather than React. Doing that requires configuring typescript's jsxImportSource compiler option, which in turn means providing a tsconfig.json file to tsx. For reasons that are a bit complex to get into, I sometimes need to keep that tsconfig.json outside of the folder heirarchy of the source I'm executing (my program is operating on externally provided files and I don't have permissions to add a tsconfig.json there).

What I've discovered is that tsx appears to silently ignores the compiler options of a tsconfig.json file if that file is outside of the source files' directory heirarchy.

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@moredip moredip added bug Something isn't working pending triage labels Jan 30, 2024
@busybox11
Copy link

You'd probably need to use tsconfig's include directive for esbuild to process the source code. It looks like it's not present anywhere in your minimal reproduction repo.

@moredip
Copy link
Author

moredip commented Feb 15, 2024

You'd probably need to use tsconfig's include directive for esbuild to process the source code. It looks like it's not present anywhere in your minimal reproduction repo.

Thanks @busybox11, this worked! I don't really understand why though.

I updated elsewhere/_tsconfig.json as follows:

  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "nano-jsx/lib"
  },
  "include": ["../subdir/**/*"]
}

and now things are working - nano-jsx is being used instead of React - but I don't understand why adding that include directive changed things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending triage
Projects
None yet
Development

No branches or pull requests

2 participants