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

Set compilerOptions.jsx = "react" #34

Merged
merged 2 commits into from
Mar 20, 2023
Merged

Set compilerOptions.jsx = "react" #34

merged 2 commits into from
Mar 20, 2023

Conversation

alx-khramov
Copy link
Contributor

Typescript offers various jsx compiling options.
This PR sets compilerOptions.jsx field to use legacy react value instead of react-jsx.
Other changes are just side effects of this action.

Reason:

Currently, we use React v17 on Lido widgets, and reef-knot also supports React v17.
React v17 has an issue with ESM because it has no exports field in the package.json.
This can cause such error during building a based on react v17 project, which uses ESM and imports reef-knot:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<...>\node_modules\react\jsx-runtime' imported from <...>
Did you mean to import react/jsx-runtime.js?

It happens because of the way how ESM in node.js is defined. In modules with a package.json containing "type": "module" imports in .mjs or .js files must be fully specified (with extensions), or it can be solved by the exports field.

It worked before because reef-knot was built as a CJS module.
The issue is fixed in react v18 – they've added the exports field to package.json, so we can switch back to react-jsx option after migrating to react v18.

More info:

@alx-khramov alx-khramov self-assigned this Mar 17, 2023
@alx-khramov alx-khramov temporarily deployed to preview March 17, 2023 16:36 — with GitHub Actions Inactive
@alx-khramov alx-khramov merged commit 1a82806 into main Mar 20, 2023
@alx-khramov alx-khramov deleted the fix/react-jsx branch March 20, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants