Skip to content

Commit

Permalink
build(Babel): Remove babel-runtime, migrate to babel-preset-env, refr…
Browse files Browse the repository at this point in the history
…eshed package.json
  • Loading branch information
nodkz committed Mar 4, 2017
1 parent 9dc98fe commit ab6e8df
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 1,294 deletions.
35 changes: 27 additions & 8 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
{
"presets": ["react", "es2015", "stage-0"],
"plugins": ["dev-expression", "transform-runtime"],

"plugins": [
"babel-plugin-transform-object-rest-spread"
],
"env": {
"cjs": {
"presets": ["es2015-loose", "stage-0"],
"plugins": ["add-module-exports"]
"lib": {
"presets": [
["env", {
"targets": {
"browsers": [
"last 5 versions",
"defaults"
]
},
"include": ["transform-es2015-classes"],
"debug": true,
}]
]
},
"es": {
"presets": ["es2015-loose-native-modules", "stage-0"]
"presets": [
["env", {
"targets": {
"chrome": 52
},
"loose": true,
"modules": false,
"debug": true
}]
]
}
}
}
}
36 changes: 12 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,30 @@
"homepage": "https://github.com/nodkz/react-relay-network-layer#readme",
"dependencies": {},
"peerDependencies": {
"babel-runtime": "^6.6.1",
"react-relay": ">=0.7.0"
},
"devDependencies": {
"babel-cli": "^6.7.7",
"babel-core": "^6.7.7",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-runtime": "^6.7.5",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-loose": "^8.0.0",
"babel-preset-es2015-loose-native-modules": "^1.0.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.7.2",
"babel-relay-plugin": "^0.11.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "^1.2.0",
"babel-register": "^6.23.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"eslint": "^3.15.0",
"eslint-config-airbnb-base": "^11.1.0",
"eslint": "^3.17.0",
"eslint-config-airbnb-base": "^11.1.1",
"eslint-module-utils": "^2.0.0",
"eslint-plugin-import": "^2.2.0",
"fetch-mock": "^5.5.0",
"graphql": "^0.9.1",
"graphql-relay": "^0.5.1",
"fetch-mock": "^5.9.4",
"mocha": "^3.1.1",
"rimraf": "^2.5.2"
"rimraf": "^2.6.1"
},
"scripts": {
"build": "npm run build-cjs && npm run build-es",
"build-cjs": "rimraf lib && BABEL_ENV=cjs babel src -d lib",
"build": "npm run build-lib && npm run build-es",
"build-lib": "rimraf lib && BABEL_ENV=lib babel src -d lib",
"build-es": "rimraf es && BABEL_ENV=es babel src -d es",
"lint": "eslint src test *.js",
"prepublish": "npm run test && npm run build",
"test": "mocha --require test/mocha-bootload --compilers js:babel-core/register test/*.test.js"
"test": "npm run lint && BABEL_ENV=lib mocha --require test/mocha-bootload --compilers js:babel-register test/*.test.js"
}
}
28 changes: 16 additions & 12 deletions src/relayNetworkLayer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable arrow-body-style, no-unused-vars */

import queries from './relay/queries';
import queriesBatch from './relay/queriesBatch';
import mutation from './relay/mutation';
Expand All @@ -21,29 +19,35 @@ export default class RelayNetworkLayer {
}
}
});

this.supports = this.supports.bind(this);
this.sendQueries = this.sendQueries.bind(this);
this.sendMutation = this.sendMutation.bind(this);
this._fetchWithMiddleware = this._fetchWithMiddleware.bind(this);
this._isBatchQueriesDisabled = this._isBatchQueriesDisabled.bind(this);
}

supports = (...options) => {
supports(...options) {
return options.every(option => this._supportedOptions.indexOf(option) !== -1);
};
}

sendQueries = (requests) => {
sendQueries(requests) {
if (requests.length > 1 && !this._isBatchQueriesDisabled()) {
return queriesBatch(requests, this._fetchWithMiddleware);
}

return queries(requests, this._fetchWithMiddleware);
};
}

sendMutation = (request) => {
sendMutation(request) {
return mutation(request, this._fetchWithMiddleware);
};
}

_fetchWithMiddleware = (req) => {
_fetchWithMiddleware(req) {
return fetchWrapper(req, this._middlewares);
};
}

_isBatchQueriesDisabled = () => {
_isBatchQueriesDisabled() {
return this._options && this._options.disableBatchQuery;
};
}
}
Loading

0 comments on commit ab6e8df

Please sign in to comment.