-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
There was a problem hiding this 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.
0c92ae9
to
5851a08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 🚀
…sts (gatsbyjs#15657) * Add babel-plugin-dynamic-import-node for tests * Add babel-plugin-dynamic-import-node to babel-preset-gatsby-package * Update snapshots * Consider BABEL_ENV as well
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/