-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use stricter ESM imports to satisfy webpack 5 #11618
Use stricter ESM imports to satisfy webpack 5 #11618
Conversation
Fixes a bug in which webpack 5 will complain due to requiring the file extension (`.js`) for ESM imports. (In this case the build NPM package has `"type": "module"`.)
@daniel-ac-martin: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/ |
👷 Deploy request for apollo-client-docs pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: ca4de1d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Apologies, this breaks the tests. I think that either the test suite would need changes to support this, or the approach is wrong and the correct method would be to coax TypeScript into outputting the file extension in the resulting |
@daniel-ac-martin What version of React are you using by chance? It looks like perhaps this might be on the React end? I found this issue that looks very similar due to export conditions not specified correctly. Looks like this should be fixed in React 18 according to that issue. I saw something similar in react-dnd which suggested adding I'll be honest I'm not the most knowledgable in the ESM/CJS exports/bundling world. Hopefully this points you in the right direction though! |
Hi @jerelmiller. |
It looks like there might also be a workaround in Webpack: https://webpack.js.org/configuration/module/#resolvefullyspecified |
Fixes an issue in which webpack 5 will complain due to requiring the file extension (
.js
) for ESM imports. (In this case the built NPM package has"type": "module"
.)This manifests as an error message similar to the following:
(FWIW, this is somewhat a reprisal of a previous PR, that couldn't go in due to other issues at that time: #9601 )
I think this will have been an issue for some time, but presumably not so many people will be using SSR, and even fewer will be running their server-side code through webpack.