jiti icon indicating copy to clipboard operation
jiti copied to clipboard

Support `.jsx` and `.tsx` by default?

Open tessro opened this issue 1 year ago • 8 comments

Describe the feature

Would you be open to adding .jsx and .tsx extensions to the default set? Currently, in React projects, Jiti throws "Cannot find module" errors when parsing files that import JSX/TSX. TypeScript typically loads these automatically, so it's a cryptic issue that is likely to trip people up. (I spent over an hour tracking it down.) Since Jiti is used as middleware in other tools (in my case, by GraphQL Code Generator), this error is typically not something a user is prepared to debug, since they may not even realize Jiti is used under the hood.

JSX/TSX are typically supported automatically by TypeScript itself so this feels like a safe change, if you're open to it! 🤞🏼

Addendum: For .tsx specifically, I believe isTypescript would also need to be updated for this to work. That feels extremely safe since .tsx files are always TypeScript.

Additional information

  • [X] Would you be willing to help implement this feature?

tessro avatar Apr 21 '23 18:04 tessro