-
Notifications
You must be signed in to change notification settings - Fork 91
Use rollup to generate bundles for UMD, ESM and CJS #63
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
032ace7
Use rollup to create umd, es modules and commonjs bundles.
Joezo 35855a7
add custom fetch note to polyfill section
jackdclark 89ae770
remove node version from support readme
jackdclark c65fe00
support note: latest 8 & 10 Node releases
jackdclark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,3 +2,7 @@ node_modules | |
| graphql-hooks-*.*.*.tgz | ||
| package-lock.json | ||
| /coverage | ||
| .DS_Store | ||
| lib | ||
| dist | ||
| es | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "lib/graphql-hooks.js": { | ||
| "bundled": 11105, | ||
| "minified": 5606, | ||
| "gzipped": 1919 | ||
| }, | ||
| "es/graphql-hooks.js": { | ||
| "bundled": 10760, | ||
| "minified": 5314, | ||
| "gzipped": 1844, | ||
| "treeshaked": { | ||
| "rollup": { | ||
| "code": 67, | ||
| "import_statements": 21 | ||
| }, | ||
| "webpack": { | ||
| "code": 1069 | ||
| } | ||
| } | ||
| }, | ||
| "es/graphql-hooks.mjs": { | ||
| "bundled": 3954, | ||
| "minified": 3954, | ||
| "gzipped": 1521, | ||
| "treeshaked": { | ||
| "rollup": { | ||
| "code": 67, | ||
| "import_statements": 21 | ||
| }, | ||
| "webpack": { | ||
| "code": 1071 | ||
| } | ||
| } | ||
| }, | ||
| "dist/graphql-hooks.js": { | ||
| "bundled": 11352, | ||
| "minified": 5114, | ||
| "gzipped": 1921 | ||
| }, | ||
| "dist/graphql-hooks.min.js": { | ||
| "bundled": 5070, | ||
| "minified": 5070, | ||
| "gzipped": 1900 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import nodeResolve from 'rollup-plugin-node-resolve'; | ||
| import babel from 'rollup-plugin-babel'; | ||
| import replace from 'rollup-plugin-replace'; | ||
| import { terser } from 'rollup-plugin-terser'; | ||
| import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; | ||
|
|
||
| import pkg from './package.json'; | ||
|
|
||
| const external = [...Object.keys(pkg.peerDependencies || {})]; | ||
|
|
||
| export default [ | ||
| // CommonJS | ||
| { | ||
| input: 'src/index.js', | ||
| output: { file: 'lib/graphql-hooks.js', format: 'cjs', indent: false }, | ||
| external, | ||
| plugins: [babel(), sizeSnapshot()] | ||
| }, | ||
|
|
||
| // ES | ||
| { | ||
| input: 'src/index.js', | ||
| output: { file: 'es/graphql-hooks.js', format: 'es', indent: false }, | ||
| external, | ||
| plugins: [babel(), sizeSnapshot()] | ||
| }, | ||
|
|
||
| // ES for Browsers | ||
| { | ||
| input: 'src/index.js', | ||
| output: { file: 'es/graphql-hooks.mjs', format: 'es', indent: false }, | ||
| external, | ||
| plugins: [ | ||
| nodeResolve({ | ||
| jsnext: true | ||
| }), | ||
| replace({ | ||
| 'process.env.NODE_ENV': JSON.stringify('production') | ||
| }), | ||
| terser({ | ||
| compress: { | ||
| pure_getters: true, | ||
| unsafe: true, | ||
| unsafe_comps: true, | ||
| warnings: false | ||
| } | ||
| }), | ||
| sizeSnapshot() | ||
| ] | ||
| }, | ||
|
|
||
| // UMD Development | ||
| { | ||
| input: 'src/index.js', | ||
| output: { | ||
| file: 'dist/graphql-hooks.js', | ||
| format: 'umd', | ||
| name: 'GraphQLHooks', | ||
| indent: false | ||
| }, | ||
| external, | ||
| plugins: [ | ||
| nodeResolve({ | ||
| jsnext: true | ||
| }), | ||
| babel({ | ||
| exclude: 'node_modules/**' | ||
| }), | ||
| replace({ | ||
| 'process.env.NODE_ENV': JSON.stringify('development') | ||
| }), | ||
| sizeSnapshot() | ||
| ] | ||
| }, | ||
|
|
||
| // UMD Production | ||
| { | ||
| input: 'src/index.js', | ||
| output: { | ||
| file: 'dist/graphql-hooks.min.js', | ||
| format: 'umd', | ||
| name: 'GraphQLHooks', | ||
| indent: false | ||
| }, | ||
| external, | ||
| plugins: [ | ||
| nodeResolve({ | ||
| jsnext: true | ||
| }), | ||
| babel({ | ||
| exclude: 'node_modules/**' | ||
| }), | ||
| replace({ | ||
| 'process.env.NODE_ENV': JSON.stringify('production') | ||
| }), | ||
| terser({ | ||
| compress: { | ||
| pure_getters: true, | ||
| unsafe: true, | ||
| unsafe_comps: true, | ||
| warnings: false | ||
| } | ||
| }), | ||
| sizeSnapshot() | ||
| ] | ||
| } | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const { NODE_ENV } = process.env; | ||
|
|
||
| module.exports = { | ||
| presets: [ | ||
| [ | ||
| '@babel/env', | ||
| { | ||
| targets: { | ||
| browsers: ['ie >= 11'] | ||
| }, | ||
| modules: false, | ||
| loose: true | ||
| } | ||
| ] | ||
| ], | ||
| plugins: [ | ||
| // don't use `loose` mode here - need to copy symbols when spreading | ||
| '@babel/proposal-object-rest-spread', | ||
| NODE_ENV === 'test' && '@babel/transform-modules-commonjs' | ||
| ].filter(Boolean) | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| const React = require('react'); | ||
| import React from 'react'; | ||
|
|
||
| const ClientContext = React.createContext(); | ||
|
|
||
| ClientContext.displayName = 'ClientContext'; | ||
|
|
||
| module.exports = ClientContext; | ||
| export default ClientContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 need to run
npm run buildinprepackalso.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.
If we add it in
prepackI believe it will run twice when we runnpm publish. Are we usingnpm pack?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.
I think
npm packmight be an edge case and if people want to use it they could donpm run buildfirst?