Skip to content
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

fix(gatsby-link): Correctly export default for CJS #36312

Merged
merged 5 commits into from
Aug 4, 2022
Merged

Conversation

wardpeet
Copy link
Contributor

@wardpeet wardpeet commented Aug 3, 2022

Description

When using microbundle with CJS output, it behaves differently than our babel transpilation.

Babel is adding __esModule: true when moving from ES to CJS. Microbundle is not. This cause problems later on when using tools like jest, that runs transforms through babel usually. Babel's interops for imports/requires do check for __esModule, if it's not there weird things happen.

Microbundle doesn't have option to add it, but Rollup that is used under the hood does:

We did find few issues on microbundle repo that seem related, but this setup seems like it's desired by maintainers and the workaround they provided (manually adding this export) is more-or-less what this PR adds

Related Issues

Fixes #36298

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 3, 2022
@wardpeet wardpeet added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 3, 2022
@pieh pieh force-pushed the fix/gatsby-link/jest2 branch from e351ecc to 0b8c651 Compare August 3, 2022 11:02
@pieh pieh mentioned this pull request Aug 3, 2022
@pieh pieh force-pushed the fix/gatsby-link/jest2 branch from 6354777 to 9ef8c12 Compare August 4, 2022 10:04
@pieh pieh marked this pull request as ready for review August 4, 2022 11:33
@LekoArts LekoArts changed the title fix jest using gatsby-link fix(gatsby-link): Correctly export default Aug 4, 2022
@LekoArts LekoArts changed the title fix(gatsby-link): Correctly export default fix(gatsby-link): Correctly export default for CJS Aug 4, 2022
@pieh pieh merged commit abb0baa into master Aug 4, 2022
@pieh pieh deleted the fix/gatsby-link/jest2 branch August 4, 2022 14:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<Link /> is an object instead of a React Component since 4.19 making tests fail
3 participants