diff --git a/.gitignore b/.gitignore index c58dd653114..8785ca25e0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # fs .DS_Store +.rpt2_cache # Logs logs diff --git a/.vscode/settings.json b/.vscode/settings.json index d0e33774401..473feaa5e27 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "files.exclude": { "**/.git": true, "**/.DS_Store": true, + "**/.rpt2_cache": true, "node_modules": true, "test-lib": true, "lib": true, diff --git a/config/buildEsmConfig.js b/config/buildEsmConfig.js new file mode 100644 index 00000000000..9e625c7e3be --- /dev/null +++ b/config/buildEsmConfig.js @@ -0,0 +1,29 @@ +import nodeResolve from 'rollup-plugin-node-resolve'; +import typescriptPlugin from 'rollup-plugin-typescript2'; +import typescript from 'typescript'; +import path from 'path'; + +// treat as externals not relative and not absolute paths +const external = id => !id.startsWith('.') && !id.startsWith('/'); + +const extensions = ['.ts', '.tsx']; +const input = './src/index.ts'; + +export default pkg => { + const projectDir = path.join(__filename, '..'); + console.info(`Building project esm ${projectDir}`); + const tsconfig = `${projectDir}/tsconfig.json`; + return { + input, + external, + output: { + file: pkg.module, + format: 'esm', + sourcemap: true, + }, + plugins: [ + nodeResolve({ extensions }), + typescriptPlugin({ typescript, tsconfig }), + ], + }; +}; diff --git a/config/rollup.config.js b/config/buildUmdConfig.js similarity index 60% rename from config/rollup.config.js rename to config/buildUmdConfig.js index b09c4e914e6..7ec2b8682d0 100644 --- a/config/rollup.config.js +++ b/config/buildUmdConfig.js @@ -1,5 +1,12 @@ -import node from 'rollup-plugin-node-resolve'; import sourcemaps from 'rollup-plugin-sourcemaps'; +import nodeResolve from 'rollup-plugin-node-resolve'; +import typescriptPlugin from 'rollup-plugin-typescript2'; +import commonjs from 'rollup-plugin-commonjs'; +import typescript from 'typescript'; +import path from 'path'; + +const extensions = ['.ts', '.tsx']; +const input = './src/index.ts'; export const globals = { // Apollo @@ -13,13 +20,25 @@ export const globals = { 'apollo-boost': 'apollo.boost', }; -export default (name, override = {}) => { +const commonjsOptions = { + include: 'node_modules/**', +}; + +export default (name, override = { output: { globals: {} } }) => { + const projectDir = path.join(__filename, '..'); + console.info(`Building project umd ${projectDir}`); + const tsconfig = `${projectDir}/tsconfig.json`; const config = Object.assign( { - input: 'lib/index.js', + input, //output: merged separately onwarn, - external: Object.keys(globals), + external: Object.keys({ ...globals, ...override.output.globals }), + plugins: [ + nodeResolve({ extensions }), + typescriptPlugin({ typescript, tsconfig }), + commonjs(commonjsOptions), + ], }, override, ); @@ -39,7 +58,7 @@ export default (name, override = {}) => { config.plugins = config.plugins || []; config.plugins.push( sourcemaps(), - node({ + nodeResolve({ // Inline anything imported from the tslib package, e.g. __extends // and __assign. This depends on the "importHelpers":true option in // tsconfig.base.json. @@ -47,6 +66,7 @@ export default (name, override = {}) => { only: ['tslib'], }), ); + return config; }; diff --git a/config/jest.config.settings.js b/config/jest.config.settings.js new file mode 100644 index 00000000000..93b3e51219d --- /dev/null +++ b/config/jest.config.settings.js @@ -0,0 +1,21 @@ +module.exports = { + transform: { + '.(ts|tsx)': 'ts-jest', + }, + + moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], + testURL: 'http://localhost', + + testMatch: ['/src/**/__tests__/*.ts'], + testPathIgnorePatterns: [ + '/node_modules/', + '/lib/', + '/lib/', + // '/../*/lib/', + ], + + // moduleNameMapper: { + // '(apollo-boost|apollo-cache-inmemory|apollo-cache|apollo-client|apollo-utilities|graphql-anywhere)(.*)': + // '/../$1/src/$2', + // }, +}; diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json index 7662c0f0c7b..b0463b433b4 100644 --- a/config/tsconfig.base.json +++ b/config/tsconfig.base.json @@ -11,7 +11,7 @@ "declaration": true, "declarationMap": true, "target": "es5", - "module": "es2015", + "module": "commonjs", "esModuleInterop": true } } diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000000..977f709d842 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,9 @@ +module.exports = { + rootDir: '.', + projects: ['/packages/*'], + + // moduleNameMapper: { + // '(apollo-boost|apollo-cache-inmemory|apollo-cache|apollo-client|apollo-utilities|graphql-anywhere)(.*)': + // '/packages/$1/src/$2', + // }, +}; diff --git a/package.json b/package.json index 2aaf7317c87..78f896387b3 100644 --- a/package.json +++ b/package.json @@ -23,45 +23,25 @@ "bundlesize": [ { "name": "apollo-cache", - "path": "./packages/apollo-cache/lib/bundle.min.js", + "path": "./packages/apollo-cache/lib/bundle.umd.min.js", "maxSize": "900 B" }, { "name": "apollo-cache-inmemory", - "path": "./packages/apollo-cache-inmemory/lib/bundle.min.js", + "path": "./packages/apollo-cache-inmemory/lib/bundle.umd.min.js", "maxSize": "6.2 kB" }, { "name": "apollo-client", - "path": "./packages/apollo-client/lib/bundle.min.js", + "path": "./packages/apollo-client/lib/bundle.umd.min.js", "maxSize": "13 kB" }, { "name": "apollo-utilities", - "path": "./packages/apollo-utilities/lib/bundle.min.js", + "path": "./packages/apollo-utilities/lib/bundle.umd.min.js", "maxSize": "4.75 kB" } ], - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "modulePathIgnorePatterns": [ - "/npm/" - ], - "testURL": "http://localhost", - "testPathIgnorePatterns": [ - "/npm/", - "/node_modules/" - ] - }, "lint-staged": { "*.ts*": [ "prettier --ignore-path \"./config/prettierignore\" --trailing-comma all --single-quote --write" @@ -109,17 +89,17 @@ "react": "16.7.0", "react-dom": "16.7.0", "rollup": "1.1.2", + "rollup-plugin-commonjs": "9.2.0", "rollup-plugin-local-resolve": "1.0.7", "rollup-plugin-node-resolve": "4.0.0", "rollup-plugin-sourcemaps": "0.4.2", + "rollup-plugin-typescript2": "0.18.1", "rxjs": "6.4.0", - "ts-jest": "23.1.4", + "ts-jest": "23.10.5", "tslib": "^1.9.3", "tslint": "5.12.1", "typescript": "3.3.1", - "uglify-js": "3.4.9", - "webpack": "3.12.0", - "webpack-bundle-analyzer": "3.0.3" + "uglify-js": "3.4.9" }, "renovate": { "extends": [ diff --git a/packages/apollo-boost/jest.config.js b/packages/apollo-boost/jest.config.js new file mode 100644 index 00000000000..82849e9ef6d --- /dev/null +++ b/packages/apollo-boost/jest.config.js @@ -0,0 +1,5 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, +}; diff --git a/packages/apollo-boost/package.json b/packages/apollo-boost/package.json index a6a6e179712..7f3b2f7a218 100644 --- a/packages/apollo-boost/package.json +++ b/packages/apollo-boost/package.json @@ -9,9 +9,9 @@ "James Burgess " ], "license": "MIT", - "main": "./lib/index.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": false, "repository": { @@ -28,14 +28,16 @@ "coverage": "jest --coverage", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts", "prebuild": "npm run clean", - "build": "tsc -p .", + "build": "tsc -b .", "postbuild": "npm run bundle", "watch": "tsc -w -p .", "clean": "rm -rf coverage/* && rm -rf lib/*", "prepublishOnly": "npm run build", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "filesize": "npm run minify", - "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js && ../../node_modules/rollup/bin/rollup -c rollup-bundle.config.js" + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +", + "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", + "postbundle": "npm run clean:tests" }, "dependencies": { "apollo-cache": "file:../apollo-cache", @@ -49,18 +51,5 @@ }, "peerDependencies": { "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "testURL": "http://localhost" } } diff --git a/packages/apollo-boost/rollup-bundle.config.js b/packages/apollo-boost/rollup-bundle.config.js deleted file mode 100644 index f9e33f016e1..00000000000 --- a/packages/apollo-boost/rollup-bundle.config.js +++ /dev/null @@ -1,36 +0,0 @@ -import sourcemaps from 'rollup-plugin-sourcemaps'; -import resolve from 'rollup-plugin-node-resolve'; - -function onwarn(message) { - const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED']; - - if (!suppressed.find(code => message.code === code)) { - return console.warn(message.message); - } -} - -const globals = { - 'graphql-anywhere/lib/async': 'graphqlAnywhere.async', - 'graphql/language/printer': 'print', - 'symbol-observable': '$$observable', - 'zen-observable': 'zenObservable', - 'fast-json-stable-stringify': 'stringify', - 'graphql-tag': 'gql', - 'apollo-utilities': 'apolloUtilities', - optimism: 'optimism', -}; - -export default { - input: 'lib/index.js', - onwarn, - output: { - file: 'lib/bundle.umd.js', - format: 'umd', - sourcemap: true, - name: 'apollo.boost', - globals, - exports: 'named', - }, - external: Object.keys(globals), - plugins: [resolve(), sourcemaps()], -}; diff --git a/packages/apollo-boost/rollup.config.js b/packages/apollo-boost/rollup.config.js index 29445a404c3..dba2288919b 100644 --- a/packages/apollo-boost/rollup.config.js +++ b/packages/apollo-boost/rollup.config.js @@ -1,4 +1,6 @@ -import build from '../../config/rollup.config'; +import buildUmdConfig from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; const globals = { 'apollo-client': 'apollo.core', @@ -9,10 +11,12 @@ const globals = { 'graphql-tag': 'graphqlTag', }; -export default build('apollo.boost', { - external: Object.keys(global), - output: { - file: 'lib/index.umd.js', - globals, - }, -}); +export default [ + buildUmdConfig('apollo.boost', { + external: Object.keys(globals), + output: { + globals, + }, + }), + buildEsmConfig(pkg), +]; diff --git a/packages/apollo-cache-inmemory/jest.config.js b/packages/apollo-cache-inmemory/jest.config.js new file mode 100644 index 00000000000..82849e9ef6d --- /dev/null +++ b/packages/apollo-cache-inmemory/jest.config.js @@ -0,0 +1,5 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, +}; diff --git a/packages/apollo-cache-inmemory/package.json b/packages/apollo-cache-inmemory/package.json index 1f1ed1ab563..27db260a9a0 100644 --- a/packages/apollo-cache-inmemory/package.json +++ b/packages/apollo-cache-inmemory/package.json @@ -11,9 +11,9 @@ "Bazyli Brzóska " ], "license": "MIT", - "main": "./lib/bundle.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": [ "./lib/fixPolyfills.js" @@ -32,13 +32,15 @@ "test": "jest", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts", "prebuild": "npm run clean", - "build": "tsc -p .", + "build": "tsc -b .", "postbuild": "npm run bundle", + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +", "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", + "postbundle": "npm run clean:tests", "watch": "tsc -w -p .", "clean": "rm -rf coverage/* && rm -rf lib/*", "prepublishOnly": "npm run build", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "filesize": "npm run minify" }, "dependencies": { @@ -49,18 +51,5 @@ }, "peerDependencies": { "graphql": "0.11.7 || ^0.12.0 || ^0.13.0 || ^14.0.0" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "testURL": "http://localhost" } } diff --git a/packages/apollo-cache-inmemory/rollup.config.js b/packages/apollo-cache-inmemory/rollup.config.js index 551b6fa7d18..216a3e587ef 100644 --- a/packages/apollo-cache-inmemory/rollup.config.js +++ b/packages/apollo-cache-inmemory/rollup.config.js @@ -1,4 +1,6 @@ -import build, { globals } from '../../config/rollup.config'; +import buildUmdConfig, { globals } from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; const globalsOverride = { ...globals, @@ -7,8 +9,11 @@ const globalsOverride = { 'graphql/language/visitor': 'visitor', }; -export default build('apollo.cache.inmemory', { - output: { - globals: globalsOverride, - }, -}); +export default [ + buildUmdConfig('apollo.cache.inmemory', { + output: { + globals: globalsOverride, + }, + }), + buildEsmConfig(pkg), +]; diff --git a/packages/apollo-cache/jest.config.js b/packages/apollo-cache/jest.config.js new file mode 100644 index 00000000000..82849e9ef6d --- /dev/null +++ b/packages/apollo-cache/jest.config.js @@ -0,0 +1,5 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, +}; diff --git a/packages/apollo-cache/package.json b/packages/apollo-cache/package.json index 774e4c0bb3f..f7ba9a2af57 100644 --- a/packages/apollo-cache/package.json +++ b/packages/apollo-cache/package.json @@ -10,9 +10,9 @@ "James Burgess " ], "license": "MIT", - "main": "./lib/bundle.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": false, "repository": { @@ -29,30 +29,19 @@ "test": "jest", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts && tslint -c \"../../config/tslint.json\" -p tsconfig.json tests/*.ts", "prebuild": "npm run clean", - "build": "tsc -p .", + "build": "tsc -b .", "postbuild": "npm run bundle", + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +", "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", + "postbundle": "npm run clean:tests", "watch": "tsc -w -p .", "clean": "rm -rf coverage/* && rm -rf lib/*", "prepublishOnly": "npm run clean && npm run build", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "filesize": "npm run minify" }, "dependencies": { "apollo-utilities": "file:../apollo-utilities", "tslib": "^1.9.3" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "testURL": "http://localhost" } } diff --git a/packages/apollo-cache/rollup.config.js b/packages/apollo-cache/rollup.config.js index fdde2e65749..ddf1d71b3fd 100644 --- a/packages/apollo-cache/rollup.config.js +++ b/packages/apollo-cache/rollup.config.js @@ -1,7 +1,5 @@ -import resolve from 'rollup-plugin-node-resolve'; +import buildUmdConfig from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; -import build from '../../config/rollup.config'; - -export default build('apollo.cache.core', { - plugins: [resolve()], -}); +export default [buildUmdConfig('apollo.cache.core'), buildEsmConfig(pkg)]; diff --git a/packages/apollo-client/.babelrc b/packages/apollo-client/.babelrc deleted file mode 100644 index 71c8a7f4b05..00000000000 --- a/packages/apollo-client/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "plugins": [ - "transform-es2015-modules-commonjs" - ], - "ignore": [ - "lib/**/*.d.ts", - "lib/bundles/**", - "node_modules/**" - ] -} diff --git a/packages/apollo-client/jest.config.js b/packages/apollo-client/jest.config.js new file mode 100644 index 00000000000..5abf56021f6 --- /dev/null +++ b/packages/apollo-client/jest.config.js @@ -0,0 +1,7 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, + // must be inside the src dir + setupFiles: ['/src/config/jest/setup.ts'], +}; diff --git a/packages/apollo-client/package.json b/packages/apollo-client/package.json index cb42312472d..14cf47245e7 100644 --- a/packages/apollo-client/package.json +++ b/packages/apollo-client/package.json @@ -3,9 +3,9 @@ "private": true, "version": "2.5.0-beta.0", "description": "A simple yet functional GraphQL client.", - "main": "./lib/bundle.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": false, "scripts": { @@ -13,17 +13,20 @@ "coverage": "jest --coverage", "dev": "./scripts/dev.sh", "deploy": "./scripts/deploy.sh", - "test": "tsc -p tsconfig.test.json --noEmit && jest", + "test": "jest", "benchmark": "npm run build:benchmark && node benchmark_lib/benchmark/index.js", "benchmark:inspect": "npm run build:benchmark && node --inspect --debug-brk benchmark_lib/benchmark/index.js", "filesize": "npm run minify", "type-check": "flow check", - "build": "tsc", + "prebuild": "npm run clean", + "build": "tsc -b .", + "postbuild": "npm run bundle", "build:benchmark": "tsc -p tsconfig.benchmark.json", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "watch": "tsc -w", + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +", "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", - "postbuild": "npm run bundle", + "postbundle": "npm run clean:tests", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts", "testonly": "jest", "preanalyze": "npm run build", @@ -56,23 +59,11 @@ "tslib": "^1.9.3", "zen-observable": "^0.8.0" }, + "devDependencies": { + "webpack": "3.12.0", + "webpack-bundle-analyzer": "3.0.3" + }, "peerDependencies": { "graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "setupFiles": [ - "/scripts/tests.js" - ], - "testURL": "http://localhost" } } diff --git a/packages/apollo-client/rollup.config.js b/packages/apollo-client/rollup.config.js index adaf06f3a37..ddfdc7e4871 100644 --- a/packages/apollo-client/rollup.config.js +++ b/packages/apollo-client/rollup.config.js @@ -1,12 +1,17 @@ -import build, { globals } from '../../config/rollup.config'; +import buildUmdConfig, { globals } from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; const globalsOverride = { ...globals, 'symbol-observable': '$$observable', }; -export default build('apollo.core', { - output: { - globals: globalsOverride, - }, -}); +export default [ + buildUmdConfig('apollo.core', { + output: { + globals: globalsOverride, + }, + }), + buildEsmConfig(pkg), +]; diff --git a/packages/apollo-client/scripts/deploy.sh b/packages/apollo-client/scripts/deploy.sh index 51632417e26..49d778ca9af 100755 --- a/packages/apollo-client/scripts/deploy.sh +++ b/packages/apollo-client/scripts/deploy.sh @@ -46,8 +46,7 @@ node -e "\ delete package.scripts; \ delete package.options; \ package.main = 'bundle.umd.js'; \ - package.module = 'index.js'; \ - package['jsnext:main'] = 'index.js'; \ + package.module = 'bundle.esm.js'; \ package.typings = 'index.d.ts'; \ package.dependencies['apollo-cache'] = apolloCacheVersion; \ package.dependencies['apollo-utilities'] = apolloUtilitiesVersion; \ diff --git a/packages/apollo-client/scripts/tests.js b/packages/apollo-client/src/config/jest/setup.ts similarity index 67% rename from packages/apollo-client/scripts/tests.js rename to packages/apollo-client/src/config/jest/setup.ts index 1cf3cd870d5..c4c52ea821c 100644 --- a/packages/apollo-client/scripts/tests.js +++ b/packages/apollo-client/src/config/jest/setup.ts @@ -1,6 +1,6 @@ -process.on('unhandledRejection', () => {}); - -const { disableFragmentWarnings } = require('graphql-tag'); +import { disableFragmentWarnings } from 'graphql-tag'; // Turn off warnings for repeated fragment names disableFragmentWarnings(); + +process.on('unhandledRejection', () => {}); diff --git a/packages/apollo-utilities/jest.config.js b/packages/apollo-utilities/jest.config.js new file mode 100644 index 00000000000..82849e9ef6d --- /dev/null +++ b/packages/apollo-utilities/jest.config.js @@ -0,0 +1,5 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, +}; diff --git a/packages/apollo-utilities/package.json b/packages/apollo-utilities/package.json index 1e98b0b33f2..6fb3583f9ed 100644 --- a/packages/apollo-utilities/package.json +++ b/packages/apollo-utilities/package.json @@ -10,9 +10,9 @@ "James Burgess " ], "license": "MIT", - "main": "./lib/bundle.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": false, "repository": { @@ -29,13 +29,15 @@ "coverage": "jest --coverage", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts", "prebuild": "npm run clean", - "build": "tsc -p .", + "build": "tsc -b .", "postbuild": "npm run bundle", + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +", "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", + "postbundle": "npm run clean:tests", "watch": "tsc -w -p .", "clean": "rm -rf coverage/* && rm -rf lib/*", "prepublishOnly": "npm run clean && npm run build", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "filesize": "npm run minify" }, "peerDependencies": { @@ -44,18 +46,5 @@ "dependencies": { "fast-json-stable-stringify": "^2.0.0", "tslib": "^1.9.3" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "testURL": "http://localhost" } } diff --git a/packages/apollo-utilities/rollup.config.js b/packages/apollo-utilities/rollup.config.js index 5e75f8f9e74..a5bf715102b 100644 --- a/packages/apollo-utilities/rollup.config.js +++ b/packages/apollo-utilities/rollup.config.js @@ -1,12 +1,17 @@ -import build, { globals } from '../../config/rollup.config'; +import buildUmdConfig, { globals } from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; const globalsOverride = { ...globals, 'fast-json-stable-stringify': 'stringify', }; -export default build('apollo.utilities', { - output: { - globals: globalsOverride, - }, -}); +export default [ + buildUmdConfig('apollo.utilities', { + output: { + globals: globalsOverride, + }, + }), + buildEsmConfig(pkg), +]; diff --git a/packages/graphql-anywhere/.travis.yml b/packages/graphql-anywhere/.travis.yml deleted file mode 100644 index a617888611f..00000000000 --- a/packages/graphql-anywhere/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: node_js - -node_js: - - "6" - - "4" - -# Allow Travis tests to run in containers. -sudo: false diff --git a/packages/graphql-anywhere/Gruntfile.js b/packages/graphql-anywhere/Gruntfile.js deleted file mode 100644 index 8ff077940c6..00000000000 --- a/packages/graphql-anywhere/Gruntfile.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function(grunt) { - grunt.initConfig({ - tslint: { - options: { - // can be a configuration object or a filepath to tslint.json - configuration: grunt.file.readJSON('tslint.json'), - }, - files: { - src: ['src/**/*.ts', 'test/**/*.ts', '!test/fixtures/**/*.ts'], - }, - }, - }); - - grunt.loadNpmTasks('grunt-tslint'); -}; diff --git a/packages/graphql-anywhere/jest.config.js b/packages/graphql-anywhere/jest.config.js new file mode 100644 index 00000000000..82849e9ef6d --- /dev/null +++ b/packages/graphql-anywhere/jest.config.js @@ -0,0 +1,5 @@ +const pkg = require('../../config/jest.config.settings'); + +module.exports = { + ...pkg, +}; diff --git a/packages/graphql-anywhere/package.json b/packages/graphql-anywhere/package.json index 4a7f15c8ed2..44e83c7d974 100644 --- a/packages/graphql-anywhere/package.json +++ b/packages/graphql-anywhere/package.json @@ -2,24 +2,26 @@ "name": "graphql-anywhere", "version": "4.2.0-beta.0", "description": "Run GraphQL queries with no schema and just one resolver", - "main": "./lib/bundle.umd.js", - "module": "./lib/index.js", - "jsnext:main": "./lib/index.js", + "main": "./lib/index.js", + "module": "./lib/bundle.esm.js", + "browser": "./lib/bundle.umd.js", "typings": "./lib/index.d.ts", "sideEffects": false, "scripts": { "prepare": "npm run lint && npm run build", "coverage": "jest --coverage", "test": "jest", - "build": "tsc", + "build": "tsc -b .", "postbuild": "npm run bundle", - "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js && ../../node_modules/rollup/bin/rollup -c rollup.async.config.js && cp ./lib/graphql-async.d.ts ./lib/async.d.ts", + "bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", + "postbundle": "npm run clean:tests", "watch": "tsc -w", "prepublishOnly": "npm run build", "lint": "tslint -c \"../../config/tslint.json\" -p tsconfig.json src/*.ts", - "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.umd.js", + "minify": "../../node_modules/uglify-js/bin/uglifyjs -c -m -o ./lib/bundle.umd.min.js -- ./lib/bundle.umd.js", "filesize": "npm run minify", - "clean": "rm -rf coverage/* && rm -rf lib/*" + "clean": "rm -rf coverage/* && rm -rf lib/*", + "clean:tests": "find ./lib -name \"__tests__\" -exec rm -rf '{}' +" }, "repository": { "type": "git", @@ -42,18 +44,5 @@ "dependencies": { "apollo-utilities": "file:../apollo-utilities", "tslib": "^1.9.3" - }, - "jest": { - "transform": { - ".(ts|tsx)": "ts-jest" - }, - "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "testURL": "http://localhost" } } diff --git a/packages/graphql-anywhere/rollup.async.config.js b/packages/graphql-anywhere/rollup.async.config.js deleted file mode 100644 index 3663810ec9f..00000000000 --- a/packages/graphql-anywhere/rollup.async.config.js +++ /dev/null @@ -1,9 +0,0 @@ -import build from '../../config/rollup.config'; - -export default build('graphqlAnywhereAsync', { - input: 'lib/graphql-async.js', - output: { - file: 'lib/async.js', - format: 'umd', - }, -}); diff --git a/packages/graphql-anywhere/rollup.config.js b/packages/graphql-anywhere/rollup.config.js index 7861554f99b..3b14d1aff24 100644 --- a/packages/graphql-anywhere/rollup.config.js +++ b/packages/graphql-anywhere/rollup.config.js @@ -1,3 +1,14 @@ -import build from '../../config/rollup.config'; +import buildUmdConfig from '../../config/buildUmdConfig'; +import buildEsmConfig from '../../config/buildEsmConfig'; +import pkg from './package.json'; -export default build('graphqlAnywhere'); +export default [ + buildUmdConfig('graphqlAnywhere'), + buildUmdConfig('graphqlAnywhereAsync', { + input: 'lib/graphql-async.js', + output: { + file: 'lib/async.js', + }, + }), + buildEsmConfig(pkg), +]; diff --git a/tsconfig.json b/tsconfig.json index 4941dcf9e4f..f7275428011 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,11 @@ { "extends": "./config/tsconfig.base.json", - "compilerOptions": { - "noLib": true - } + "references": [ + { "path": "packages/apollo-boost" }, + { "path": "packages/apollo-cache" }, + { "path": "packages/apollo-cache-inmemory" }, + { "path": "packages/apollo-client" }, + { "path": "packages/apollo-utilities" }, + { "path": "packages/graphql-anywhere" } + ] }