Skip to content

Commit

Permalink
chore: drop IE support, remove regenerator runtime (graphql#1628)
Browse files Browse the repository at this point in the history
use es6 as default typescript target
use browserslist always
remove all usage of regenerator runtime
  • Loading branch information
acao authored Aug 6, 2020
1 parent 21af822 commit 2fcd9e8
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 91 deletions.
11 changes: 6 additions & 5 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ie 11
ios 10
last 2 chrome versions
last 2 edge versions
last 2 firefox versions
last 2 versions
Firefox ESR
not dead
not IE 11
not ios 10
maintained node versions
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,29 @@ An online immutable parser for [GraphQL](http://graphql.org/), designed to be us

Utilities to support the [GraphQL Language Service](packages/graphql-language-service#readme).

## Browser & Runtime Support

Many of these packages need to work in multiple environments.

By default, all typescript packages target `es6`.

`graphql-language-service-server` and `graphql-language-service-cli` are made for the node runtime, so they target `es2017`

`codemirror-graphql` and the `graphiql` browser bundle use the [`.browserslistrc`](./.browserlistrc), which targets modern browsers to keep bundle size small and keep the language services performant where async/await is used, and especially to avoid the requirement of `rengenerator-runtime` or special babel configuration.

### [`.browserslistrc`](./.browserlistrc):

```
last 2 versions
Firefox ESR
not dead
not IE 11
not ios 10
maintained node versions
```

To be clear, we do _not_ support Internet Explorer or older versions of evergreen browsers.

## Development

To get setup for local development of this monorepo, refer to [DEVELOPMENT.md](./DEVELOPMENT.md)
Expand Down
13 changes: 4 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// for ESM don't transpile modules

const envConfig = {
ignoreBrowserslistConfig: true,
modules: 'commonjs',
targets: { node: true },
bugfixes: true,
};

if (process.env.ESM) {
envConfig.modules = false;
envConfig.targets = { node: true };
envConfig.bugfixes = true;
}

if (process.env.CDN) {
envConfig.modules = 'amd';
envConfig.modules = 'umd';
envConfig.targets = null;
envConfig.ignoreBrowserslistConfig = false;
}

module.exports = {
Expand All @@ -32,8 +30,5 @@ module.exports = {
compact: false,
},
},
plugins: [
require.resolve('@babel/plugin-proposal-class-properties'),
require.resolve('@babel/plugin-syntax-dynamic-import'),
],
plugins: [require.resolve('@babel/plugin-proposal-class-properties')],
};
5 changes: 1 addition & 4 deletions examples/graphiql-webpack/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ module.exports = {
],
require.resolve('@babel/preset-react'),
],
plugins: [
require.resolve('@babel/plugin-syntax-dynamic-import'),
require.resolve('@babel/plugin-proposal-class-properties'),
],
plugins: [require.resolve('@babel/plugin-proposal-class-properties')],
};
13 changes: 1 addition & 12 deletions examples/monaco-graphql-webpack/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,11 @@ module.exports = {
[
require.resolve('@babel/preset-env'),
{
// corejs: { version: 3, proposals: true },
// useBuiltIns: 'usage',
targets: { browsers: ['last 2 chrome versions'] },
bugfixes: true,
},
],
[require.resolve('@babel/preset-typescript'), {}],
],
plugins: [
require.resolve('@babel/plugin-syntax-dynamic-import'),
require.resolve('@babel/plugin-proposal-class-properties'),
[
'@babel/plugin-transform-runtime',
{
regenerator: true,
},
],
],
plugins: [require.resolve('@babel/plugin-proposal-class-properties')],
};
2 changes: 0 additions & 2 deletions examples/monaco-graphql-webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* global monaco */

import 'regenerator-runtime/runtime';

import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';

import { api as GraphQLAPI } from 'monaco-graphql';
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@
"@babel/core": "^7.9.0",
"@babel/node": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/polyfill": "^7.8.7",
"@babel/preset-env": "7.9.5",
"@babel/preset-flow": "7.9.0",
Expand Down
40 changes: 0 additions & 40 deletions packages/graphiql/index.html

This file was deleted.

5 changes: 2 additions & 3 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"build": "yarn build-clean && yarn build-cjs && yarn build-esm",
"build-cjs": "tsc",
"build-esm": "tsc --project ./tsconfig.esm.json",
"build-clean": "rimraf webpack *.html bundle",
"build-clean": "rimraf webpack bundle monaco",
"build-bundles": "yarn build-bundles-clean && yarn build-bundles-dev && yarn build-bundles-min",
"build-bundles-dev": "cross-env NODE_ENV=development CDN=1 yarn webpack -d --bail && copy 'resources/renderExample.js' bundle/dev/",
"build-bundles-min": "cross-env ANALYZE=1 NODE_ENV=production CDN=1 yarn webpack -p --bail && copy 'resources/renderExample.js' bundle/dist/",
"build-bundles-clean": "rimraf 'graphiql.*{js,css}' *.html",
"build-bundles-clean": "rimraf 'graphiql.*{js,css}'",
"build-demo": "build-storybook -o ./storybook",
"dev": "cross-env NODE_ENV=development webpack-dev-server --config resources/webpack.config.js",
"cypress-open": "yarn e2e-server 'cypress open'",
Expand All @@ -53,7 +53,6 @@
"i18next-browser-languagedetector": "^4.1.1",
"monaco-editor": "^0.20.0",
"react-i18next": "^11.4.0",
"regenerator-runtime": "^0.13.5",
"theme-ui": "^0.3.1",
"@theme-ui/core": "^0.4.0-alpha.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql/resources/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const resultConfig = {
output: {
path: isDev ? rootPath('bundle/dev') : rootPath('bundle/dist'),
// library: 'GraphiQL',
libraryTarget: 'umd',
libraryTarget: 'window',
// libraryExport: 'default',
filename: '[name].js',
globalObject: 'this',
Expand Down
4 changes: 1 addition & 3 deletions packages/graphiql/src/cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import 'regenerator-runtime';

export default GraphiQL;
import { GraphiQL } from './components/GraphiQL';
export default GraphiQL;

if (typeof window !== 'undefined') {
// @ts-ignore
Expand Down
1 change: 0 additions & 1 deletion packages/graphiql/src/workers/graphql.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import type { worker as WorkerNamespace } from 'monaco-editor';
import 'regenerator-runtime/runtime';

// @ts-ignore
import * as worker from 'monaco-editor/esm/vs/editor/editor.worker';
Expand Down
1 change: 0 additions & 1 deletion packages/monaco-graphql/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../resources/tsconfig.base.cjs.json",
"compilerOptions": {
"module": "amd",
"moduleResolution": "node",
"baseUrl": ".",
"rootDir": "./src",
Expand Down
1 change: 0 additions & 1 deletion resources/jestBabelTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const babelJest = require('babel-jest');

// thanks to @bobbybobby!
Expand Down
4 changes: 2 additions & 2 deletions resources/tsconfig.base.cjs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"composite": true,
"target": "es5",
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
Expand All @@ -19,7 +19,7 @@
"noUnusedLocals": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "es2017", "esnext"],
"lib": ["dom", "es2017", "es2018", "esnext"],
"types": ["node", "jest"],
"baseUrl": "."
},
Expand Down
3 changes: 1 addition & 2 deletions resources/tsconfig.base.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "./tsconfig.base.cjs.json",
"compilerOptions": {
"module": "esnext",
"target": "es5"
"module": "ESNext"
}
}
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"

"@babel/plugin-transform-runtime@7.9.0", "@babel/plugin-transform-runtime@^7.9.0":
"@babel/plugin-transform-runtime@7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.9.0.tgz#45468c0ae74cc13204e1d3b1f4ce6ee83258af0b"
integrity sha512-pUu9VSf3kI1OqbWINQ7MaugnitRss1z533436waNXp+0N3ur3zfut37sXiQMxkuCF4VUjwZucen/quskCh7NHw==
Expand Down Expand Up @@ -10268,7 +10268,6 @@ grapheme-breaker@^0.3.2:
monaco-editor "^0.20.0"
monaco-graphql "^0.2.0"
react-i18next "^11.4.0"
regenerator-runtime "^0.13.5"
theme-ui "^0.3.1"

graphql-config@^3.0.2:
Expand Down Expand Up @@ -17112,7 +17111,7 @@ regenerator-runtime@^0.11.0:
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==

regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.5:
regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4:
version "0.13.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==
Expand Down

0 comments on commit 2fcd9e8

Please sign in to comment.