react_on_rails 14.0.2 → 14.0.3
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 +22 -14
- data/CONTRIBUTING.md +11 -1
- data/Gemfile.development_dependencies +2 -1
- data/Gemfile.lock +7 -3
- data/NEWS.md +2 -2
- data/SUMMARY.md +1 -1
- data/lib/generators/USAGE +1 -1
- data/lib/generators/react_on_rails/base_generator.rb +16 -15
- data/lib/generators/react_on_rails/generator_messages.rb +1 -8
- data/lib/generators/react_on_rails/install_generator.rb +3 -9
- data/lib/generators/react_on_rails/templates/base/base/{Procfile.dev-static → Procfile.dev-static.tt} +2 -2
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +5 -0
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/{react_on_rails.rb → react_on_rails.rb.tt} +2 -2
- data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +1 -1
- data/lib/react_on_rails/configuration.rb +32 -42
- data/lib/react_on_rails/helper.rb +3 -3
- data/lib/react_on_rails/{webpacker_utils.rb → packer_utils.rb} +67 -42
- data/lib/react_on_rails/packs_generator.rb +4 -4
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +2 -2
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +4 -4
- data/lib/react_on_rails/test_helper.rb +4 -4
- data/lib/react_on_rails/utils.rb +20 -14
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +1 -1
- data/lib/react_on_rails.rb +1 -1
- data/lib/tasks/assets.rake +1 -1
- metadata +7 -7
- data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97f684f9ead5fb7736c7d7836501ac3964144cb63c3e707faf51b0a212251622
|
|
4
|
+
data.tar.gz: 376bf8a5fb5d632b28cef7b36272e17a29d5270cca71f2d5c067ec206b3e9a98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65b1bd21643a3d515b35082f7655ab4305d2dcb22b4906995f64c9056a06648b070c4b8656f46c2c4b599aed9c4d85468e1d7136d4f56f185db919e7faa05309
|
|
7
|
+
data.tar.gz: 145d1f91174c913d97fa171f81f1dd5d1e6daf04c7190094a0552ef6238ce5966cf39f5bd4b075c5a2112da18c108c6e98bd932d2a17799c20ef38efa848c622
|
data/CHANGELOG.md
CHANGED
|
@@ -18,10 +18,17 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
|
|
|
18
18
|
### [Unreleased]
|
|
19
19
|
Changes since the last non-beta release.
|
|
20
20
|
|
|
21
|
+
### [14.0.3] - 2024-06-28
|
|
22
|
+
|
|
23
|
+
#### Fixed
|
|
24
|
+
- Fixed css-loader installation with [PR 1634](https://github.com/shakacode/react_on_rails/pull/1634) by [vaukalak](https://github.com/vaukalak).
|
|
25
|
+
- Address a number of typos and grammar mistakes [PR 1631](https://github.com/shakacode/react_on_rails/pull/1631) by [G-Rath](https://github.com/G-Rath).
|
|
26
|
+
- Adds an adapter module & improves test suite to support all versions of Shakapacker. [PR 1622](https://github.com/shakacode/react_on_rails/pull/1622) by [adriangohjw](https://github.com/adriangohjw) and [judahmeek](https://github.com/judahmeek).
|
|
27
|
+
|
|
21
28
|
### [14.0.2] - 2024-06-11
|
|
22
29
|
|
|
23
30
|
#### Fixed
|
|
24
|
-
-
|
|
31
|
+
- Generator errors with Shakapacker v8+ fixed [PR 1629](https://github.com/shakacode/react_on_rails/pull/1629) by [vaukalak](https://github.com/vaukalak)
|
|
25
32
|
|
|
26
33
|
### [14.0.1] - 2024-05-16
|
|
27
34
|
|
|
@@ -174,7 +181,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
|
|
|
174
181
|
|
|
175
182
|
#### Changed
|
|
176
183
|
- Changed logic of determining the usage of the default rails/webpacker webpack config or a custom command to only check if the config.build_production_command is defined. [PR 1402](https://github.com/shakacode/react_on_rails/pull/1402) by [justin808](https://github.com/justin808) and [gscarv13](https://github.com/gscarv13).
|
|
177
|
-
-
|
|
184
|
+
- Minimum required Ruby is 2.7 to match latest rails/webpacker.
|
|
178
185
|
|
|
179
186
|
### [12.4.0] - 2021-09-22
|
|
180
187
|
#### Added
|
|
@@ -201,7 +208,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
|
|
|
201
208
|
- Added the ability to assign a module with a `call` method to `config.build_production_command`. See [the configuration docs](https://www.shakacode.com/react-on-rails/docs/guides/configuration). [PR 1362: Accept custom module for config.build_production_command](https://github.com/shakacode/react_on_rails/pull/1362).
|
|
202
209
|
|
|
203
210
|
#### Fixed
|
|
204
|
-
- Stop setting NODE_ENV value during precompile, as it
|
|
211
|
+
- Stop setting NODE_ENV value during precompile, as it interfered with rails/webpacker's setting of NODE_ENV to production by default. Fixes [#1334](https://github.com/shakacode/react_on_rails/issues/1334). [PR 1356: Don't set NODE_ENV in assets.rake](https://github.com/shakacode/react_on_rails/pull/1356) by [alexrozanski](https://github.com/alexrozanski).
|
|
205
212
|
|
|
206
213
|
### [12.0.4] - 2020-11-14
|
|
207
214
|
#### Fixed
|
|
@@ -221,7 +228,7 @@ which was only used in the workaround. [PR 1580](https://github.com/shakacode/re
|
|
|
221
228
|
|
|
222
229
|
### [12.0.1] - 2020-07-09
|
|
223
230
|
#### Fixed
|
|
224
|
-
- Changed invocation of webpacker:clean to use a very large number of versions so it does not
|
|
231
|
+
- Changed invocation of webpacker:clean to use a very large number of versions so it does not accidentally delete the server-bundle.js. [PR 1306](https://github.com/shakacode/react_on_rails/pull/1306) by By [justin808](https://github.com/justin808).
|
|
225
232
|
|
|
226
233
|
### [12.0.0] - 2020-07-08
|
|
227
234
|
For upgrade instructions, see [docs/guides/upgrading-react-on-rails.md](https://www.shakacode.com/react-on-rails/docs/guides/upgrading-react-on-rails).
|
|
@@ -380,7 +387,7 @@ Do not use. Unpublished. Caused by an issue with the release script.
|
|
|
380
387
|
|
|
381
388
|
### [11.0.7] - 2018-05-16
|
|
382
389
|
#### Fixed
|
|
383
|
-
- Fix npm
|
|
390
|
+
- Fix npm publishing. [PR 1090](https://github.com/shakacode/react_on_rails/pull/1090) by [justin808](https://github.com/justin808).
|
|
384
391
|
|
|
385
392
|
### [11.0.6] - 2018-05-15
|
|
386
393
|
#### Changed
|
|
@@ -756,7 +763,7 @@ No changes.
|
|
|
756
763
|
- Don't assume ActionMailer is available. [#608](https://github.com/shakacode/react_on_rails/pull/608) by [tuzz](https://github.com/tuzz).
|
|
757
764
|
|
|
758
765
|
## [6.2.1] - 2016-11-19
|
|
759
|
-
- Removed
|
|
766
|
+
- Removed unnecessary passing of context in the HelloWorld Container example and basic generator. [#612](https://github.com/shakacode/react_on_rails/pull/612) by [justin808](https://github.com/justin808)
|
|
760
767
|
|
|
761
768
|
- Turbolinks 5 bugfix to use `before-cache`, not `before-render`. [#611](https://github.com/shakacode/react_on_rails/pull/611) by [volkanunsal](https://github.com/volkanunsal).
|
|
762
769
|
|
|
@@ -782,12 +789,12 @@ No changes.
|
|
|
782
789
|
|
|
783
790
|
##### Fixed
|
|
784
791
|
- React on Rails now correctly parses single-digit version strings from package.json [#491](https://github.com/shakacode/react_on_rails/pull/491) by [samphilipd ](https://github.com/samphilipd).
|
|
785
|
-
- Fixed assets symlinking to correctly use filenames with spaces.
|
|
792
|
+
- Fixed assets symlinking to correctly use filenames with spaces. Beginning in [#510](https://github.com/shakacode/react_on_rails/pull/510), ending in [#513](https://github.com/shakacode/react_on_rails/pull/513) by [dzirtusss](https://github.com/dzirtusss).
|
|
786
793
|
- Check encoding of request's original URL and force it to UTF-8 [#527](https://github.com/shakacode/react_on_rails/pull/527) by [lucke84](https://github.com/lucke84)
|
|
787
794
|
|
|
788
795
|
## [6.0.5] - 2016-07-11
|
|
789
796
|
##### Added
|
|
790
|
-
- Added better error messages to avoid issues with shared redux stores [#470](https://github.com/shakacode/react_on_rails/pull/470) by
|
|
797
|
+
- Added better error messages to avoid issues with shared redux stores [#470](https://github.com/shakacode/react_on_rails/pull/470) by [justin808](https://github.com/justin808).
|
|
791
798
|
|
|
792
799
|
## [6.0.4] - 2016-06-13
|
|
793
800
|
##### Fixed
|
|
@@ -799,7 +806,7 @@ No changes.
|
|
|
799
806
|
|
|
800
807
|
## [6.0.2] - 2016-06-06
|
|
801
808
|
##### Fixed
|
|
802
|
-
- Fix
|
|
809
|
+
- Fix collisions in ids of DOM nodes generated by `react_component` by indexing in using a UUID rather than an auto-increment value. This means that it should be overridden using the `id` parameter of `react_component` if one wants to generate a predictable id (_e.g._ for testing purpose). See [Issue #437](https://github.com/shakacode/react_on_rails/issues/437). Fixed in [#438](https://github.com/shakacode/react_on_rails/pull/438) by [Michael Baudino](https://github.com/michaelbaudino).
|
|
803
810
|
|
|
804
811
|
## [6.0.1] - 2016-05-27
|
|
805
812
|
##### Fixed
|
|
@@ -807,16 +814,16 @@ No changes.
|
|
|
807
814
|
|
|
808
815
|
## [6.0.0] - 2016-05-25
|
|
809
816
|
##### Breaking Changes
|
|
810
|
-
- Added automatic compilation of assets at precompile is now done by ReactOnRails. Thus, you don't need to provide your own assets.rake file that does the precompilation.
|
|
817
|
+
- Added automatic compilation of assets at precompile is now done by ReactOnRails. Thus, you don't need to provide your own `assets.rake` file that does the precompilation.
|
|
811
818
|
[#398](https://github.com/shakacode/react_on_rails/pull/398) by [robwise](https://github.com/robwise), [jbhatab](https://github.com/jbhatab), and [justin808](https://github.com/justin808).
|
|
812
819
|
- **Migration to v6**
|
|
813
820
|
- Do not run the generator again if you've already run it.
|
|
814
821
|
|
|
815
822
|
- See [shakacode/react-webpack-rails-tutorial/pull/287](https://github.com/shakacode/react-webpack-rails-tutorial/pull/287) for an example of upgrading from v5.
|
|
816
823
|
|
|
817
|
-
- To configure the asset
|
|
824
|
+
- To configure the asset compilation you can either
|
|
818
825
|
1. Specify a `config/react_on_rails` setting for `build_production_command` to be nil to turn this feature off.
|
|
819
|
-
2. Specify the script command you want to run to build your production assets, and remove your assets.rake file.
|
|
826
|
+
2. Specify the script command you want to run to build your production assets, and remove your `assets.rake` file.
|
|
820
827
|
|
|
821
828
|
- If you are using the ReactOnRails test helper, then you will need to add the 'config.npm_build_test_command' to your config to tell react_on_rails what command to run when you run rspec.
|
|
822
829
|
|
|
@@ -903,7 +910,7 @@ All 5.1.0 changes can be found in [#362](https://github.com/shakacode/react_on_r
|
|
|
903
910
|
## [4.0.3] - 2016-03-17
|
|
904
911
|
|
|
905
912
|
##### Fixed
|
|
906
|
-
- `ReactOnRailsHelper#react_component`: Invalid deprecation message when called with only one
|
|
913
|
+
- `ReactOnRailsHelper#react_component`: Invalid deprecation message when called with only one parameter, the component name.
|
|
907
914
|
|
|
908
915
|
## [4.0.2] - 2016-03-17
|
|
909
916
|
|
|
@@ -1133,7 +1140,8 @@ Best done with Object destructing:
|
|
|
1133
1140
|
##### Fixed
|
|
1134
1141
|
- Fix several generator-related issues.
|
|
1135
1142
|
|
|
1136
|
-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.
|
|
1143
|
+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.3...master
|
|
1144
|
+
[14.0.3]: https://github.com/shakacode/react_on_rails/compare/14.0.2...14.0.3
|
|
1137
1145
|
[14.0.2]: https://github.com/shakacode/react_on_rails/compare/14.0.1...14.0.2
|
|
1138
1146
|
[14.0.1]: https://github.com/shakacode/react_on_rails/compare/14.0.0...14.0.1
|
|
1139
1147
|
[14.0.0]: https://github.com/shakacode/react_on_rails/compare/13.4.0...14.0.0
|
data/CONTRIBUTING.md
CHANGED
|
@@ -137,12 +137,22 @@ spec/dummy.
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
```sh
|
|
140
|
-
# Optionally change default
|
|
140
|
+
# Optionally change default capybara driver
|
|
141
141
|
export DRIVER=selenium_firefox
|
|
142
142
|
cd react_on_rails/
|
|
143
143
|
yarn run dummy:spec
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
+
To convert the development environment over to Shakapacker v6 instead of the default Shakapacker v8:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
# Optionally change default capybara driver
|
|
150
|
+
export DRIVER=selenium_firefox
|
|
151
|
+
cd react_on_rails/
|
|
152
|
+
script/convert
|
|
153
|
+
yarn run dummy:spec
|
|
154
|
+
```
|
|
155
|
+
|
|
146
156
|
### Run NPM JS tests
|
|
147
157
|
|
|
148
158
|
```sh
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
gem "shakapacker", "
|
|
3
|
+
gem "shakapacker", "8.0.0"
|
|
4
4
|
gem "bootsnap", require: false
|
|
5
5
|
gem "rails", "~> 7.1"
|
|
6
6
|
|
|
@@ -24,6 +24,7 @@ gem "amazing_print"
|
|
|
24
24
|
|
|
25
25
|
group :development, :test do
|
|
26
26
|
gem "listen"
|
|
27
|
+
gem "debug"
|
|
27
28
|
gem "pry"
|
|
28
29
|
gem "pry-byebug"
|
|
29
30
|
gem "pry-doc"
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
react_on_rails (14.0.
|
|
4
|
+
react_on_rails (14.0.2)
|
|
5
5
|
addressable
|
|
6
6
|
connection_pool
|
|
7
7
|
execjs (~> 2.5)
|
|
@@ -119,6 +119,9 @@ GEM
|
|
|
119
119
|
tins (~> 1.6)
|
|
120
120
|
crass (1.0.6)
|
|
121
121
|
date (3.3.4)
|
|
122
|
+
debug (1.9.2)
|
|
123
|
+
irb (~> 1.10)
|
|
124
|
+
reline (>= 0.3.8)
|
|
122
125
|
diff-lcs (1.5.1)
|
|
123
126
|
docile (1.4.0)
|
|
124
127
|
drb (2.2.1)
|
|
@@ -334,7 +337,7 @@ GEM
|
|
|
334
337
|
rubyzip (>= 1.2.2, < 3.0)
|
|
335
338
|
websocket (~> 1.0)
|
|
336
339
|
semantic_range (3.0.0)
|
|
337
|
-
shakapacker (
|
|
340
|
+
shakapacker (8.0.0)
|
|
338
341
|
activesupport (>= 5.2)
|
|
339
342
|
package_json
|
|
340
343
|
rack-proxy (>= 0.6.1)
|
|
@@ -397,6 +400,7 @@ DEPENDENCIES
|
|
|
397
400
|
capybara
|
|
398
401
|
capybara-screenshot
|
|
399
402
|
coveralls
|
|
403
|
+
debug
|
|
400
404
|
equivalent-xml
|
|
401
405
|
gem-release
|
|
402
406
|
generator_spec
|
|
@@ -422,7 +426,7 @@ DEPENDENCIES
|
|
|
422
426
|
scss_lint
|
|
423
427
|
sdoc
|
|
424
428
|
selenium-webdriver (= 4.9.0)
|
|
425
|
-
shakapacker (=
|
|
429
|
+
shakapacker (= 8.0.0)
|
|
426
430
|
spring (~> 4.0)
|
|
427
431
|
sprockets (~> 4.0)
|
|
428
432
|
sqlite3 (~> 1.6)
|
data/NEWS.md
CHANGED
|
@@ -28,11 +28,11 @@ that supports SSR.
|
|
|
28
28
|
* 2016-12-20: New Video on Egghead.io: [Creating a component with React on Rails](https://egghead.io/lessons/react-creating-a-component-with-react-on-rails)
|
|
29
29
|
* 2016-11-03: Spoke at [LA Ruby, 7pm, Thursday, November 10 in Venice, CA: "React on Rails: Why, What, and How?"](http://www.meetup.com/laruby/events/234825187/). [Video and pictures in this article](https://blog.shakacode.com/my-react-on-rails-talk-at-the-la-ruby-rails-meetup-november-10-2016-eaaa83aff800#.ej6h4eglp).
|
|
30
30
|
* 2016-08-27: We now have a [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference.
|
|
31
|
-
* 2016-08-21: v6.1 ships with
|
|
31
|
+
* 2016-08-21: v6.1 ships with several new features and bug fixes. See the [Changelog](CHANGELOG.md).
|
|
32
32
|
* 2016-07-28: If you're doing server rendering, be sure to use mini\_racer! See [issues/428](https://github.com/shakacode/react_on_rails/issues/428). It's supposedly much faster than `therubyracer`.
|
|
33
33
|
|
|
34
34
|
* 2016-08-27: We now have a [Documentation Gitbook](https://shakacode.gitbooks.io/react-on-rails/content/) for improved readability & reference.
|
|
35
|
-
* 2016-08-21: v6.1 ships with
|
|
35
|
+
* 2016-08-21: v6.1 ships with several new features and bug fixes. See the [Changelog](CHANGELOG.md).
|
|
36
36
|
* 2016-06-13: 6.0.4 shipped with a critical fix regarding a missing polyfill for `clearTimeout`, used by babel-polyfill.
|
|
37
37
|
* 2016-06-06: 6.0.2 shipped with a critical fix if you are fragment caching the server generated React.
|
|
38
38
|
* 2016-05-24: 6.0.0 Released! Simplified generator and install process! See the [CHANGELOG.md](./CHANGELOG.md) for details.
|
data/SUMMARY.md
CHANGED
data/lib/generators/USAGE
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require "rails/generators"
|
|
4
4
|
require_relative "generator_messages"
|
|
5
5
|
require_relative "generator_helper"
|
|
6
|
-
|
|
7
6
|
module ReactOnRails
|
|
8
7
|
module Generators
|
|
9
8
|
class BaseGenerator < Rails::Generators::Base
|
|
@@ -30,17 +29,21 @@ module ReactOnRails
|
|
|
30
29
|
def copy_base_files
|
|
31
30
|
base_path = "base/base/"
|
|
32
31
|
base_files = %w[app/controllers/hello_world_controller.rb
|
|
33
|
-
app/views/layouts/hello_world.html.erb
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
app/views/layouts/hello_world.html.erb]
|
|
33
|
+
base_templates = %w[config/initializers/react_on_rails.rb
|
|
34
|
+
Procfile.dev
|
|
35
|
+
Procfile.dev-static]
|
|
37
36
|
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
|
|
37
|
+
base_templates.each do |file|
|
|
38
|
+
template("#{base_path}/#{file}.tt", file, { packer_type: ReactOnRails::PackerUtils.packer_type })
|
|
39
|
+
end
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
def copy_js_bundle_files
|
|
41
43
|
base_path = "base/base/"
|
|
42
44
|
base_files = %w[app/javascript/packs/server-bundle.js
|
|
43
|
-
app/javascript/bundles/HelloWorld/components/HelloWorldServer.js
|
|
45
|
+
app/javascript/bundles/HelloWorld/components/HelloWorldServer.js
|
|
46
|
+
app/javascript/bundles/HelloWorld/components/HelloWorld.module.css]
|
|
44
47
|
base_files.each { |file| copy_file("#{base_path}#{file}", file) }
|
|
45
48
|
end
|
|
46
49
|
|
|
@@ -59,16 +62,14 @@ module ReactOnRails
|
|
|
59
62
|
config = {
|
|
60
63
|
message: "// The source code including full typescript support is available at:"
|
|
61
64
|
}
|
|
62
|
-
base_files.each
|
|
63
|
-
template("#{base_path}/#{file}.tt", file, config)
|
|
64
|
-
end
|
|
65
|
+
base_files.each { |file| template("#{base_path}/#{file}.tt", file, config) }
|
|
65
66
|
end
|
|
66
67
|
|
|
67
|
-
def
|
|
68
|
-
puts "Adding Shakapacker
|
|
68
|
+
def copy_packer_config
|
|
69
|
+
puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config"
|
|
69
70
|
base_path = "base/base/"
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
config = "config/shakapacker.yml"
|
|
72
|
+
copy_file("#{base_path}#{config}", config)
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
def add_base_gems_to_gemfile
|
|
@@ -81,7 +82,7 @@ module ReactOnRails
|
|
|
81
82
|
run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact"
|
|
82
83
|
else
|
|
83
84
|
# otherwise add latest
|
|
84
|
-
puts "Adding the
|
|
85
|
+
puts "Adding the latest react-on-rails NPM module. Double check this is correct in package.json"
|
|
85
86
|
run "yarn add react-on-rails --exact"
|
|
86
87
|
end
|
|
87
88
|
|
|
@@ -91,7 +92,7 @@ module ReactOnRails
|
|
|
91
92
|
|
|
92
93
|
puts "Adding CSS handlers"
|
|
93
94
|
|
|
94
|
-
run "yarn add css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader
|
|
95
|
+
run "yarn add -D css-loader css-minimizer-webpack-plugin mini-css-extract-plugin style-loader"
|
|
95
96
|
|
|
96
97
|
puts "Adding dev dependencies"
|
|
97
98
|
run "yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh"
|
|
@@ -65,16 +65,9 @@ module GeneratorMessages
|
|
|
65
65
|
|
|
66
66
|
Alternative steps to run the app:
|
|
67
67
|
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
- Run bin/shakapacker-dev-server to start the Webpack dev server for compilation of Webpack
|
|
71
|
-
assets as soon as you save. This default setup with the dev server does not work
|
|
72
|
-
for server rendering
|
|
68
|
+
- We recommend using Procfile.dev with foreman, overmind, or a similar program. Alternately, you can run each of the processes listed in Procfile.dev in a separate tab in your terminal.
|
|
73
69
|
|
|
74
70
|
- Visit http://localhost:3000/hello_world and see your React On Rails app running!
|
|
75
|
-
|
|
76
|
-
- To turn on HMR, edit config/shakapacker.yml and set HMR to true. Restart the rails server
|
|
77
|
-
and bin/shakapacker-dev-server. Or use Procfile.dev.
|
|
78
71
|
MSG
|
|
79
72
|
end
|
|
80
73
|
end
|
|
@@ -88,19 +88,13 @@ module ReactOnRails
|
|
|
88
88
|
Dir.chdir("#{__dir__}/bin") do
|
|
89
89
|
files_to_copy.concat(Dir.glob("*"))
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
files_to_become_executable = files_to_copy.map { |filename| "bin/#{filename}" }
|
|
92
92
|
|
|
93
|
-
File.chmod(0o755, *
|
|
93
|
+
File.chmod(0o755, *files_to_become_executable)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def add_post_install_message
|
|
97
|
-
|
|
98
|
-
unless using_shakapacker_7_or_above?
|
|
99
|
-
message = message.gsub("config/shakapacker", "config/webpacker")
|
|
100
|
-
message = message.gsub("bin/shakapacker", "bin/webpacker")
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
GeneratorMessages.add_info(message)
|
|
97
|
+
GeneratorMessages.add_info(GeneratorMessages.helpful_message_after_installation)
|
|
104
98
|
end
|
|
105
99
|
|
|
106
100
|
def using_shakapacker_7_or_above?
|
|
@@ -5,5 +5,5 @@ web: rails s -p 3000
|
|
|
5
5
|
# When making frequent changes to client side assets, you will prefer building webpack assets
|
|
6
6
|
# upon saving rather than when you refresh your browser page.
|
|
7
7
|
# Note, if using React on Rails localization you will need to run
|
|
8
|
-
# `bundle exec rake react_on_rails:locale` before you run bin
|
|
9
|
-
webpack: sh -c 'rm -rf public/packs/* || true && bin
|
|
8
|
+
# `bundle exec rake react_on_rails:locale` before you run bin/<%= config[:packer_type] %>
|
|
9
|
+
webpack: sh -c 'rm -rf public/packs/* || true && bin/<%= config[:packer_type] %> -w'
|
|
@@ -24,8 +24,8 @@ ReactOnRails.configure do |config|
|
|
|
24
24
|
# to automatically refresh your webpack assets on every test run.
|
|
25
25
|
#
|
|
26
26
|
# Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
|
|
27
|
-
# and set the config
|
|
28
|
-
config.build_test_command = "RAILS_ENV=test bin
|
|
27
|
+
# and set the config/<%= config[:packer_type] %>.yml option for test to true.
|
|
28
|
+
config.build_test_command = "RAILS_ENV=test bin/<%= config[:packer_type] %>"
|
|
29
29
|
|
|
30
30
|
################################################################################
|
|
31
31
|
################################################################################
|
|
@@ -111,29 +111,29 @@ module ReactOnRails
|
|
|
111
111
|
|
|
112
112
|
# on ReactOnRails
|
|
113
113
|
def setup_config_values
|
|
114
|
-
|
|
114
|
+
check_autobundling_requirements if auto_load_bundle
|
|
115
115
|
ensure_webpack_generated_files_exists
|
|
116
116
|
configure_generated_assets_dirs_deprecation
|
|
117
117
|
configure_skip_display_none_deprecation
|
|
118
118
|
ensure_generated_assets_dir_present
|
|
119
119
|
check_server_render_method_is_only_execjs
|
|
120
|
-
|
|
120
|
+
error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
|
|
121
121
|
# check_deprecated_settings
|
|
122
122
|
adjust_precompile_task
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
private
|
|
126
126
|
|
|
127
|
-
def
|
|
127
|
+
def check_autobundling_requirements
|
|
128
128
|
raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present?
|
|
129
129
|
return unless components_subdirectory.present?
|
|
130
130
|
|
|
131
|
-
ReactOnRails::
|
|
132
|
-
ReactOnRails::
|
|
133
|
-
ReactOnRails::
|
|
131
|
+
ReactOnRails::PackerUtils.raise_shakapacker_not_installed unless ReactOnRails::PackerUtils.using_packer?
|
|
132
|
+
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless
|
|
133
|
+
ReactOnRails::PackerUtils.shakapacker_version_requirement_met?(
|
|
134
134
|
ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION
|
|
135
135
|
)
|
|
136
|
-
ReactOnRails::
|
|
136
|
+
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def adjust_precompile_task
|
|
@@ -141,7 +141,7 @@ module ReactOnRails
|
|
|
141
141
|
|
|
142
142
|
return if skip_react_on_rails_precompile || build_production_command.blank?
|
|
143
143
|
|
|
144
|
-
raise(ReactOnRails::Error, compile_command_conflict_message) if
|
|
144
|
+
raise(ReactOnRails::Error, compile_command_conflict_message) if ReactOnRails::PackerUtils.precompile?
|
|
145
145
|
|
|
146
146
|
precompile_tasks = lambda {
|
|
147
147
|
Rake::Task["react_on_rails:generate_packs"].invoke
|
|
@@ -151,9 +151,8 @@ module ReactOnRails
|
|
|
151
151
|
# We set it very big so that it is not used, and then clean just
|
|
152
152
|
# removes files older than 1 hour.
|
|
153
153
|
versions = 100_000
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Rake::Task[shakapacker_clean_task].invoke(versions)
|
|
154
|
+
puts "Invoking task #{ReactOnRails::PackerUtils.packer_type}:clean from React on Rails"
|
|
155
|
+
Rake::Task["#{ReactOnRails::PackerUtils.packer_type}:clean"].invoke(versions)
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
if Rake::Task.task_defined?("assets:precompile")
|
|
@@ -167,22 +166,23 @@ module ReactOnRails
|
|
|
167
166
|
end
|
|
168
167
|
end
|
|
169
168
|
|
|
170
|
-
def
|
|
171
|
-
return unless ReactOnRails::
|
|
169
|
+
def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
|
|
170
|
+
return unless ReactOnRails::PackerUtils.using_packer?
|
|
172
171
|
|
|
173
172
|
return if generated_assets_dir.blank?
|
|
174
173
|
|
|
175
|
-
|
|
174
|
+
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
|
|
176
175
|
|
|
177
|
-
if File.expand_path(generated_assets_dir) ==
|
|
176
|
+
if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s
|
|
178
177
|
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
|
|
179
|
-
"with
|
|
178
|
+
"with #{ReactOnRails::PackerUtils.packer_type}. " \
|
|
179
|
+
"Remove this line from your configuration file.")
|
|
180
180
|
else
|
|
181
181
|
msg = <<~MSG
|
|
182
|
-
Error configuring /config/initializers/react_on_rails.rb: You are using
|
|
182
|
+
Error configuring /config/initializers/react_on_rails.rb: You are using #{ReactOnRails::PackerUtils.packer_type}
|
|
183
183
|
and your specified value for generated_assets_dir = #{generated_assets_dir}
|
|
184
184
|
that does not match the value for public_output_path specified in
|
|
185
|
-
|
|
185
|
+
#{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}. You should remove the configuration
|
|
186
186
|
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
|
|
187
187
|
MSG
|
|
188
188
|
raise ReactOnRails::Error, msg
|
|
@@ -202,7 +202,7 @@ module ReactOnRails
|
|
|
202
202
|
end
|
|
203
203
|
|
|
204
204
|
def ensure_generated_assets_dir_present
|
|
205
|
-
return if generated_assets_dir.present? || ReactOnRails::
|
|
205
|
+
return if generated_assets_dir.present? || ReactOnRails::PackerUtils.using_packer?
|
|
206
206
|
|
|
207
207
|
self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
|
|
208
208
|
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
|
|
@@ -211,11 +211,13 @@ module ReactOnRails
|
|
|
211
211
|
def configure_generated_assets_dirs_deprecation
|
|
212
212
|
return if generated_assets_dirs.blank?
|
|
213
213
|
|
|
214
|
-
if ReactOnRails::
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"
|
|
214
|
+
if ReactOnRails::PackerUtils.using_packer?
|
|
215
|
+
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
|
|
216
|
+
# rubocop:disable Layout/LineLength
|
|
217
|
+
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \
|
|
218
|
+
"the generated_assets_dir when using #{ReactOnRails::PackerUtils.packer_type.upcase_first}. This is defined by " \
|
|
219
|
+
"public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}."
|
|
220
|
+
# rubocop:enable Layout/LineLength
|
|
219
221
|
return
|
|
220
222
|
end
|
|
221
223
|
|
|
@@ -225,7 +227,7 @@ module ReactOnRails
|
|
|
225
227
|
self.generated_assets_dir = generated_assets_dirs
|
|
226
228
|
else
|
|
227
229
|
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \
|
|
228
|
-
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using
|
|
230
|
+
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Shakapacker " \
|
|
229
231
|
"and define neither if using Webpacker"
|
|
230
232
|
end
|
|
231
233
|
end
|
|
@@ -247,7 +249,7 @@ module ReactOnRails
|
|
|
247
249
|
|
|
248
250
|
def raise_missing_components_subdirectory
|
|
249
251
|
msg = <<~MSG
|
|
250
|
-
**ERROR** ReactOnRails: auto_load_bundle is set to true, yet components_subdirectory is
|
|
252
|
+
**ERROR** ReactOnRails: auto_load_bundle is set to true, yet components_subdirectory is not configured.\
|
|
251
253
|
Please set components_subdirectory to the desired directory. For more information, please see \
|
|
252
254
|
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md
|
|
253
255
|
MSG
|
|
@@ -255,28 +257,16 @@ module ReactOnRails
|
|
|
255
257
|
raise ReactOnRails::Error, msg
|
|
256
258
|
end
|
|
257
259
|
|
|
258
|
-
def shakapacker_precompile?
|
|
259
|
-
return Webpacker.config.webpacker_precompile? if ReactOnRails::WebpackerUtils.using_shakapacker_6?
|
|
260
|
-
|
|
261
|
-
Webpacker.config.shakapacker_precompile?
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
def shakapacker_clean_task
|
|
265
|
-
ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker:clean" : "shakapacker:clean"
|
|
266
|
-
end
|
|
267
|
-
|
|
268
260
|
def compile_command_conflict_message
|
|
269
|
-
packer = ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker" : "shakapacker"
|
|
270
|
-
|
|
271
261
|
<<~MSG
|
|
272
262
|
|
|
273
|
-
React on Rails and
|
|
263
|
+
React on Rails and #{ReactOnRails::PackerUtils.packer_type.upcase_first} error in configuration!
|
|
274
264
|
In order to use config/react_on_rails.rb config.build_production_command,
|
|
275
|
-
you must edit config/#{
|
|
276
|
-
'#{
|
|
265
|
+
you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration:
|
|
266
|
+
'#{ReactOnRails::PackerUtils.packer_type}_precompile: false'
|
|
277
267
|
|
|
278
268
|
Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
|
|
279
|
-
default bin/#{
|
|
269
|
+
default bin/#{ReactOnRails::PackerUtils.packer_type} script will be used for assets:precompile.
|
|
280
270
|
|
|
281
271
|
MSG
|
|
282
272
|
end
|
|
@@ -316,7 +316,7 @@ module ReactOnRails
|
|
|
316
316
|
def load_pack_for_generated_component(react_component_name, render_options)
|
|
317
317
|
return unless render_options.auto_load_bundle
|
|
318
318
|
|
|
319
|
-
ReactOnRails::
|
|
319
|
+
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
|
|
320
320
|
if Rails.env.development?
|
|
321
321
|
is_component_pack_present = File.exist?(generated_components_pack_path(react_component_name))
|
|
322
322
|
raise_missing_autoloaded_bundle(react_component_name) unless is_component_pack_present
|
|
@@ -330,8 +330,8 @@ module ReactOnRails
|
|
|
330
330
|
|
|
331
331
|
private
|
|
332
332
|
|
|
333
|
-
def generated_components_pack_path(
|
|
334
|
-
"#{ReactOnRails::
|
|
333
|
+
def generated_components_pack_path(component_name)
|
|
334
|
+
"#{ReactOnRails::PackerUtils.packer_source_entry_path}/generated/#{component_name}.js"
|
|
335
335
|
end
|
|
336
336
|
|
|
337
337
|
def build_react_component_result_for_server_rendered_string(
|
|
@@ -1,24 +1,55 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module ReactOnRails
|
|
4
|
-
module
|
|
5
|
-
def self.
|
|
6
|
-
|
|
4
|
+
module PackerUtils
|
|
5
|
+
def self.using_packer?
|
|
6
|
+
using_shakapacker_const? || using_webpacker_const?
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.using_shakapacker_const?
|
|
10
|
+
return @using_shakapacker_const if defined?(@using_shakapacker_const)
|
|
11
|
+
|
|
12
|
+
@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
|
|
13
|
+
shakapacker_version_requirement_met?([7, 0, 0])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.using_webpacker_const?
|
|
17
|
+
return @using_webpacker_const if defined?(@using_webpacker_const)
|
|
18
|
+
|
|
19
|
+
@using_webpacker_const = (ReactOnRails::Utils.gem_available?("shakapacker") &&
|
|
20
|
+
shakapacker_version_as_array[0] <= 6) ||
|
|
21
|
+
ReactOnRails::Utils.gem_available?("webpacker")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.packer_type
|
|
25
|
+
return "shakapacker" if using_shakapacker_const?
|
|
26
|
+
return "webpacker" if using_webpacker_const?
|
|
27
|
+
|
|
28
|
+
nil
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.packer
|
|
32
|
+
return nil unless using_packer?
|
|
7
33
|
|
|
8
|
-
|
|
9
|
-
|
|
34
|
+
if using_shakapacker_const?
|
|
35
|
+
require "shakapacker"
|
|
36
|
+
return ::Shakapacker
|
|
37
|
+
end
|
|
38
|
+
require "webpacker"
|
|
39
|
+
::Webpacker
|
|
10
40
|
end
|
|
11
41
|
|
|
12
42
|
def self.dev_server_running?
|
|
13
|
-
return false unless
|
|
43
|
+
return false unless using_packer?
|
|
14
44
|
|
|
15
|
-
|
|
45
|
+
packer.dev_server.running?
|
|
16
46
|
end
|
|
17
47
|
|
|
18
48
|
def self.shakapacker_version
|
|
49
|
+
return @shakapacker_version if defined?(@shakapacker_version)
|
|
19
50
|
return nil unless ReactOnRails::Utils.gem_available?("shakapacker")
|
|
20
51
|
|
|
21
|
-
@shakapacker_version
|
|
52
|
+
@shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s
|
|
22
53
|
end
|
|
23
54
|
|
|
24
55
|
def self.shakapacker_version_as_array
|
|
@@ -27,7 +58,7 @@ module ReactOnRails
|
|
|
27
58
|
@shakapacker_version_as_array = [match[1].to_i, match[2].to_i, match[3].to_i]
|
|
28
59
|
end
|
|
29
60
|
|
|
30
|
-
def self.
|
|
61
|
+
def self.shakapacker_version_requirement_met?(required_version)
|
|
31
62
|
req_ver = semver_to_string(required_version)
|
|
32
63
|
|
|
33
64
|
Gem::Version.new(shakapacker_version) >= Gem::Version.new(req_ver)
|
|
@@ -36,12 +67,8 @@ module ReactOnRails
|
|
|
36
67
|
# This returns either a URL for the webpack-dev-server, non-server bundle or
|
|
37
68
|
# the hashed server bundle if using the same bundle for the client.
|
|
38
69
|
# Otherwise returns a file path.
|
|
39
|
-
def self.
|
|
40
|
-
|
|
41
|
-
# [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js")
|
|
42
|
-
# "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js"
|
|
43
|
-
# Next line will throw if the file or manifest does not exist
|
|
44
|
-
hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name)
|
|
70
|
+
def self.bundle_js_uri_from_packer(bundle_name)
|
|
71
|
+
hashed_bundle_name = packer.manifest.lookup!(bundle_name)
|
|
45
72
|
|
|
46
73
|
# Support for hashing the server-bundle and having that built
|
|
47
74
|
# the webpack-dev-server is provided by the config value
|
|
@@ -49,48 +76,52 @@ module ReactOnRails
|
|
|
49
76
|
# would mean that the bundle is created by the webpack-dev-server
|
|
50
77
|
is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file
|
|
51
78
|
|
|
52
|
-
if
|
|
79
|
+
if packer.dev_server.running? && (!is_server_bundle ||
|
|
53
80
|
ReactOnRails.configuration.same_bundle_for_client_and_server)
|
|
54
|
-
"#{
|
|
81
|
+
"#{packer.dev_server.protocol}://#{packer.dev_server.host_with_port}#{hashed_bundle_name}"
|
|
55
82
|
else
|
|
56
83
|
File.expand_path(File.join("public", hashed_bundle_name)).to_s
|
|
57
84
|
end
|
|
58
85
|
end
|
|
59
86
|
|
|
60
|
-
def self.
|
|
61
|
-
Webpacker.config.
|
|
87
|
+
def self.precompile?
|
|
88
|
+
return ::Webpacker.config.webpacker_precompile? if using_webpacker_const?
|
|
89
|
+
return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker_const?
|
|
90
|
+
|
|
91
|
+
false
|
|
62
92
|
end
|
|
63
93
|
|
|
64
|
-
def self.
|
|
65
|
-
|
|
94
|
+
def self.packer_source_path
|
|
95
|
+
packer.config.source_path
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.packer_source_entry_path
|
|
99
|
+
packer.config.source_entry_path
|
|
66
100
|
end
|
|
67
101
|
|
|
68
102
|
def self.nested_entries?
|
|
69
|
-
|
|
103
|
+
packer.config.nested_entries?
|
|
70
104
|
end
|
|
71
105
|
|
|
72
|
-
def self.
|
|
73
|
-
|
|
74
|
-
Webpacker.config.public_output_path.to_s
|
|
106
|
+
def self.packer_public_output_path
|
|
107
|
+
packer.config.public_output_path.to_s
|
|
75
108
|
end
|
|
76
109
|
|
|
77
110
|
def self.manifest_exists?
|
|
78
|
-
|
|
111
|
+
packer.config.public_manifest_path.exist?
|
|
79
112
|
end
|
|
80
113
|
|
|
81
|
-
def self.
|
|
82
|
-
|
|
83
|
-
config_webpacker_yml = Webpacker.config.send(:data)
|
|
84
|
-
config_webpacker_yml[:source_path].present?
|
|
114
|
+
def self.packer_source_path_explicit?
|
|
115
|
+
packer.config.send(:data)[:source_path].present?
|
|
85
116
|
end
|
|
86
117
|
|
|
87
118
|
def self.check_manifest_not_cached
|
|
88
|
-
return unless
|
|
119
|
+
return unless using_packer? && packer.config.cache_manifest?
|
|
89
120
|
|
|
90
121
|
msg = <<-MSG.strip_heredoc
|
|
91
122
|
ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the
|
|
92
123
|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper
|
|
93
|
-
To fix this: edit your config
|
|
124
|
+
To fix this: edit your config/#{packer_type}.yml file and set cache_manifest to false for test.
|
|
94
125
|
MSG
|
|
95
126
|
puts wrap_message(msg)
|
|
96
127
|
exit!
|
|
@@ -111,7 +142,7 @@ module ReactOnRails
|
|
|
111
142
|
def self.raise_nested_entries_disabled
|
|
112
143
|
msg = <<~MSG
|
|
113
144
|
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \
|
|
114
|
-
|
|
145
|
+
config/#{packer_type}.yml to enable nested entries. for more information read
|
|
115
146
|
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker
|
|
116
147
|
MSG
|
|
117
148
|
|
|
@@ -120,9 +151,9 @@ module ReactOnRails
|
|
|
120
151
|
|
|
121
152
|
def self.raise_shakapacker_version_incompatible_for_autobundling
|
|
122
153
|
msg = <<~MSG
|
|
123
|
-
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{
|
|
154
|
+
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or \
|
|
124
155
|
above to use the automated bundle generation feature. The currently installed version is \
|
|
125
|
-
#{
|
|
156
|
+
#{semver_to_string(ReactOnRails::PackerUtils.shakapacker_version_as_array)}.
|
|
126
157
|
MSG
|
|
127
158
|
|
|
128
159
|
raise ReactOnRails::Error, msg
|
|
@@ -131,7 +162,7 @@ module ReactOnRails
|
|
|
131
162
|
def self.raise_shakapacker_not_installed
|
|
132
163
|
msg = <<~MSG
|
|
133
164
|
**ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \
|
|
134
|
-
#{ReactOnRails::
|
|
165
|
+
#{semver_to_string(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)} or above to use the \
|
|
135
166
|
automated bundle generation feature.
|
|
136
167
|
MSG
|
|
137
168
|
|
|
@@ -141,11 +172,5 @@ module ReactOnRails
|
|
|
141
172
|
def self.semver_to_string(ary)
|
|
142
173
|
"#{ary[0]}.#{ary[1]}.#{ary[2]}"
|
|
143
174
|
end
|
|
144
|
-
|
|
145
|
-
def self.using_shakapacker_6?
|
|
146
|
-
shakapacker_major_version = shakapacker_version_as_array[0]
|
|
147
|
-
|
|
148
|
-
shakapacker_major_version == 6
|
|
149
|
-
end
|
|
150
175
|
end
|
|
151
176
|
end
|
|
@@ -102,7 +102,7 @@ module ReactOnRails
|
|
|
102
102
|
|
|
103
103
|
generated_interim_server_bundle_path = server_bundle_entrypoint.sub(".js", "-generated.js")
|
|
104
104
|
generated_server_bundle_file_name = component_name(generated_interim_server_bundle_path)
|
|
105
|
-
source_entrypoint_parent = Pathname(ReactOnRails::
|
|
105
|
+
source_entrypoint_parent = Pathname(ReactOnRails::PackerUtils.packer_source_entry_path).parent
|
|
106
106
|
generated_nonentrypoints_path = "#{source_entrypoint_parent}/generated"
|
|
107
107
|
|
|
108
108
|
FileUtils.mkdir_p(generated_nonentrypoints_path)
|
|
@@ -115,12 +115,12 @@ module ReactOnRails
|
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def server_bundle_entrypoint
|
|
118
|
-
Rails.root.join(ReactOnRails::
|
|
118
|
+
Rails.root.join(ReactOnRails::PackerUtils.packer_source_entry_path,
|
|
119
119
|
ReactOnRails.configuration.server_bundle_js_file)
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
def generated_packs_directory_path
|
|
123
|
-
source_entry_path = ReactOnRails::
|
|
123
|
+
source_entry_path = ReactOnRails::PackerUtils.packer_source_entry_path
|
|
124
124
|
|
|
125
125
|
"#{source_entry_path}/generated"
|
|
126
126
|
end
|
|
@@ -185,7 +185,7 @@ module ReactOnRails
|
|
|
185
185
|
end
|
|
186
186
|
|
|
187
187
|
def components_search_path
|
|
188
|
-
source_path = ReactOnRails::
|
|
188
|
+
source_path = ReactOnRails::PackerUtils.packer_source_path
|
|
189
189
|
|
|
190
190
|
"#{source_path}/**/#{ReactOnRails.configuration.components_subdirectory}"
|
|
191
191
|
end
|
|
@@ -19,8 +19,8 @@ module ReactOnRails
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Several Scenarios:
|
|
22
|
-
# 1. No webpack watch processes for static assets and files are
|
|
23
|
-
# 2. Only webpack watch process for server bundle as we're the
|
|
22
|
+
# 1. No webpack watch processes for static assets and files are missing or out of date.
|
|
23
|
+
# 2. Only webpack watch process for server bundle as we're the hot reloading setup.
|
|
24
24
|
# 3. For whatever reason, the watch processes are running, but some clean script removed
|
|
25
25
|
# the generated bundles.
|
|
26
26
|
def call
|
|
@@ -16,7 +16,7 @@ module ReactOnRails
|
|
|
16
16
|
|
|
17
17
|
React on Rails is aborting your test run
|
|
18
18
|
|
|
19
|
-
If you wish to use the config
|
|
19
|
+
If you wish to use the config/#{ReactOnRails::PackerUtils.packer_type}.yml compile option for tests
|
|
20
20
|
them remove your call to the ReactOnRails test helper.
|
|
21
21
|
MSG
|
|
22
22
|
puts Rainbow(msg).red
|
|
@@ -10,7 +10,7 @@ module ReactOnRails
|
|
|
10
10
|
module TestHelper
|
|
11
11
|
class WebpackAssetsStatusChecker
|
|
12
12
|
include Utils::Required
|
|
13
|
-
# source_path is typically configured in the
|
|
13
|
+
# source_path is typically configured in the (shaka/web)packer.yml file
|
|
14
14
|
# for `source_path`
|
|
15
15
|
# or for legacy React on Rails, it's /client, where all client files go
|
|
16
16
|
attr_reader :source_path, :generated_assets_full_path
|
|
@@ -30,8 +30,8 @@ module ReactOnRails
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def stale_generated_files(files)
|
|
33
|
-
manifest_needed = ReactOnRails::
|
|
34
|
-
!ReactOnRails::
|
|
33
|
+
manifest_needed = ReactOnRails::PackerUtils.using_packer? &&
|
|
34
|
+
!ReactOnRails::PackerUtils.manifest_exists?
|
|
35
35
|
|
|
36
36
|
return ["manifest.json"] if manifest_needed
|
|
37
37
|
|
|
@@ -63,7 +63,7 @@ module ReactOnRails
|
|
|
63
63
|
file_list = make_file_list(make_globs(generated_assets_full_path)).to_ary
|
|
64
64
|
puts "V" * 80
|
|
65
65
|
puts "Please define config.webpack_generated_files (array) so the test helper knows " \
|
|
66
|
-
"which files are required. If you are using
|
|
66
|
+
"which files are required. If you are using Shakapacker, you typically need to only " \
|
|
67
67
|
"include 'manifest.json'."
|
|
68
68
|
puts "Detected the possible following files to check for webpack compilation in " \
|
|
69
69
|
"#{generated_assets_full_path}"
|
|
@@ -67,7 +67,7 @@ module ReactOnRails
|
|
|
67
67
|
source_path: nil,
|
|
68
68
|
generated_assets_full_path: nil,
|
|
69
69
|
webpack_generated_files: nil)
|
|
70
|
-
ReactOnRails::
|
|
70
|
+
ReactOnRails::PackerUtils.check_manifest_not_cached
|
|
71
71
|
if webpack_assets_status_checker.nil?
|
|
72
72
|
source_path ||= ReactOnRails::Utils.source_path
|
|
73
73
|
generated_assets_full_path ||= ReactOnRails::Utils.generated_assets_full_path
|
|
@@ -86,10 +86,10 @@ module ReactOnRails
|
|
|
86
86
|
puts
|
|
87
87
|
@printed_once = true
|
|
88
88
|
|
|
89
|
-
if ReactOnRails::
|
|
90
|
-
ReactOnRails::Utils.
|
|
89
|
+
if ReactOnRails::PackerUtils.using_packer? &&
|
|
90
|
+
ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules?
|
|
91
91
|
msg = <<-MSG.strip_heredoc
|
|
92
|
-
WARNING: Define config.
|
|
92
|
+
WARNING: Define config/#{ReactOnRails::PackerUtils.packer_type}.yml to include sourcePath to configure
|
|
93
93
|
the location of your JavaScript source for React on Rails.
|
|
94
94
|
Default location of #{source_path} is used.
|
|
95
95
|
MSG
|
data/lib/react_on_rails/utils.rb
CHANGED
|
@@ -79,12 +79,14 @@ module ReactOnRails
|
|
|
79
79
|
return @server_bundle_path if @server_bundle_path && !Rails.env.development?
|
|
80
80
|
|
|
81
81
|
bundle_name = ReactOnRails.configuration.server_bundle_js_file
|
|
82
|
-
@server_bundle_path = if ReactOnRails::
|
|
82
|
+
@server_bundle_path = if ReactOnRails::PackerUtils.using_packer?
|
|
83
83
|
begin
|
|
84
84
|
bundle_js_file_path(bundle_name)
|
|
85
|
-
rescue
|
|
85
|
+
rescue Object.const_get(
|
|
86
|
+
ReactOnRails::PackerUtils.packer_type.capitalize
|
|
87
|
+
)::Manifest::MissingEntryError
|
|
86
88
|
File.expand_path(
|
|
87
|
-
File.join(ReactOnRails::
|
|
89
|
+
File.join(ReactOnRails::PackerUtils.packer_public_output_path,
|
|
88
90
|
bundle_name)
|
|
89
91
|
)
|
|
90
92
|
end
|
|
@@ -94,12 +96,12 @@ module ReactOnRails
|
|
|
94
96
|
end
|
|
95
97
|
|
|
96
98
|
def self.bundle_js_file_path(bundle_name)
|
|
97
|
-
if ReactOnRails::
|
|
98
|
-
ReactOnRails::
|
|
99
|
+
if ReactOnRails::PackerUtils.using_packer? && bundle_name != "manifest.json"
|
|
100
|
+
ReactOnRails::PackerUtils.bundle_js_uri_from_packer(bundle_name)
|
|
99
101
|
else
|
|
100
102
|
# Default to the non-hashed name in the specified output directory, which, for legacy
|
|
101
103
|
# React on Rails, this is the output directory picked up by the asset pipeline.
|
|
102
|
-
# For
|
|
104
|
+
# For Shakapacker, this is the public output path defined in the (shaka/web)packer.yml file.
|
|
103
105
|
File.join(generated_assets_full_path, bundle_name)
|
|
104
106
|
end
|
|
105
107
|
end
|
|
@@ -129,23 +131,23 @@ module ReactOnRails
|
|
|
129
131
|
end
|
|
130
132
|
|
|
131
133
|
def self.source_path
|
|
132
|
-
if ReactOnRails::
|
|
133
|
-
ReactOnRails::
|
|
134
|
+
if ReactOnRails::PackerUtils.using_packer?
|
|
135
|
+
ReactOnRails::PackerUtils.packer_source_path
|
|
134
136
|
else
|
|
135
137
|
ReactOnRails.configuration.node_modules_location
|
|
136
138
|
end
|
|
137
139
|
end
|
|
138
140
|
|
|
139
|
-
def self.
|
|
140
|
-
return false unless ReactOnRails::
|
|
141
|
+
def self.using_packer_source_path_is_not_defined_and_custom_node_modules?
|
|
142
|
+
return false unless ReactOnRails::PackerUtils.using_packer?
|
|
141
143
|
|
|
142
|
-
!ReactOnRails::
|
|
144
|
+
!ReactOnRails::PackerUtils.packer_source_path_explicit? &&
|
|
143
145
|
ReactOnRails.configuration.node_modules_location.present?
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
def self.generated_assets_full_path
|
|
147
|
-
if ReactOnRails::
|
|
148
|
-
ReactOnRails::
|
|
149
|
+
if ReactOnRails::PackerUtils.using_packer?
|
|
150
|
+
ReactOnRails::PackerUtils.packer_public_output_path
|
|
149
151
|
else
|
|
150
152
|
File.expand_path(ReactOnRails.configuration.generated_assets_dir)
|
|
151
153
|
end
|
|
@@ -156,7 +158,11 @@ module ReactOnRails
|
|
|
156
158
|
rescue Gem::LoadError
|
|
157
159
|
false
|
|
158
160
|
rescue StandardError
|
|
159
|
-
|
|
161
|
+
begin
|
|
162
|
+
Gem.available?(name).present?
|
|
163
|
+
rescue NoMethodError
|
|
164
|
+
false
|
|
165
|
+
end
|
|
160
166
|
end
|
|
161
167
|
|
|
162
168
|
# Todo -- remove this for v13, as we don't need both boolean and number
|
data/lib/react_on_rails.rb
CHANGED
|
@@ -18,7 +18,7 @@ require "react_on_rails/version_syntax_converter"
|
|
|
18
18
|
require "react_on_rails/test_helper"
|
|
19
19
|
require "react_on_rails/git_utils"
|
|
20
20
|
require "react_on_rails/utils"
|
|
21
|
-
require "react_on_rails/
|
|
21
|
+
require "react_on_rails/packer_utils"
|
|
22
22
|
require "react_on_rails/packs_generator"
|
|
23
23
|
require "react_on_rails/test_helper/webpack_assets_compiler"
|
|
24
24
|
require "react_on_rails/test_helper/webpack_assets_status_checker"
|
data/lib/tasks/assets.rake
CHANGED
|
@@ -5,7 +5,7 @@ namespace :react_on_rails do
|
|
|
5
5
|
namespace :assets do
|
|
6
6
|
desc <<~DESC
|
|
7
7
|
If config.build_production_command is defined, this command is automatically
|
|
8
|
-
added to task assets:precompile and the regular
|
|
8
|
+
added to task assets:precompile and the regular packer compile will not run.
|
|
9
9
|
The defined command is either a script or a module with a method `call`.
|
|
10
10
|
DESC
|
|
11
11
|
task webpack: :locale do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: react_on_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 14.0.
|
|
4
|
+
version: 14.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Gordon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-06-
|
|
11
|
+
date: 2024-06-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -129,8 +129,8 @@ files:
|
|
|
129
129
|
- lib/generators/react_on_rails/react_no_redux_generator.rb
|
|
130
130
|
- lib/generators/react_on_rails/react_with_redux_generator.rb
|
|
131
131
|
- lib/generators/react_on_rails/templates/.eslintrc
|
|
132
|
-
- lib/generators/react_on_rails/templates/base/base/Procfile.dev
|
|
133
|
-
- lib/generators/react_on_rails/templates/base/base/Procfile.dev
|
|
132
|
+
- lib/generators/react_on_rails/templates/base/base/Procfile.dev-static.tt
|
|
133
|
+
- lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt
|
|
134
134
|
- lib/generators/react_on_rails/templates/base/base/app/controllers/hello_world_controller.rb
|
|
135
135
|
- lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx
|
|
136
136
|
- lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css
|
|
@@ -140,7 +140,7 @@ files:
|
|
|
140
140
|
- lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt
|
|
141
141
|
- lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb
|
|
142
142
|
- lib/generators/react_on_rails/templates/base/base/babel.config.js.tt
|
|
143
|
-
- lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb
|
|
143
|
+
- lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt
|
|
144
144
|
- lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml
|
|
145
145
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/clientWebpackConfig.js.tt
|
|
146
146
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt
|
|
@@ -175,6 +175,7 @@ files:
|
|
|
175
175
|
- lib/react_on_rails/locales/base.rb
|
|
176
176
|
- lib/react_on_rails/locales/to_js.rb
|
|
177
177
|
- lib/react_on_rails/locales/to_json.rb
|
|
178
|
+
- lib/react_on_rails/packer_utils.rb
|
|
178
179
|
- lib/react_on_rails/packs_generator.rb
|
|
179
180
|
- lib/react_on_rails/prerender_error.rb
|
|
180
181
|
- lib/react_on_rails/react_component/render_options.rb
|
|
@@ -189,7 +190,6 @@ files:
|
|
|
189
190
|
- lib/react_on_rails/version.rb
|
|
190
191
|
- lib/react_on_rails/version_checker.rb
|
|
191
192
|
- lib/react_on_rails/version_syntax_converter.rb
|
|
192
|
-
- lib/react_on_rails/webpacker_utils.rb
|
|
193
193
|
- lib/tasks/assets.rake
|
|
194
194
|
- lib/tasks/generate_packs.rake
|
|
195
195
|
- lib/tasks/locale.rake
|
|
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
220
220
|
- !ruby/object:Gem::Version
|
|
221
221
|
version: '0'
|
|
222
222
|
requirements: []
|
|
223
|
-
rubygems_version: 3.5.
|
|
223
|
+
rubygems_version: 3.5.3
|
|
224
224
|
signing_key:
|
|
225
225
|
specification_version: 4
|
|
226
226
|
summary: Rails with react server rendering with webpack.
|