Skip to content
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

Merged
merged 4 commits into from
Dec 14, 2019

Conversation

hwillson
Copy link
Member

With AC 3 (@apollo/client) we're no longer exporting the utilities that were previously available via apollo-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.:

import { getOperationName } from "@apollo/client/utilities";

This PR also tackles cleaning up / removing some of the utilities that AC 3 no longer uses.

Comment on lines +111 to +127
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(),
],
};
}

Copy link
Member Author

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.

Copy link
Member

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.

@hwillson hwillson requested a review from benjamn December 13, 2019 16:09
Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🛠✨

@hwillson hwillson force-pushed the utilities-entry-point branch from 118b487 to 87c7a2b Compare December 14, 2019 02:04
@hwillson hwillson merged commit bfa2875 into release-3.0 Dec 14, 2019
@hwillson hwillson deleted the utilities-entry-point branch December 14, 2019 02:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants