react_webpack_rails 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -7
- data/CONTRIBUTING.md +1 -1
- data/README.md +0 -4
- data/docs/README.md +0 -5
- data/docs/hot_reloading.md +43 -0
- data/js/src/index.js +1 -0
- data/js/src/integrations/react.js +13 -1
- data/js/src/nodes.js +18 -13
- data/js/src/version.js +1 -1
- data/js/test/integrations/react.spec.js +18 -2
- data/js/test/nodes.spec.js +7 -1
- data/lib/generators/react_webpack_rails/install/core_generator.rb +1 -0
- data/lib/generators/react_webpack_rails/install/hot_reload_generator.rb +11 -0
- data/lib/generators/react_webpack_rails/install/view_helpers_generator.rb +1 -1
- data/lib/generators/react_webpack_rails/install_generator.rb +3 -1
- data/lib/generators/react_webpack_rails/templates/.eslintrc +9 -0
- data/lib/generators/react_webpack_rails/templates/forever/production.json +1 -1
- data/lib/generators/react_webpack_rails/templates/karma.conf.js +2 -2
- data/lib/generators/react_webpack_rails/templates/packages/core.json +22 -19
- data/lib/generators/react_webpack_rails/templates/packages/hot-reload.json +2 -2
- data/lib/generators/react_webpack_rails/templates/packages/js-specs.json +7 -7
- data/lib/generators/react_webpack_rails/templates/packages/redux.json +3 -3
- data/lib/generators/react_webpack_rails/templates/packages/server-side.json +2 -2
- data/lib/generators/react_webpack_rails/templates/packages/view-helpers.json +1 -1
- data/lib/generators/react_webpack_rails/templates/react/node_server.js +3 -2
- data/lib/generators/react_webpack_rails/templates/webpack.config.js +8 -6
- data/lib/generators/react_webpack_rails/templates/webpack/dev.config.js +5 -0
- data/lib/generators/react_webpack_rails/templates/webpack/hot-dev.config.js +9 -3
- data/lib/react_webpack_rails/node_integration_runner.rb +2 -0
- data/lib/react_webpack_rails/version.rb +1 -1
- data/lib/react_webpack_rails/view_helpers.rb +1 -1
- data/package.json +17 -14
- data/react_webpack_rails.gemspec +3 -3
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af9564bfb4b12c69e4d66eeac675460937160f2f
|
4
|
+
data.tar.gz: c3288864a9793770dc625a038dd4bf5bc1064ec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 216d8a5c7400488a76af02e6aff743622c34087bb696457dedb3a1e63847c10b2d9fa5966f8ef6fe1ee5df2a8572dd5d36c8f28126ea1713a30b38afbca0dce0
|
7
|
+
data.tar.gz: 6079da81cf633683d9c58a3a8e175b7f4265cdec441998f6058eee390ea495d7bf1fd03224204ae7a8f076b2e085f7133cf7a24514d36ee1655ed023daa7c0fb
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,90 @@
|
|
1
|
+
## 0.7.0
|
2
|
+
- updated packages
|
3
|
+
- added ready to use eslint setup
|
4
|
+
- added NODE_ENV eq 'development' for webpack dev config.
|
5
|
+
- fixed server-side render
|
6
|
+
|
7
|
+
#### migration 0.6.0 -> 0.7.0
|
8
|
+
- update your packges using [ncu](https://github.com/tjunnone/npm-check-updates) or manually in package.json.
|
9
|
+
- setup eslint
|
10
|
+
- install eslit-config-airbnb and it's dependencies:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
(
|
14
|
+
export PKG=eslint-config-airbnb;
|
15
|
+
npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
|
16
|
+
)
|
17
|
+
```
|
18
|
+
- add .eslintrc file in project root path:
|
19
|
+
|
20
|
+
```json
|
21
|
+
{
|
22
|
+
"extends": "airbnb",
|
23
|
+
"env": {
|
24
|
+
"mocha": true
|
25
|
+
},
|
26
|
+
"rules": {
|
27
|
+
"import/no-extraneous-dependencies": [0]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
```
|
31
|
+
- Set NODE_EVN in development:
|
32
|
+
|
33
|
+
in `dev.config.js` add:
|
34
|
+
|
35
|
+
```js
|
36
|
+
const Webpack = require('webpack');
|
37
|
+
[...]
|
38
|
+
config.plugins.push(
|
39
|
+
new Webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}})
|
40
|
+
);
|
41
|
+
```
|
42
|
+
- If using server-side render, update node_server.js - required by new httpdispatcher version,
|
43
|
+
|
44
|
+
replace:
|
45
|
+
|
46
|
+
```js
|
47
|
+
const dispatcher = require('httpdispatcher');
|
48
|
+
```
|
49
|
+
with:
|
50
|
+
|
51
|
+
```js
|
52
|
+
const httpdispatcher = require('httpdispatcher');
|
53
|
+
const dispatcher = new httpdispatcher();
|
54
|
+
```
|
55
|
+
|
56
|
+
|
57
|
+
## 0.6.0
|
58
|
+
- new way of registering component
|
59
|
+
```jsx
|
60
|
+
import RWR from 'react-webpack-rails'
|
61
|
+
import FileInput from './components/FileInput';
|
62
|
+
|
63
|
+
RWR.run();
|
64
|
+
RWR.registerComponent({ FileInput });
|
65
|
+
```
|
66
|
+
- new option to reg
|
67
|
+
```jsx
|
68
|
+
import RWR from 'react-webpack-rails'
|
69
|
+
import FileInput from './components/FileInput';
|
70
|
+
import RangeInput from './components/RangeInput';
|
71
|
+
import NumberInput from './components/NumberInput';
|
72
|
+
|
73
|
+
RWR.run();
|
74
|
+
RWR.registerComponents({ FileInput, RangeInput, NumberInput });
|
75
|
+
```
|
76
|
+
- add rwr-view_helpers to generators
|
77
|
+
- update node_server.js to modern one
|
78
|
+
- bump npm packages versions
|
79
|
+
|
1
80
|
## 0.5.0
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
81
|
+
- fixed forever setup - solving problems with running node server,
|
82
|
+
- renamed `react_element` -> `rwr_element`,
|
83
|
+
- dropped deprecated react_router integration,
|
84
|
+
- npm dependencies bump,
|
85
|
+
- support Rails 5:
|
86
|
+
- added Turbolinks 5 compatibility,
|
87
|
+
- added Rails 5 dummy app for testing.
|
9
88
|
|
10
89
|
|
11
90
|
#### migration 0.4.1 -> 0.5.0
|
data/CONTRIBUTING.md
CHANGED
@@ -8,7 +8,7 @@ Found a bug in React Webpack Rails? Open an issue on [GitHub Issues](https://git
|
|
8
8
|
|
9
9
|
Interested in contributing to React Webpack Rails? That's great, and thank you for your interest!
|
10
10
|
|
11
|
-
After checking out the repo, run `bundle exec rake setup:all` to install every environment dependencies.
|
11
|
+
After checking out the repo, switch to development branch & run `bundle exec rake setup:all` to install every environment dependencies.
|
12
12
|
|
13
13
|
To get your contributions accepted, make sure:
|
14
14
|
|
data/README.md
CHANGED
@@ -4,16 +4,12 @@
|
|
4
4
|
#### Rails - Webpack setup with React integration.
|
5
5
|
This gem provides easy and convenient way to build modern JavaScript stack on top of Rails applications using [Webpack](http://webpack.github.io/) and [React](https://facebook.github.io/react/).
|
6
6
|
|
7
|
-
### Development branch!
|
8
|
-
See [0.4-stable](https://github.com/netguru/react_webpack_rails/tree/0.4-stable) for latest release.
|
9
|
-
|
10
7
|
## Features
|
11
8
|
* [Install Generator](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md) for quick [Webpack](http://webpack.github.io/) setup.
|
12
9
|
* Integrated [react-hot-loader](https://github.com/gaearon/react-hot-loader)
|
13
10
|
* ES6/7 support with [babeljs](https://babeljs.io/).
|
14
11
|
* Node.js based [server-side JavaScript execution](https://github.com/netguru/react_webpack_rails/blob/master/docs/server_side_rendering.md).
|
15
12
|
* [React](https://facebook.github.io/react/) integration with server prerender option.
|
16
|
-
* [React-router](https://github.com/rackt/react-router) integration.
|
17
13
|
|
18
14
|
### Plugins:
|
19
15
|
* [rwr-alt](https://github.com/netguru/rwr-alt) plugin that makes it possible to populate and share Alt stores between react component located in different parts of rails views.
|
data/docs/README.md
CHANGED
@@ -9,11 +9,6 @@
|
|
9
9
|
* [js: unmountComponent](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#unmountcomponent)
|
10
10
|
* [ruby: react_component](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#react_component)
|
11
11
|
|
12
|
-
1.2 [ReactRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#ReactRouter)
|
13
|
-
* [js: getRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#getrouter)
|
14
|
-
* [js: renderRouter](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#renderrouter)
|
15
|
-
* [ruby: react_router](https://github.com/netguru/react_webpack_rails/blob/master/docs/api.md#react_router)
|
16
|
-
|
17
12
|
2. [Server-Side Rendering](https://github.com/netguru/react_webpack_rails/blob/master/docs/server_side_rendering.md)
|
18
13
|
|
19
14
|
3. [Install Generator](https://github.com/netguru/react_webpack_rails/blob/master/docs/install_generator.md)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Hot reloading
|
2
|
+
|
3
|
+
## Migration to react-hot-loader v3
|
4
|
+
|
5
|
+
RWR is now using react-hot-loader v3 instead of v1 (https://github.com/netguru/react_webpack_rails/pull/143)
|
6
|
+
|
7
|
+
V3 is a complete overhaul which fixes many problems with previous version, i.e. reloading functional components.
|
8
|
+
|
9
|
+
The upgrade requires a few steps which can be applied automatically via our generator:
|
10
|
+
|
11
|
+
```
|
12
|
+
bundle exec rails generate react_webpack_rails:install:hot_reload
|
13
|
+
```
|
14
|
+
|
15
|
+
|
16
|
+
Detailed steps are outlined below:
|
17
|
+
|
18
|
+
1. Bump `react-hot-loader` version in `package.json` file
|
19
|
+
|
20
|
+
```
|
21
|
+
"react-hot-loader": "^3.0.0-beta.6"
|
22
|
+
```
|
23
|
+
|
24
|
+
2. Replace react-hot with `react-hot-loader/webpack` in `webpack/hot-dev.config.js` file
|
25
|
+
|
26
|
+
```javascript
|
27
|
+
jsxLoader.loaders.unshift('react-hot-loader/webpack');
|
28
|
+
```
|
29
|
+
|
30
|
+
3. Add `react-hot-loader/patch` in `webpack/hot-dev.config.js` file
|
31
|
+
|
32
|
+
```javascript
|
33
|
+
config.entry.main.unshift('react-hot-loader/patch')
|
34
|
+
```
|
35
|
+
|
36
|
+
4. Add following code at the bottom of your `app/react/index.js` file to enable hot-reloading:
|
37
|
+
|
38
|
+
```javascript
|
39
|
+
if (module.hot) {
|
40
|
+
module.hot.accept();
|
41
|
+
RWR.reloadNodes();
|
42
|
+
}
|
43
|
+
```
|
data/js/src/index.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
import ReactDOMServer from 'react-dom/server';
|
4
|
+
import { AppContainer } from 'react-hot-loader';
|
4
5
|
|
5
6
|
class ReactIntegration {
|
6
7
|
constructor() {
|
@@ -33,11 +34,13 @@ class ReactIntegration {
|
|
33
34
|
|
34
35
|
createComponent(name, props) {
|
35
36
|
const constructor = this.getComponent(name);
|
36
|
-
|
37
|
+
const element = React.createElement(constructor, props);
|
38
|
+
return React.createElement(AppContainer, null, element);
|
37
39
|
}
|
38
40
|
|
39
41
|
renderComponent(name, props, node) {
|
40
42
|
const component = this.createComponent(name, props);
|
43
|
+
this._attachIntegrationData(node, name, props);
|
41
44
|
ReactDOM.render(component, node);
|
42
45
|
}
|
43
46
|
|
@@ -65,6 +68,15 @@ class ReactIntegration {
|
|
65
68
|
}.bind(this),
|
66
69
|
};
|
67
70
|
}
|
71
|
+
|
72
|
+
_attachIntegrationData(node, name, props) {
|
73
|
+
const nativeNode = node.selector ? node[0] : node; // normalize jquery objects to native nodes
|
74
|
+
const dataset = nativeNode.dataset;
|
75
|
+
if (dataset.rwrElement) return;
|
76
|
+
dataset.rwrElement = 'true';
|
77
|
+
dataset.integrationName = 'react-component';
|
78
|
+
dataset.payload = JSON.stringify({ name, props });
|
79
|
+
};
|
68
80
|
}
|
69
81
|
|
70
82
|
export default new ReactIntegration;
|
data/js/src/nodes.js
CHANGED
@@ -34,18 +34,23 @@ function _unmountNode(node) {
|
|
34
34
|
if (typeof(unmount) === 'function') { unmount(node, data.payload); }
|
35
35
|
}
|
36
36
|
|
37
|
+
function mountNodes(searchSelector) {
|
38
|
+
const nodes = _findDOMNodes(searchSelector);
|
39
|
+
for (let i = 0; i < nodes.length; ++i) {
|
40
|
+
_mountNode(nodes[i]);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
function unmountNodes(searchSelector) {
|
45
|
+
const nodes = _findDOMNodes(searchSelector);
|
46
|
+
for (let i = 0; i < nodes.length; ++i) {
|
47
|
+
_unmountNode(nodes[i]);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
37
51
|
export default {
|
38
|
-
mountNodes
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
},
|
44
|
-
|
45
|
-
unmountNodes: function _unmountNodes(searchSelector) {
|
46
|
-
const nodes = _findDOMNodes(searchSelector);
|
47
|
-
for (let i = 0; i < nodes.length; ++i) {
|
48
|
-
_unmountNode(nodes[i]);
|
49
|
-
}
|
50
|
-
},
|
52
|
+
mountNodes,
|
53
|
+
unmountNodes,
|
54
|
+
// Used after hot module replacement
|
55
|
+
reloadNodes: mountNodes,
|
51
56
|
};
|
data/js/src/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export default '0.
|
1
|
+
export default '0.7.0';
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import expect, { spyOn } from 'expect';
|
2
2
|
import React, { PropTypes } from 'react';
|
3
3
|
import ReactDOM from 'react-dom';
|
4
|
+
import { AppContainer } from 'react-hot-loader';
|
4
5
|
import subject from '../../src/integrations/react';
|
5
6
|
|
6
7
|
class HelloComponent extends React.Component {
|
@@ -70,10 +71,13 @@ describe('ReactIntegration', function () {
|
|
70
71
|
});
|
71
72
|
|
72
73
|
describe('#createComponent', function () {
|
73
|
-
it('creates component with given props', function () {
|
74
|
+
it('creates component with given props wrapped in AppContainer for hot-reloading', function () {
|
74
75
|
subject.registerComponent('HelloWorld', HelloComponent);
|
75
|
-
const
|
76
|
+
const wrapper = subject.createComponent('HelloWorld', { username: 'testUser' });
|
76
77
|
|
78
|
+
expect(wrapper.type).toBe(AppContainer);
|
79
|
+
|
80
|
+
const component = wrapper.props.children;
|
77
81
|
expect(component.props).toEqual({ username: 'testUser' });
|
78
82
|
expect(component.type).toBe(HelloComponent);
|
79
83
|
});
|
@@ -90,6 +94,18 @@ describe('ReactIntegration', function () {
|
|
90
94
|
});
|
91
95
|
});
|
92
96
|
|
97
|
+
describe('#renderComponent', function () {
|
98
|
+
it('attaches integration data to node', function () {
|
99
|
+
const node = { nodeType: 1, nodeName: 'DIV', dataset: {} };
|
100
|
+
const props = { key: 1 };
|
101
|
+
const reactSpy = spyOn(ReactDOM, 'render');
|
102
|
+
subject.renderComponent('componentName', props, node);
|
103
|
+
expect(node.dataset.rwrElement).toEqual('true');
|
104
|
+
expect(node.dataset.integrationName).toEqual('react-component');
|
105
|
+
expect(node.dataset.payload).toEqual('{"name":"componentName","props":{"key":1}}');
|
106
|
+
});
|
107
|
+
});
|
108
|
+
|
93
109
|
describe('#integrationWrapper', function () {
|
94
110
|
const node = { nodeType: 1, nodeName: 'DIV' };
|
95
111
|
|
data/js/test/nodes.spec.js
CHANGED
@@ -2,7 +2,7 @@ import expect, { spyOn, createSpy } from 'expect';
|
|
2
2
|
import Nodes from '../src/nodes';
|
3
3
|
import IntegrationsManager from '../src/integrations-manager';
|
4
4
|
|
5
|
-
const { mountNodes, unmountNodes } = Nodes;
|
5
|
+
const { mountNodes, unmountNodes, reloadNodes } = Nodes;
|
6
6
|
|
7
7
|
const node = {
|
8
8
|
nodeType: 1,
|
@@ -118,4 +118,10 @@ describe('Nodes', function () {
|
|
118
118
|
});
|
119
119
|
});
|
120
120
|
});
|
121
|
+
|
122
|
+
describe('#reloadNodes', function () {
|
123
|
+
it('is equal to mountNodes', function () {
|
124
|
+
expect(reloadNodes).toEqual(mountNodes);
|
125
|
+
});
|
126
|
+
});
|
121
127
|
});
|
@@ -37,6 +37,17 @@ module ReactWebpackRails
|
|
37
37
|
inject_into_file settings[:layout_file], settings[:parsed_command], after: "#{settings[:body_tag]}\n"
|
38
38
|
end
|
39
39
|
|
40
|
+
def index
|
41
|
+
append_to_file 'app/react/index.js' do <<-'JS'.strip_heredoc
|
42
|
+
|
43
|
+
if (module.hot) {
|
44
|
+
module.hot.accept();
|
45
|
+
RWR.reloadNodes();
|
46
|
+
}
|
47
|
+
JS
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
40
51
|
private
|
41
52
|
|
42
53
|
def template_language_settings(command)
|
@@ -16,12 +16,12 @@ module.exports = function (config) {
|
|
16
16
|
{
|
17
17
|
test: /\.jsx?$/,
|
18
18
|
exclude: /node_modules/,
|
19
|
-
loader: 'babel'
|
19
|
+
loader: 'babel-loader'
|
20
20
|
}]
|
21
21
|
},
|
22
22
|
watch: true,
|
23
23
|
resolve: {
|
24
|
-
extensions: ["
|
24
|
+
extensions: [".js", ".jsx", ".js.jsx"]
|
25
25
|
},
|
26
26
|
devtool: 'inline-source-map',
|
27
27
|
},
|
@@ -1,27 +1,30 @@
|
|
1
1
|
{
|
2
2
|
"private": true,
|
3
3
|
"devDependencies": {
|
4
|
-
"babel-eslint": "^
|
5
|
-
"eslint": "^
|
6
|
-
"eslint-
|
7
|
-
"
|
4
|
+
"babel-eslint": "^7.2.0",
|
5
|
+
"eslint": "^3.18.0",
|
6
|
+
"eslint-config-airbnb": "^13.0.0",
|
7
|
+
"eslint-plugin-import": "^2.2.0",
|
8
|
+
"eslint-plugin-jsx-a11y": "^2.2.0",
|
9
|
+
"eslint-plugin-react": "^6.7.0",
|
10
|
+
"webpack-notifier": "^1.5.0"
|
8
11
|
},
|
9
12
|
"dependencies": {
|
10
|
-
"babel-core": "^6.
|
11
|
-
"babel-loader": "^6.
|
12
|
-
"babel-preset-es2015": "^6.
|
13
|
-
"babel-preset-react": "^6.
|
14
|
-
"babel-preset-stage-1": "^6.
|
15
|
-
"css-loader": "^0.
|
16
|
-
"extract-text-webpack-plugin": "^1.0
|
17
|
-
"node-sass": "^
|
18
|
-
"react": "^15.
|
19
|
-
"react-addons-test-utils": "^15.
|
20
|
-
"react-dom": "^15.
|
21
|
-
"react-webpack-rails": "^0.
|
22
|
-
"sass-loader": "^
|
23
|
-
"style-loader": "^0.
|
24
|
-
"webpack": "^
|
13
|
+
"babel-core": "^6.24.0",
|
14
|
+
"babel-loader": "^6.4.1",
|
15
|
+
"babel-preset-es2015": "^6.24.0",
|
16
|
+
"babel-preset-react": "^6.23.0",
|
17
|
+
"babel-preset-stage-1": "^6.22.0",
|
18
|
+
"css-loader": "^0.27.3",
|
19
|
+
"extract-text-webpack-plugin": "^2.1.0",
|
20
|
+
"node-sass": "^4.5.1",
|
21
|
+
"react": "^15.4.2",
|
22
|
+
"react-addons-test-utils": "^15.4.2",
|
23
|
+
"react-dom": "^15.4.2",
|
24
|
+
"react-webpack-rails": "^0.6.0",
|
25
|
+
"sass-loader": "^6.0.3",
|
26
|
+
"style-loader": "^0.15.0",
|
27
|
+
"webpack": "^2.3.0"
|
25
28
|
},
|
26
29
|
"scripts": {
|
27
30
|
"start": "webpack -w --config webpack/dev.config.js",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
|
-
"react-hot-loader": "^
|
4
|
-
"webpack-dev-server": "^
|
3
|
+
"react-hot-loader": "^3.0.0-beta.6",
|
4
|
+
"webpack-dev-server": "^2.4.2"
|
5
5
|
},
|
6
6
|
"scripts": {
|
7
7
|
"start-hot-dev": "webpack-dev-server --hot --inline --config webpack/hot-dev.config.js"
|
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"devDependencies": {
|
3
3
|
"expect": "^1.20.0",
|
4
|
-
"karma": "^1.
|
5
|
-
"karma-chrome-launcher": "^
|
6
|
-
"karma-mocha": "^1.
|
7
|
-
"karma-sinon": "^1.0.
|
4
|
+
"karma": "^1.5.0",
|
5
|
+
"karma-chrome-launcher": "^2.0.0",
|
6
|
+
"karma-mocha": "^1.3.0",
|
7
|
+
"karma-sinon": "^1.0.5",
|
8
8
|
"karma-sourcemap-loader": "^0.3.7",
|
9
|
-
"karma-webpack": "^
|
10
|
-
"mocha": "^2.
|
11
|
-
"sinon": "^1.
|
9
|
+
"karma-webpack": "^2.0.3",
|
10
|
+
"mocha": "^3.2.0",
|
11
|
+
"sinon": "^2.1.0"
|
12
12
|
},
|
13
13
|
"scripts": {
|
14
14
|
"test": "karma start"
|
@@ -4,10 +4,11 @@ require('./index');
|
|
4
4
|
const fs = require('fs');
|
5
5
|
const path = require('path');
|
6
6
|
const http = require('http');
|
7
|
-
const
|
7
|
+
const httpdispatcher = require('httpdispatcher');
|
8
|
+
const dispatcher = new httpdispatcher();
|
8
9
|
const { integrationsManager } = require('react-webpack-rails');
|
9
10
|
|
10
|
-
const PORT = 8081;
|
11
|
+
const PORT = parseInt(process.env.PORT || 8081);
|
11
12
|
const ASSETS_MAPPING_PATH = 'tmp/cache/assets-mapping.json';
|
12
13
|
|
13
14
|
global.__RWR_ENV__ = {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
2
|
+
var path = require('path');
|
2
3
|
|
3
4
|
module.exports = {
|
4
5
|
entry: {
|
@@ -11,24 +12,25 @@ module.exports = {
|
|
11
12
|
module: {
|
12
13
|
loaders: [
|
13
14
|
{
|
14
|
-
key: 'jsx',
|
15
15
|
test: /\.jsx?$/,
|
16
16
|
exclude: /(node_modules)/,
|
17
|
-
loaders: ['babel']
|
17
|
+
loaders: ['babel-loader']
|
18
18
|
},
|
19
19
|
{
|
20
|
-
key: 'style',
|
21
20
|
test: /\.s?css$/,
|
22
21
|
loader: ExtractTextPlugin.extract('css!sass')
|
23
22
|
}
|
24
23
|
]
|
25
24
|
},
|
26
25
|
resolve: {
|
27
|
-
|
26
|
+
alias: {
|
27
|
+
'rwr-redux$': path.resolve(__dirname, '../../')
|
28
|
+
},
|
29
|
+
extensions: ['.js', '.jsx', '.js.jsx']
|
28
30
|
},
|
29
31
|
plugins: [
|
30
|
-
new ExtractTextPlugin(
|
31
|
-
allChunks: true
|
32
|
+
new ExtractTextPlugin({
|
33
|
+
filename: '../stylesheets/react_bundle.css', allChunks: true
|
32
34
|
})
|
33
35
|
]
|
34
36
|
};
|
@@ -1,7 +1,12 @@
|
|
1
|
+
const Webpack = require('webpack');
|
1
2
|
const WebpackNotifierPlugin = require('webpack-notifier');
|
2
3
|
const config = require('./../webpack.config');
|
3
4
|
|
4
5
|
config.plugins.push(new WebpackNotifierPlugin());
|
5
6
|
config.devtool = 'eval-source-map';
|
6
7
|
|
8
|
+
config.plugins.push(
|
9
|
+
new Webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}})
|
10
|
+
);
|
11
|
+
|
7
12
|
module.exports = config;
|
@@ -1,9 +1,13 @@
|
|
1
1
|
var config = require('./dev.config');
|
2
2
|
|
3
|
-
var jsxLoader = config.module.loaders.filter(function(loader) {
|
4
|
-
|
3
|
+
var jsxLoader = config.module.loaders.filter(function(loader) {
|
4
|
+
return /jsx/.test(loader.test);
|
5
|
+
})[0];
|
6
|
+
jsxLoader.loaders.unshift('react-hot-loader/webpack');
|
5
7
|
|
6
|
-
var scssLoader = config.module.loaders.filter(function(loader) {
|
8
|
+
var scssLoader = config.module.loaders.filter(function(loader) {
|
9
|
+
return /s?css/.test(loader.test);
|
10
|
+
})[0];
|
7
11
|
scssLoader.loader = 'style!css!sass!';
|
8
12
|
|
9
13
|
config.output.publicPath = 'http://localhost:8080/assets/'
|
@@ -13,4 +17,6 @@ config.entry.main.push(
|
|
13
17
|
'webpack-dev-server/client?http://localhost:8080'
|
14
18
|
)
|
15
19
|
|
20
|
+
config.entry.main.unshift('react-hot-loader/patch')
|
21
|
+
|
16
22
|
module.exports = config;
|
@@ -14,7 +14,7 @@ module ReactWebpackRails
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def react_element(integration_name, payload = {}, html_options = {}, &block)
|
17
|
-
message = 'since v0.5.0: react_element is
|
17
|
+
message = 'since v0.5.0: react_element is deprecated. Use rwr_element instead'
|
18
18
|
ActiveSupport::Deprecation.warn message
|
19
19
|
|
20
20
|
rwr_element(integration_name, payload, html_options, &block)
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-webpack-rails",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.7.0",
|
4
4
|
"description": "Js part of react_webpack_rails - webpack based React & Rails integration.",
|
5
5
|
"main": "js/lib/index.js",
|
6
6
|
"files": [
|
@@ -28,20 +28,23 @@
|
|
28
28
|
},
|
29
29
|
"homepage": "https://github.com/netguru/react_webpack_rails#readme",
|
30
30
|
"dependencies": {
|
31
|
-
"babel-polyfill": "^6.
|
32
|
-
"react": "^15.
|
33
|
-
"react-dom": "^15.
|
31
|
+
"babel-polyfill": "^6.23.0",
|
32
|
+
"react": "^15.4.2",
|
33
|
+
"react-dom": "^15.4.2",
|
34
|
+
"react-hot-loader": "^3.0.0-beta.6"
|
34
35
|
},
|
35
36
|
"devDependencies": {
|
36
|
-
"babel-cli": "^6.
|
37
|
-
"babel-core": "^6.
|
38
|
-
"babel-preset-es2015": "^6.
|
39
|
-
"babel-preset-react": "^6.
|
40
|
-
"eslint": "^
|
41
|
-
"eslint-config-airbnb": "^
|
42
|
-
"eslint-plugin-
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
37
|
+
"babel-cli": "^6.24.0",
|
38
|
+
"babel-core": "^6.24.0",
|
39
|
+
"babel-preset-es2015": "^6.24.0",
|
40
|
+
"babel-preset-react": "^6.23.0",
|
41
|
+
"eslint": "^3.17.1",
|
42
|
+
"eslint-config-airbnb": "^14.1.0",
|
43
|
+
"eslint-plugin-import": "^2.2.0",
|
44
|
+
"eslint-plugin-jsx-a11y": "^4.0.0",
|
45
|
+
"eslint-plugin-react": "^6.10.0",
|
46
|
+
"expect": "^1.20.2",
|
47
|
+
"history": "^4.6.0",
|
48
|
+
"mocha": "^3.2.0"
|
46
49
|
}
|
47
50
|
}
|
data/react_webpack_rails.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
27
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.14.6'
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
28
28
|
|
29
29
|
spec.add_dependency 'rails', '>= 3.2'
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_webpack_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Gawlik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 1.14.6
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 1.14.6
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '12.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '12.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '3.
|
48
|
+
version: '3.5'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
55
|
+
version: '3.5'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rails
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- docs/README.md
|
92
92
|
- docs/api.md
|
93
93
|
- docs/deployment.md
|
94
|
+
- docs/hot_reloading.md
|
94
95
|
- docs/install_generator.md
|
95
96
|
- docs/server_side_rendering.md
|
96
97
|
- js/.eslintrc
|
@@ -116,6 +117,7 @@ files:
|
|
116
117
|
- lib/generators/react_webpack_rails/merge_helpers.rb
|
117
118
|
- lib/generators/react_webpack_rails/package_merge.rb
|
118
119
|
- lib/generators/react_webpack_rails/templates/.babelrc
|
120
|
+
- lib/generators/react_webpack_rails/templates/.eslintrc
|
119
121
|
- lib/generators/react_webpack_rails/templates/examples/component_view.html.erb
|
120
122
|
- lib/generators/react_webpack_rails/templates/examples/react_examples_controller.rb
|
121
123
|
- lib/generators/react_webpack_rails/templates/examples/ssr-component_view.html.erb
|
@@ -172,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
174
|
version: '0'
|
173
175
|
requirements: []
|
174
176
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.6.10
|
176
178
|
signing_key:
|
177
179
|
specification_version: 4
|
178
180
|
summary: React and Rails integration done with webpack
|