-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
jest-worker: should not expose .default
babel interop
#5803
Comments
PR welcome! 😀 |
See comment in PR |
After a year with an open PR, i think this is a really user-hostile decision. |
The PR didn't work properly. Using the plugin was discussed a bit in #7554 and it seems like people have been burnt by |
There’s lots of alternatives including a manual entry point that does the un-.defaulting. As for Babel themselves, it’s reasonable for Babel to expect consumers to couple to Babel interop, it’s not reasonable for “not Babel” to do so. |
Yeah, that's an option. Do you know if that would still work for people doing |
Yes, it would work for both. |
enzyme does this with all it top-level entry points, for example. |
That sounds perfect then. Reopening 😀 |
The link at the top is broken. Should be updated to: https://github.com/facebook/jest/blob/master/packages/jest-worker/src/index.ts |
@ljharb can i use this https://www.npmjs.com/package/babel-plugin-add-module-exports or do i need to explicitly, change to |
@saenglert as long as the main entry point of the package only has one default export, that transform should do the job. |
@ljharb please i dont really understand your explanation do you mean this transformation |
We're exporting multiple things (which I don't wanna change), so the babel plugin won't work. A named export is probably our only option, although it's a breaking change. Instead of |
@SimenB i'm pretty sure you could still change things by attaching all the named exports to the default export, and explicitly add __esModule: true, and it wouldn't be a breaking change - it'd be pretty gross tho, to be sure. |
Just ditch the default export, I don't think it's worth it to go through weird hoops to support both and keep TypeScript happy. |
@SimenB I changed it to the named export, got all tests passing at the |
@anje123 if you open up a PR with your WIP stuff I can take a look 🙂 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
import a from 'jest-worker'
of course, works fine, because it's using babel on both ends.However,
const b = require('jest-worker')
results ina !== b
, and to get at the proper value, you need to dob.default
.Entry points should not expose babel interop details like
.default
- can https://github.com/facebook/jest/blob/master/packages/jest-worker/src/index.js usemodule.exports =
instead ofexport default
(or can you use theadd-module-exports
transform?The text was updated successfully, but these errors were encountered: