-
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
Add exports
to package.json
#11570
Add exports
to package.json
#11570
Conversation
👷 Deploy request for apollo-client-docs pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: 992ae9a 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 |
e9b6c46
to
d933b56
Compare
If users have been adding deep imports to specific files, those will stop working. I noticed some users have been working around this issue for a while. Here's one example: We can also list the
However, this seems to trip the |
Update: I added wildcard exports, which should address my previous concerns. Also added some more tests to validate this. The deep imports work, and now the esm imports also point where they should without needing to use This should be ready for review. Perhaps a maintainer can create a preview build that would be easy to swap in. |
Hey @phryneas - found your comment in: However, I believe this should not be a breaking change because the wildcards address any potential deep imports. I have added some tests for the deep imports, and they work properly. If we can identify other imports people are using, we can also add them to the tests. I have also verified the modified |
Hi @andreialecu, I'm sorry though, but everything I said there still stands. That said: we are targeting a major this year, and bundle changes as well as an Unfortunately, the changes you made here (as any other |
I understand the concern for breaking changes, can you point out to a case you think will be broken by these changes, besides anecdotally? The previous PRs did not handle this properly. I suggest you do a thorough review to see if things are different here. Can you point me to a specific repo somewhere on github that will be broken by these changes? Or, could you create a preview build that people can test, and that they can provide feedback about whether it breaks anything? I don't see why this couldn't be a temporary solution until then. |
To be frank, I can not. I can point out half a dozen packages that have been broken in various ways by changes like this. But I cannot point a finger at "what" will break, I can only say "it's extremely likely that something will break for a certain percentage of our user base". If we were to publish this change, we couldn't go back on it, as undoing this change would be a breaking change in itself. I know that this is not an ideal situation, but a change like this would need weeks of rigorous testing, a dedicated release candidate circle etc. etc. - it's not something we can just ship out like that. |
Agree, and that is why I explicitly proposed creating a preview build for people to test. However, in other packages, that was caused directly because some exports that people were deep importing were not re-exported. For example there's an explicit mention of how this would be added in a non-breaking way to eslint here: eslint/eslint#13654 (comment) - just by making sure everything is still reachable. This exports issue has plagued the community for years, resulting in suboptimal code in many libraries. It will open up a way to remove many ugly hacks. Just take a look at this for example: https://github.com/yavin-dev/framework/blob/cd2b41054f723789600f5de4ae7d4f16f11584b5/packages/client/src/plugins/elide-apollo-client.ts#L5-L11 There is no reason this will change anything and I believe the fears are exaggerated. There's no "other bundle" to pick because the same files are referenced by the (perhaps @hi-ogawa, the Vite maintainer who originally pointed me to this issue in Apollo could chime in on whether this sort of change can cause any problems) In my opinion, it doesn't seem good to close this issue so superficially. |
I'm not closing this issue superficially without looking into it deeper, and I'm really sorry if that's the impression you have. I'm not only an Apollo Client maintainer, but also a Redux maintainer, and I've followed @.acemarke on his path to get Redux Toolkit to work correctly in every environment closely (as in, we regularly chatted about it). He has blog articles, a conference talk and a few podcast episodes about it if you're interested.
As I said, this is not the only problem. There are bundlers around that completely change what they import based on the existence of an On your vite.js problem, quoting from the other thread:
Right now, the workaround is to directly import PS: The only workaround we could do right now would be to create some |
Sorry if I gave some confusion as an outsider of apollo/angular ecosystem. As far as I understand, Again I'm not familiar with the ecosystem, but to me, I thought this could be a documentation issue first since |
Good call! This documentation is probably older than the |
Thank you for the context. I am leaving some notes here for posterity after doing a deeper dive into the issues seen by Redux Toolkit and Immer:
This blog post explains the saga of updating redux-toolkit for ESM support: https://blog.isquaredsoftware.com/2023/08/esm-modernization-lessons/ Some notes:
My key takeaway is that most of the issues above were related to using the
Also, FWIW based on my previous comment:
The Angular project uses Webpack 5, and the react-native project uses Metro. There were no issues from these changes in either project. |
Updated the
prepareDist.js
script to generate anexports
field, which will help ESM loaders properly identify which entry point to use.Fixes #11569 #9925 #9976 #9048 #9156 #8218 apollographql/apollo-feature-requests#287
Generates: