Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] chore: convert to TS #235

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules

# don't commit compiled files
lib
yarn-error.log
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

### v2.10.1

* Fix failures in IE11 by avoiding unsupported (by IE11) constructor arguments to `Set` by [rocwang](https://github.com/rocwang) in [#190](https://github.com/apollographql/graphql-tag/pull/190)

### v2.10.0
* Add support for `graphql@14` by [timsuchanek](https://github.com/timsuchanek) in [#210](https://github.com/apollographql/graphql-tag/pull/210), [#211](https://github.com/apollographql/graphql-tag/pull/211)

Expand Down
3 changes: 0 additions & 3 deletions index.d.ts

This file was deleted.

3 changes: 2 additions & 1 deletion loader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";

const os = require('os');
const gql = require('./src');
// TODO!
const gql = require('./lib/index.js').default;

// Takes `source` (the source GraphQL query string)
// and `doc` (the parsed GraphQL document) and tacks on
Expand Down
62 changes: 48 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"name": "graphql-tag",
"version": "2.10.0",
"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",
"browser": "./lib/graphql-tag.umd.js",
"main": "./lib/index.js",
"module": "./lib/graphql-tag.esm.js",
"typings": "./lib/index.d.ts",
"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",
"prepublish": "npm run bundle"
"test-watch": "jest --watch",
"bundle": "rollup -c",
"compile": "rimraf ./lib && tsc -p ./tsconfig.cjs.json && npm run bundle && npm run move-flow-types",
"move-flow-types": "cp src/index.js.flow lib/index.js.flow",
"test-legacy": "mocha test/graphql.js test/graphql-v0.12.js && tav --ci --compat"
},
"repository": {
"type": "git",
Expand All @@ -22,15 +25,46 @@
"homepage": "https://github.com/apollostack/graphql-tag#readme",
"dependencies": {},
"devDependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.9.0",
"chai": "^4.0.2",
"graphql": "^14.0.2",
"mocha": "^3.4.1",
"rollup": "^0.45.0",
"test-all-versions": "^3.3.2"
"@types/graphql": "14.0.5",
"@types/jest": "23.3.13",
"babel-core": "6.26.3",
"babel-jest": "23.6.0",
"babel-preset-env": "1.7.0",
"chai": "4.0.2",
"graphql": "14.0.2",
"jest": "23.6.0",
"mocha": "3.4.1",
"rimraf": "2.6.3",
"rollup": "1.1.2",
"rollup-plugin-filesize": "6.0.1",
"rollup-plugin-node-resolve": "4.0.0",
"rollup-plugin-typescript2": "0.19.2",
"test-all-versions": "3.3.2",
"ts-jest": "23.10.5",
"tslint": "5.12.1",
"typescript": "3.2.4"
},
"peerDependencies": {
"graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
},
"babel": {
"presets": ["env"]
},
"jest": {
"collectCoverageFrom": [
"src/*{ts}"
],
"testMatch": [
"<rootDir>/test/*.test.ts"
],
"transform": {
".js": "babel-jest",
".ts": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
}
}
58 changes: 50 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
export default {
entry: 'src/index.js',
dest: 'lib/graphql-tag.umd.js',
format: 'umd',
sourceMap: true,
moduleName: 'graphql-tag',
onwarn
};
import typescript from 'typescript';
import typescriptPlugin from 'rollup-plugin-typescript2';
import filesize from 'rollup-plugin-filesize';
import node from 'rollup-plugin-node-resolve';

function onwarn(message) {
const suppressed = [
Expand All @@ -17,3 +13,49 @@ function onwarn(message) {
return console.warn(message.message);
}
}

function umd(input, output) {
return {
input,
output: {
file: output,
format: 'umd',
name: 'graphql-tag'
},
sourceMap: true,
onwarn,
plugins: [
node({
module: true,
only: ['tslib']
}),
typescriptPlugin({ typescript, tsconfig: './tsconfig.json' }),
filesize(),
]
}
}

function esm(input, output) {
return {
input,
output: {
file: output,
format: 'esm',
},
sourceMap: true,
onwarn,
plugins: [
node({
module: true,
only: ['tslib']
}),
typescriptPlugin({ typescript, tsconfig: './tsconfig.json' }),
filesize(),
]
}
}

export default [
esm('lib/index.js', 'lib/graphql-tag.esm.js'),
umd('lib/index.js', 'lib/graphql-tag.umd.js'),
];
Loading