webpacker-react 0.3.2 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd82216b4881dd69bb037b341705bd2dc5fd931c
4
- data.tar.gz: 9d64980d6e77a94222f82cac5b5e654ccc1fb174
2
+ SHA256:
3
+ metadata.gz: 930b01c3e56e79e4a3bc2a9044f876b39802b1029e40dc5e834460caafe0b481
4
+ data.tar.gz: 22ba3c95472fb5959268db7d5c60a3e622dd6c578ef5633075de6f27aabd0b89
5
5
  SHA512:
6
- metadata.gz: 85db2e8f30ba255e74f611aaff2ae0c30f80306c6e820af1b6dd26643d553fdcd8607a1b481f01ea168dc38cf424778e8253324ac0becf690cf9b7978d8faeeb
7
- data.tar.gz: 1642380cb0cc1d225bfe475198b2fe38d4a2d9615731aefd20dfb1cbfdd1f94849a162f8d716b3fc080f6f126374304fbc3a631b1caf838fd47d1870f4ac9748
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
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
- Style/CaseIndentation:
20
+ Layout/CaseIndentation:
21
21
  Enabled: true
22
22
 
23
23
  # Align comments with method definitions.
24
- Style/CommentIndentation:
24
+ Layout/CommentIndentation:
25
25
  Enabled: true
26
26
 
27
27
  # No extra empty lines.
28
- Style/EmptyLines:
28
+ Layout/EmptyLines:
29
29
  Enabled: true
30
30
 
31
31
  # In a regular class definition, no empty lines around the body.
32
- Style/EmptyLinesAroundClassBody:
32
+ Layout/EmptyLinesAroundClassBody:
33
33
  Enabled: true
34
34
 
35
35
  # In a regular module definition, no empty lines around the body.
36
- Style/EmptyLinesAroundModuleBody:
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
- Style/IndentationConsistency:
45
+ Layout/IndentationConsistency:
46
46
  Enabled: true
47
- EnforcedStyle: rails
47
+ EnforcedStyle: indented_internal_methods
48
48
 
49
49
  # Two spaces, no tabs (for indentation).
50
- Style/IndentationWidth:
50
+ Layout/IndentationWidth:
51
51
  Enabled: true
52
52
 
53
- Style/SpaceAfterColon:
53
+ Layout/SpaceAfterColon:
54
54
  Enabled: true
55
55
 
56
- Style/SpaceAfterComma:
56
+ Layout/SpaceAfterComma:
57
57
  Enabled: true
58
58
 
59
- Style/SpaceAroundEqualsInParameterDefault:
59
+ Layout/SpaceAroundEqualsInParameterDefault:
60
60
  Enabled: true
61
61
 
62
- Style/SpaceAroundKeyword:
62
+ Layout/SpaceAroundKeyword:
63
63
  Enabled: true
64
64
 
65
- Style/SpaceAroundOperators:
65
+ Layout/SpaceAroundOperators:
66
66
  Enabled: true
67
67
 
68
- Style/SpaceBeforeFirstArg:
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
- Style/SpaceBeforeBlockBraces:
76
+ Layout/SpaceBeforeBlockBraces:
77
77
  Enabled: true
78
78
 
79
79
  # Use `foo { bar }` not `foo {bar}`.
80
- Style/SpaceInsideBlockBraces:
80
+ Layout/SpaceInsideBlockBraces:
81
81
  Enabled: true
82
82
 
83
83
  # Use `{ a: 1 }` not `{a:1}`.
84
- Style/SpaceInsideHashLiteralBraces:
84
+ Layout/SpaceInsideHashLiteralBraces:
85
85
  Enabled: true
86
86
 
87
- Style/SpaceInsideParens:
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
- Style/Tab:
96
+ Layout/Tab:
97
97
  Enabled: true
98
98
 
99
99
  # Blank lines should not have any spaces.
100
- Style/TrailingBlankLines:
100
+ Layout/TrailingBlankLines:
101
101
  Enabled: true
102
102
 
103
103
  # No trailing whitespace.
104
- Style/TrailingWhitespace:
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/v0.3.2...HEAD
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.1.1"
5
- gem "webpacker", "~> 2.0.0"
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.3.2)
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.1.1)
11
- actionpack (= 5.1.1)
10
+ actioncable (5.2.3)
11
+ actionpack (= 5.2.3)
12
12
  nio4r (~> 2.0)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.1.1)
15
- actionpack (= 5.1.1)
16
- actionview (= 5.1.1)
17
- activejob (= 5.1.1)
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.1.1)
21
- actionview (= 5.1.1)
22
- activesupport (= 5.1.1)
20
+ actionpack (5.2.3)
21
+ actionview (= 5.2.3)
22
+ activesupport (= 5.2.3)
23
23
  rack (~> 2.0)
24
- rack-test (~> 0.6.3)
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.1.1)
28
- activesupport (= 5.1.1)
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.1.1)
34
- activesupport (= 5.1.1)
33
+ activejob (5.2.3)
34
+ activesupport (= 5.2.3)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.1.1)
37
- activesupport (= 5.1.1)
38
- activerecord (5.1.1)
39
- activemodel (= 5.1.1)
40
- activesupport (= 5.1.1)
41
- arel (~> 8.0)
42
- activesupport (5.1.1)
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 (~> 0.7)
48
+ i18n (>= 0.7, < 2)
45
49
  minitest (~> 5.1)
46
50
  tzinfo (~> 1.1)
47
- addressable (2.5.0)
48
- public_suffix (~> 2.0, >= 2.0.2)
49
- arel (8.0.0)
50
- ast (2.3.0)
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 (2.12.0)
56
+ capybara (3.25.0)
53
57
  addressable
54
- mime-types (>= 1.16)
55
- nokogiri (>= 1.3.3)
56
- rack (>= 1.0.0)
57
- rack-test (>= 0.5.4)
58
- xpath (~> 2.0)
59
- cliver (0.3.2)
60
- concurrent-ruby (1.0.5)
61
- erubi (1.6.0)
62
- globalid (0.4.0)
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 (0.8.1)
65
- loofah (2.0.3)
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.6.5)
68
- mime-types (>= 1.16, < 4)
69
- method_source (0.8.2)
70
- mime-types (3.1)
71
- mime-types-data (~> 3.2015)
72
- mime-types-data (3.2016.0521)
73
- mini_portile2 (2.1.0)
74
- minitest (5.10.1)
75
- multi_json (1.12.1)
76
- nio4r (2.0.0)
77
- nokogiri (1.7.0.1)
78
- mini_portile2 (~> 2.1.0)
79
- parser (2.4.0.0)
80
- ast (~> 2.2)
81
- poltergeist (1.13.0)
82
- capybara (~> 2.1)
83
- cliver (~> 0.3.1)
84
- websocket-driver (>= 0.2.0)
85
- powerpack (0.1.1)
86
- public_suffix (2.0.5)
87
- rack (2.0.1)
88
- rack-test (0.6.3)
89
- rack (>= 1.0)
90
- rails (5.1.1)
91
- actioncable (= 5.1.1)
92
- actionmailer (= 5.1.1)
93
- actionpack (= 5.1.1)
94
- actionview (= 5.1.1)
95
- activejob (= 5.1.1)
96
- activemodel (= 5.1.1)
97
- activerecord (= 5.1.1)
98
- activesupport (= 5.1.1)
99
- bundler (>= 1.3.0, < 2.0)
100
- railties (= 5.1.1)
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.3)
106
- loofah (~> 2.0)
107
- railties (5.1.1)
108
- actionpack (= 5.1.1)
109
- activesupport (= 5.1.1)
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.18.1, < 2.0)
113
- rainbow (2.2.1)
114
- rake (10.5.0)
115
- rubocop (0.47.1)
116
- parser (>= 2.3.3.1, < 3.0)
117
- powerpack (~> 0.1)
118
- rainbow (>= 1.99.1, < 3.0)
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 (~> 1.0, >= 1.0.1)
121
- ruby-progressbar (1.8.1)
122
- sprockets (3.7.1)
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.0)
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.19.4)
146
+ thor (0.20.3)
130
147
  thread_safe (0.3.6)
131
- tzinfo (1.2.3)
148
+ tzinfo (1.2.5)
132
149
  thread_safe (~> 0.1)
133
- unicode-display_width (1.1.3)
134
- webpacker (2.0)
150
+ unicode-display_width (1.6.0)
151
+ webpacker (4.0.7)
135
152
  activesupport (>= 4.2)
136
- multi_json (~> 1.2)
153
+ rack-proxy (>= 0.6.1)
137
154
  railties (>= 4.2)
138
- websocket-driver (0.6.5)
155
+ websocket-driver (0.7.1)
139
156
  websocket-extensions (>= 0.1.0)
140
- websocket-extensions (0.1.2)
141
- xpath (2.0.0)
142
- nokogiri (~> 1.3)
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
- poltergeist
152
- rails (~> 5.1.1)
153
- rake (~> 10.0)
168
+ puma (~> 4.0)
169
+ rails (~> 5.2.0)
170
+ rake (~> 12.0)
154
171
  rubocop (>= 0.47)
155
- webpacker (~> 2.0.0)
172
+ selenium-webdriver
173
+ webpacker (~> 4.0.0)
156
174
  webpacker-react!
157
175
 
158
176
  BUNDLED WITH
159
- 1.15.4
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 [![CircleCI](https://circleci.com/gh/renchap/webpacker-react.svg?style=svg)](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.2) is [available here](https://github.com/renchap/webpacker-react/tree/v0.3.2).*
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.3.2"
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/guides/hmr-react/) allows to reload / add / remove modules live in the browser without
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
- First, install `react-hot-loader` (version 3):
112
+ 1. install `react-hot-loader` (version 4):
113
+ ```
114
+ ./bin/yarn add react-hot-loader@4
115
+ ```
113
116
 
114
- ```
115
- ./bin/yarn add react-hot-loader@beta
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
- We provide a convenience function to add the necessary changes to your config if it's not
121
- significantly different than the standard Webpacker config:
122
+ const environment = require("./environment")
123
+ const webpackerReactconfigureHotModuleReplacement = require('webpacker-react/configure-hot-module-replacement')
122
124
 
123
- ```js
124
- //development.js
125
- ...
125
+ const config = environment.toWebpackConfig()
126
126
 
127
- const sharedConfig = require('./shared.js')
128
- const configureHotModuleReplacement = require('webpacker-react/configure-hot-module-replacement')
127
+ module.exports = webpackerReactconfigureHotModuleReplacement(config)
128
+ ```
129
129
 
130
- module.exports = merge(configureHotModuleReplacement(sharedConfig), ...)
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
- 2. prepend `react-hot-loader/patch` to your entries:
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
- 3. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`). Make sure the following line is in your development.rb:
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
- 4. finally opt in to HMR from your pack files:
136
+ 5. finally, enable React Hot Loader for your root components (the ones you register with `WebpackerReact.setup`):
170
137
  ```es6
171
- import SomeRootReactComponent from 'components/some-root-react-component'
172
- import WebpackerReact from 'webpacker-react/hmr'
138
+ // For example in app/javascripts/components/hello.js
139
+ import React from 'react'
140
+ import { hot } from 'react-hot-loader'
173
141
 
174
- WebpackerReact.setup({SomeRootReactComponent})
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
- You also need to ensure that `output.publicPath` are correctly set. This should be already handled by Webpacker.
144
+ // This is the important line!
145
+ export default hot(module)(Hello)
146
+ ```
181
147
 
182
148
  ## Development
183
149
 
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ namespace :example_app do
27
27
 
28
28
  desc "Runs webpack in test/example_app"
29
29
  task webpack: :yarn do
30
- sh "cd test/example_app && NODE_ENV=test ./bin/webpack"
30
+ sh "cd test/example_app && RAILS_ENV=test ./bin/webpack"
31
31
  end
32
32
  end
33
33
 
@@ -0,0 +1,7 @@
1
+ {
2
+ "presets": [["env", {
3
+ "targets": {
4
+ "browsers": ["> 1%", "last 2 versions"]
5
+ }
6
+ }]]
7
+ }