-
-
Notifications
You must be signed in to change notification settings - Fork 27k
require('ts-pattern') not work on react-scripts 5 but work on react-scripts 4. #12725
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
Comments
Hi @ChengOuyang, I found this issue interesting so being here to help. Firstly, I saw you were initializing the project directory Secondly, I gave a try with the codesandbox: https://codesandbox.io/s/brave-buck-g0cvb8?file=/src/App.js It seems that the package |
esm import is work, but cjs require not work |
Emm..., changing |
Hmm..., looks I can reproduce in my local. Looking into it... |
Reproduce the project below: |
I can't reproduce it on sandbox either, but I can reproduce it locally with cra…… |
Thanks @ChengOuyang. Let me take a look. |
Looks when using By far, adding support for the My suggestion is, you may stick to |
Thanks
Thanks, this problem we found in the project is actually two problems:
We have solved problem 1, and the project is running normally, but problem 2 is rather strange, so I went to the official here to mention it... |
For tip 1, the behavior of including which file is actually determined by the exports field in package.json. Here is how it works: https://webpack.js.org/guides/package-exports/. For tip 2, yep, agree, it could feel a bit strange that |
Describe the bug
const tsPattern = require('ts-pattern');
The tsPattern is a string but not a module on react-scripts 5, and other library is work.
Did you try recovering your dependencies?
(Write your answer here.)
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
(paste the output of the command here.)
Steps to reproduce
(Write your steps here:)
Expected behavior
The tsPattern should be a module be return a string on react-scripts 5, and other library is work.
Actual behavior
(Write what happened. Please add screenshots!)
Reproducible demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
The text was updated successfully, but these errors were encountered: