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

Fix IE11 support and duplicate helpers by adding new Rollup config #274

Merged
merged 7 commits into from
Jun 8, 2019
Merged
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
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
comment: off
coverage:
status:
project: yes
patch: no
changes: no
44 changes: 44 additions & 0 deletions .sail.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
workflow:
- install
- sail:parallel:
- build
- lint
- test
- e2e
tasks:
install:
image: node:10
command:
- yarn
args:
- install
- --frozen-lockfile
lint:
image: node:10
command:
- yarn
args:
- lint
test:
image: node:10
env:
- CODECOV_TOKEN
command:
- yarn
args:
- run
- run-s
- coverage
- codecov
build:
image: node:10
command:
- yarn
args:
- build
e2e:
image: cypress/browsers:node10.2.1-chrome74
command:
- bash
args:
- ./scripts/run-e2e.sh
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@

<br />
<br />

<a href="https://travis-ci.org/FormidableLabs/urql">
<img alt="Build Status" src="https://travis-ci.org/FormidableLabs/urql.svg?branch=master" />
</a>
<a href="https://coveralls.io/github/FormidableLabs/urql?branch=master">
<img alt="Test Coverage" src="https://coveralls.io/repos/github/FormidableLabs/urql/badge.svg?branch=master" />
</a>
<a href="https://npmjs.com/package/urql">
<img alt="NPM Version" src="https://img.shields.io/npm/v/urql.svg" />
</a>
<a href="https://codecov.io/gh/FormidableLabs/urql">
<img alt="Test Coverage" src="https://codecov.io/gh/FormidableLabs/urql/branch/master/graph/badge.svg" />
</a>
<a href="https://bundlephobia.com/result?p=urql">
<img alt="Minified gzip size" src="https://img.shields.io/bundlephobia/minzip/urql.svg?label=gzip%20size" />
</a>
<a href="https://github.com/FormidableLabs/urql#maintenance-status">
<img alt="Maintenance Status" src="https://img.shields.io/badge/maintenance-active-green.svg" />
</a>
Expand Down
1 change: 1 addition & 0 deletions examples/2-using-subscriptions/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.build
lib
cypress/videos
Binary file not shown.
30 changes: 17 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"build": "run-p build:types build:bundle",
"build:clean": "rimraf dist",
"build:types": "tsc -d --emitDeclarationOnly --outDir dist/types",
"build:bundle": "microbundle --format es,cjs --no-compress",
"build:bundle": "rollup -c rollup.config.js",
"build:prune": "rimraf dist/types/**/*.test.d.ts dist/types/test-utils",
"postbuild:bundle": "terser dist/urql.es.js -o dist/urql.es.min.js",
"test": "jest",
"bundlesize": "bundlesize",
"coverage": "jest --coverage",
"lint": "eslint . --ext .ts,.tsx",
"check-formatting": "prettier --write src/**/*.{ts,tsx}",
"prepublishOnly": "run-s build build:prune"
"prepublishOnly": "run-s build build:prune",
"codecov": "codecov"
},
"author": "Formidable",
"license": "MIT",
Expand Down Expand Up @@ -82,22 +82,20 @@
"pre-commit": "lint-staged"
}
},
"bundlesize": [
{
"path": "./dist/*.min.js",
"maxSize": "10 kB"
}
],
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-react-jsx": "^7.3.0",
"@types/enzyme": "3.1.16",
"@types/graphql": "^14.0.7",
"@types/jest": "^23.3.13",
"@types/react": "16.8.2",
"@types/react-test-renderer": "^16.8.0",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"bundlesize": "^0.17.0",
"coveralls": "^3.0.3",
"babel-plugin-closure-elimination": "^1.3.0",
"babel-plugin-transform-async-to-promises": "^0.8.11",
"codecov": "^3.5.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.3.5",
Expand All @@ -111,7 +109,6 @@
"husky": "^1.2.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.7",
"microbundle": "^0.11.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.17.1",
"react": "^16.8.6",
Expand All @@ -121,6 +118,13 @@
"react-ssr-prepass": "^1.0.5",
"react-test-renderer": "^16.8.6",
"rimraf": "^2.6.2",
"rollup": "^1.14.3",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.1",
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-typescript2": "^0.21.1",
"terser": "^4.0.0",
"ts-jest": "^24.0.2",
"typescript": "^3.5.1"
Expand Down
179 changes: 179 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import { DEFAULT_EXTENSIONS } from '@babel/core';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import buble from 'rollup-plugin-buble';
import babel from 'rollup-plugin-babel';
import { terser } from 'rollup-plugin-terser';

const pkgInfo = require('./package.json');
const external = ['dns', 'fs', 'path', 'url'];

if (pkgInfo.peerDependencies) {
external.push(...Object.keys(pkgInfo.peerDependencies));
}

if (pkgInfo.dependencies) {
external.push(...Object.keys(pkgInfo.dependencies));
}

const externalPredicate = new RegExp(`^(${external.join('|')})($|/)`);
const externalTest = id => {
if (id === 'babel-plugin-transform-async-to-promises/helpers') {
return false;
}

return externalPredicate.test(id);
};

const terserPretty = terser({
sourcemap: true,
warnings: true,
ecma: 5,
keep_fnames: true,
ie8: false,
compress: {
pure_getters: true,
toplevel: true,
booleans_as_integers: false,
keep_fnames: true,
keep_fargs: true,
if_return: false,
ie8: false,
sequences: false,
loops: false,
conditionals: false,
join_vars: false
},
mangle: false,
output: {
beautify: true,
braces: true,
indent_level: 2
}
});

const terserMinified = terser({
sourcemap: true,
warnings: true,
ecma: 5,
ie8: false,
toplevel: true,
compress: {
keep_infinity: true,
pure_getters: true,
passes: 10
},
output: {
comments: false
}
});

const plugins = [
nodeResolve({
mainFields: ['module', 'jsnext', 'main'],
browser: true
}),
commonjs({
ignoreGlobal: true,
include: /\/node_modules\//,
namedExports: {
'react': Object.keys(require('react'))
},
}),
typescript({
typescript: require('typescript'),
cacheRoot: './node_modules/.cache/.rts2_cache',
tsconfigDefaults: {
compilerOptions: {
sourceMap: true,
declaration: true
},
},
tsconfigOverride: {
compilerOptions: {
target: 'es6',
},
},
}),
buble({
transforms: {
unicodeRegExp: false,
dangerousForOf: true,
dangerousTaggedTemplateString: true
},
objectAssign: 'Object.assign',
exclude: 'node_modules/**'
}),
babel({
babelrc: false,
extensions: [...DEFAULT_EXTENSIONS, 'ts', 'tsx'],
exclude: 'node_modules/**',
presets: [],
plugins: [
['babel-plugin-closure-elimination', {}],
['@babel/plugin-transform-object-assign', {}],
['@babel/plugin-transform-react-jsx', {
pragma: 'React.createElement',
pragmaFrag: 'React.Fragment',
useBuiltIns: true
}],
['babel-plugin-transform-async-to-promises', {
inlineHelpers: true,
externalHelpers: true
}]
]
})
];

const config = {
input: './src/index.ts',
external: externalTest,
treeshake: {
propertyReadSideEffects: false
}
};

export default [
{
...config,
plugins: [...plugins, terserPretty],
output: [
{
sourcemap: true,
legacy: true,
freeze: false,
esModule: false,
file: './dist/urql.js',
format: 'cjs'
},
{
sourcemap: true,
legacy: true,
freeze: false,
esModule: false,
file: './dist/urql.es.js',
format: 'esm'
}
]
}, {
...config,
plugins: [...plugins, terserMinified],
output: [
{
sourcemap: true,
legacy: true,
freeze: false,
file: './dist/urql.min.js',
format: 'cjs'
},
{
sourcemap: true,
legacy: true,
freeze: false,
file: './dist/urql.es.min.js',
format: 'esm'
}
]
}
];
Loading