question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jest-worker: should not expose `.default` babel interop

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Oct 9, 2020

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 do export class JestWorker. Possibly name it Worker instead as we don’t need to repeat the package name in the export

1reaction
ljharbcommented, Oct 9, 2020

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-runtime missing interop-require-default - Stack Overflow
The plugin babel-preset-es2015 is missing in your package.json, and not installed when you do npm install . Add it, and install again.
Read more >
Options - Babel.js
By default babel.transformFromAst will clone the input AST to avoid mutations. Specifying cloneInputAst: false can improve parsing performance if the input ...
Read more >
Helping Babel move to ES Modules - BigBinary Blog
The Babel project recently moved to running builds on Node.js 14, which means that Babel can now use ES Modules (ESM) instead of...
Read more >
babel-preset-jest | Yarn - Package Manager
main. Features. Fixes. Chore & Maintenance. Performance. 29.2.0. Features. [@jest/cli, jest-config] A seed for the test run will be randomly generated, ...
Read more >
Babel-loader - Webpack - W3cubDocs
By default this will be added to every file that requires it. You can instead require the babel runtime as a separate module...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found