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

Apollo Client bundling examples and reporting #5449

Merged
merged 2 commits into from
Oct 24, 2019
Merged

Conversation

hwillson
Copy link
Member

This PR introduces a few different Apollo Client bundling example applications. These applications demonstrate how Apollo Client can be bundled using modern bundling tools like Rollup and webpack, along with features like tree shaking / dead code elimination. Each application can be run on its own, but the larger intent of these changes is to provide a way to gather metrics around production bundle sizes for applications using Apollo Client, with its dependencies. So instead of reporting on the bundle size for just @apollo/client, the provided bundlesize.sh script can be used to gather full Apollo Client based application bundle size metrics. These metrics should help give us a better understanding of Apollo related bundle sizes during real world production use.

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.

I went ahead and eliminated the graphql-tag dependency, but I think there's still a CJS/require issue with bundling for browsers?

input: './src/index.js',
output: {
file: `./public/js/${outputPrefix}.min.js`,
format: 'cjs',
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, when I try to run the apps, I'm seeing

Uncaught ReferenceError: require is not defined

in the browser console for the Rollup apps, I think because the output format is CJS, which doesn't run natively in browsers. Am I missing something here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes - graphql-tag causes some interesting bundling issues for sure. I'll fix this - thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

@benjamn Digging into this, I'm not seeing the same thing; can you run a npm run build on AC first, then try running the app again? Since the example app is referencing the compiled files in dist, maybe they just need to be updated first.

@benjamn benjamn mentioned this pull request Oct 16, 2019
31 tasks
hwillson and others added 2 commits October 24, 2019 11:43
This commit introduces a few different Apollo Client bundling
example applications. These applications demonstrate how Apollo
Client can be bundled using modern bundling tools like Rollup and
webpack, along with features like tree shaking / dead code
elimination. Each application can be run on its own, but the
larger intent of these changes is to provide a way to gather
metrics around production bundle sizes for applications using
Apollo Client, with its dependencies. So instead of reporting on the
bundle size for just `@apollo/client`, the provided
`bundlesize.sh` script can be used to gather full Apollo Client
based application bundle size metrics. These metrics should help
give us a better understanding of Apollo related bundle sizes during
real world production use.
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.

Ok, this is working for me now!

@benjamn benjamn merged commit ee3ca40 into release-3.0 Oct 24, 2019
@benjamn benjamn deleted the bundling-reference branch October 24, 2019 15:46
@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