Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Import helpers like __extends from tslib.
Browse files Browse the repository at this point in the history
This reduces the minified size of lib/react-apollo.umd.js from 28074B to
22773B (18.9%). The minified+gzip size drops from 6930B to 6451B (6.9%).

The gzip percentage is smaller because there was some repetition between
the multiple declarations of the __extends function, and gzip is good at
compressing long repeated substrings.
  • Loading branch information
benjamn committed Dec 14, 2018
1 parent 4bac03a commit 6e92599
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 40 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"hoist-non-react-statics": "^3.0.0",
"invariant": "^2.2.2",
"lodash.isequal": "^4.5.0",
"prop-types": "^15.6.0"
"prop-types": "^15.6.0",
"tslib": "^1.9.3"
}
}
62 changes: 23 additions & 39 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,39 @@ function onwarn(message) {
}
}

export default [
// for browser
{
input: 'lib/browser.js',
function umd(inputFile, outputFile) {
return {
input: inputFile,
output: {
file: 'lib/react-apollo.browser.umd.js',
file: outputFile,
format: 'umd',
name: 'react-apollo',
sourcemap: true,
exports: 'named',
},
plugins: [
node({
module: true,
only: ['tslib']
})
],
onwarn,
},
};
}

export default [
// for browser
umd("lib/browser.js",
"lib/react-apollo.browser.umd.js"),
// for server
{
input: 'lib/index.js',
output: {
file: 'lib/react-apollo.umd.js',
format: 'umd',
name: 'react-apollo',
sourcemap: false,
exports: 'named',
},
onwarn,
},
umd("lib/index.js",
"lib/react-apollo.umd.js"),
// for test-utils
{
input: 'lib/test-utils.js',
output: {
file: 'lib/test-utils.js',
format: 'umd',
name: 'react-apollo',
sourcemap: false,
exports: 'named',
},
onwarn,
},
umd("lib/test-utils.js",
"lib/test-utils.js"),
// for test-links
{
input: 'lib/test-links.js',
output: {
file: 'lib/test-links.js',
format: 'umd',
name: 'react-apollo',
sourcemap: false,
exports: 'named',
},
onwarn,
},
umd("lib/test-links.js",
"lib/test-links.js"),
// for filesize
{
input: 'lib/react-apollo.browser.umd.js',
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"lib": ["es2015", "dom"],
"module": "es2015",
"moduleResolution": "node",
"importHelpers": true,
"noUnusedParameters": true,
"outDir": "lib",
"pretty": true,
Expand Down

0 comments on commit 6e92599

Please sign in to comment.