Skip to content

Commit

Permalink
update babel/scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sghall committed Apr 18, 2017
1 parent e24f2da commit bd18c09
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 45 deletions.
22 changes: 9 additions & 13 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
{
"presets": ["./scripts/babel-preset-es2015", "stage-1", "react"],
"plugins": [
["transform-replace-object-assign", "simple-assign"],
"transform-dev-warning"
"./scripts/babel-transform-object-assign-require"
],
"env": {
"test": {
"sourceMaps": "both"
},
"docs-production": {
"coverage": {
"plugins": [
["transform-replace-object-assign", "simple-assign"],
"transform-react-remove-prop-types",
"transform-react-constant-elements",
"transform-react-inline-elements"
["istanbul"]
]
},
"release": {
"test": {
"sourceMaps": "both"
},
"production": {
"plugins": [
"transform-runtime",
["transform-react-remove-prop-types", {"mode": "wrap"}]
"transform-dev-warning",
"transform-runtime"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ All stable releases are tagged ([view tags](https://github.com/sghall/resonance/

Please create a new branch from an up to date master on your fork. (Note, urgent hotfixes should be branched off the latest stable release rather than master)

1. Fork the Reonance repository on Github
1. Fork the Resonance repository on Github
2. Clone your fork to your local machine `git clone git@github.com:<yourname>/resonance.git`
3. Create a branch `git checkout -b my-topic-branch`
4. Make your changes, lint, then push to to github with `git push --set-upstream origin my-topic-branch`.
Expand Down
16 changes: 16 additions & 0 deletions docs/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"presets": ["es2015", "stage-1", "react"],
"env": {
"development": {
"plugins": [
"react-hot-loader/babel"
]
},
"production": {
"plugins": [
"transform-dev-warning",
"transform-runtime"
]
}
}
}
9 changes: 4 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,21 @@
"webpack-dev-server": "^2.4.2"
},
"dependencies": {
"babel-polyfill": "^6.16.0",
"babel-polyfill": "^6.23.0",
"d3-array": "^1.1.1",
"d3-ease": "^1.0.3",
"d3-format": "^1.1.1",
"d3-hierarchy": "^1.1.4",
"d3-scale": "^1.0.5",
"d3-shape": "^1.0.6",
"material-ui": "^0.17.1",
"material-ui": "^0.17.4",
"moment": "^2.17.1",
"react-redux": "^5.0.3",
"react-redux": "^5.0.4",
"react-router": "^3.0.0",
"react-tap-event-plugin": "^2.0.0",
"react-title-component": "^1.0.1",
"redux": "^3.6.0",
"redux-thunk": "^2.2.0",
"reselect": "^2.5.4",
"simple-assign": "^0.1.0"
"reselect": "^2.5.4"
}
}
16 changes: 8 additions & 8 deletions docs/webpack.prd.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ module.exports = Object.assign({}, webpackBaseConfig, {
context: '.',
manifest: dllManifest,
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
output: {
comments: false,
},
}),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false,
// },
// output: {
// comments: false,
// },
// }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"d3-interpolate": "^1.1.3",
"d3-timer": "^1.0.4",
"lodash": "^4.17.4",
"simple-assign": "^0.1.0"
"object-assign": "^4.1.1"
},
"devDependencies": {
"app-module-path": "^2.1.0",
Expand All @@ -70,37 +70,38 @@
"chai": "^3.5.0",
"coveralls": "^2.11.15",
"cross-env": "^4.0.0",
"enzyme": "^2.6.0",
"eslint": "^3.10.2",
"enzyme": "^2.8.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-babel": "^4.0.0",
"eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-mocha": "^4.7.0",
"eslint-plugin-react": "^6.7.1",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-mocha": "^4.9.0",
"eslint-plugin-react": "^6.10.3",
"flow-bin": "^0.44.0",
"fs-extra": "^2.0.0",
"fs-extra": "^2.1.2",
"glob": "^7.1.1",
"istanbul": "^1.1.0-alpha.1",
"jsdom": "^9.8.3",
"json-loader": "^0.5.4",
"karma": "^1.1.1",
"karma": "^1.6.0",
"karma-browserstack-launcher": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.0",
"karma-webpack": "^2.0.3",
"minimist": "^1.2.0",
"mocha": "^3.1.2",
"mocha": "^3.2.0",
"nodemon": "^1.11.0",
"phantomjs-prebuilt": "^2.1.13",
"prop-types": "^15.5.6",
"react": "^15.5.3",
"react-dom": "^15.5.3",
"react-addons-test-utils": "^15.4.0",
"recursive-readdir-sync": "^1.0.6",
"rimraf": "^2.5.3",
"rimraf": "^2.6.1",
"sinon": "^2.1.0",
"webpack": "^2.4.1"
}
Expand Down
8 changes: 5 additions & 3 deletions scripts/babel-preset-es2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const ENV = process.env.BABEL_ENV;

module.exports = {
presets: [
[es2015, {
modules: ENV === 'es' ? false : 'commonjs',
}],
[
es2015, {
modules: ENV === 'modules' ? false : 'commonjs',
},
],
],
};
57 changes: 57 additions & 0 deletions scripts/babel-transform-object-assign-require.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* eslint-disable */

/**
*
* https://github.com/facebook/react/blob/master/scripts/babel/transform-object-assign-require.js
*
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

'use strict';

module.exports = function autoImporter(babel) {
const t = babel.types;

function getAssignIdent(path, file, state) {
if (!state.id) {
state.id = path.scope.generateUidIdentifier('assign');
path.scope.getProgramParent().push({
id: state.id,
init: t.callExpression(
t.identifier('require'),
[t.stringLiteral('object-assign')]
),
});
}
return state.id;
}

return {
pre: function() {
// map from module to generated identifier
this.id = null;
},

visitor: {
CallExpression: function(path, file) {
if (path.get('callee').matchesPattern('Object.assign')) {
// generate identifier and require if it hasn't been already
const id = getAssignIdent(path, file, this);
path.node.callee = id;
}
},

MemberExpression: function(path, file) {
if (path.matchesPattern('Object.assign')) {
const id = getAssignIdent(path, file, this);
path.replaceWith(id);
}
},
},
};
};

0 comments on commit bd18c09

Please sign in to comment.