Skip to content

Commit

Permalink
source map for rollup (apollographql#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
evans authored Mar 14, 2018
1 parent 66b5266 commit de6de2e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
"lint-staged": "6.1.0",
"pre-commit": "1.2.2",
"prettier": "1.11.1",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-node-resolve": "^3.0.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"ts-jest": "20.0.14",
"typescript": "2.5.2"
}
Expand Down
9 changes: 3 additions & 6 deletions packages/apollo-cache/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import resolve from 'rollup-plugin-node-resolve';

import build from '../../rollup.config';

export default Object.assign(
{
plugins: [resolve()],
},
build('apollo.cache.core'),
);
export default build('apollo.cache.core', {
plugins: [resolve()],
});
30 changes: 21 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sourcemaps from 'rollup-plugin-sourcemaps';

export const globals = {
// Apollo
'apollo-client': 'apollo.core',
Expand All @@ -8,24 +10,34 @@ export const globals = {
'graphql-anywhere': 'graphqlAnywhere',
};

export default (name, override = {}) =>
Object.assign(
export default (name, override = {}) => {
const config = Object.assign(
{
input: 'lib/index.js',
output: {
file: 'lib/bundle.umd.js',
format: 'umd',
},
//output: merged separately
onwarn,
external: Object.keys(globals),
},
override,
);

config.output = Object.assign(
{
file: 'lib/bundle.umd.js',
format: 'umd',
name,
exports: 'named',
sourcemap: true,
external: Object.keys(globals),
onwarn,
globals,
},
override,
config.output,
);

config.plugins = config.plugins || [];
config.plugins.push(sourcemaps());
return config;
};

function onwarn(message) {
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED'];

Expand Down

0 comments on commit de6de2e

Please sign in to comment.