webpacker-react 0.3.2 → 1.0.0.beta.1
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 +5 -5
- data/.circleci/config.yml +32 -0
- data/.rubocop.yml +22 -22
- data/CHANGELOG.md +17 -1
- data/Gemfile +3 -2
- data/Gemfile.lock +122 -104
- data/LICENSE +21 -0
- data/README.md +27 -61
- data/Rakefile +1 -1
- data/javascript/webpacker_react-npm-module/.babelrc +7 -0
- data/javascript/webpacker_react-npm-module/dist/package.json +5 -3
- data/javascript/webpacker_react-npm-module/dist/yarn.lock +9 -0
- data/javascript/webpacker_react-npm-module/package.json +7 -7
- data/javascript/webpacker_react-npm-module/src/configure-hot-module-replacement.js +2 -17
- data/javascript/webpacker_react-npm-module/src/index.js +4 -28
- data/javascript/webpacker_react-npm-module/src/ujs.js +3 -3
- data/javascript/webpacker_react-npm-module/yarn.lock +1773 -1170
- data/lib/webpacker/react/version.rb +1 -1
- data/webpacker-react.gemspec +12 -11
- metadata +14 -14
- data/.travis.yml +0 -5
- data/circle.yml +0 -14
- data/javascript/webpacker_react-npm-module/src/hmr.js +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 930b01c3e56e79e4a3bc2a9044f876b39802b1029e40dc5e834460caafe0b481
|
4
|
+
data.tar.gz: 22ba3c95472fb5959268db7d5c60a3e622dd6c578ef5633075de6f27aabd0b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40feed327e3343148088b78ff4a09859abedb834287ce4dc90036c0089b391de4efe7a0b33e353a97f433ee7b216594e18e13f2394d431e5b25dee8f5c2905a7
|
7
|
+
data.tar.gz: 45f3d6733482d021e750afaa21093cd84b1f4f49d1a71a468b93ce18e7320729a7c4280d33c62209e1d196ac9aca184995ca7302e43eeed661764e7491852ba8
|
@@ -0,0 +1,32 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
working_directory: ~/webpacker-react
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.4.3-node-browsers
|
7
|
+
environment:
|
8
|
+
RAILS_ENV: test
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
|
12
|
+
# Install dependencies
|
13
|
+
- run:
|
14
|
+
name: bundle install
|
15
|
+
command: bundle install --path=vendor/bundle --jobs=4 --retry=3
|
16
|
+
- run:
|
17
|
+
command: yarn
|
18
|
+
pwd: javascript/webpacker_react-npm-module
|
19
|
+
- run:
|
20
|
+
command: yarn
|
21
|
+
pwd: javascript/webpacker_react-npm-module/dist
|
22
|
+
|
23
|
+
# Lint
|
24
|
+
- run:
|
25
|
+
command: yarn lint
|
26
|
+
pwd: javascript/webpacker_react-npm-module
|
27
|
+
- run:
|
28
|
+
command: bundle exec rubocop
|
29
|
+
|
30
|
+
# Tests
|
31
|
+
- run:
|
32
|
+
command: bundle exec rake test
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.3
|
3
3
|
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
|
4
4
|
# to ignore them, so only the ones explicitly set in this file are enabled.
|
5
5
|
DisabledByDefault: true
|
@@ -17,23 +17,23 @@ Style/BracesAroundHashParameters:
|
|
17
17
|
Enabled: true
|
18
18
|
|
19
19
|
# Align `when` with `case`.
|
20
|
-
|
20
|
+
Layout/CaseIndentation:
|
21
21
|
Enabled: true
|
22
22
|
|
23
23
|
# Align comments with method definitions.
|
24
|
-
|
24
|
+
Layout/CommentIndentation:
|
25
25
|
Enabled: true
|
26
26
|
|
27
27
|
# No extra empty lines.
|
28
|
-
|
28
|
+
Layout/EmptyLines:
|
29
29
|
Enabled: true
|
30
30
|
|
31
31
|
# In a regular class definition, no empty lines around the body.
|
32
|
-
|
32
|
+
Layout/EmptyLinesAroundClassBody:
|
33
33
|
Enabled: true
|
34
34
|
|
35
35
|
# In a regular module definition, no empty lines around the body.
|
36
|
-
|
36
|
+
Layout/EmptyLinesAroundModuleBody:
|
37
37
|
Enabled: true
|
38
38
|
|
39
39
|
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
@@ -42,30 +42,30 @@ Style/HashSyntax:
|
|
42
42
|
|
43
43
|
# Method definitions after `private` or `protected` isolated calls need one
|
44
44
|
# extra level of indentation.
|
45
|
-
|
45
|
+
Layout/IndentationConsistency:
|
46
46
|
Enabled: true
|
47
|
-
EnforcedStyle:
|
47
|
+
EnforcedStyle: indented_internal_methods
|
48
48
|
|
49
49
|
# Two spaces, no tabs (for indentation).
|
50
|
-
|
50
|
+
Layout/IndentationWidth:
|
51
51
|
Enabled: true
|
52
52
|
|
53
|
-
|
53
|
+
Layout/SpaceAfterColon:
|
54
54
|
Enabled: true
|
55
55
|
|
56
|
-
|
56
|
+
Layout/SpaceAfterComma:
|
57
57
|
Enabled: true
|
58
58
|
|
59
|
-
|
59
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
60
60
|
Enabled: true
|
61
61
|
|
62
|
-
|
62
|
+
Layout/SpaceAroundKeyword:
|
63
63
|
Enabled: true
|
64
64
|
|
65
|
-
|
65
|
+
Layout/SpaceAroundOperators:
|
66
66
|
Enabled: true
|
67
67
|
|
68
|
-
|
68
|
+
Layout/SpaceBeforeFirstArg:
|
69
69
|
Enabled: true
|
70
70
|
|
71
71
|
# Defining a method with parameters needs parentheses.
|
@@ -73,18 +73,18 @@ Style/MethodDefParentheses:
|
|
73
73
|
Enabled: true
|
74
74
|
|
75
75
|
# Use `foo {}` not `foo{}`.
|
76
|
-
|
76
|
+
Layout/SpaceBeforeBlockBraces:
|
77
77
|
Enabled: true
|
78
78
|
|
79
79
|
# Use `foo { bar }` not `foo {bar}`.
|
80
|
-
|
80
|
+
Layout/SpaceInsideBlockBraces:
|
81
81
|
Enabled: true
|
82
82
|
|
83
83
|
# Use `{ a: 1 }` not `{a:1}`.
|
84
|
-
|
84
|
+
Layout/SpaceInsideHashLiteralBraces:
|
85
85
|
Enabled: true
|
86
86
|
|
87
|
-
|
87
|
+
Layout/SpaceInsideParens:
|
88
88
|
Enabled: true
|
89
89
|
|
90
90
|
# Check quotes usage according to lint rule below.
|
@@ -93,15 +93,15 @@ Style/StringLiterals:
|
|
93
93
|
EnforcedStyle: double_quotes
|
94
94
|
|
95
95
|
# Detect hard tabs, no hard tabs.
|
96
|
-
|
96
|
+
Layout/Tab:
|
97
97
|
Enabled: true
|
98
98
|
|
99
99
|
# Blank lines should not have any spaces.
|
100
|
-
|
100
|
+
Layout/TrailingBlankLines:
|
101
101
|
Enabled: true
|
102
102
|
|
103
103
|
# No trailing whitespace.
|
104
|
-
|
104
|
+
Layout/TrailingWhitespace:
|
105
105
|
Enabled: true
|
106
106
|
|
107
107
|
# Use quotes for string literals when they are enough.
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.0-beta.1]
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- Instructions to set up `react-hot-loader` 4 (fixed #51)
|
13
|
+
|
14
|
+
### Updated
|
15
|
+
- Instructions for setting up `webpacker-react` with a modern Webpacker version
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Tests now uses headless chrome instead of Poltergeist
|
19
|
+
- Babel is configured with `babel-preset-env`
|
20
|
+
|
21
|
+
### Removed
|
22
|
+
- Support for `react-hot-loader`. Please look at the README for instructions on how to use `react-hot-loader` 4 with your app, it is much simpler and better!
|
23
|
+
|
9
24
|
## [0.3.2] - 2017-09-13
|
10
25
|
|
11
26
|
### Fixed
|
@@ -39,7 +54,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
39
54
|
- render React components from controllers using `render react_component: 'name'` (#1 by @daninfpj)
|
40
55
|
- basic Hot Module Remplacement (#7 by @mfazekas)
|
41
56
|
|
42
|
-
[Unreleased]: https://github.com/renchap/webpacker-react/compare/
|
57
|
+
[Unreleased]: https://github.com/renchap/webpacker-react/compare/v1.0.0-beta.1...HEAD
|
58
|
+
[1.0.0-beta.1]: https://github.com/renchap/webpacker-react/tree/v1.0.0-beta.1
|
43
59
|
[0.3.2]: https://github.com/renchap/webpacker-react/tree/v0.3.2
|
44
60
|
[0.3.1]: https://github.com/renchap/webpacker-react/tree/v0.3.1
|
45
61
|
[0.3.0]: https://github.com/renchap/webpacker-react/tree/v0.3.0
|
data/Gemfile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gem "rubocop", ">= 0.47", require: false
|
4
|
-
gem "rails", "~> 5.
|
5
|
-
gem "webpacker", "~>
|
4
|
+
gem "rails", "~> 5.2.0"
|
5
|
+
gem "webpacker", "~> 4.0.0"
|
6
|
+
gem "puma", "~> 4.0"
|
6
7
|
|
7
8
|
# Specify your gem's dependencies in webpacker-react.gemspec
|
8
9
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,145 +1,162 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webpacker-react (0.
|
4
|
+
webpacker-react (0.4.0)
|
5
5
|
webpacker
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (5.
|
11
|
-
actionpack (= 5.
|
10
|
+
actioncable (5.2.3)
|
11
|
+
actionpack (= 5.2.3)
|
12
12
|
nio4r (~> 2.0)
|
13
|
-
websocket-driver (
|
14
|
-
actionmailer (5.
|
15
|
-
actionpack (= 5.
|
16
|
-
actionview (= 5.
|
17
|
-
activejob (= 5.
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailer (5.2.3)
|
15
|
+
actionpack (= 5.2.3)
|
16
|
+
actionview (= 5.2.3)
|
17
|
+
activejob (= 5.2.3)
|
18
18
|
mail (~> 2.5, >= 2.5.4)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.
|
21
|
-
actionview (= 5.
|
22
|
-
activesupport (= 5.
|
20
|
+
actionpack (5.2.3)
|
21
|
+
actionview (= 5.2.3)
|
22
|
+
activesupport (= 5.2.3)
|
23
23
|
rack (~> 2.0)
|
24
|
-
rack-test (
|
24
|
+
rack-test (>= 0.6.3)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.
|
28
|
-
activesupport (= 5.
|
27
|
+
actionview (5.2.3)
|
28
|
+
activesupport (= 5.2.3)
|
29
29
|
builder (~> 3.1)
|
30
30
|
erubi (~> 1.4)
|
31
31
|
rails-dom-testing (~> 2.0)
|
32
32
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.
|
34
|
-
activesupport (= 5.
|
33
|
+
activejob (5.2.3)
|
34
|
+
activesupport (= 5.2.3)
|
35
35
|
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.
|
37
|
-
activesupport (= 5.
|
38
|
-
activerecord (5.
|
39
|
-
activemodel (= 5.
|
40
|
-
activesupport (= 5.
|
41
|
-
arel (
|
42
|
-
|
36
|
+
activemodel (5.2.3)
|
37
|
+
activesupport (= 5.2.3)
|
38
|
+
activerecord (5.2.3)
|
39
|
+
activemodel (= 5.2.3)
|
40
|
+
activesupport (= 5.2.3)
|
41
|
+
arel (>= 9.0)
|
42
|
+
activestorage (5.2.3)
|
43
|
+
actionpack (= 5.2.3)
|
44
|
+
activerecord (= 5.2.3)
|
45
|
+
marcel (~> 0.3.1)
|
46
|
+
activesupport (5.2.3)
|
43
47
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
|
-
i18n (
|
48
|
+
i18n (>= 0.7, < 2)
|
45
49
|
minitest (~> 5.1)
|
46
50
|
tzinfo (~> 1.1)
|
47
|
-
addressable (2.
|
48
|
-
public_suffix (
|
49
|
-
arel (
|
50
|
-
ast (2.
|
51
|
+
addressable (2.6.0)
|
52
|
+
public_suffix (>= 2.0.2, < 4.0)
|
53
|
+
arel (9.0.0)
|
54
|
+
ast (2.4.0)
|
51
55
|
builder (3.2.3)
|
52
|
-
capybara (
|
56
|
+
capybara (3.25.0)
|
53
57
|
addressable
|
54
|
-
|
55
|
-
nokogiri (
|
56
|
-
rack (>= 1.
|
57
|
-
rack-test (>= 0.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
mini_mime (>= 0.1.3)
|
59
|
+
nokogiri (~> 1.8)
|
60
|
+
rack (>= 1.6.0)
|
61
|
+
rack-test (>= 0.6.3)
|
62
|
+
regexp_parser (~> 1.5)
|
63
|
+
xpath (~> 3.2)
|
64
|
+
childprocess (1.0.1)
|
65
|
+
rake (< 13.0)
|
66
|
+
concurrent-ruby (1.1.5)
|
67
|
+
crass (1.0.4)
|
68
|
+
erubi (1.8.0)
|
69
|
+
globalid (0.4.2)
|
63
70
|
activesupport (>= 4.2.0)
|
64
|
-
i18n (
|
65
|
-
|
71
|
+
i18n (1.6.0)
|
72
|
+
concurrent-ruby (~> 1.0)
|
73
|
+
jaro_winkler (1.5.3)
|
74
|
+
loofah (2.2.3)
|
75
|
+
crass (~> 1.0.2)
|
66
76
|
nokogiri (>= 1.5.9)
|
67
|
-
mail (2.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
nio4r (2.
|
77
|
-
nokogiri (1.
|
78
|
-
mini_portile2 (~> 2.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
rack-test (
|
89
|
-
rack (>= 1.0)
|
90
|
-
rails (5.
|
91
|
-
actioncable (= 5.
|
92
|
-
actionmailer (= 5.
|
93
|
-
actionpack (= 5.
|
94
|
-
actionview (= 5.
|
95
|
-
activejob (= 5.
|
96
|
-
activemodel (= 5.
|
97
|
-
activerecord (= 5.
|
98
|
-
|
99
|
-
|
100
|
-
|
77
|
+
mail (2.7.1)
|
78
|
+
mini_mime (>= 0.1.1)
|
79
|
+
marcel (0.3.3)
|
80
|
+
mimemagic (~> 0.3.2)
|
81
|
+
method_source (0.9.2)
|
82
|
+
mimemagic (0.3.3)
|
83
|
+
mini_mime (1.0.2)
|
84
|
+
mini_portile2 (2.4.0)
|
85
|
+
minitest (5.11.3)
|
86
|
+
nio4r (2.4.0)
|
87
|
+
nokogiri (1.10.3)
|
88
|
+
mini_portile2 (~> 2.4.0)
|
89
|
+
parallel (1.17.0)
|
90
|
+
parser (2.6.3.0)
|
91
|
+
ast (~> 2.4.0)
|
92
|
+
public_suffix (3.1.1)
|
93
|
+
puma (4.0.0)
|
94
|
+
nio4r (~> 2.0)
|
95
|
+
rack (2.0.7)
|
96
|
+
rack-proxy (0.6.5)
|
97
|
+
rack
|
98
|
+
rack-test (1.1.0)
|
99
|
+
rack (>= 1.0, < 3)
|
100
|
+
rails (5.2.3)
|
101
|
+
actioncable (= 5.2.3)
|
102
|
+
actionmailer (= 5.2.3)
|
103
|
+
actionpack (= 5.2.3)
|
104
|
+
actionview (= 5.2.3)
|
105
|
+
activejob (= 5.2.3)
|
106
|
+
activemodel (= 5.2.3)
|
107
|
+
activerecord (= 5.2.3)
|
108
|
+
activestorage (= 5.2.3)
|
109
|
+
activesupport (= 5.2.3)
|
110
|
+
bundler (>= 1.3.0)
|
111
|
+
railties (= 5.2.3)
|
101
112
|
sprockets-rails (>= 2.0.0)
|
102
113
|
rails-dom-testing (2.0.3)
|
103
114
|
activesupport (>= 4.2.0)
|
104
115
|
nokogiri (>= 1.6)
|
105
|
-
rails-html-sanitizer (1.0.
|
106
|
-
loofah (~> 2.
|
107
|
-
railties (5.
|
108
|
-
actionpack (= 5.
|
109
|
-
activesupport (= 5.
|
116
|
+
rails-html-sanitizer (1.0.4)
|
117
|
+
loofah (~> 2.2, >= 2.2.2)
|
118
|
+
railties (5.2.3)
|
119
|
+
actionpack (= 5.2.3)
|
120
|
+
activesupport (= 5.2.3)
|
110
121
|
method_source
|
111
122
|
rake (>= 0.8.7)
|
112
|
-
thor (>= 0.
|
113
|
-
rainbow (
|
114
|
-
rake (
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
123
|
+
thor (>= 0.19.0, < 2.0)
|
124
|
+
rainbow (3.0.0)
|
125
|
+
rake (12.3.2)
|
126
|
+
regexp_parser (1.5.1)
|
127
|
+
rubocop (0.72.0)
|
128
|
+
jaro_winkler (~> 1.5.1)
|
129
|
+
parallel (~> 1.10)
|
130
|
+
parser (>= 2.6)
|
131
|
+
rainbow (>= 2.2.2, < 4.0)
|
119
132
|
ruby-progressbar (~> 1.7)
|
120
|
-
unicode-display_width (
|
121
|
-
ruby-progressbar (1.
|
122
|
-
|
133
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
134
|
+
ruby-progressbar (1.10.1)
|
135
|
+
rubyzip (1.2.3)
|
136
|
+
selenium-webdriver (3.142.3)
|
137
|
+
childprocess (>= 0.5, < 2.0)
|
138
|
+
rubyzip (~> 1.2, >= 1.2.2)
|
139
|
+
sprockets (3.7.2)
|
123
140
|
concurrent-ruby (~> 1.0)
|
124
141
|
rack (> 1, < 3)
|
125
|
-
sprockets-rails (3.2.
|
142
|
+
sprockets-rails (3.2.1)
|
126
143
|
actionpack (>= 4.0)
|
127
144
|
activesupport (>= 4.0)
|
128
145
|
sprockets (>= 3.0.0)
|
129
|
-
thor (0.
|
146
|
+
thor (0.20.3)
|
130
147
|
thread_safe (0.3.6)
|
131
|
-
tzinfo (1.2.
|
148
|
+
tzinfo (1.2.5)
|
132
149
|
thread_safe (~> 0.1)
|
133
|
-
unicode-display_width (1.
|
134
|
-
webpacker (
|
150
|
+
unicode-display_width (1.6.0)
|
151
|
+
webpacker (4.0.7)
|
135
152
|
activesupport (>= 4.2)
|
136
|
-
|
153
|
+
rack-proxy (>= 0.6.1)
|
137
154
|
railties (>= 4.2)
|
138
|
-
websocket-driver (0.
|
155
|
+
websocket-driver (0.7.1)
|
139
156
|
websocket-extensions (>= 0.1.0)
|
140
|
-
websocket-extensions (0.1.
|
141
|
-
xpath (2.0
|
142
|
-
nokogiri (~> 1.
|
157
|
+
websocket-extensions (0.1.4)
|
158
|
+
xpath (3.2.0)
|
159
|
+
nokogiri (~> 1.8)
|
143
160
|
|
144
161
|
PLATFORMS
|
145
162
|
ruby
|
@@ -148,12 +165,13 @@ DEPENDENCIES
|
|
148
165
|
bundler (~> 1.13)
|
149
166
|
capybara
|
150
167
|
minitest (~> 5.0)
|
151
|
-
|
152
|
-
rails (~> 5.
|
153
|
-
rake (~>
|
168
|
+
puma (~> 4.0)
|
169
|
+
rails (~> 5.2.0)
|
170
|
+
rake (~> 12.0)
|
154
171
|
rubocop (>= 0.47)
|
155
|
-
|
172
|
+
selenium-webdriver
|
173
|
+
webpacker (~> 4.0.0)
|
156
174
|
webpacker-react!
|
157
175
|
|
158
176
|
BUNDLED WITH
|
159
|
-
1.
|
177
|
+
1.17.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Renaud Chaput
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Webpacker-React [](https://circleci.com/gh/renchap/webpacker-react)
|
2
2
|
|
3
|
-
*__Note:__ This is the documentation for the Git master branch. Documentation for the latest release (0.
|
3
|
+
*__Note:__ This is the documentation for the Git master branch. Documentation for the latest release (1.0.0-beta.1) is [available here](https://github.com/renchap/webpacker-react/tree/v0.3.2).*
|
4
4
|
|
5
5
|
Webpacker-React makes it easy to use [React](https://facebook.github.io/react/) with [Webpacker](https://github.com/rails/webpacker) in your Rails applications.
|
6
6
|
|
@@ -15,7 +15,7 @@ Your Rails application needs to use Webpacker and have the React integration don
|
|
15
15
|
First, you need to add the webpacker-react gem to your Rails app Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem 'webpacker-react', "~> 0.
|
18
|
+
gem 'webpacker-react', "~> 1.0.0.beta.1"
|
19
19
|
```
|
20
20
|
|
21
21
|
Once done, run `bundle` to install the gem.
|
@@ -105,79 +105,45 @@ You can also pass any of the usual arguments to `render` in this call: `layout`,
|
|
105
105
|
|
106
106
|
### Hot Module Replacement
|
107
107
|
|
108
|
-
[HMR](https://webpack.js.org/
|
108
|
+
[HMR](https://webpack.js.org/concepts/hot-module-replacement/) allows to reload / add / remove modules live in the browser without
|
109
109
|
reloading the page. This allows any change you make to your React components to be applied as soon as you save,
|
110
110
|
preserving their current state.
|
111
111
|
|
112
|
-
|
112
|
+
1. install `react-hot-loader` (version 4):
|
113
|
+
```
|
114
|
+
./bin/yarn add react-hot-loader@4
|
115
|
+
```
|
113
116
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
You then need to update your Webpack config.
|
117
|
+
2. update your Babel or Webpack config. We provide a convenience function to add the necessary changes to your config if it's not significantly different than the standard Webpacker config:
|
118
|
+
```js
|
119
|
+
// config/webpack/development.js
|
120
|
+
// This assumes Webpacker 3+
|
119
121
|
|
120
|
-
|
121
|
-
|
122
|
+
const environment = require("./environment")
|
123
|
+
const webpackerReactconfigureHotModuleReplacement = require('webpacker-react/configure-hot-module-replacement')
|
122
124
|
|
123
|
-
|
124
|
-
//development.js
|
125
|
-
...
|
125
|
+
const config = environment.toWebpackConfig()
|
126
126
|
|
127
|
-
|
128
|
-
|
127
|
+
module.exports = webpackerReactconfigureHotModuleReplacement(config)
|
128
|
+
```
|
129
129
|
|
130
|
-
|
131
|
-
```
|
132
|
-
|
133
|
-
If you need to change your configuration manually:
|
134
|
-
|
135
|
-
1. add `react-hot-loader/babel` to your `babel-loader` rules:
|
136
|
-
```javascript
|
137
|
-
{
|
138
|
-
module: {
|
139
|
-
rules: [
|
140
|
-
{
|
141
|
-
test: /\.jsx?(.erb)?$/,
|
142
|
-
exclude: /node_modules/,
|
143
|
-
loader: 'babel-loader',
|
144
|
-
options: {
|
145
|
-
plugins: ['react-hot-loader/babel']
|
146
|
-
}
|
147
|
-
}
|
148
|
-
}
|
149
|
-
```
|
130
|
+
If you prefer to do it manually, you need to add `react-hot-loader/babel` in your Babel plugins (in your `.babelrc` or `.babelrc.js`). You can include it only for development.
|
150
131
|
|
151
|
-
|
152
|
-
```javascript
|
153
|
-
{
|
154
|
-
entry:
|
155
|
-
{ application: [ 'react-hot-loader/patch', '../app/javascript/packs/application.js' ],
|
156
|
-
...
|
157
|
-
}
|
158
|
-
```
|
132
|
+
3. once Babel is configured, `webpack-dev-server` needs to be set up for HMR. This is easy, just switch `hmr: true` in your `webpacker.yml` for development!
|
159
133
|
|
160
|
-
|
161
|
-
```ruby
|
162
|
-
config.x.webpacker[:dev_server_host] = 'http://localhost:8080/'
|
163
|
-
```
|
164
|
-
and start `webpack-dev-server` in hot replacement mode:
|
165
|
-
```
|
166
|
-
./bin/webpack-dev-server --hot
|
167
|
-
```
|
134
|
+
4. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`).
|
168
135
|
|
169
|
-
|
136
|
+
5. finally, enable React Hot Loader for your root components (the ones you register with `WebpackerReact.setup`):
|
170
137
|
```es6
|
171
|
-
|
172
|
-
import
|
138
|
+
// For example in app/javascripts/components/hello.js
|
139
|
+
import React from 'react'
|
140
|
+
import { hot } from 'react-hot-loader'
|
173
141
|
|
174
|
-
|
175
|
-
if (module.hot)
|
176
|
-
module.hot.accept('components/some-root-react-component', () =>
|
177
|
-
WebpackerReact.renderOnHMR(SomeRootReactComponent) )
|
178
|
-
```
|
142
|
+
const Hello = () => <div>Hello World!</div>
|
179
143
|
|
180
|
-
|
144
|
+
// This is the important line!
|
145
|
+
export default hot(module)(Hello)
|
146
|
+
```
|
181
147
|
|
182
148
|
## Development
|
183
149
|
|
data/Rakefile
CHANGED