Skip to content

Commit

Permalink
Use Rollup to build also as ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
abdonrd committed Oct 15, 2019
1 parent 7818b80 commit c290d2e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "2.10.1",
"description": "A JavaScript template literal tag that parses GraphQL queries",
"main": "./lib/graphql-tag.umd.js",
"module": "./src/index.js",
"jsnext:main": "./src/index.js",
"module": "./lib/graphql-tag.js",
"jsnext:main": "./lib/graphql-tag.js",
"scripts": {
"bundle": "rollup -c && cp src/index.js.flow lib/graphql-tag.umd.js.flow",
"test": "mocha test/graphql.js test/graphql-v0.12.js && tav --ci --compat",
Expand Down
23 changes: 17 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
export default {
input: 'src/index.js',
output: {
file: 'lib/graphql-tag.umd.js',
format: 'umd',
name: 'graphql-tag',
sourcemap: true
},
output: [
{
file: 'lib/graphql-tag.js',
format: 'esm',
sourcemap: true
},
{
file: 'lib/graphql-tag.umd.js',
format: 'umd',
globals: {
'graphql': 'graphql'
},
name: 'graphql-tag',
sourcemap: true,
exports: 'named'
}
],
onwarn
};

Expand Down
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
var parser = require('graphql/language/parser');

var parse = parser.parse;
import { parse } from 'graphql';

// Strip insignificant whitespace
// Note that this could do a lot more, such as reorder fields etc.
Expand Down Expand Up @@ -177,4 +175,4 @@ gql.disableFragmentWarnings = disableFragmentWarnings;
gql.enableExperimentalFragmentVariables = enableExperimentalFragmentVariables;
gql.disableExperimentalFragmentVariables = disableExperimentalFragmentVariables;

module.exports = gql;
export default gql;

0 comments on commit c290d2e

Please sign in to comment.