diff --git a/package.json b/package.json index 04a763e569..9d35867132 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/rollup.config.js b/rollup.config.js index 8ab8d4b7e5..e72c5ff20b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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', diff --git a/tsconfig.json b/tsconfig.json index 766cef61dd..0cc499e3a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "lib": ["es2015", "dom"], "module": "es2015", "moduleResolution": "node", + "importHelpers": true, "noUnusedParameters": true, "outDir": "lib", "pretty": true,