react-rails 2.6.2 → 2.7.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96a680594edd90c4c4b7956ca981b98c39c0be650c2570bcac0640fe4641ba0f
4
- data.tar.gz: 0c8153bde6bfaaddb6c86c8450729d9ac2aa336ea976dbc959fe94c0a66907a1
3
+ metadata.gz: 34e2141d97fafdc9f052046cca1b328162c2e629c5a766ee446280db9ce2ca76
4
+ data.tar.gz: 42f9d30392a3c215f2e9e97cd837437ad5051b9de694b557ff73a508143c0204
5
5
  SHA512:
6
- metadata.gz: aac97afcf29aa71177ddbac2e11f117cb64fb524cd435701c3c6f70fb81775f870becfd1ba04f5167830b72808b8e8afbcf18c802477335c28d78ee5b0ec6d2e
7
- data.tar.gz: 8988ff16c6619dc0ee8df11b060b49107e63524641b90ba497199d1cbbff96b696be61b3b8eb2237ab6b121e636352c07f5a7066426ff5c8c80608d85a7c32fb
6
+ metadata.gz: 8da70ab5914716f3f5679aaaa2881085232537b35ab76fa1a0a8c3f540738730e55820f3e94ff8d91dd53005395c7b307ca6ad152fd3f9b5b6fdf823b400f0d1
7
+ data.tar.gz: 9dab395f855aae1468910bc91dd8c8edbd23fd5e508ade3623f5b71a82c88d81abe9c60aa1b8516241bbe823f651f215d94edb527b522c07e0b79193d9a1cba3
data/CHANGELOG.md CHANGED
@@ -1,12 +1,40 @@
1
1
  # react-rails
2
2
 
3
- #### Breaking Changes
3
+ If you need help upgrading `react-rails`, `webpacker` to `shakapacker`, or JS packages, contact justin@shakacode.com. The ShakaCode.com team is helping to maintain this Ruby gem. You also might want to consider the [react_on_rails](https://github.com/shakacode/react_on_rails) gem.
4
+
5
+ [#1209 2.7 Release Discussion](https://github.com/reactjs/react-rails/issues/1209)
6
+
7
+ ## Unreleased
8
+ Changes since last non-beta release.
9
+
10
+ _Please add entries here for your pull requests that are not yet released._
11
+
12
+ ## [2.7.0.rc.0] - TBD
4
13
 
5
14
  #### New Features
15
+ - Camelizes keys with primitive values, in addition to hashes #946
16
+ - Expose alternative implementations for `ReactUJS.getConstructor` #1050
17
+ - Include turbolinks in dev and update webdrivers #1174
18
+ - Add support for multiple `require.context` with addition of `useContexts` #1144
19
+ - Update dependencies
20
+
21
+ #### Update dependencies
22
+ - react to 17.0.2 #1218
23
+ - webpack to 5.74.0
24
+ - webpack-dev-server to 2.11.5 #1150
25
+ - Node-sass to 7.0.0 #1158
26
+ - url-parse to 1.5.10 #1167
27
+ - minimist to 1.2.6 #1169
28
+ - async to 2.6.4 #1178
29
+ - rack to 2.2.3.1 #1182
30
+ - eventsource to 1.1.1 #1183
31
+ - rails-html-sanitizer to 1.4.3 #1188
32
+ - tzinfo to 1.2.10 #1190
6
33
 
7
34
  #### Deprecation
8
35
 
9
36
  #### Bug Fixes
37
+ - Fix installation crash caused by absolute path for `source_entry_path` in default `config/webpacker.yml` coming from `shakapacker` version 6.x - #1216
10
38
 
11
39
  ## 2.6.2
12
40
 
@@ -526,3 +554,6 @@
526
554
  - View helper and UJS for mounting components
527
555
  - Server rendering with `prerender: true`
528
556
  - Transform `.jsx` in the asset pipeline
557
+
558
+ [Unreleased]: https://github.com/reactjs/react-rails/compare/v2.7.0...master
559
+ [2.7.0]: https://github.com/shakacode/shakapacker/compare/v2.6.2...v2.7.0
data/README.md CHANGED
@@ -2,24 +2,28 @@
2
2
 
3
3
  [![Gem](https://img.shields.io/gem/v/react-rails.svg?style=flat-square)](http://rubygems.org/gems/react-rails)
4
4
  [![npm](https://img.shields.io/npm/v/react_ujs.svg?style=flat-square)](https://www.npmjs.com/package/react_ujs)
5
- [![Build Status](https://img.shields.io/travis/reactjs/react-rails/master.svg?style=flat-square)](https://travis-ci.org/reactjs/react-rails)
6
- [![Maintainers Wanted](https://img.shields.io/badge/Maintainers-Wanted-red.svg?style=flat-square)]()
5
+ [![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml)[![Maintainers Wanted](https://img.shields.io/badge/Maintainers-Wanted-red.svg?style=flat-square)]()
7
6
 
8
7
 
9
8
  React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits:
10
9
  * Automatically renders React server-side and client-side
11
- * Supports Webpacker 4.x, 3.x, 2.x, 1.1+
10
+ * Supports Webpacker 4.x, 3.x, 2.x, 1.1+ or Shakapacker v6+
12
11
  * Supports Sprockets 4.x, 3.x, 2.x
13
12
  * Lets you use [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html), [ES6](http://es6-features.org/), [TypeScript](https://www.typescriptlang.org/), [CoffeeScript](http://coffeescript.org/)
14
13
 
15
- A source code example utilizing React-Rails: https://github.com/BookOfGreg/react-rails-example-app
14
+ ## Resouces
15
+ * [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE). Then join the channel `#react-rails`.
16
+ * If you need help upgrading `react-rails`, `webpacker`, or JS packages, contact [justin@shakacode.com](mailto:justin@shakacode.com). The [ShakaCode.com](https://www.shakacode.com) team is helping to maintain this Ruby gem. Check out [this discussion](https://github.com/reactjs/react-rails/discussions/1200).
17
+ * If you are upgrading, you might consider migrating to the [react_on_rails](https://github.com/shakacode/react_on_rails) gem.
18
+ * Source code example utilizing React-Rails: https://github.com/BookOfGreg/react-rails-example-app
16
19
 
17
20
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
18
21
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
19
22
  ## Contents
20
23
 
21
- - [Get started with Webpacker](#get-started-with-webpacker)
24
+ - [Get started with Shakapacker](#get-started-with-shakapacker)
22
25
  - [File naming](#file-naming)
26
+ - [Typescript support](#typescript-support)
23
27
  - [Use with Asset Pipeline](#use-with-asset-pipeline)
24
28
  - [Custom JSX Transformer](#custom-jsx-transformer)
25
29
  - [React.js versions](#reactjs-versions)
@@ -55,31 +59,45 @@ https://github.com/reactjs/React-Rails/wiki
55
59
  The Wiki page features a significant amount of additional information about React-Rails which includes instructional articles and answers to the most frequently asked questions.
56
60
 
57
61
 
58
- ## Get started with Webpacker
62
+ ## Get started with Shakapacker
59
63
 
60
- [Alternatively, get started with Sprockets](#use-with-asset-pipeline)
64
+ _Alternatively, get started with [Sprockets](#use-with-asset-pipeline)_
61
65
 
62
- [Webpacker](https://github.com/rails/webpacker) provides modern JS tooling for Rails. Here are the listed steps for integrating Webpacker and Rails-React with Rails:
66
+ #### 1) Create a new Rails app:
67
+ Prevent installing default javascript dependencies by using `--skip-javascript` option:
63
68
 
64
- ##### 1) Create a new Rails app:
65
- ```
66
- $ rails new my-app
69
+ ```bash
70
+ $ rails new my-app --skip-javascript
67
71
  $ cd my-app
68
72
  ```
69
73
 
70
- ##### 2) Add `react-rails` to your Gemfile:
71
- ```ruby
72
- gem 'react-rails'
74
+ #### 2) Install `shakapacker`:
75
+ ```bash
76
+ $ bundle add shakapacker --strict
77
+ $ rails webpacker:install
73
78
  ```
74
- Note: On rails versions < 6.0, You need to add `gem 'webpacker'` to your Gemfile in step 2 above.
75
79
 
76
- ##### 3) Now run the installers:
80
+ #### 3) Install `react` and some other required npm packages:
81
+ ```bash
82
+ $ yarn add react react-dom @babel/preset-react prop-types \
83
+ css-loader style-loader mini-css-extract-plugin css-minimizer-webpack-plugin
84
+ ```
77
85
 
78
- ###### Rails 6.x and 5.x:
86
+ Also update the Babel configuration in the `package.json` file:
87
+
88
+ ```diff
89
+ "babel": {
90
+ "presets": [
91
+ - "./node_modules/shakapacker/package/babel/preset.js"
92
+ + "./node_modules/shakapacker/package/babel/preset.js",
93
+ + "@babel/preset-react"
94
+ ]
95
+ },
79
96
  ```
80
- $ bundle install
81
- $ rails webpacker:install # OR (on rails version < 5.0) rake webpacker:install
82
- $ rails webpacker:install:react # OR (on rails version < 5.0) rake webpacker:install:react
97
+
98
+ #### 4) Install `react-rails`:
99
+ ```bash
100
+ $ bundle add 'react-rails' --strict
83
101
  $ rails generate react:install
84
102
  ```
85
103
 
@@ -89,31 +107,27 @@ This gives you:
89
107
  - [`ReactRailsUJS`](#ujs) setup in `app/javascript/packs/application.js`
90
108
  - `app/javascript/packs/server_rendering.js` for [server-side rendering](#server-side-rendering)
91
109
 
92
- Note: On rails versions < 6.0, link the JavaScript pack in Rails view using `javascript_pack_tag` [helper](https://github.com/rails/webpacker#usage):
93
- ```erb
94
- <!-- application.html.erb in Head tag below turbolinks -->
95
- <%= javascript_pack_tag 'application' %>
96
- ```
97
-
98
- ##### 4) Generate your first component:
99
- ```
110
+ #### 5) Generate your first component:
111
+ ```bash
100
112
  $ rails g react:component HelloWorld greeting:string
101
113
  ```
102
114
 
103
- ##### 5) You can also generate your component in a subdirectory:
104
- ```
115
+ You can also generate your component in a subdirectory:
116
+
117
+ ```bash
105
118
  $ rails g react:component my_subdirectory/HelloWorld greeting:string
106
119
  ```
120
+
107
121
  Note: Your component is added to `app/javascript/components/` by default.
108
122
 
109
123
  Note: If your component is in a subdirectory you will append the directory path to your erb component call.
110
124
 
111
- Example:
112
- ```
125
+ Example:
126
+ ```erb
113
127
  <%= react_component("my_subdirectory/HelloWorld", { greeting: "Hello from react-rails." }) %>
114
128
  ```
115
129
 
116
- ##### 6) [Render it in a Rails view](#view-helper):
130
+ #### 6) [Render it in a Rails view](#view-helper):
117
131
 
118
132
  ```erb
119
133
  <!-- erb: paste this in view -->
@@ -121,10 +135,19 @@ Example:
121
135
  ```
122
136
 
123
137
  ##### 7) Lets Start the app:
124
- ```
138
+ ```bash
125
139
  $ rails s
126
140
  ```
127
- output: greeting: Hello from react-rails", inspect webpage in your browser too see change in tag props.
141
+ Output: greeting: Hello from react-rails", inspect webpage in your browser to see the change in tag props.
142
+
143
+ ##### 7) Run dev server (optional)
144
+ In order to run dev server with HMR feature you need to parallely run:
145
+
146
+ ```bash
147
+ $ ./bin/webpacker-dev-server
148
+ ```
149
+
150
+ Note: On Rails 6 you need to specify `webpack-dev-server` host. To this end, update `config/initializers/content_security_policy.rb` and uncomment relevant lines.
128
151
 
129
152
  ### Component name
130
153
 
@@ -150,6 +173,24 @@ ReactRailsUJS.useContext(myCustomContext)
150
173
 
151
174
  If `require` fails to find your component, [`ReactRailsUJS`](#ujs) falls back to the global namespace, described in [Use with Asset Pipeline](#use-with-asset-pipeline).
152
175
 
176
+ In some cases, having multiple `require.context` entries may be desired. Examples of this include:
177
+
178
+ - Refactoring a typical Rails application into a Rails API with an (eventually) separate Single Page Application (SPA). For this use case, one can add a separate pack in addition to the typical `application` one. React components can be shared between the packs but the new pack can use a minimal Rails view layout, different default styling, etc.
179
+ - In a larger application, you might find it helpful to split your JavaScript by routes/controllers to avoid serving unused components and improve your site performance by keeping bundles smaller. For example, you might have separate bundles for homepage, search, and checkout routes. In that scenario, you can add an array of `require.context` component directory paths via `useContexts` to `server_rendering.js`, to allow for [Server-Side Rendering](#server-side-rendering) across your application:
180
+
181
+ ```js
182
+ // server_rendering.js
183
+ var homepageRequireContext = require.context('homepage', true);
184
+ var searchRequireContext = require.context('search', true);
185
+ var checkoutRequireContext = require.context('checkout', true);
186
+
187
+ var ReactRailsUJS = require('react_ujs');
188
+ ReactRailsUJS.useContexts([
189
+ homepageRequireContext,
190
+ searchRequireContext,
191
+ checkoutRequireContext
192
+ ]);
193
+ ```
153
194
  ### File naming
154
195
 
155
196
  React-Rails supports plenty of file extensions such as: .js, .jsx.js, .js.jsx, .es6.js, .coffee, etcetera!
@@ -164,14 +205,52 @@ Component File Name | `react_component` call
164
205
 
165
206
  ### Typescript support
166
207
 
167
- If you want to use React-Rails with Typescript, simply run the installer and add @types:
208
+ ```bash
209
+ yarn add typescript @babel/preset-typescript
168
210
  ```
169
- $ bundle exec rails webpacker:install:typescript
170
- $ yarn add @types/react @types/react-dom
211
+
212
+ Babel won’t perform any type-checking on TypeScript code. To optionally use type-checking run:
213
+
214
+ ```bash
215
+ yarn add fork-ts-checker-webpack-plugin
171
216
  ```
172
217
 
173
- Doing this will allow React-Rails to support the .tsx extension. Additionally, it is recommended to add `ts` and `tsx` to the `server_renderer_extensions` in your application configuration:
218
+ Add `tsconfig.json` with the following content:
219
+
220
+ ```json
221
+ {
222
+ "compilerOptions": {
223
+ "declaration": false,
224
+ "emitDecoratorMetadata": true,
225
+ "experimentalDecorators": true,
226
+ "lib": ["es6", "dom"],
227
+ "module": "es6",
228
+ "moduleResolution": "node",
229
+ "sourceMap": true,
230
+ "target": "es5",
231
+ "jsx": "react",
232
+ "noEmit": true
233
+ },
234
+ "exclude": ["**/*.spec.ts", "node_modules", "vendor", "public"],
235
+ "compileOnSave": false
236
+ }
237
+ ```
238
+
239
+ Then modify the webpack config to use it as a plugin:
240
+
241
+ ```js
242
+ // config/webpack/webpack.config.js
243
+ const { webpackConfig, merge } = require("shakapacker");
244
+ const ForkTSCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
245
+
246
+ module.exports = merge(webpackConfig, {
247
+ plugins: [new ForkTSCheckerWebpackPlugin()],
248
+ });
174
249
  ```
250
+
251
+ Doing this will allow React-Rails to support the .tsx extension. Additionally, it is recommended to add `ts` and `tsx` to the `server_renderer_extensions` in your application configuration:
252
+
253
+ ```ruby
175
254
  config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]
176
255
  ```
177
256
 
@@ -179,9 +258,9 @@ config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]
179
258
 
180
259
  You can use `assert_react_component` to test component render:
181
260
 
182
- app/views/welcome/index.html.erb
183
-
184
261
  ```erb
262
+ <!-- app/views/welcome/index.html.erb -->
263
+
185
264
  <%= react_component("HelloWorld", { greeting: "Hello from react-rails.", info: { name: "react-rails" } }, { class: "hello-world" }) %>
186
265
  ```
187
266
 
@@ -404,13 +483,27 @@ delete window.Turbolinks;
404
483
 
405
484
  ### `getConstructor`
406
485
 
407
- Components are loaded with `ReactRailsUJS.getConstructor(className)`. This function has two built-in implementations:
486
+ Components are loaded with `ReactRailsUJS.getConstructor(className)`. This function has two default implementations, depending on if you're using the asset pipeline or Shakapacker:
408
487
 
409
- - On the asset pipeline, it looks up `className` in the global namespace.
410
- - On Webpacker, it `require`s files and accesses named exports, as described in [Get started with Webpacker](#get-started-with-webpacker).
488
+ - On the asset pipeline, it looks up `className` in the global namespace (`ReactUJS.constructorFromGlobal`).
489
+ - On Shakapacker, it `require`s files and accesses named exports, as described in [Get started with Shakapacker](#get-started-with-shakapacker), falling back to the global namespace (`ReactUJS.constructorFromRequireContextWithGlobalFallback`).
411
490
 
412
491
  You can override this function to customize the mapping of name-to-constructor. [Server-side rendering](#server-side-rendering) also uses this function.
413
492
 
493
+ For example, the fallback behavior of
494
+ `ReactUJS.constructorFromRequireContextWithGlobalFallback` can sometimes make
495
+ server-side rendering errors hard to debug as it will swallow the original error
496
+ (more info
497
+ [here](https://github.com/reactjs/react-rails/issues/264#issuecomment-552326663)).
498
+ `ReactUJS.constructorFromRequireContext` is provided for this reason. You can
499
+ use it like so:
500
+
501
+ ```js
502
+ // Replaces calls to `ReactUJS.useContext`
503
+ ReactUJS.getConstructor = ReactUJS.constructorFromRequireContext(require.context('components', true));
504
+ ```
505
+
506
+
414
507
  ## Server-Side Rendering
415
508
 
416
509
  You can render React components inside your Rails server with `prerender: true`:
@@ -622,6 +715,12 @@ You can also specify this option in `react_component`:
622
715
  <%= react_component('HelloMessage', {name: 'John'}, {camelize_props: true}) %>
623
716
  ```
624
717
 
718
+ ### Changing Component Templates
719
+
720
+ To make simple changes to Component templates, copy the respective template file to your Rails project at `lib/templates/react/component/template_filename`.
721
+
722
+ For example, to change the [ES6 Component template](https://github.com/reactjs/react-rails/blob/master/lib/generators/templates/component.es6.jsx), copy it to `lib/templates/react/component/component.es6.jsx` and modify it.
723
+
625
724
  ## Upgrading
626
725
 
627
726
  ### 2.3 to 2.4
@@ -686,7 +785,7 @@ Hot Module Replacement is [possible with this gem](https://stackoverflow.com/a/5
686
785
 
687
786
  Sample repo that shows HMR working with `react-rails`: [https://github.com/edelgado/react-rails-hmr](https://github.com/edelgado/react-rails-hmr)
688
787
 
689
- One caveat is that currently you [cannot Server-Side Render along with HMR](https://github.com/reactjs/react-rails/issues/925#issuecomment-415469572).
788
+ One caveat is that currently you [cannot Server-Side Render along with HMR](https://github.com/reactjs/react-rails/issues/925#issuecomment-415469572).
690
789
 
691
790
  ## Related Projects
692
791
 
@@ -7,7 +7,7 @@
7
7
  exports["ReactRailsUJS"] = factory(require("react-dom"), require("react"), require("react-dom/server"));
8
8
  else
9
9
  root["ReactRailsUJS"] = factory(root["ReactDOM"], root["React"], root["ReactDOMServer"]);
10
- })(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__) {
10
+ })(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__) {
11
11
  return /******/ (function(modules) { // webpackBootstrap
12
12
  /******/ // The module cache
13
13
  /******/ var installedModules = {};
@@ -73,7 +73,7 @@ return /******/ (function(modules) { // webpackBootstrap
73
73
  /******/ __webpack_require__.p = "";
74
74
  /******/
75
75
  /******/ // Load entry module and return exports
76
- /******/ return __webpack_require__(__webpack_require__.s = 7);
76
+ /******/ return __webpack_require__(__webpack_require__.s = 8);
77
77
  /******/ })
78
78
  /************************************************************************/
79
79
  /******/ ([
@@ -108,17 +108,47 @@ module.exports = function(className) {
108
108
  /* 1 */
109
109
  /***/ (function(module, exports) {
110
110
 
111
- module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
111
+ // Load React components by requiring them from "components/", for example:
112
+ //
113
+ // - "pages/index" -> `require("components/pages/index")`
114
+ // - "pages/show.Header" -> `require("components/pages/show").Header`
115
+ // - "pages/show.Body.Content" -> `require("components/pages/show").Body.Content`
116
+ //
117
+ module.exports = function(reqctx) {
118
+ return function(className) {
119
+ var parts = className.split(".")
120
+ var filename = parts.shift()
121
+ var keys = parts
122
+ // Load the module:
123
+ var component = reqctx("./" + filename)
124
+ // Then access each key:
125
+ keys.forEach(function(k) {
126
+ component = component[k]
127
+ })
128
+ // support `export default`
129
+ if (component.__esModule) {
130
+ component = component["default"]
131
+ }
132
+ return component
133
+ }
134
+ }
135
+
112
136
 
113
137
  /***/ }),
114
138
  /* 2 */
139
+ /***/ (function(module, exports) {
140
+
141
+ module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
142
+
143
+ /***/ }),
144
+ /* 3 */
115
145
  /***/ (function(module, exports, __webpack_require__) {
116
146
 
117
- var nativeEvents = __webpack_require__(8)
118
- var pjaxEvents = __webpack_require__(9)
119
- var turbolinksEvents = __webpack_require__(10)
120
- var turbolinksClassicDeprecatedEvents = __webpack_require__(12)
121
- var turbolinksClassicEvents = __webpack_require__(11)
147
+ var nativeEvents = __webpack_require__(9)
148
+ var pjaxEvents = __webpack_require__(10)
149
+ var turbolinksEvents = __webpack_require__(11)
150
+ var turbolinksClassicDeprecatedEvents = __webpack_require__(13)
151
+ var turbolinksClassicEvents = __webpack_require__(12)
122
152
 
123
153
  // see what things are globally available
124
154
  // and setup event handlers to those things
@@ -170,14 +200,14 @@ module.exports = function(ujs) {
170
200
 
171
201
 
172
202
  /***/ }),
173
- /* 3 */
203
+ /* 4 */
174
204
  /***/ (function(module, exports, __webpack_require__) {
175
205
 
176
206
  // Make a function which:
177
207
  // - First tries to require the name
178
208
  // - Then falls back to global lookup
179
209
  var fromGlobal = __webpack_require__(0)
180
- var fromRequireContext = __webpack_require__(13)
210
+ var fromRequireContext = __webpack_require__(1)
181
211
 
182
212
  module.exports = function(reqctx) {
183
213
  var fromCtx = fromRequireContext(reqctx)
@@ -201,7 +231,7 @@ module.exports = function(reqctx) {
201
231
 
202
232
 
203
233
  /***/ }),
204
- /* 4 */
234
+ /* 5 */
205
235
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
206
236
 
207
237
  "use strict";
@@ -209,7 +239,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
209
239
  /* harmony export (immutable) */ __webpack_exports__["supportsHydration"] = supportsHydration;
210
240
  /* harmony export (immutable) */ __webpack_exports__["reactHydrate"] = reactHydrate;
211
241
  /* harmony export (immutable) */ __webpack_exports__["createReactRootLike"] = createReactRootLike;
212
- const ReactDOM = __webpack_require__(1)
242
+ const ReactDOM = __webpack_require__(2)
213
243
 
214
244
  function supportsHydration() {
215
245
  return typeof ReactDOM.hydrate === "function" || typeof ReactDOM.hydrateRoot === "function"
@@ -238,29 +268,30 @@ function legacyReactRootLike(node) {
238
268
 
239
269
 
240
270
  /***/ }),
241
- /* 5 */
271
+ /* 6 */
242
272
  /***/ (function(module, exports) {
243
273
 
244
- module.exports = __WEBPACK_EXTERNAL_MODULE_5__;
274
+ module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
245
275
 
246
276
  /***/ }),
247
- /* 6 */
277
+ /* 7 */
248
278
  /***/ (function(module, exports) {
249
279
 
250
- module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
280
+ module.exports = __WEBPACK_EXTERNAL_MODULE_7__;
251
281
 
252
282
  /***/ }),
253
- /* 7 */
283
+ /* 8 */
254
284
  /***/ (function(module, exports, __webpack_require__) {
255
285
 
256
- var React = __webpack_require__(5)
257
- var ReactDOM = __webpack_require__(1)
258
- var ReactDOMServer = __webpack_require__(6)
286
+ var React = __webpack_require__(6)
287
+ var ReactDOM = __webpack_require__(2)
288
+ var ReactDOMServer = __webpack_require__(7)
259
289
 
260
- var detectEvents = __webpack_require__(2)
290
+ var detectEvents = __webpack_require__(3)
261
291
  var constructorFromGlobal = __webpack_require__(0)
262
- var constructorFromRequireContextWithGlobalFallback = __webpack_require__(3)
263
- const { supportsHydration, reactHydrate, createReactRootLike } = __webpack_require__(4)
292
+ var constructorFromRequireContext = __webpack_require__(1)
293
+ var constructorFromRequireContextWithGlobalFallback = __webpack_require__(4)
294
+ const { supportsHydration, reactHydrate, createReactRootLike } = __webpack_require__(5)
264
295
 
265
296
  var ReactRailsUJS = {
266
297
  // This attribute holds the name of component which should be mounted
@@ -321,6 +352,11 @@ var ReactRailsUJS = {
321
352
  // the default is ReactRailsUJS.ComponentGlobal
322
353
  getConstructor: constructorFromGlobal,
323
354
 
355
+ // Available for customizing `getConstructor`
356
+ constructorFromGlobal: constructorFromGlobal,
357
+ constructorFromRequireContext: constructorFromRequireContext,
358
+ constructorFromRequireContextWithGlobalFallback: constructorFromRequireContextWithGlobalFallback,
359
+
324
360
  // Given a Webpack `require.context`,
325
361
  // try finding components with `require`,
326
362
  // then falling back to global lookup.
@@ -395,6 +431,7 @@ var ReactRailsUJS = {
395
431
  detectEvents: function() {
396
432
  detectEvents(this)
397
433
  },
434
+
398
435
  }
399
436
 
400
437
  // These stable references are so that handlers can be added and removed:
@@ -429,7 +466,7 @@ module.exports = ReactRailsUJS
429
466
 
430
467
 
431
468
  /***/ }),
432
- /* 8 */
469
+ /* 9 */
433
470
  /***/ (function(module, exports) {
434
471
 
435
472
  module.exports = {
@@ -452,7 +489,7 @@ module.exports = {
452
489
 
453
490
 
454
491
  /***/ }),
455
- /* 9 */
492
+ /* 10 */
456
493
  /***/ (function(module, exports) {
457
494
 
458
495
  module.exports = {
@@ -472,7 +509,7 @@ module.exports = {
472
509
 
473
510
 
474
511
  /***/ }),
475
- /* 10 */
512
+ /* 11 */
476
513
  /***/ (function(module, exports) {
477
514
 
478
515
  module.exports = {
@@ -488,7 +525,7 @@ module.exports = {
488
525
 
489
526
 
490
527
  /***/ }),
491
- /* 11 */
528
+ /* 12 */
492
529
  /***/ (function(module, exports) {
493
530
 
494
531
  module.exports = {
@@ -506,7 +543,7 @@ module.exports = {
506
543
 
507
544
 
508
545
  /***/ }),
509
- /* 12 */
546
+ /* 13 */
510
547
  /***/ (function(module, exports) {
511
548
 
512
549
  module.exports = {
@@ -526,36 +563,6 @@ module.exports = {
526
563
  }
527
564
 
528
565
 
529
- /***/ }),
530
- /* 13 */
531
- /***/ (function(module, exports) {
532
-
533
- // Load React components by requiring them from "components/", for example:
534
- //
535
- // - "pages/index" -> `require("components/pages/index")`
536
- // - "pages/show.Header" -> `require("components/pages/show").Header`
537
- // - "pages/show.Body.Content" -> `require("components/pages/show").Body.Content`
538
- //
539
- module.exports = function(reqctx) {
540
- return function(className) {
541
- var parts = className.split(".")
542
- var filename = parts.shift()
543
- var keys = parts
544
- // Load the module:
545
- var component = reqctx("./" + filename)
546
- // Then access each key:
547
- keys.forEach(function(k) {
548
- component = component[k]
549
- })
550
- // support `export default`
551
- if (component.__esModule) {
552
- component = component["default"]
553
- }
554
- return component
555
- }
556
- }
557
-
558
-
559
566
  /***/ })
560
567
  /******/ ]);
561
568
  });