git ssb

1+

dinoworm ๐Ÿ› / catstack



Commit 99bc16e5212f7086422943407911f7c31443ab4c

fashion-driven development

use es2015 modules (import / export) instead of es5 modules (require, module.exports) unless where necessary (bulkify only recognizes es5 modules)

- %s/^const \(.*\) = require('\(.*\)')$/import \1 from '\2'/i
- %s/module.exports = /export default
Michael Williams committed on 1/3/2016, 6:53:28 AM
Parent: 8d668726e7d11fcdfc803f3c47ed305680c7194f

Files changed

api.jschanged
app/api.jschanged
app/config.jschanged
app/dev/root.jschanged
app/dev/tools.jschanged
app/four-oh-four/container.jschanged
app/four-oh-four/routes.jschanged
app/landing/component.jschanged
app/landing/container.jschanged
app/landing/routes.jschanged
app/layout/container.jschanged
app/reducer.jschanged
app/render-browser.jschanged
app/render.jschanged
app/routes.jschanged
app/services/index.jschanged
app/stack/index.jschanged
app/static.jschanged
app/store.jschanged
app/todos/container.jschanged
app/todos/reducer.jschanged
app/todos/routes.jschanged
app/util/fetch-all-data.jschanged
app/util/fetch-element.jschanged
render.jschanged
static.jschanged
api.jsView
@@ -1,8 +1,8 @@
11 require('babel-core/register')
22
3-const config = require('app/config')
4-const createApi = require('app/api')
3+const config = require('app/config').default
4+const createApi = require('app/api').default
55 const Url = require('url')
66
77 const server = createApi(config)
88
app/api.jsView
@@ -1,13 +1,11 @@
1-const feathers = require('feathers')
2-const { mapObjIndexed, reduce, toPairs } = require('ramda')
1+import feathers from 'feathers'
2+import { mapObjIndexed, reduce, toPairs } from 'ramda'
33
4-const services = require('app/services')
5-const config = require('app/config')
4+import services from 'app/services'
5+import config from 'app/config'
66
7-module.exports = createServer
8-
9-function createServer (config) {
7+export default function createServer (config) {
108 const app = feathers()
119
1210 useAll(app, services)
1311
app/config.jsView
@@ -1,1 +1,3 @@
1-module.exports = require('simple-rc')()
1+import getConfig from 'simple-rc'
2+
3+export default getConfig()
app/dev/root.jsView
@@ -1,15 +1,15 @@
1-const React = require('react')
2-const { Provider } = require('react-redux')
3-const { ReduxRouter } = require('redux-router')
1+import React from 'react'
2+import { Provider } from 'react-redux'
3+import { ReduxRouter } from 'redux-router'
44
5-const routes = require('app/routes')
5+import routes from 'app/routes'
66
77 if (process.env.NODE_ENV === 'development') {
88 var DevTools = require('app/components/dev-tools')
99 }
1010
11-class Root extends React.Component {
11+export default class Root extends React.Component {
1212 render() {
1313 const { store } = this.props;
1414
1515 return (
@@ -26,6 +26,4 @@
2626 </Provider>
2727 )
2828 }
2929 }
30-
31-module.exports = Root
app/dev/tools.jsView
@@ -1,13 +1,11 @@
1-const React = require('react')
2-const { createDevTools } = require('redux-devtools')
3-const LogMonitor = require('redux-devtools-log-monitor').default
4-const DockMonitor = require('redux-devtools-dock-monitor').default
1+import React from 'react'
2+import { createDevTools } from 'redux-devtools'
3+import LogMonitor from 'redux-devtools-log-monitor'
4+import DockMonitor from 'redux-devtools-dock-monitor'
55
6-const DevTools = createDevTools(
6+export default createDevTools(
77 <DockMonitor toggleVisibilityKey='H'
88 changePositionKey='Q'>
99 <LogMonitor />
1010 </DockMonitor>
1111 )
12-
13-module.exports = DevTools
app/four-oh-four/container.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
1+import React from 'react'
2+import { connect } from 'react-redux'
33
44 class FourOhFourContainer extends React.Component {
55 render () {
66 return <div>
@@ -8,7 +8,7 @@
88 </div>
99 }
1010 }
1111
12-module.exports = connect(
12+export default connect(
1313 (state) => ({})
1414 )(FourOhFourContainer)
app/four-oh-four/routes.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { Route } = require('react-router')
1+import React from 'react'
2+import { Route } from 'react-router'
33
4-const FourOhFourContainer = require('./container')
4+import FourOhFourContainer from './container'
55
6-module.exports = <Route path="*" component={FourOhFourContainer} />
6+export default <Route path="*" component={FourOhFourContainer} />
app/landing/component.jsView
@@ -1,13 +1,11 @@
1-const React = require('react')
1+import React from 'react'
22
3-const style = require('./style.css')
3+import style from './style.css'
44
5-class Landing extends React.Component {
5+export default class Landing extends React.Component {
66 render () {
77 return <div className={style.container}>
88 landing!
99 </div>
1010 }
1111 }
12-
13-module.exports = Landing
app/landing/container.jsView
@@ -1,14 +1,14 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
1+import React from 'react'
2+import { connect } from 'react-redux'
33
4-const Landing = require('./component')
4+import Landing from './component'
55
66 class LandingContainer extends React.Component {
77 render () {
88 return <Landing />
99 }
1010 }
1111
12-module.exports = connect(
12+export default connect(
1313 (state) => ({})
1414 )(LandingContainer)
app/landing/routes.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { IndexRoute } = require('react-router')
1+import React from 'react'
2+import { IndexRoute } from 'react-router'
33
4-const LandingContainer = require('./container')
4+import LandingContainer from './container'
55
6-module.exports = <IndexRoute component={LandingContainer} />
6+export default <IndexRoute component={LandingContainer} />
app/layout/container.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
1+import React from 'react'
2+import { connect } from 'react-redux'
33
44 class LayoutContainer extends React.Component {
55 render () {
66 const { children } = this.props
@@ -11,7 +11,7 @@
1111 </div>
1212 }
1313 }
1414
15-module.exports = connect(
15+export default connect(
1616 (state) => ({})
1717 )(LayoutContainer)
app/reducer.jsView
@@ -1,16 +1,18 @@
11 const bulk = require('bulk-require')
2-const { combineReducers } = require('redux')
3-const { routeReducer } = require('redux-simple-router')
4-const { map } = require('ramda')
2+import { combineReducers } from 'redux'
3+import { routeReducer } from 'redux-simple-router'
4+import { map } from 'ramda'
55
6-module.exports = combineReducers({
6+export default combineReducers({
77 ...map(
8- (module) => module.reducer,
8+ (module) => module.reducer.default,
99 bulk(__dirname, '*/reducer.js')
1010 ),
1111 ...map(
12- (module) => combineReducers(module.reducers),
12+ (module) => combineReducers(
13+ module.reducers.map(m => m.default)
14+ ),
1315 bulk(__dirname, '*/reducers/*.js')
1416 ),
1517 routing: routeReducer
1618 })
app/render-browser.jsView
@@ -1,16 +1,17 @@
1-const React = require('react')
2-const { render } = require('react-dom')
3-const { Provider } = require('react-redux')
4-const { Router } = require('react-router')
5-const { createHistory } = require('history')
6-const { syncReduxAndRouter } = require('redux-simple-router')
1+import React from 'react'
2+import { render } from 'react-dom'
3+import { Provider } from 'react-redux'
4+import { Router } from 'react-router'
5+import { createHistory } from 'history'
6+import { syncReduxAndRouter } from 'redux-simple-router'
77
8-const routes = require('app/routes')
9-const createStore = require('app/store')
10-const fetchElement = require('app/util/fetch-element')
8+import routes from 'app/routes'
9+import createStore from 'app/store'
10+import fetchElement from 'app/util/fetch-element'
1111
1212 if (process.env.NODE_ENV === 'development') {
13+ var DevTools = require('app/dev/tools').default
1314 }
1415
1516 const store = createStore(window.__data)
1617 const history = createHistory()
@@ -30,10 +31,8 @@
3031 document.querySelector('main')
3132 )
3233
3334 if (process.env.NODE_ENV === 'development') {
34- const DevTools = require('app/dev/tools')
35-
3635 render(
3736 <Provider store={store} key="provider">
3837 <div>
3938 { main }
app/render.jsView
@@ -1,24 +1,22 @@
11 // https://github.com/jlongster/react-redux-universal-hot-example/blob/master/src/server.js
22
3-const http =require('http')
4-const Url = require('url')
5-const React = require('react')
6-const { renderToString } = require('react-dom/server')
7-const { Provider } = require('react-redux')
8-const { createHistory } = require('history')
9-const { Router, RoutingContext, match } = require('react-router')
10-const sendHtml = require('send-data/html')
11-const sendError = require('send-data/error')
12-const redirect = require('predirect')
3+import http from 'http'
4+import Url from 'url'
5+import React from 'react'
6+import { renderToString } from 'react-dom/server'
7+import { Provider } from 'react-redux'
8+import { createHistory } from 'history'
9+import { Router, RoutingContext, match } from 'react-router'
10+import sendHtml from 'send-data/html'
11+import sendError from 'send-data/error'
12+import redirect from 'predirect'
1313
14-const createStore = require('app/store')
15-const routes = require('app/routes')
16-const fetchAllData = require('app/util/fetch-all-data')
14+import createStore from 'app/store'
15+import routes from 'app/routes'
16+import fetchAllData from 'app/util/fetch-all-data'
1717
18-module.exports = createRender
19-
20-function createRender (config) {
18+export default function createRender (config) {
2119 const staticUrl = Url.format(config.static.url)
2220
2321 return http.createServer(render)
2422
app/routes.jsView
@@ -1,24 +1,22 @@
1-const React = require('react')
2-const { Route, IndexRoute } = require('react-router')
31 const bulk = require('bulk-require')
4-const { mapObjIndexed, values } = require('ramda')
2+import React from 'react'
3+import { Route, IndexRoute } from 'react-router'
4+import { mapObjIndexed, values } from 'ramda'
55
6-const LayoutContainer = require('app/layout/container')
7-const FourOhFourRoutes = require('app/four-oh-four/routes')
6+import LayoutContainer from 'app/layout/container'
7+import FourOhFourRoutes from 'app/four-oh-four/routes'
88
9-const routes = (
9+export default (
1010 <Route path='/' component={LayoutContainer}>
1111 {
1212 values(mapObjIndexed(
1313 (module, moduleName) => ({
14- ...module.routes,
14+ ...module.routes.default,
1515 key: moduleName
1616 }),
1717 bulk(__dirname, '!(four-oh-four)/routes.js')
1818 ))
1919 }
2020 { FourOhFourRoutes }
2121 </Route>
2222 )
23-
24-module.exports = routes
app/services/index.jsView
@@ -1,10 +1,13 @@
11 const bulk = require('bulk-require')
2-const { map } = require('ramda')
2+import { map } from 'ramda'
33
4-module.exports = {
5- ...bulk(__dirname, '*/service.js'),
4+export default {
65 ...map(
7- (module) => module.services,
6+ (module) => m.service.default,
7+ bulk(__dirname, '*/service.js')
8+ ),
9+ ...map(
10+ (module) => module.services.map(m => m.default),
811 bulk(__dirname, '*/services/*.js')
912 )
1013 }
app/stack/index.jsView
@@ -1,16 +1,14 @@
1-const feathers = require('feathers')
2-const { mapObjIndexed, reduce, toPairs } = require('ramda')
1+import feathers from 'feathers'
2+import { mapObjIndexed, reduce, toPairs } from 'ramda'
33
44 const stackCreators = {
55 services: require('./services'),
66 static: require('./static'),
77 render: require('./render')
88 }
99
10-module.exports = createStack
11-
12-function createStack(config) {
10+export default function createStack(config) {
1311 const stacks = createStacks(config)
1412
1513 const app = feathers()
1614
app/static.jsView
@@ -1,9 +1,7 @@
1-const http = require('http')
1+import http from 'http'
22
3-module.exports = createStatic
4-
5-function createStatic (config) {
3+export default function createStatic (config) {
64 const ecstatic = config.livereload ?
75 require('ecstatic-lr') : require('ecstatic')
86
97 return http.createServer(
app/store.jsView
@@ -1,10 +1,15 @@
1-const { createStore, compose, applyMiddleware } = require('redux')
2-const thunk = require('redux-thunk')
3-const { createHistory } = require('history')
1+import { createStore, compose, applyMiddleware } from 'redux'
2+import thunk from 'redux-thunk'
3+import { createHistory } from 'history'
44
5-const reducer = require('app/reducer')
5+import reducer from 'app/reducer'
66
7+if (process.env.NODE_ENV === 'development') {
8+ var logger = require('redux-logger')
9+ var DevTools = require('app/dev/tools').default
10+}
11+
712 let storeEnhancers = []
813 let middleware = []
914
1015 middleware.push(thunk)
@@ -13,14 +18,12 @@
1318 applyMiddleware(...middleware)
1419 )
1520
1621 if (process.env.NODE_ENV === 'development') {
17- let logger = require('redux-logger')
1822 storeEnhancers.push(
1923 applyMiddleware(logger())
2024 )
2125
22- let DevTools = require('app/dev/tools')
2326 storeEnhancers.push(DevTools.instrument())
2427
2528 if (module.browser) {
2629 let { persistState } = require('redux-devtools')
@@ -35,16 +38,15 @@
3538 const createEnhancedStore = compose(
3639 ...storeEnhancers
3740 )(createStore)
3841
39-function finalCreateStore(initialState) {
42+export default function finalCreateStore(initialState) {
43+ const store = createEnhancedStore(reducer, initialState)
4044
4145 if (module.hot) {
4246 module.hot.accept('app/reducer', () => {
4347 store.replaceReducer(require('app/reducer'))
4448 })
4549 }
4650
47- return createEnhancedStore(reducer, initialState)
51+ return store
4852 }
49-
50-module.exports = finalCreateStore
app/todos/container.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { connect } = require('react-redux')
1+import React from 'react'
2+import { connect } from 'react-redux'
33
44 class TodosContainer extends React.Component {
55 render () {
66 return <div>
@@ -8,7 +8,7 @@
88 </div>
99 }
1010 }
1111
12-module.exports = connect(
12+export default connect(
1313 (state) => ({})
1414 )(TodosContainer)
app/todos/reducer.jsView
@@ -1,7 +1,5 @@
1-module.exports = todos
2-
3-function todos (state = {}, action) {
1+export default function todos (state = {}, action) {
42 switch (action.type) {
53 case 'CREATE_TODO':
64 return {
75 ...state,
app/todos/routes.jsView
@@ -1,6 +1,6 @@
1-const React = require('react')
2-const { Route } = require('react-router')
1+import React from 'react'
2+import { Route } from 'react-router'
33
4-const TodosContainer = require('./container')
4+import TodosContainer from './container'
55
6-module.exports = <Route path="todos" component={TodosContainer} />
6+export default <Route path="todos" component={TodosContainer} />
app/util/fetch-all-data.jsView
@@ -1,11 +1,9 @@
11 // https://github.com/jlongster/react-redux-universal-hot-example/blob/master/src/helpers/fetchAllData.js
22
3-const Promise = require('pinkie-promise')
3+import Promise from 'pinkie-promise'
44
5-module.exports = fetchAllData
6-
7-function fetchAllData(components, getState, dispatch, location, params) {
5+export default function fetchAllData(components, getState, dispatch, location, params) {
86 const fetchers = components
97 .filter((component) => !!component) // Weed out 'undefined' routes
108 .filter((component) => component.fetchData) // only look at ones with a static fetchData()
119 .map((component) => component.fetchData) // pull out fetch data methods
app/util/fetch-element.jsView
@@ -1,9 +1,7 @@
1-const React = require('react')
1+import React from 'react'
22
3-module.exports = fetchElement
4-
5-function fetchElement (Component, props) {
3+export default function fetchElement (Component, props) {
64 if (Component.fetchData) {
75 Component.fetchData(
86 store.getState, store.dispatch,
97 props.location, props.params
render.jsView
@@ -1,9 +1,9 @@
11 require('babel-core/register')
22 require('css-modules-require-hook')
33
4-const config = require('app/config')
5-const createRender = require('app/render')
4+const config = require('app/config').default
5+const createRender = require('app/render').default
66 const Url = require('url')
77
88 const server = createRender(config)
99
static.jsView
@@ -1,6 +1,8 @@
1-const config = require('app/config')
2-const createStatic = require('app/static')
1+require('babel-core/register')
2+
3+const config = require('app/config').default
4+const createStatic = require('app/static').default
35 const Url = require('url')
46
57 const server = createStatic(config)
68

Built with git-ssb-web