-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🐛 Bug: react/webpack example breaks on JSX syntax in a .js file #103
Comments
Thanks for filing! I transferred this over to the right repo. Could you please post the error messages you're seeing? Just a note that "it doesn't work" isn't quite enough to go off of. When I try with Node 22.12.0, I get:
|
I apologize. Yes, here is the message (pretty much the same one you got there:
Then if I set
I believe this is related to mocha/webpack/babel/node attempting to parse files in a different way or order now. Node 22 tries to parse the file in both ESM and CommonJS and falls back to one with the other fails. This might be an issue with webpack, babel, or mocha not handling the errors node is throwing at it, or something else because it seems to work fine in previous versions of node. |
Is this really an issue for the examples rather than Mocha proper? We're seeing the same issue in the Preact repo, requiring that we add |
Good question. I think at least this specific instance of the error is a problem in the example: #108 fixes it. IMO using JSX syntax in a As for the general case of using Babel to test files with JSX syntax in Mocha, my hunch is this not specific to Mocha. Mocha generally tries not to be opinionated on how to configure tools like Babel. I'd look first to how Babel is acting. But if you have a reproduction that shows an issue in Mocha itself, we'd happily take an issue on the Mocha repo! |
Gotcha, I missed the Can try to get something together for a repro, but for us, using |
Bug Report Checklist
faq
label, but none matched my issue.Expected
I expect to be able to run
mocha
andwebpack
with the same code using babel to transpile the code.Actual
mocha
runs the tests but the @babel/register isn't working properlyMinimal, Reproducible Example
I used the
react-webpack
example in the mocha-examples repo.https://github.com/mochajs/mocha-examples/tree/main/packages/react-webpack
Versions
Additional Info
If I change the "type" in the
package.json
tocommonjs
, the tests start working, but webpack starts failing.It's possible there's a solution that doesn't involve changing mochajs and it's just a configuration that's missing. In that case, this is more of an issue with the examples not working anymore.
The text was updated successfully, but these errors were encountered: