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

feat: support .tsx file as entry #82

Merged
merged 3 commits into from
Sep 12, 2024

Conversation

uinz
Copy link
Contributor

@uinz uinz commented Aug 29, 2024

The main purpose of this MR is to enable the output files with suffixes such as .d.ts, .d.mts, .d.cts, .cjs, and .mjs to be mapped to .tsx in the same way as .js.

This modification involves adjusting the file extension mapping in the extensionMap object to establish the appropriate associations. Additionally, several test cases have been updated to ensure the correct functionality and stability when handling these new extensions.

By doing so, the project's flexibility and compatibility are enhanced, allowing for a wider range of file extensions to be processed and mapped to .tsx as needed.

}),
'tsconfig.json': createTsconfigJson({
compilerOptions: {
jsx: 'preserve',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to a different option and assert the output type too?

Currently, preserve doesn't actually seem to be preserving the JSX and needs to be passed in as a top-level option in esbuild as well:
https://esbuild.github.io/try/#dAAwLjIzLjEAeyBsb2FkZXI6ICdqc3gnLCBqc3g6J3ByZXNlcnZlJywgdHNjb25maWdSYXc6ICd7ICJjb21waWxlck9wdGlvbnMiOiB7ICJqc3giOiAicHJlc2VydmUiIH0gfScgfQBleHBvcnQgY29uc3QgYSA9IDxhPmhpPC9hPg

evanw/esbuild@7a727e3

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I set it to react or react-jsx, due to the absence of a type signature for react, a type error will be reported. Can I add @types/react for this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure go ahead, will review again tomorrow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated

@uinz uinz force-pushed the feat/support-tsx-as-entry branch from 44b2487 to 4b18b7f Compare August 31, 2024 01:01
@privatenumber privatenumber merged commit 9f1195f into privatenumber:master Sep 12, 2024
2 checks passed
@privatenumber
Copy link
Owner

Nice work, thanks for the PR!

@privatenumber
Copy link
Owner

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants