Skip to content

Commit

Permalink
Implement ES6 export file
Browse files Browse the repository at this point in the history
This upgrade all dev dependencies in order to implement ES6 exports
in order to solve apollographql#303.

This also remove yarn.lock entirely because this package is meant to
work with npm only as can be seen from the mention of npm command in
package.json.

Fixes apollographql#303
Closes apollographql#272
Closes apollographql#273
  • Loading branch information
PowerKiKi authored and benjamn committed Jan 29, 2021
1 parent e06bd06 commit 9558fe3
Show file tree
Hide file tree
Showing 10 changed files with 4,157 additions and 2,370 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": [ "es2015" ]
"presets": [ "@babel/preset-env" ]
}
1 change: 1 addition & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require: '@babel/register'
4 changes: 2 additions & 2 deletions loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const os = require('os');
const gql = require('./src');
import os from 'os';
import gql from './src';

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
Expand Down
5,150 changes: 4,120 additions & 1,030 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "2.11.0",
"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",
"sideEffects": false,
"scripts": {
"bundle": "rollup -c && cp src/index.js.flow lib/graphql-tag.umd.js.flow",
Expand All @@ -23,13 +23,14 @@
"homepage": "https://github.com/apollographql/graphql-tag#readme",
"dependencies": {},
"devDependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"chai": "^4.0.2",
"graphql": "^15.0.0",
"mocha": "^3.4.1",
"rollup": "^0.45.0",
"test-all-versions": "^3.3.2"
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/register": "^7.12.1",
"chai": "^4.2.0",
"graphql": "^15.4.0",
"mocha": "^8.2.1",
"rollup": "^2.33.1",
"test-all-versions": "^5.0.1"
},
"peerDependencies": {
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
Expand Down
21 changes: 17 additions & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
export default {
entry: 'src/index.js',
dest: 'lib/graphql-tag.umd.js',
input: 'src/index.js',
output: [
{
file: 'lib/graphql-tag.js',
format: 'esm',
sourcemap: true
},
{
file: 'lib/graphql-tag.umd.js',
format: 'umd',
sourceMap: true,
moduleName: 'graphql-tag',
globals: {
'graphql/language': 'language'
},
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/language';

// 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;
7 changes: 4 additions & 3 deletions test/graphql.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const gql = require('../src');
const loader = require('../loader');
const assert = require('chai').assert;
import { assert } from 'chai';

import gql from '../src';
import loader from '../loader';

describe('gql', () => {
it('parses queries', () => {
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts

This file was deleted.

Loading

0 comments on commit 9558fe3

Please sign in to comment.