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

Support for "esbuild-jest" #90

Closed
makoru-hikage opened this issue Aug 2, 2021 · 6 comments
Closed

Support for "esbuild-jest" #90

makoru-hikage opened this issue Aug 2, 2021 · 6 comments

Comments

@makoru-hikage
Copy link
Contributor

This is for projects using React which requires es6 builds. React projects typically uses ES6 builds.

@glennsl
Copy link
Owner

glennsl commented Aug 4, 2021

What would be required for this?

@makoru-hikage
Copy link
Contributor Author

makoru-hikage commented Aug 6, 2021

Thank you for your reply! Fortunately, you do not need to do any additional code changes for this. I initially thought you would need to.

I just needed to add this in a Jest config file (or "jest" property if you are storing your Jest config in package.json):

{
    "transform": {
      "^.+\\.jsx?$": "esbuild-jest"
    },
    "transformIgnorePatterns": ["<rootDir>/node_modules/(?!(rescript|@glennsl/bs-jest)/)"]
  }

This will require "esbuild-jest" of course. When someone uses rescript build -with-deps with this property in bsconfig.json:

"package-specs": {
    "module": "es6",
    "in-source": true
  }

All res* and ml* files are transpiled into js (or mjs) in ES6 flavor. However, the compiled res/ml files in node_modules aren't transpiled, so this thing "transformIgnorePatterns": ["<rootDir>/node_modules/(?!(rescript|@glennsl/bs-jest)/)"] is added to the Jest config.

Shall I add something to the docs?

@makoru-hikage
Copy link
Contributor Author

Please take note that I have not done any test files involving React. I use it here: https://github.com/makoru-hikage/sasquare-reasonml

(Please do not mind that misnomer on my personal project.)

@glennsl
Copy link
Owner

glennsl commented Aug 7, 2021

Thanks for the explanation!

Shall I add something to the docs?

Yes. Please do! As a sub-heading to the troubleshooting section, for example, or just referencing this issue if you're feeling lazy.

@makoru-hikage
Copy link
Contributor Author

Thank you! I shall write a sub-heading, submit a PR and close this upon merging.

@glennsl
Copy link
Owner

glennsl commented Aug 12, 2021

Closing this as resolved in #91 then. Thanks again!

@glennsl glennsl closed this as completed Aug 12, 2021
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

No branches or pull requests

2 participants