react_on_rails 11.1.8 → 11.2.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 +4 -4
- data/.eslintrc +8 -2
- data/.prettierignore +1 -0
- data/.prettierrc +20 -0
- data/.release-it.json +3 -0
- data/CHANGELOG.md +19 -3
- data/CONTRIBUTING.md +1 -9
- data/Gemfile +0 -1
- data/Gemfile.rails32 +0 -1
- data/README.md +1 -1
- data/SUMMARY.md +1 -0
- data/docs/additional-reading/images.md +1 -1
- data/docs/additional-reading/rails_view_rendering_from_inline_javascript.md +2 -1
- data/docs/additional-reading/upgrade-webpacker-v3-to-v4.md +10 -0
- data/docs/api/view-helpers-api.md +10 -6
- data/docs/basics/configuration.md +4 -4
- data/docs/basics/recommended-project-structure.md +1 -1
- data/docs/misc-pending/code-splitting.md +2 -2
- data/docs/testimonials/hvmn.md +3 -3
- data/docs/tutorial.md +26 -1
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -0
- data/lib/generators/react_on_rails/install_generator.rb +2 -0
- data/lib/react_on_rails.rb +1 -0
- data/lib/react_on_rails/assets_precompile.rb +3 -0
- data/lib/react_on_rails/configuration.rb +2 -1
- data/lib/react_on_rails/git_utils.rb +2 -0
- data/lib/react_on_rails/helper.rb +12 -20
- data/lib/react_on_rails/json_output.rb +1 -1
- data/lib/react_on_rails/locales_to_js.rb +2 -0
- data/lib/react_on_rails/server_rendering_js_code.rb +42 -0
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +30 -5
- data/lib/react_on_rails/utils.rb +1 -1
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +4 -1
- data/lib/react_on_rails/webpacker_utils.rb +4 -1
- data/package-scripts.yml +46 -0
- data/package.json +24 -15
- data/rakelib/release.rake +3 -2
- data/react_on_rails.gemspec +1 -1
- data/webpackConfigLoader.js +2 -2
- data/yarn.lock +4431 -1689
- metadata +11 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 58ddd567b8392bb832697cd980a5267f111d59bfa993bb50b47fc18599f249f5
         | 
| 4 | 
            +
              data.tar.gz: d16cc96276768d7739d4271247808dd65a1ce1566fdb44bc1e65283731756be1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 188e2ec8f54d6019ad2e626cfd2f063485f9d30ab0c1d538e8b9dc43bbd7c9aa58e8c8fb9e4eee9a4d433ac1cbd4b81ad67ba828069b1959ad4176f8c26e0947
         | 
| 7 | 
            +
              data.tar.gz: ef4e23b168089ec5e05dd8dd1658fba60e73fbd8f90a38ffa503d1d47bc0831275a52d0e063d262e5e73f10a45c01aac7a4a19f3751bd946841290e89aef4e78
         | 
    
        data/.eslintrc
    CHANGED
    
    | @@ -1,8 +1,11 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
            extends: | 
| 2 | 
            +
            extends:
         | 
| 3 | 
            +
              - eslint-config-shakacode
         | 
| 4 | 
            +
              - prettier
         | 
| 5 | 
            +
              - prettier/react
         | 
| 3 6 |  | 
| 4 7 | 
             
            plugins:
         | 
| 5 | 
            -
              -  | 
| 8 | 
            +
              - prettier
         | 
| 6 9 |  | 
| 7 10 | 
             
            globals:
         | 
| 8 11 | 
             
              __DEBUG_SERVER_ERRORS__: true
         | 
| @@ -15,6 +18,9 @@ env: | |
| 15 18 |  | 
| 16 19 | 
             
            rules:
         | 
| 17 20 | 
             
              no-console: 0
         | 
| 21 | 
            +
              function-paren-newline: 0
         | 
| 22 | 
            +
              object-curly-newline: 0
         | 
| 23 | 
            +
             | 
| 18 24 |  | 
| 19 25 | 
             
              # https://github.com/benmosher/eslint-plugin-import/issues/340
         | 
| 20 26 | 
             
              import/no-extraneous-dependencies: 0
         | 
    
        data/.prettierignore
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            node_modules
         | 
    
        data/.prettierrc
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            printWidth: 110
         | 
| 2 | 
            +
            tabWidth: 2
         | 
| 3 | 
            +
            useTabs: false
         | 
| 4 | 
            +
            semi: true
         | 
| 5 | 
            +
            singleQuote: true
         | 
| 6 | 
            +
            trailingComma: all
         | 
| 7 | 
            +
            bracketSpacing: true
         | 
| 8 | 
            +
            jsxBracketSameLine: false
         | 
| 9 | 
            +
            parser: flow
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            overrides:
         | 
| 12 | 
            +
            - files: "*.@(css|scss)"
         | 
| 13 | 
            +
              options:
         | 
| 14 | 
            +
                parser: css
         | 
| 15 | 
            +
                singleQuote: false
         | 
| 16 | 
            +
                printWidth: 120
         | 
| 17 | 
            +
            - files: "*.@(json)"
         | 
| 18 | 
            +
              options:
         | 
| 19 | 
            +
                parser: json
         | 
| 20 | 
            +
                printWidth: 100
         | 
    
        data/.release-it.json
    ADDED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            # Change Log
         | 
| 2 2 | 
             
            All notable changes to this project's source code will be documented in this file. Items under `Unreleased` is upcoming features that will be out in next version. NOTE: major versions of the npm module and the gem must be kept in sync.
         | 
| 3 3 |  | 
| 4 | 
            -
            Migration instructions for the major updates can be found [here](docs/basics/upgrading-react-on-rails.md#upgrading-to-version-9.md). Some smaller migration information can be found here. | 
| 4 | 
            +
            Migration instructions for the major updates can be found [here](docs/basics/upgrading-react-on-rails.md#upgrading-to-version-9.md). Some smaller migration information can be found here.
         | 
| 5 5 |  | 
| 6 6 | 
             
            ## Need Help Migrating?
         | 
| 7 7 | 
             
            If you would like help in migrating between React on Rails versions or help with implementing server rendering, please contact [justin@shakacode.com](mailto:justin@shakacode.com) for information about our [ShakaCode Pro Support](https://www.shakacode.com/work/shakacode-pro-support.pdf).
         | 
| @@ -16,6 +16,21 @@ Changes since last non-beta release. | |
| 16 16 |  | 
| 17 17 | 
             
            *Please add entries here for your pull requests that are not yet released.*
         | 
| 18 18 |  | 
| 19 | 
            +
            ### [11.2.0] - 2018-10-25
         | 
| 20 | 
            +
            #### Improved
         | 
| 21 | 
            +
            - To support React v16, updated API for manually calling `ReactOnRails.render(name, props, domNodeId, hydrate)`. Added 3rd @param hydrate Pass truthy to update server rendered html. Default is falsey Any truthy values calls hydrate rather than render. (https://github.com/shakacode/react_on_rails/pull/1159) by [justin808](https://github.com/justin808) and [coopersamuel](https://github.com/coopersamuel).
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            - Enabled the use of webpack-dev-server with Server-side rendering. (https://github.com/shakacode/react_on_rails/pull/1173) by [justin808](https://github.com/justin808) and [judahmeek](https://github.com/judahmeek).
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            #### Changed
         | 
| 26 | 
            +
            - Changed the default for:
         | 
| 27 | 
            +
              ```rb
         | 
| 28 | 
            +
              config.raise_on_prerender_error = Rails.env.development? 
         | 
| 29 | 
            +
              ```
         | 
| 30 | 
            +
              
         | 
| 31 | 
            +
              Thus, developers will need to fix server rendering errors before continuing.
         | 
| 32 | 
            +
              [PR 1145](https://github.com/shakacode/react_on_rails/pull/1145) by [justin808](https://github.com/justin808).
         | 
| 33 | 
            +
              
         | 
| 19 34 | 
             
            ### [11.1.8] - 2018-10-14
         | 
| 20 35 |  | 
| 21 36 | 
             
            #### Improved
         | 
| @@ -50,7 +65,7 @@ Changes since last non-beta release. | |
| 50 65 |  | 
| 51 66 | 
             
            #### Fixed
         | 
| 52 67 | 
             
            - Tests now properly exit if the config.build_test_command fails!
         | 
| 53 | 
            -
            - Source path for project using Webpacker would default to "app/javascript" even if when the node_modules | 
| 68 | 
            +
            - Source path for project using Webpacker would default to "app/javascript" even if when the node_modules
         | 
| 54 69 | 
             
              directory was set to "client". Fix now makes the configuration of this crystal clear.
         | 
| 55 70 | 
             
            - renamed method RenderOptions.has_random_dom_id? to RenderOptions.random_dom_id? for rubocop rule.
         | 
| 56 71 | 
             
            [PR 1133](https://github.com/shakacode/react_on_rails/pull/1133) by [justin808](https://github.com/justin808)
         | 
| @@ -839,7 +854,8 @@ Best done with Object destructing: | |
| 839 854 | 
             
            ##### Fixed
         | 
| 840 855 | 
             
            - Fix several generator related issues.
         | 
| 841 856 |  | 
| 842 | 
            -
            [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11. | 
| 857 | 
            +
            [Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.2.0...master
         | 
| 858 | 
            +
            [11.2.0]: https://github.com/shakacode/react_on_rails/compare/11.1.8...11.2.0
         | 
| 843 859 | 
             
            [11.1.8]: https://github.com/shakacode/react_on_rails/compare/11.1.7...11.1.8
         | 
| 844 860 | 
             
            [11.1.7]: https://github.com/shakacode/react_on_rails/compare/11.1.6...11.1.7
         | 
| 845 861 | 
             
            [11.1.6]: https://github.com/shakacode/react_on_rails/compare/11.1.5...11.1.6
         | 
    
        data/CONTRIBUTING.md
    CHANGED
    
    | @@ -127,14 +127,6 @@ _Note: running `npm i` automatically builds the npm package before installing. H | |
| 127 127 | 
             
            ### Prereqs
         | 
| 128 128 | 
             
            After checking out the repo, making sure you have rvm and nvm setup (setup ruby and node), cd to `spec/dummy` and run `bin/setup` to install ruby dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 129 129 |  | 
| 130 | 
            -
            Additionally, our RSpec tests use the poltergeist web driver. You will need to install the phantomjs node module:
         | 
| 131 | 
            -
             | 
| 132 | 
            -
            ```sh
         | 
| 133 | 
            -
            yarn global add phantomjs-prebuilt
         | 
| 134 | 
            -
            ```
         | 
| 135 | 
            -
             | 
| 136 | 
            -
            Note this *must* be installed globally for the dummy test project rspec runner to see it properly.
         | 
| 137 | 
            -
             | 
| 138 130 | 
             
            ### Local Node Package
         | 
| 139 131 | 
             
            Because the example and dummy apps rely on the react-on-rails node package, they should link directly to your local version to pick up any changes you may have made to that package. To achieve this, switch to the dummy app's root directory and run this command below which runs something like [this script](spec/dummy/package.json#L14)
         | 
| 140 132 |  | 
| @@ -171,7 +163,7 @@ spec/dummy. | |
| 171 163 |  | 
| 172 164 | 
             
            ```sh
         | 
| 173 165 | 
             
            # Optionally change default selenium_firefox driver
         | 
| 174 | 
            -
            export DRIVER= | 
| 166 | 
            +
            export DRIVER=selenium_firefox
         | 
| 175 167 | 
             
            cd react_on_rails/
         | 
| 176 168 | 
             
            yarn run dummy:spec
         | 
| 177 169 | 
             
            ```
         | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.rails32
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -34,7 +34,7 @@ _Requires creating a free account._ | |
| 34 34 |  | 
| 35 35 | 
             
            React on Rails Pro provides Node server rendering and other performance enhancements for React on Rails. 
         | 
| 36 36 |  | 
| 37 | 
            -
            
         | 
| 37 | 
            +
            [](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
         | 
| 38 38 |  | 
| 39 39 | 
             
            * [HVMN Testimonial, Written by Paul Benigeri, October 12, 2018](./docs/testimonials/hvmn.md)
         | 
| 40 40 | 
             
            * [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
         | 
    
        data/SUMMARY.md
    CHANGED
    
    | @@ -26,6 +26,7 @@ | |
| 26 26 | 
             
              + [Generator Details](docs/basics/generator-details.md)
         | 
| 27 27 | 
             
              + [Updating Dependencies](./docs/additional-reading/updating-dependencies.md)
         | 
| 28 28 | 
             
              + [Manual Installation Overview](docs/misc-pending/manual-installation-overview.md)
         | 
| 29 | 
            +
              + [Upgrading from rails/webpacker v3 to v4](docs/additional-reading/upgrade-webpacker-v3-to-v4.md)
         | 
| 29 30 |  | 
| 30 31 | 
             
            ## **Rails**
         | 
| 31 32 | 
             
              + [Rails Engine Integration](./docs/additional-reading/rails-engine-integration.md)
         | 
| @@ -39,7 +39,7 @@ const assetLoaderRules = [ | |
| 39 39 |  | 
| 40 40 |  | 
| 41 41 |  | 
| 42 | 
            -
            A full example can be found at [spec/dummy/client/app/components/ImageExample/ImageExample. | 
| 42 | 
            +
            A full example can be found at [spec/dummy/client/app/components/ImageExample/ImageExample.jsx](../../spec/dummy/client/app/components/ImageExample/ImageExample.jsx)
         | 
| 43 43 |  | 
| 44 44 | 
             
            You are free to use images either in image tags or as background images in SCSS files. You can 
         | 
| 45 45 | 
             
            use a "global" location of /client/app/assets/images or a relative path to your JS or SCSS file, as
         | 
| @@ -12,9 +12,10 @@ You can easily render React components in your JavaScript with `render` method t | |
| 12 12 | 
             
             * @param name Name of your registered component
         | 
| 13 13 | 
             
             * @param props Props to pass to your component
         | 
| 14 14 | 
             
             * @param domNodeId
         | 
| 15 | 
            +
             * @param hydrate [optional] Pass truthy to update server rendered html. Default is falsy
         | 
| 15 16 | 
             
             * @returns {virtualDomElement} Reference to your component's backing instance
         | 
| 16 17 | 
             
             */
         | 
| 17 | 
            -
            ReactOnRails.render(componentName, props,  | 
| 18 | 
            +
            ReactOnRails.render(componentName, props, domNodeId)
         | 
| 18 19 | 
             
            ```
         | 
| 19 20 |  | 
| 20 21 | 
             
            ## Why do we need this?
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            # Upgrading rails/webpacker v3.5 to v4
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            The following steps can be followed to update a Webpacker v3.5 app to v4.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            1. Update the gem `webpacker` and the package `@rails/webpacker`
         | 
| 6 | 
            +
            1. Merge changes from the new default [.babelrc](../lib/install/config/.babelrc) to your `/.babelrc`. If you are using React, you need to add `"@babel/preset-react"`, to the list of `presets`.
         | 
| 7 | 
            +
            1. Copy the file [.browserslistrc](../lib/install/config/.browserslistrc) to `/`.
         | 
| 8 | 
            +
            1. Merge any differences between [config/webpacker.yml](../lib/install/config/webpacker.yml) and your `/config/webpacker.yml`.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Here is an [example commit of these changes](https://github.com/shakacode/react_on_rails-tutorial-v11/pull/1/files).
         | 
| @@ -10,14 +10,18 @@ Once the bundled files have been generated in your `app/assets/webpack` folder a | |
| 10 10 | 
             
            ```ruby
         | 
| 11 11 | 
             
            react_component(component_name,
         | 
| 12 12 | 
             
                            props: {},
         | 
| 13 | 
            -
                            prerender: nil | 
| 14 | 
            -
                            trace: nil,
         | 
| 15 | 
            -
                            replay_console: nil,
         | 
| 16 | 
            -
                            raise_on_prerender_error: nil,
         | 
| 17 | 
            -
                            id: nil,
         | 
| 13 | 
            +
                            prerender: nil)
         | 
| 18 14 | 
             
                            html_options: {})
         | 
| 19 15 | 
             
            ```
         | 
| 20 16 |  | 
| 17 | 
            +
            Uncommonly used options:
         | 
| 18 | 
            +
            ```
         | 
| 19 | 
            +
              trace: nil,
         | 
| 20 | 
            +
              replay_console: nil,
         | 
| 21 | 
            +
              raise_on_prerender_error: nil,
         | 
| 22 | 
            +
              id: nil,
         | 
| 23 | 
            +
            ```
         | 
| 24 | 
            +
             | 
| 21 25 | 
             
            - **component_name:** Can be a React component, created using an ES6 class or a generator function that returns a React component (or, only on the server side, an object with shape { redirectLocation, error, renderedHtml }), or a "renderer function" that manually renders a React component to the dom (client side only).
         | 
| 22 26 | 
             
              All options except `props, id, html_options` will inherit from your `react_on_rails.rb` initializer, as described [here](../basics/configuration.md).
         | 
| 23 27 | 
             
            - **general options:**
         | 
| @@ -41,7 +45,7 @@ adding meta-tags to a page. It is exactly like react_component except for the fo | |
| 41 45 |  | 
| 42 46 | 
             
            1. `prerender: true` is automatically added to options, as this method doesn't make sense for 
         | 
| 43 47 | 
             
               client only rendering.
         | 
| 44 | 
            -
            2. Your JavaScript for server rendering must return an Object  | 
| 48 | 
            +
            2. Your JavaScript generator function for server rendering must return an Object rather than a React Component.
         | 
| 45 49 | 
             
            3. Your view code must expect an object and not a string.
         | 
| 46 50 |  | 
| 47 51 | 
             
            Here is an example of ERB view code:
         | 
| @@ -124,7 +124,6 @@ ReactOnRails.configure do |config| | |
| 124 124 | 
             
              # While you may configure this to be the same as your client bundle file, this file is typically
         | 
| 125 125 | 
             
              # different. Note, be sure to include the exact file name with the ".js" if you are not hashing this file.
         | 
| 126 126 | 
             
              # If you are hashing this file (supposing you are using the same file for client rendering), then
         | 
| 127 | 
            -
              # 
         | 
| 128 127 | 
             
              # you should include a name that matches your bundle name in your webpack config.
         | 
| 129 128 | 
             
              config.server_bundle_js_file = "server-bundle.js"
         | 
| 130 129 |  | 
| @@ -145,10 +144,11 @@ ReactOnRails.configure do |config| | |
| 145 144 | 
             
              #
         | 
| 146 145 | 
             
              config.logging_on_server = true
         | 
| 147 146 |  | 
| 148 | 
            -
              # Default is  | 
| 149 | 
            -
              #  | 
| 147 | 
            +
              # Default is true only for development? to raise exception on server if the JS code throws for
         | 
| 148 | 
            +
              # server rendering. The reason is that the server logs will show the error and force you to fix
         | 
| 149 | 
            +
              # any server rendering issues immediately during development. 
         | 
| 150 150 | 
             
              # 
         | 
| 151 | 
            -
              config.raise_on_prerender_error =  | 
| 151 | 
            +
              config.raise_on_prerender_error = Rails.env.development? 
         | 
| 152 152 |  | 
| 153 153 | 
             
              ################################################################################
         | 
| 154 154 | 
             
              # Server Renderer Configuration for ExecJS
         | 
| @@ -47,7 +47,7 @@ mv app/javascript client | |
| 47 47 | 
             
            `rails/webpacker` probably doesn't support having your main node_modules directory under `/client`, so only follow these steps if you want to use your own webpack configuration (which is highly recommended!).
         | 
| 48 48 |  | 
| 49 49 | 
             
            1. Move the `/package.json` to `/client/package.json`
         | 
| 50 | 
            -
            2. Create a `/ | 
| 50 | 
            +
            2. Create a `/package.json` that delegates to `/client/package.json`. See the example in [spec/dummy/package.json](../../spec/dummy/package.json).
         | 
| 51 51 | 
             
            3. See the webpack configuration in [spec/dummy/client](../../spec/dummy/client) for a webpack configuration example.
         | 
| 52 52 |  | 
| 53 53 |  | 
| @@ -21,7 +21,7 @@ Different markup is generated on the client than on the server. Why does this ha | |
| 21 21 |  | 
| 22 22 | 
             
            ### The solution
         | 
| 23 23 |  | 
| 24 | 
            -
            To prevent this, you have to wait until the code chunk is fetched before doing the initial render on the client side. To accomplish this, react on rails allows you to register a renderer. This works just like registering a generator function, except that the function you pass takes three arguments: `renderer(props, railsContext, domNodeId)`, and is responsible for calling `ReactDOM.render` to render the component to the DOM. React on rails will automatically detect when a generator function takes three arguments, and will not call `ReactDOM.render`, instead allowing you to control the initial render yourself.
         | 
| 24 | 
            +
            To prevent this, you have to wait until the code chunk is fetched before doing the initial render on the client side. To accomplish this, react on rails allows you to register a renderer. This works just like registering a generator function, except that the function you pass takes three arguments: `renderer(props, railsContext, domNodeId)`, and is responsible for calling `ReactDOM.render` or `ReactDOM.hydrate` to render the component to the DOM. React on rails will automatically detect when a generator function takes three arguments, and will not call `ReactDOM.render` or `ReactDOM.hydrate`, instead allowing you to control the initial render yourself. Note, you have to be careful to call `ReactDOM.hydrate` rather than `ReactDOM.render` if you are are server rendering.
         | 
| 25 25 |  | 
| 26 26 | 
             
            Here's an example of how you might use this in practice:
         | 
| 27 27 |  | 
| @@ -115,7 +115,7 @@ See: | |
| 115 115 |  | 
| 116 116 | 
             
            - [spec/dummy/client/app/startup/clientRegistration.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/clientRegistration.jsx)
         | 
| 117 117 | 
             
            - [spec/dummy/client/app/startup/serverRegistration.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/serverRegistration.jsx)
         | 
| 118 | 
            -
            - [spec/dummy/client/app/startup/ | 
| 118 | 
            +
            - [spec/dummy/client/app/startup/DeferredRenderAppClient](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/DeferredRenderAppClient.jsx)<-- Code splitting implemented here
         | 
| 119 119 | 
             
            - [spec/dummy/client/app/startup/DeferredRenderAppServer.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/startup/DeferredRenderAppServer.jsx)
         | 
| 120 120 | 
             
            - [spec/dummy/client/app/components/DeferredRender.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/components/DeferredRender.jsx)
         | 
| 121 121 | 
             
            - [spec/dummy/client/app/components/DeferredRenderAsyncPage.jsx](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/client/app/components/DeferredRenderAsyncPage.jsx)
         | 
    
        data/docs/testimonials/hvmn.md
    CHANGED
    
    | @@ -16,9 +16,9 @@ The price we paid for the consultation + the React on Rails pro license has alre | |
| 16 16 |  | 
| 17 17 | 
             
            If you have any questions, please reach out.
         | 
| 18 18 |  | 
| 19 | 
            -
            Paul Benigeri
         | 
| 20 | 
            -
             | 
| 21 | 
            -
            [LinkedIn](https://www.linkedin.com/in/benigeri/)
         | 
| 19 | 
            +
            Paul Benigeri, Head of E-Commerce
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            [paul@hvmn.com](mailto:paul@hvmn.com), [LinkedIn](https://www.linkedin.com/in/benigeri/)
         | 
| 22 22 |  | 
| 23 23 | 
             
            Related Article: [HVMN’s 90% Reduction in Server Response Time from React on Rails Pro](https://blog.shakacode.com/hvmns-90-reduction-in-server-response-time-from-react-on-rails-pro-eb08226687db)
         | 
| 24 24 |  | 
    
        data/docs/tutorial.md
    CHANGED
    
    | @@ -84,15 +84,40 @@ rails generate react_on_rails:install | |
| 84 84 | 
             
            bundle && yarn
         | 
| 85 85 | 
             
            ```
         | 
| 86 86 |  | 
| 87 | 
            -
             | 
| 87 | 
            +
            Then run server with static client side files:
         | 
| 88 88 |  | 
| 89 89 | 
             
            ```
         | 
| 90 90 | 
             
            foreman start -f Procfile.dev
         | 
| 91 91 | 
             
            ```
         | 
| 92 92 |  | 
| 93 | 
            +
            To run with the webpack-dev-server:
         | 
| 94 | 
            +
            ```
         | 
| 95 | 
            +
            foreman start -f Procfile.dev-server
         | 
| 96 | 
            +
            ```
         | 
| 97 | 
            +
             | 
| 93 98 | 
             
            Visit [http://localhost:3000/hello_world](http://localhost:3000/hello_world) and see your **React On Rails** app running!
         | 
| 94 99 | 
             
            Note, foreman defaults to PORT 5000 unless you set the value of PORT in your environment or in the Procfile.
         | 
| 95 100 |  | 
| 101 | 
            +
            ## Using a pre-release of rails/webpacker
         | 
| 102 | 
            +
            Until `rails/webpacker` v4 ships, or if you ever want to try out the master branch, you can modify the React on Rails tutorial instructions slightly. You can see the sequence of commits here. To summarize:
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            Don't `run rails new with the --webpack=react option`. Instead, add the webpacker gem to the Gemfile such that it points to master, like this if `11.2.0` is the version you want.
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            ```ruby
         | 
| 107 | 
            +
            gem 'webpacker', github: "rails/webpacker"
         | 
| 108 | 
            +
            gem 'react_on_rails', '11.2.0' # always use exact version
         | 
| 109 | 
            +
            ```
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            Then run these commands:
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            ```sh
         | 
| 114 | 
            +
            bundle exec rails webpacker:install
         | 
| 115 | 
            +
            yarn add "rails/webpacker" # because the installer has a bug that puts in an invalid version in your package.json.
         | 
| 116 | 
            +
            bundle exec rails webpacker:install:react
         | 
| 117 | 
            +
            yarn add --dev webpack-dev-server
         | 
| 118 | 
            +
            run rails generate react_on_rails:install && bundle && yarn
         | 
| 119 | 
            +
            ```
         | 
| 120 | 
            +
             | 
| 96 121 | 
             
            ### Custom IP & PORT setup (Cloud9 example)
         | 
| 97 122 |  | 
| 98 123 | 
             
            In case you are running some custom setup with different IP or PORT you should also edit Procfile.dev. For example to be able to run on free Cloud9 IDE we are putting IP 0.0.0.0 and PORT 8080. The default generated file `Procfile.dev` uses `-p 3000`.
         | 
| @@ -36,6 +36,7 @@ module ReactOnRails | |
| 36 36 |  | 
| 37 37 | 
             
                  def replace_prerender_if_server_rendering
         | 
| 38 38 | 
             
                    return unless options.example_server_rendering
         | 
| 39 | 
            +
             | 
| 39 40 | 
             
                    hello_world_index = File.join(destination_root, "app", "views", "hello_world", "index.html.erb")
         | 
| 40 41 | 
             
                    hello_world_contents = File.read(hello_world_index)
         | 
| 41 42 | 
             
                    new_hello_world_contents = hello_world_contents.gsub(/prerender: false/,
         | 
| @@ -62,6 +62,7 @@ module ReactOnRails | |
| 62 62 |  | 
| 63 63 | 
             
                  def missing_yarn?
         | 
| 64 64 | 
             
                    return false unless ReactOnRails::Utils.running_on_windows? ? `where yarn`.blank? : `which yarn`.blank?
         | 
| 65 | 
            +
             | 
| 65 66 | 
             
                    error = "yarn is required. Please install it before continuing. https://yarnpkg.com/en/docs/install"
         | 
| 66 67 | 
             
                    GeneratorMessages.add_error(error)
         | 
| 67 68 | 
             
                    true
         | 
| @@ -69,6 +70,7 @@ module ReactOnRails | |
| 69 70 |  | 
| 70 71 | 
             
                  def missing_node?
         | 
| 71 72 | 
             
                    return false unless ReactOnRails::Utils.running_on_windows? ? `where node`.blank? : `which node`.blank?
         | 
| 73 | 
            +
             | 
| 72 74 | 
             
                    error = "** nodejs is required. Please install it before continuing. https://nodejs.org/en/"
         | 
| 73 75 | 
             
                    GeneratorMessages.add_error(error)
         | 
| 74 76 | 
             
                    true
         | 
    
        data/lib/react_on_rails.rb
    CHANGED
    
    | @@ -11,6 +11,7 @@ require "react_on_rails/version" | |
| 11 11 | 
             
            require "react_on_rails/version_checker"
         | 
| 12 12 | 
             
            require "react_on_rails/configuration"
         | 
| 13 13 | 
             
            require "react_on_rails/server_rendering_pool"
         | 
| 14 | 
            +
            require "react_on_rails/server_rendering_js_code"
         | 
| 14 15 | 
             
            require "react_on_rails/engine"
         | 
| 15 16 | 
             
            require "react_on_rails/react_component/render_options"
         | 
| 16 17 | 
             
            require "react_on_rails/version_syntax_converter"
         | 
| @@ -64,6 +64,7 @@ module ReactOnRails | |
| 64 64 | 
             
                  # references from webpack's CSS would be invalid. The fix is to symlink the double-digested
         | 
| 65 65 | 
             
                  # file back to the original digested name, and make a similar symlink for the gz version.
         | 
| 66 66 | 
             
                  return unless @symlink_non_digested_assets_regex
         | 
| 67 | 
            +
             | 
| 67 68 | 
             
                  manifest_glob = Dir.glob(@assets_path.join(".sprockets-manifest-*.json")) +
         | 
| 68 69 | 
             
                                  Dir.glob(@assets_path.join("manifest-*.json")) +
         | 
| 69 70 | 
             
                                  Dir.glob(@assets_path.join("manifest.yml"))
         | 
| @@ -86,6 +87,7 @@ module ReactOnRails | |
| 86 87 | 
             
                  manifest_data.each do |original_filename, rails_digested_filename|
         | 
| 87 88 | 
             
                    # TODO: we should remove any original_filename that is NOT in the webpack deploy folder.
         | 
| 88 89 | 
             
                    next unless original_filename =~ @symlink_non_digested_assets_regex
         | 
| 90 | 
            +
             | 
| 89 91 | 
             
                    # We're symlinking from the digested filename back to the original filename which has
         | 
| 90 92 | 
             
                    # already been symlinked by Webpack
         | 
| 91 93 | 
             
                    symlink_file(rails_digested_filename, original_filename)
         | 
| @@ -100,6 +102,7 @@ module ReactOnRails | |
| 100 102 | 
             
                def delete_broken_symlinks
         | 
| 101 103 | 
             
                  Dir.glob(@assets_path.join("*")).each do |filename|
         | 
| 102 104 | 
             
                    next unless File.lstat(filename).symlink?
         | 
| 105 | 
            +
             | 
| 103 106 | 
             
                    begin
         | 
| 104 107 | 
             
                      target = File.readlink(filename)
         | 
| 105 108 | 
             
                    rescue StandardError
         | 
| @@ -21,7 +21,7 @@ module ReactOnRails | |
| 21 21 | 
             
                  prerender: false,
         | 
| 22 22 | 
             
                  replay_console: true,
         | 
| 23 23 | 
             
                  logging_on_server: true,
         | 
| 24 | 
            -
                  raise_on_prerender_error:  | 
| 24 | 
            +
                  raise_on_prerender_error: Rails.env.development?,
         | 
| 25 25 | 
             
                  trace: Rails.env.development?,
         | 
| 26 26 | 
             
                  development_mode: Rails.env.development?,
         | 
| 27 27 | 
             
                  server_renderer_pool_size: DEFAULT_POOL_SIZE,
         | 
| @@ -218,6 +218,7 @@ module ReactOnRails | |
| 218 218 |  | 
| 219 219 | 
             
                def configure_skip_display_none_deprecation
         | 
| 220 220 | 
             
                  return if skip_display_none.nil?
         | 
| 221 | 
            +
             | 
| 221 222 | 
             
                  Rails.logger.warn "[DEPRECATION] ReactOnRails: remove skip_display_none from configuration."
         | 
| 222 223 | 
             
                end
         | 
| 223 224 | 
             
              end
         | 
| @@ -6,8 +6,10 @@ module ReactOnRails | |
| 6 6 | 
             
              module GitUtils
         | 
| 7 7 | 
             
                def self.uncommitted_changes?(message_handler)
         | 
| 8 8 | 
             
                  return false if ENV["COVERAGE"] == "true"
         | 
| 9 | 
            +
             | 
| 9 10 | 
             
                  status = `git status --porcelain`
         | 
| 10 11 | 
             
                  return false if $CHILD_STATUS.success? && status.empty?
         | 
| 12 | 
            +
             | 
| 11 13 | 
             
                  error = if !$CHILD_STATUS.success?
         | 
| 12 14 | 
             
                            "You do not have Git installed. Please install Git, and commit your changes before continuing"
         | 
| 13 15 | 
             
                          else
         | 
| @@ -136,7 +136,7 @@ module ReactOnRails | |
| 136 136 | 
             
                # It is exactly like react_component except for the following:
         | 
| 137 137 | 
             
                # 1. prerender: true is automatically added, as this method doesn't make sense for client only
         | 
| 138 138 | 
             
                #    rendering.
         | 
| 139 | 
            -
                # 2. Your JavaScript for server rendering must return an Object  | 
| 139 | 
            +
                # 2. Your JavaScript generator function for server rendering must return an Object rather than a React component.
         | 
| 140 140 | 
             
                # 3. Your view code must expect an object and not a string.
         | 
| 141 141 | 
             
                #
         | 
| 142 142 | 
             
                # Here is an example of the view code:
         | 
| @@ -206,6 +206,7 @@ module ReactOnRails | |
| 206 206 | 
             
                # that contains a data props.
         | 
| 207 207 | 
             
                def redux_store_hydration_data
         | 
| 208 208 | 
             
                  return if @registered_stores_defer_render.blank?
         | 
| 209 | 
            +
             | 
| 209 210 | 
             
                  @registered_stores_defer_render.reduce("".dup) do |accum, redux_store_data|
         | 
| 210 211 | 
             
                    accum << render_redux_store_data(redux_store_data)
         | 
| 211 212 | 
             
                  end.html_safe
         | 
| @@ -265,6 +266,7 @@ module ReactOnRails | |
| 265 266 |  | 
| 266 267 | 
             
                def json_safe_and_pretty(hash_or_string)
         | 
| 267 268 | 
             
                  return "{}" if hash_or_string.nil?
         | 
| 269 | 
            +
             | 
| 268 270 | 
             
                  unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
         | 
| 269 271 | 
             
                    raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument "\
         | 
| 270 272 | 
             
                        "(#{hash_or_string.class} given)."
         | 
| @@ -405,9 +407,7 @@ module ReactOnRails | |
| 405 407 |  | 
| 406 408 | 
             
                # Returns object with values that are NOT html_safe!
         | 
| 407 409 | 
             
                def server_rendered_react_component(render_options)
         | 
| 408 | 
            -
                   | 
| 409 | 
            -
                    return { "html" => "", "consoleReplayScript" => "" }
         | 
| 410 | 
            -
                  end
         | 
| 410 | 
            +
                  return { "html" => "", "consoleReplayScript" => "" } unless render_options.prerender
         | 
| 411 411 |  | 
| 412 412 | 
             
                  react_component_name = render_options.react_component_name
         | 
| 413 413 | 
             
                  props = render_options.props
         | 
| @@ -433,22 +433,13 @@ module ReactOnRails | |
| 433 433 | 
             
                  #
         | 
| 434 434 | 
             
                  # Read more here: http://timelessrepo.com/json-isnt-a-javascript-subset
         | 
| 435 435 |  | 
| 436 | 
            -
                   | 
| 437 | 
            -
             | 
| 438 | 
            -
            ( | 
| 439 | 
            -
             | 
| 440 | 
            -
             | 
| 441 | 
            -
             | 
| 442 | 
            -
             | 
| 443 | 
            -
                name: '#{react_component_name}',
         | 
| 444 | 
            -
                domNodeId: '#{render_options.dom_id}',
         | 
| 445 | 
            -
                props: props,
         | 
| 446 | 
            -
                trace: #{render_options.trace},
         | 
| 447 | 
            -
                railsContext: railsContext
         | 
| 448 | 
            -
              });
         | 
| 449 | 
            -
            })()
         | 
| 450 | 
            -
                  JS
         | 
| 451 | 
            -
                  # rubocop:enable Layout/IndentHeredoc
         | 
| 436 | 
            +
                  js_code = ReactOnRails::ServerRenderingJsCode.server_rendering_component_js_code(
         | 
| 437 | 
            +
                    props_string: props_string(props).gsub("\u2028", '\u2028').gsub("\u2029", '\u2029'),
         | 
| 438 | 
            +
                    rails_context: rails_context(server_side: true).to_json,
         | 
| 439 | 
            +
                    redux_stores: initialize_redux_stores,
         | 
| 440 | 
            +
                    react_component_name: react_component_name,
         | 
| 441 | 
            +
                    render_options: render_options
         | 
| 442 | 
            +
                  )
         | 
| 452 443 |  | 
| 453 444 | 
             
                  begin
         | 
| 454 445 | 
             
                    result = ReactOnRails::ServerRenderingPool.server_render_js_with_console_logging(js_code, render_options)
         | 
| @@ -480,6 +471,7 @@ module ReactOnRails | |
| 480 471 | 
             
                  JS
         | 
| 481 472 |  | 
| 482 473 | 
             
                  return result unless @registered_stores.present? || @registered_stores_defer_render.present?
         | 
| 474 | 
            +
             | 
| 483 475 | 
             
                  declarations = "var reduxProps, store, storeGenerator;\n".dup
         | 
| 484 476 | 
             
                  all_stores = (@registered_stores || []) + (@registered_stores_defer_render || [])
         | 
| 485 477 |  |