Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
merge 2.0.0-beta3 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bdefore committed Dec 22, 2015
2 parents c65a74e + 684ce26 commit 654b4b6
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 117 deletions.
30 changes: 12 additions & 18 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
{
"stage": 0,
"optional": "runtime",
"loose": "all",
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"typecheck"
[ "transform-runtime" ],
[ "typecheck" ],
[ "transform-decorators-legacy" ]
],
"env": {
"development": {
"plugins": [
"react-transform"
],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-catch-errors",
"imports": [
"react",
"redbox-react"
]
}]
}
}
"plugins": []
},
"production": {
"plugins": []
}
}
}
2 changes: 1 addition & 1 deletion bin/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)
// require('../server.babel'); // babel registration (runtime transpilation for node)

var webpack = require('webpack');
var webpackConfig = require('./merge-configs');
Expand Down
2 changes: 1 addition & 1 deletion bin/local-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ compile() {
cp $ROOT_DIR/.babelrc $PROJECT_PATH/node_modules/universal-redux
cp $ROOT_DIR/.eslintrc $PROJECT_PATH/node_modules/universal-redux
cp $ROOT_DIR/server.babel.js $PROJECT_PATH/node_modules/universal-redux
babel $ROOT_DIR/src/ -d $PROJECT_PATH/node_modules/universal-redux/lib > /dev/null
babel $ROOT_DIR/src/ --presets es2015,stage-0,react --plugins transform-runtime --out-dir $PROJECT_PATH/node_modules/universal-redux/lib > /dev/null
echo Update complete, continuing to watch...
}

Expand Down
72 changes: 72 additions & 0 deletions bin/merge-babel-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
var fs = require('fs');
var strip = require('strip-loader');
var path = require('path');
var util = require('util');

module.exports = function(userBabelConfig, verbose) {

var babelrc = fs.readFileSync(path.resolve(__dirname, '..', './.babelrc'));
var babelConfig = {};
var jsLoaders;

try {
babelConfig = JSON.parse(babelrc);
} catch (err) {
console.error('==> ERROR: Error parsing your .babelrc.');
console.error(err);
}

if(userBabelConfig) {
console.log('Merging universal-redux Babel defaults with project Babel configuration');

var userBabelConfigFile = fs.readFileSync(path.resolve(userBabelConfig));
var userBabelConfig = {};

try {
userBabelConfig = JSON.parse(userBabelConfigFile);
} catch (err) {
console.error('==> ERROR: Error parsing your project-level Babel configuration.');
console.error(err);
}

babelConfig = Object.assign(babelConfig, userBabelConfig);
}

if (process.env.NODE_ENV !== 'production') {

var hmrConfig = [
"react-transform", {
"transforms": [
{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
},
{
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}
]
}
]

babelConfig.env.development.plugins.unshift(hmrConfig);

jsLoaders = ['babel-loader?' + JSON.stringify(babelConfig)];
} else {
jsLoaders = [strip.loader('debug'), 'babel-loader?' + JSON.stringify(babelConfig)];
}

// output configuration files if user wants verbosity
if(verbose) {
var utilOptions = {
depth: 10,
colors: true
};

console.log('Babel config:');
console.log(util.inspect(babelConfig, utilOptions));
}

return jsLoaders;
}
5 changes: 5 additions & 0 deletions bin/merge-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var path = require('path');
var util = require('util');
var webpack = require('webpack');
var mergeWebpack = require('webpack-config-merger');
var mergeBabel = require('./merge-babel-config');
var baseWebpackConfig = require('../config/webpack.config.js');
var baseDevConfig = mergeWebpack(baseWebpackConfig.common, baseWebpackConfig.development);
var baseProdConfig = mergeWebpack(baseWebpackConfig.common, baseWebpackConfig.production);
Expand All @@ -24,6 +25,10 @@ if(userConfig.webpack.merge) {
combinedWebpackConfig = userConfig.webpack.config;
}

// add babel for js transpiling
var babelConfig = mergeBabel(userConfig.babelConfig, userConfig.verbose);
combinedWebpackConfig.module.loaders.unshift({ test: /\.jsx?$/, exclude: /node_modules/, loaders: babelConfig });

// gather tools config
var combinedToolsConfig = baseToolsConfig;
if(userConfig.toolsConfigPath) {
Expand Down
2 changes: 1 addition & 1 deletion bin/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)
// require('../server.babel'); // babel registration (runtime transpilation for node)

var path = require('path');
var renderer = require('../lib/server');
Expand Down
2 changes: 1 addition & 1 deletion bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)
// require('../server.babel'); // babel registration (runtime transpilation for node)

var path = require('path');
var Express = require('express');
Expand Down
4 changes: 3 additions & 1 deletion config/universal-redux.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ module.exports = {
*/
lint: {
enabled: true
// config: projectRoot + '.eslintrc'
// config: projectRoot + '/.eslintrc'
},

babelConfig: projectRoot + '/.babelrc',

/*
// Enable native desktop notifications for Webpack build events.
// Will not be run on production.
Expand Down
44 changes: 2 additions & 42 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('babel/polyfill');
// require('babel/polyfill');

// begin shared setup
var path = require('path');
Expand All @@ -7,52 +7,12 @@ var relativeAssetsPath = '../static/dist';
var assetsPath = path.join(__dirname, relativeAssetsPath);

// begin dev setup
var fs = require('fs');
var host = (process.env.HOST || 'localhost');
var port = parseInt(process.env.PORT) + 1 || 3001;
var babelrc = fs.readFileSync(path.resolve(__dirname, '..', './.babelrc'));
var babelrcObject = {};

// begin prod setup
var CleanPlugin = require('clean-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var strip = require('strip-loader');

if (process.env.NODE_ENV !== 'production') {

try {
babelrcObject = JSON.parse(babelrc);
} catch (err) {
console.error('==> ERROR: Error parsing your .babelrc.');
console.error(err);
}

var babelrcObjectDevelopment = babelrcObject.env && babelrcObject.env.development || {};
var babelLoaderQuery = Object.assign({}, babelrcObject, babelrcObjectDevelopment);
delete babelLoaderQuery.env;

babelLoaderQuery.plugins = babelLoaderQuery.plugins || [];
if (babelLoaderQuery.plugins.indexOf('react-transform') < 0) {
babelLoaderQuery.plugins.push('react-transform');
}

babelLoaderQuery.extra = babelLoaderQuery.extra || {};
if (!babelLoaderQuery.extra['react-transform']) {
babelLoaderQuery.extra['react-transform'] = {};
}
if (!babelLoaderQuery.extra['react-transform'].transforms) {
babelLoaderQuery.extra['react-transform'].transforms = [];
}
babelLoaderQuery.extra['react-transform'].transforms.push({
transform: 'react-transform-hmr',
imports: ['react'],
locals: ['module']
});

var jsLoaders = ['babel?' + JSON.stringify(babelLoaderQuery)];
} else {
var jsLoaders = [strip.loader('debug'), 'babel'];
}

module.exports = {
common: {
Expand All @@ -67,7 +27,7 @@ module.exports = {
},
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: jsLoaders},
// { test: /\.jsx?$/, exclude: /node_modules/, loaders: jsLoaders }, // now prepended in merge-configs and merge-babel-config
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" },
Expand Down
26 changes: 0 additions & 26 deletions examples/jwt/.babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion examples/jwt/bin/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var fs = require('fs');
var path = require('path');

var babelrc = fs.readFileSync(path.resolve(__dirname, '../.babelrc'));
var babelrc = fs.readFileSync(path.resolve(__dirname, '../node_modules/universal-redux/.babelrc'));
var config;

try {
Expand Down
4 changes: 3 additions & 1 deletion examples/jwt/config/universal-redux.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ module.exports = {
// Expects: Boolean
*/
lint: {
enabled: true,
enabled: false,
config: projectRoot + '/.eslintrc'
},

// babelConfig: projectRoot + '/.babelrc',

/*
// Enable native desktop notifications for Webpack build events.
// Will not be run on production.
Expand Down
12 changes: 4 additions & 8 deletions examples/jwt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "JWT example with Universal Redux",
"main": "index.js",
"scripts": {
"scripts": {
"start": "concurrent --kill-others \"better-npm-run api\" \"better-npm-run auth\" \"better-npm-run server\"",
"build": "better-npm-run build",
"postinstall": "./bin/build_for_heroku.sh",
Expand Down Expand Up @@ -86,14 +86,9 @@
"concurrently": "1.0.0",
"jsonwebtoken": "^5.4.1",
"superagent": "^1.6.1",
"universal-redux": "^1.0.0-beta4"
"universal-redux": "^2.0.0-beta3"
},
"devDependencies": {
"babel-core": "~5.8.33",
"babel-eslint": "^4.1.3",
"babel-plugin-react-transform": "~1.1.1",
"babel-plugin-typecheck": "^2.0.0",
"babel-runtime": "~5.8.29",
"better-npm-run": "0.0.5",
"classnames": "^2.2.0",
"deep-equal": "^1.0.1",
Expand All @@ -109,11 +104,12 @@
"react-addons-css-transition-group": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "4.0.0",
"react-router": "1.0.2",
"react-toolbox": "^0.13.4",
"react-tools": "^0.10.0",
"react-transform-catch-errors": "^1.0.0",
"redbox-react": "^1.1.1",
"redux-simple-router": "0.0.10",
"redux-simple-router": "1.0.1",
"url-loader": "^0.5.7",
"warning": "^2.1.0"
}
Expand Down
24 changes: 15 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A universal redux renderer (ES6, Webpack, Express)",
"author": "Buck DeFore <[email protected]> (http://github.com/bdefore)",
"license": "MIT",
"version": "1.0.0",
"version": "2.0.0-beta3",
"repository": {
"type": "git",
"url": "git+https://github.com/bdefore/universal-redux.git"
Expand All @@ -25,21 +25,27 @@
],
"main": "lib/index.js",
"scripts": {
"compile": "babel src/ -d lib/",
"compile": "babel --presets es2015,stage-0,react --plugins transform-runtime src/ --out-dir lib/",
"dev": "./bin/local-dev.sh",
"prepublish": "npm run compile",
"lint": "eslint -c .eslintrc src",
"test": "karma start"
},
"dependencies": {
"autoprefixer-loader": "^3.1.0",
"babel": "~5.8.29",
"babel-core": "~5.8.33",
"babel-eslint": "^4.1.3",
"babel-loader": "~5.3.3",
"babel-plugin-react-transform": "~1.1.1",
"babel-plugin-typecheck": "^2.0.0",
"babel-runtime": "~5.8.29",
"babel": "~6.3.13",
"babel-cli": "6.3.17",
"babel-core": "~6.3.21",
"babel-eslint": "^5.0.0-beta3",
"babel-loader": "~6.2.0",
"babel-plugin-react-transform": "~2.0.0-beta1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-plugin-typecheck": "^3.5.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babel-runtime": "~6.3.19",
"bootstrap-sass": "^3.3.5",
"bootstrap-sass-loader": "^1.0.9",
"clean-webpack-plugin": "^0.1.4",
Expand Down
3 changes: 1 addition & 2 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* THIS IS THE ENTRY POINT FOR THE CLIENT, JUST LIKE server.js IS THE ENTRY POINT FOR THE SERVER.
*/
// node modules dependencies
import 'babel/polyfill';
import React from 'react';
import { each } from 'lodash';
import ReactDOM from 'react-dom';
Expand Down Expand Up @@ -63,7 +62,7 @@ if (process.env.NODE_ENV !== 'production') {
}

if (__DEVTOOLS__ && !window.devToolsExtension) {
const DevTools = require('./containers/DevTools/DevTools');
const DevTools = require('./containers/DevTools/DevTools').default;
ReactDOM.render(
<Provider store={store} key="provider">
<div>
Expand Down
Loading

0 comments on commit 654b4b6

Please sign in to comment.