jest: jest-worker: should not expose `.default` babel interop
import a from 'jest-worker'
of course, works fine, because it’s using babel on both ends.
However, const b = require('jest-worker')
results in a !== b
, and to get at the proper value, you need to do b.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 use module.exports =
instead of export default
(or can you use the add-module-exports
transform?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (19 by maintainers)
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
export default class JestWorker
we can doexport class JestWorker
. Possibly name itWorker
instead as we don’t need to repeat the package name in the export@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.
@SimenB @jeysal I would love to take this up as my first issue if possible
That sounds perfect then. Reopening 😀
enzyme does this with all it top-level entry points, for example.
Yes, it would work for both.
See comment in PR
add-module-exports
sounds good to me, I agree it’s annoying having to do.default
in node (and probably not good for real ESM support in node).PR welcome! 😀