-
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: use require instead if the ESM import statement #11331
fix: use require instead if the ESM import statement #11331
Conversation
Hm, does my change break the tests? It seems so. |
It seems like You are changing dynamic import into static one here. What about doing this other way and making this entirely ESM: |
Do you have example project that is failing currently that I could investigate? |
@pieh see #11198 (comment) for a repository for testing the problem. All previous gatsby releases have this issue so it might be because of another dependency. |
It seems a new install (using Yarn) does not have this issue. I'll do a diff between the working and not working setup. |
This does not change anything, the needed runtime transforms are still not applied. I think it is different between Yarn and npm. |
Yeah, I cloned the reproduction and had same problem when installing with |
Seems so. But so far we do not know the exact cause. I'm closing the PR. |
It seems it still happens with npm, but not Yarn. |
Description
This fixes an issue with the
build
script.In the dev mode it seems we have the babel transform plugin for the engine and dynamic require / import.
But the build does not and we have to use
require
. In fact the code in this file usesexports
but not therequire
. I guess this was overseen.We should use the CJS way to use them (require) instead of the ESM one (import).
https://github.com/gatsbyjs/gatsby/blame/master/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js#L97
https://github.com/gatsbyjs/gatsby/blame/master/packages/gatsby/src/internal-plugins/query-runner/pages-writer.js#L104
Related Issues
#11198