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

fix(babel-preset-gatsby): Add babel-plugin-dynamic-import-node for tests #15657

Merged
merged 5 commits into from Jul 12, 2019

Conversation

sidharthachatterjee
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee commented Jul 12, 2019

Node 8 (which we still support) doesn't understand dynamic imports. While it's okay to keep these untranspiled (like in gatsby-image/withIEPolyfill) because webpack will handle them anyway, this breaks tests run on Node 8 (https://circleci.com/gh/gatsbyjs/gatsby/169116?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link).

To fix this, we need to conditionally transpile these to deferred requires for Node in test environments. This PR does that for this monorepo's jest config and for babel-preset-gatsby which we recommend in https://www.gatsbyjs.org/docs/unit-testing/

@sidharthachatterjee sidharthachatterjee requested a review from a team as a code owner July 12, 2019 11:57
jest-transformer.js Outdated Show resolved Hide resolved
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, this is a good change as it's sometimes hard to find why these things fail.

wardpeet
wardpeet previously approved these changes Jul 12, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🚀

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🚀

@sidharthachatterjee sidharthachatterjee added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Jul 12, 2019
@gatsbybot gatsbybot merged commit ad5e8a0 into master Jul 12, 2019
@lannonbr lannonbr deleted the fix/dynamic-import branch July 12, 2019 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants