webpacker-react 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: ab20541e11a8ca3cfda69b8359711dc6ec01b878
4
- data.tar.gz: 44795485fe7bdec875cdc9975bfb5c79d036dcc0
3
+ metadata.gz: 39f84822cc56ef9521b865a2cb02191c7e885de6
4
+ data.tar.gz: 3bc1aaa3c2e8907bdf68b1e0f988ec4a9be19dc2
5
5
  SHA512:
6
- metadata.gz: 89a2087cf23242199f588d80139f809fb35b87a5b3abc530bd7ad2ff0aea3c08c399a3bd7bd875b5cd5b2b7d7d1e5a7a19028bee27d7066ce523e007186fd409
7
- data.tar.gz: b20d46ad6d1ac3dfb130aa6c691be91738b879ec4d457fa84f25f8a40f9bee175da743d5180f1af50cfd8f3abf5a8d6801ca6931a394f26a40543be033135a10
6
+ metadata.gz: 03c1a606967a281f0ed6a2cb2bb382cfb908b35865c7595bd9a740d1c2466ea1f0d17bbbd2d2256b72c924cf9649622b1bd316d3a3f92649e068cd56ff74c6d7
7
+ data.tar.gz: e1cbc00fcb44f24844f19ae562b54bdaf464ddc9b71dfb44e85d74243bf8ae45c4ff0dc71942ffe91c1094d1939555a601f0c4399d3b68288a8478f51c162de3
data/.gitignore CHANGED
@@ -1,7 +1,6 @@
1
1
  node_modules/
2
2
  /.bundle/
3
3
  /.yardoc
4
- /Gemfile.lock
5
4
  /_yardoc/
6
5
  /coverage/
7
6
  /doc/
@@ -14,5 +13,6 @@ node_modules/
14
13
  test/example_app/log/*
15
14
  test/example_app/tmp/*
16
15
  test/example_app/public/packs
16
+ test/example_app/public/packs-test
17
17
 
18
18
  .rvmrc
data/.rubocop.yml CHANGED
@@ -4,6 +4,7 @@ AllCops:
4
4
  # to ignore them, so only the ones explicitly set in this file are enabled.
5
5
  DisabledByDefault: true
6
6
  Exclude:
7
+ - '**/node_modules/**/*'
7
8
  - '**/vendor/**/*'
8
9
 
9
10
  # Prefer &&/|| over and/or.
data/CHANGELOG.md CHANGED
@@ -5,17 +5,30 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
- ## 0.2.0 - 2017-03-20
8
+
9
+ ## [0.3.0] - 2017-05-27
10
+
11
+ ### Added
12
+ - Webpacker 1.2 and 2.0 support
13
+ - Added a `tag` option to change the tag used to render the component (default is `div`)
14
+
15
+ ## [0.2.0] - 2017-03-20
16
+
9
17
  ### Added
10
18
  - support for Turbolinks 5, Turbolinks 2.4 and PJAX. Components will be mounted and unmounted when Turbolinks-specific events occur. Also, the integration works with Turbolinks 5 cache.
11
19
  - New `WebpackerReact.setup({Component1, Component2, ...})` initialization API. The old API couldn't properly detect the components' names, thus user is required to provide the names in the configuration object's keys.
12
20
  ### Removed
13
21
  - `WebpackerReact.register(Component)` has been dropped in favor of `WebpackerReact.setup({Component})`
14
- ## 0.1.0 - 2017-02-23
22
+
23
+ ## [0.1.0] - 2017-02-23
24
+
15
25
  ### Added
16
26
  - First released version
17
27
  - render React components from views using the `react_component` helper
18
28
  - render React components from controllers using `render react_component: 'name'` (#1 by @daninfpj)
19
29
  - basic Hot Module Remplacement (#7 by @mfazekas)
20
30
 
21
- [Unreleased]: https://github.com/renchap/webpacker-react/compare/v0.1.0...HEAD
31
+ [Unreleased]: https://github.com/renchap/webpacker-react/compare/v0.3.0...HEAD
32
+ [0.3.0]: https://github.com/renchap/webpacker-react/tree/v0.3.0
33
+ [0.2.0]: https://github.com/renchap/webpacker-react/tree/v0.2.0
34
+ [0.1.0]: https://github.com/renchap/webpacker-react/tree/v0.1.0
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem "rubocop", ">= 0.47", require: false
4
- gem "rails", github: "rails/rails"
5
- gem "arel", github: "rails/arel"
6
- gem "webpacker", github: "rails/webpacker"
4
+ gem "rails", "~> 5.1.1"
5
+ gem "webpacker", "~> 2.0.0"
7
6
 
8
7
  # Specify your gem's dependencies in webpacker-react.gemspec
9
8
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webpacker-react (0.3.0)
5
+ webpacker
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.1.1)
11
+ actionpack (= 5.1.1)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.1.1)
15
+ actionpack (= 5.1.1)
16
+ actionview (= 5.1.1)
17
+ activejob (= 5.1.1)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.1.1)
21
+ actionview (= 5.1.1)
22
+ activesupport (= 5.1.1)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.1.1)
28
+ activesupport (= 5.1.1)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.1.1)
34
+ activesupport (= 5.1.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.1.1)
37
+ activesupport (= 5.1.1)
38
+ activerecord (5.1.1)
39
+ activemodel (= 5.1.1)
40
+ activesupport (= 5.1.1)
41
+ arel (~> 8.0)
42
+ activesupport (5.1.1)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.5.0)
48
+ public_suffix (~> 2.0, >= 2.0.2)
49
+ arel (8.0.0)
50
+ ast (2.3.0)
51
+ builder (3.2.3)
52
+ capybara (2.12.0)
53
+ addressable
54
+ mime-types (>= 1.16)
55
+ nokogiri (>= 1.3.3)
56
+ rack (>= 1.0.0)
57
+ rack-test (>= 0.5.4)
58
+ xpath (~> 2.0)
59
+ cliver (0.3.2)
60
+ concurrent-ruby (1.0.5)
61
+ erubi (1.6.0)
62
+ globalid (0.4.0)
63
+ activesupport (>= 4.2.0)
64
+ i18n (0.8.1)
65
+ loofah (2.0.3)
66
+ nokogiri (>= 1.5.9)
67
+ mail (2.6.5)
68
+ mime-types (>= 1.16, < 4)
69
+ method_source (0.8.2)
70
+ mime-types (3.1)
71
+ mime-types-data (~> 3.2015)
72
+ mime-types-data (3.2016.0521)
73
+ mini_portile2 (2.1.0)
74
+ minitest (5.10.1)
75
+ multi_json (1.12.1)
76
+ nio4r (2.0.0)
77
+ nokogiri (1.7.0.1)
78
+ mini_portile2 (~> 2.1.0)
79
+ parser (2.4.0.0)
80
+ ast (~> 2.2)
81
+ poltergeist (1.13.0)
82
+ capybara (~> 2.1)
83
+ cliver (~> 0.3.1)
84
+ websocket-driver (>= 0.2.0)
85
+ powerpack (0.1.1)
86
+ public_suffix (2.0.5)
87
+ rack (2.0.1)
88
+ rack-test (0.6.3)
89
+ rack (>= 1.0)
90
+ rails (5.1.1)
91
+ actioncable (= 5.1.1)
92
+ actionmailer (= 5.1.1)
93
+ actionpack (= 5.1.1)
94
+ actionview (= 5.1.1)
95
+ activejob (= 5.1.1)
96
+ activemodel (= 5.1.1)
97
+ activerecord (= 5.1.1)
98
+ activesupport (= 5.1.1)
99
+ bundler (>= 1.3.0, < 2.0)
100
+ railties (= 5.1.1)
101
+ sprockets-rails (>= 2.0.0)
102
+ rails-dom-testing (2.0.3)
103
+ activesupport (>= 4.2.0)
104
+ nokogiri (>= 1.6)
105
+ rails-html-sanitizer (1.0.3)
106
+ loofah (~> 2.0)
107
+ railties (5.1.1)
108
+ actionpack (= 5.1.1)
109
+ activesupport (= 5.1.1)
110
+ method_source
111
+ rake (>= 0.8.7)
112
+ thor (>= 0.18.1, < 2.0)
113
+ rainbow (2.2.1)
114
+ rake (10.5.0)
115
+ rubocop (0.47.1)
116
+ parser (>= 2.3.3.1, < 3.0)
117
+ powerpack (~> 0.1)
118
+ rainbow (>= 1.99.1, < 3.0)
119
+ ruby-progressbar (~> 1.7)
120
+ unicode-display_width (~> 1.0, >= 1.0.1)
121
+ ruby-progressbar (1.8.1)
122
+ sprockets (3.7.1)
123
+ concurrent-ruby (~> 1.0)
124
+ rack (> 1, < 3)
125
+ sprockets-rails (3.2.0)
126
+ actionpack (>= 4.0)
127
+ activesupport (>= 4.0)
128
+ sprockets (>= 3.0.0)
129
+ thor (0.19.4)
130
+ thread_safe (0.3.6)
131
+ tzinfo (1.2.3)
132
+ thread_safe (~> 0.1)
133
+ unicode-display_width (1.1.3)
134
+ webpacker (2.0)
135
+ activesupport (>= 4.2)
136
+ multi_json (~> 1.2)
137
+ railties (>= 4.2)
138
+ websocket-driver (0.6.5)
139
+ websocket-extensions (>= 0.1.0)
140
+ websocket-extensions (0.1.2)
141
+ xpath (2.0.0)
142
+ nokogiri (~> 1.3)
143
+
144
+ PLATFORMS
145
+ ruby
146
+
147
+ DEPENDENCIES
148
+ bundler (~> 1.13)
149
+ capybara
150
+ minitest (~> 5.0)
151
+ poltergeist
152
+ rails (~> 5.1.1)
153
+ rake (~> 10.0)
154
+ rubocop (>= 0.47)
155
+ webpacker (~> 2.0.0)
156
+ webpacker-react!
157
+
158
+ BUNDLED WITH
159
+ 1.15.0
data/README.md CHANGED
@@ -1,20 +1,13 @@
1
- # Webpacker::React [![CircleCI](https://circleci.com/gh/renchap/webpacker-react.svg?style=svg)](https://circleci.com/gh/renchap/webpacker-react)
1
+ # Webpacker-React [![CircleCI](https://circleci.com/gh/renchap/webpacker-react.svg?style=svg)](https://circleci.com/gh/renchap/webpacker-react)
2
+
3
+ *__Note:__ This is the documentation for the Git master branch. Documentation for the latest release (0.3.0) is [available here](https://github.com/renchap/webpacker-react/tree/v0.3.0).*
2
4
 
3
5
  Webpacker-React makes it easy to use [React](https://facebook.github.io/react/) with [Webpacker](https://github.com/rails/webpacker) in your Rails applications.
4
6
 
5
- Important note: Webpacker is not yet officially released. It will be included in Rails 5.1 but is highly experimental for now.
7
+ It supports Webpacker 1.2+.
6
8
 
7
9
  An example application is available: https://github.com/renchap/webpacker-react-example/
8
10
 
9
- This gem is a work in progress. Final feature list:
10
-
11
- - [x] uses the new Webpacker way of integrating Javascript with Rails (using packs)
12
- - [x] render React components from views using a `react_component` helper
13
- - [x] render React components from controllers using `render react_component: 'name'`
14
- - [x] support for [hot reloading](https://github.com/gaearon/react-hot-loader)
15
- - [ ] render components server-side
16
- - [ ] use a Rails generator to create new components
17
-
18
11
  ## Installation
19
12
 
20
13
  Your Rails application needs to use Webpacker and have the React integration done. Please refer to their documentation documentation for this: https://github.com/rails/webpacker/blob/master/README.md#ready-for-react
@@ -22,7 +15,7 @@ Your Rails application needs to use Webpacker and have the React integration don
22
15
  First, you need to add the webpacker-react gem to your Rails app Gemfile:
23
16
 
24
17
  ```ruby
25
- gem 'webpacker-react', "~> 0.1.0"
18
+ gem 'webpacker-react', "~> 0.3.0"
26
19
  ```
27
20
 
28
21
  Once done, run `bundle` to install the gem.
@@ -77,12 +70,19 @@ Now you can render React components from your views or your controllers.
77
70
 
78
71
  ### Rendering from a view
79
72
 
80
- Use the `react_component` helper:
73
+ Use the `react_component` helper. The first argument is your component's name, the second one is the `props`:
81
74
 
82
75
  ```erb
83
76
  <%= react_component('Hello', name: 'React') %>
84
77
  ```
85
78
 
79
+ You can pass a `tag` argument to render the React component in another tag than the default `div`. All other arguments will be passed to `content_tag`:
80
+
81
+ ```erb
82
+ <%= react_component('Hello', { name: 'React' }, tag: :span, class: 'my-custom-component') %>
83
+ # This will render <span class="my-custom-component" data-react-class="Hello" data-react-props="..."></div>
84
+ ```
85
+
86
86
  ### Rendering from a controller
87
87
 
88
88
  ```rb
@@ -93,7 +93,13 @@ class PageController < ApplicationController
93
93
  end
94
94
  ```
95
95
 
96
- You can pass any of the usual arguments to render in this call: `layout`, `status`, `content_type`, etc.
96
+ You can use the `tag_options` argument to change the generated HTML, similar to the `react_component` method above:
97
+
98
+ ```rb
99
+ render react_component: 'Hello', props: { name: 'React' }, tag_options: { tag: :span, class: 'my-custom-component' }
100
+ ```
101
+
102
+ You can also pass any of the usual arguments to `render` in this call: `layout`, `status`, `content_type`, etc.
97
103
 
98
104
  *Note: you need to have [Webpack process your code](https://github.com/rails/webpacker#binstubs) before it is available to the browser, either by manually running `./bin/webpack` or having the `./bin/webpack-watcher` process running.*
99
105
 
@@ -103,10 +109,10 @@ You can pass any of the usual arguments to render in this call: `layout`, `statu
103
109
  reloading the page. This allows any change you make to your React components to be applied as soon as you save,
104
110
  preserving their current state.
105
111
 
106
- First, install `react-hot-loader`:
112
+ First, install `react-hot-loader` (version 3):
107
113
 
108
114
  ```
109
- ./bin/yarn add react-hot-loader@3.0.0-beta.6
115
+ ./bin/yarn add react-hot-loader@beta
110
116
  ```
111
117
 
112
118
  You then need to update your Webpack config.
@@ -118,26 +124,15 @@ significantly different than the standard Webpacker config:
118
124
  //development.js
119
125
  ...
120
126
 
121
- var configureHotModuleReplacement = require('webpacker-react/configure-hot-module-replacement')
122
-
123
- var sharedConfig = require('./shared.js')
124
- sharedConfig.config = configureHotModuleReplacement(sharedConfig.config)
127
+ const sharedConfig = require('./shared.js')
128
+ const configureHotModuleReplacement = require('webpacker-react/configure-hot-module-replacement')
125
129
 
126
- module.exports = merge(sharedConfig, ...)
130
+ module.exports = merge(configureHotModuleReplacement(sharedConfig), ...)
127
131
  ```
128
132
 
129
133
  If you need to change your configuration manually:
130
134
 
131
- 1. set the public URL used to load `webpack-dev-server` assets
132
- ```js
133
- {
134
- output: {
135
- publicPath: 'http://localhost:8080'
136
- }
137
- }
138
- ```
139
-
140
- 2. add `react-hot-loader/babel` to your `babel-loader` rules:
135
+ 1. add `react-hot-loader/babel` to your `babel-loader` rules:
141
136
  ```javascript
142
137
  {
143
138
  module: {
@@ -147,17 +142,13 @@ If you need to change your configuration manually:
147
142
  exclude: /node_modules/,
148
143
  loader: 'babel-loader',
149
144
  options: {
150
- presets: [
151
- 'react',
152
- [ 'latest', { 'es2015': { 'modules': false } } ]
153
- ],
154
145
  plugins: ['react-hot-loader/babel']
155
146
  }
156
147
  }
157
148
  }
158
149
  ```
159
150
 
160
- 3. prepend `react-hot-loader/patch` to your entries:
151
+ 2. prepend `react-hot-loader/patch` to your entries:
161
152
  ```javascript
162
153
  {
163
154
  entry:
@@ -166,7 +157,7 @@ If you need to change your configuration manually:
166
157
  }
167
158
  ```
168
159
 
169
- 4. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`). Make sure the following line is in your development.rb:
160
+ 3. you now need to use `webpack-dev-server` (in place of `webpack` or `webpack-watcher`). Make sure the following line is in your development.rb:
170
161
  ```ruby
171
162
  config.x.webpacker[:dev_server_host] = 'http://localhost:8080/'
172
163
  ```
@@ -175,7 +166,7 @@ and start `webpack-dev-server` in hot replacement mode:
175
166
  ./bin/webpack-dev-server --hot
176
167
  ```
177
168
 
178
- 5. finally opt in to HMR from your pack files:
169
+ 4. finally opt in to HMR from your pack files:
179
170
  ```es6
180
171
  import SomeRootReactComponent from 'components/some-root-react-component'
181
172
  import WebpackerReact from 'webpacker-react/hmr'
@@ -186,6 +177,8 @@ and start `webpack-dev-server` in hot replacement mode:
186
177
  WebpackerReact.renderOnHMR(SomeRootReactComponent) )
187
178
  ```
188
179
 
180
+ You also need to ensure that `output.publicPath` are correctly set. This should be already handled by Webpacker.
181
+
189
182
  ## Development
190
183
 
191
184
  To work on this gem locally, you first need to clone and setup [the example application](https://github.com/renchap/webpacker-react-example).
@@ -215,27 +208,15 @@ After launching `./bin/webpack-watcher` and `./bin/rails server` in your example
215
208
 
216
209
  ## Testing
217
210
 
218
- Make sure you run first:
219
-
220
- ```sh
221
- $ test/example_app/bin/yarn
222
- $ test/example_app/bin/webpack
223
- ```
211
+ If you changed the local javascript package, first ensure it is build (see above).
224
212
 
225
- And optionally:
226
-
227
- ```sh
228
- $ cd test/example_app/vendor/
229
- $ yarn link "webpacker-react"
230
- ```
231
-
232
- Finally, run the test suite:
213
+ To run the test suite:
233
214
 
234
215
  ```sh
235
216
  $ rake test
236
217
  ```
237
218
 
238
- If you change the javascript code, please ensure there are no style errors:
219
+ If you change the javascript code, please ensure there are no style errors before committing:
239
220
 
240
221
  ```sh
241
222
  $ cd javascript/webpacker_react-npm-module/
@@ -247,6 +228,10 @@ $ yarn lint
247
228
  Bug reports and pull requests are welcome on GitHub at https://github.com/renchap/webpacker-react.
248
229
  Please feel free to open issues about your needs and features you would like to be added.
249
230
 
231
+ ## Wishlist
232
+
233
+ - [ ] server-side rendering (#3)
234
+
250
235
  ### Thanks
251
236
 
252
237
  This gem has been inspired by the awesome work on [react-rails](https://github.com/reactjs/react-rails) and [react_on_rails](https://github.com/shakacode/react_on_rails/). Many thanks to their authors!
data/Rakefile CHANGED
@@ -5,6 +5,9 @@ Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test"
6
6
  t.libs << "lib"
7
7
  t.test_files = FileList["test/**/*_test.rb"]
8
+ t.verbose = true
8
9
  end
9
10
 
10
11
  task default: :test
12
+
13
+ Dir["lib/tasks/*.rake"].each { |f| load f }
data/circle.yml CHANGED
@@ -1,21 +1,14 @@
1
1
  machine:
2
2
  node:
3
- version: 6.1.0
4
- checkout:
3
+ version: 7.9.0
4
+ compile:
5
5
  post:
6
6
  - yarn:
7
7
  pwd: javascript/webpacker_react-npm-module
8
8
  - yarn:
9
9
  pwd: javascript/webpacker_react-npm-module/dist
10
- - yarn link:
11
- pwd: javascript/webpacker_react-npm-module/dist
12
- compile:
13
- override:
14
- - test/example_app/bin/yarn
15
- - yarn link webpacker-react:
16
- pwd: test/example_app/vendor
17
- - test/example_app/bin/webpack
18
10
  test:
19
11
  pre:
20
12
  - yarn lint:
21
13
  pwd: javascript/webpacker_react-npm-module
14
+ - bundle exec rubocop
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpacker-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Javascript",
5
5
  "main": "index.js",
6
6
  "homepage": "https://github.com/renchap/webpacker-react",
@@ -16,7 +16,8 @@
16
16
  "files": [
17
17
  "index.js",
18
18
  "configure-hot-module-replacement.js",
19
- "hmr.js"
19
+ "hmr.js",
20
+ "ujs.js"
20
21
  ],
21
22
  "scripts": {
22
23
  "prepublish": "cd .. ; yarn run build"
@@ -2,14 +2,9 @@ import webpack from 'webpack'
2
2
  import merge from 'webpack-merge'
3
3
 
4
4
  function configureHotModuleReplacement(originalConfig) {
5
- const webpackDevServerAddr = process.env.WEBPACK_DEV_SERVER_ADDR || 'http://localhost:8080/'
6
5
  const config = merge(
7
6
  originalConfig,
8
7
  {
9
- output: {
10
- // needed for HMR to know where to load the hot update chunks
11
- publicPath: webpackDevServerAddr
12
- },
13
8
  plugins: [
14
9
  new webpack.NamedModulesPlugin()
15
10
  ]
@@ -1573,7 +1573,7 @@ lodash.cond@^4.3.0:
1573
1573
  version "4.5.2"
1574
1574
  resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"
1575
1575
 
1576
- lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0, "lodash@~> 4":
1576
+ lodash@^4.0.0, lodash@^4.2.0, lodash@^4.3.0:
1577
1577
  version "4.17.4"
1578
1578
  resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
1579
1579
 
@@ -2010,13 +2010,7 @@ restore-cursor@^1.0.1:
2010
2010
  exit-hook "^1.0.0"
2011
2011
  onetime "^1.0.0"
2012
2012
 
2013
- rimraf@2, rimraf@^2.2.8:
2014
- version "2.6.1"
2015
- resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d"
2016
- dependencies:
2017
- glob "^7.0.5"
2018
-
2019
- rimraf@~2.5.1, rimraf@~2.5.4:
2013
+ rimraf@2, rimraf@^2.2.8, rimraf@~2.5.1, rimraf@~2.5.4:
2020
2014
  version "2.5.4"
2021
2015
  resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
2022
2016
  dependencies:
@@ -0,0 +1,7 @@
1
+ # webpacker:check_webpack_binstubs is looking for binstubs
2
+ # in the gem root directory. We need to disable it for our
3
+ # tests, as it tries to check they exist when loading the
4
+ # example app
5
+
6
+ task "webpacker:check_webpack_binstubs"
7
+ Rake::Task["webpacker:check_webpack_binstubs"].clear
@@ -0,0 +1,15 @@
1
+ require "English"
2
+
3
+ namespace :example_app do
4
+ desc "Runs yarn in test/example_app"
5
+ task :yarn do
6
+ sh "cd test/example_app && yarn"
7
+ end
8
+
9
+ desc "Runs webpack in test/example_app"
10
+ task webpack: :yarn do
11
+ sh "cd test/example_app && NODE_ENV=test ./bin/webpack"
12
+ end
13
+ end
14
+
15
+ Rake::Task["test"].enhance ["example_app:webpack"]
@@ -11,8 +11,10 @@ module Webpacker
11
11
  end
12
12
 
13
13
  def render(props = {}, options = {})
14
+ tag = options.delete(:tag) || :div
14
15
  data = { data: { "react-class" => @name, "react-props" => props.to_json } }
15
- content_tag(:div, nil, options.deep_merge(data))
16
+
17
+ content_tag(tag, nil, options.deep_merge(data))
16
18
  end
17
19
  end
18
20
  end
@@ -12,7 +12,8 @@ module Webpacker
12
12
  initializer :webpacker_react_renderer, group: :all do |_app|
13
13
  ActionController::Renderers.add :react_component do |component_name, options|
14
14
  props = options.fetch(:props, {})
15
- html = Webpacker::React::Component.new(component_name).render(props)
15
+ tag_options = options.fetch(:tag_options, {})
16
+ html = Webpacker::React::Component.new(component_name).render(props, tag_options)
16
17
  render_options = options.merge(inline: html)
17
18
  render(render_options)
18
19
  end
@@ -1,5 +1,5 @@
1
1
  module Webpacker
2
2
  module React
3
- VERSION = "0.2.0".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renaud Chaput
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-20 00:00:00.000000000 Z
11
+ date: 2017-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webpacker
@@ -108,6 +108,7 @@ files:
108
108
  - CHANGELOG.md
109
109
  - CODE_OF_CONDUCT.md
110
110
  - Gemfile
111
+ - Gemfile.lock
111
112
  - README.md
112
113
  - Rakefile
113
114
  - _config.yml
@@ -124,6 +125,8 @@ files:
124
125
  - javascript/webpacker_react-npm-module/src/index.js
125
126
  - javascript/webpacker_react-npm-module/src/ujs.js
126
127
  - javascript/webpacker_react-npm-module/yarn.lock
128
+ - lib/tasks/disable_webpacker_checks.rake
129
+ - lib/tasks/example_app.rake
127
130
  - lib/webpacker/react.rb
128
131
  - lib/webpacker/react/component.rb
129
132
  - lib/webpacker/react/helpers.rb