-
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
Export utilities via @apollo/client/utilities #5683
Conversation
06a79c0
to
49f28ad
Compare
function prepareUtilities() { | ||
const utilsDistDir = `${distDir}/utilities`; | ||
return { | ||
input: `${utilsDistDir}/index.js`, | ||
external, | ||
output: { | ||
file: `${utilsDistDir}/utilities.cjs.js`, | ||
format: 'cjs', | ||
sourcemap: true, | ||
exports: 'named', | ||
}, | ||
plugins: [ | ||
nodeResolve(), | ||
], | ||
}; | ||
} | ||
|
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.
We can't follow our usual approach of creating a file that just re-exports only the items it needs from the main apollo-client.cjs.js
bundle, as we aren't exporting utilities in apollo-client.cjs.js
. Here we're building a separate utilities.cjs.js
bundle instead.
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.
Yep, makes sense. Even easier this way.
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! 🛠✨
118b487
to
87c7a2b
Compare
With AC 3 (
@apollo/client
) we're no longer exporting the utilities that were previously available viaapollo-utilities
. While not exporting them from the main bundle is intentional, there is value in being able to access some of these utilities directly. This PR creates a new@apollo/client/utilities
entry point, and makes many of AC 3's internal utilities externally accessible. E.g.:This PR also tackles cleaning up / removing some of the utilities that AC 3 no longer uses.