webpacker 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +3 -0
  3. data/.gitignore +0 -2
  4. data/.travis.yml +3 -3
  5. data/CHANGELOG.md +45 -1
  6. data/Gemfile.lock +144 -0
  7. data/README.md +23 -7
  8. data/docs/deployment.md +3 -6
  9. data/docs/env.md +1 -1
  10. data/docs/misc.md +1 -1
  11. data/docs/props.md +119 -1
  12. data/docs/testing.md +103 -0
  13. data/docs/typescript.md +2 -1
  14. data/docs/webpack-dev-server.md +44 -1
  15. data/docs/webpack.md +37 -1
  16. data/exe/webpack +8 -0
  17. data/exe/webpack-dev-server +8 -0
  18. data/lib/install/config/webpacker.yml +9 -2
  19. data/lib/install/elm.rb +11 -9
  20. data/lib/install/examples/elm/hello_elm.js +4 -3
  21. data/lib/install/examples/vue/hello_vue.js +1 -1
  22. data/lib/install/template.rb +3 -5
  23. data/lib/install/vue.rb +7 -5
  24. data/lib/tasks/webpacker/check_node.rake +6 -3
  25. data/lib/webpacker/configuration.rb +4 -0
  26. data/lib/webpacker/dev_server.rb +19 -5
  27. data/lib/webpacker/dev_server_proxy.rb +1 -1
  28. data/lib/webpacker/dev_server_runner.rb +51 -0
  29. data/lib/webpacker/helper.rb +5 -16
  30. data/lib/webpacker/manifest.rb +8 -8
  31. data/lib/webpacker/runner.rb +22 -0
  32. data/lib/webpacker/version.rb +1 -1
  33. data/lib/webpacker/webpack_runner.rb +15 -0
  34. data/package.json +4 -2
  35. data/package/config.js +19 -2
  36. data/package/environment.js +3 -3
  37. data/package/environments/development.js +15 -11
  38. data/package/environments/production.js +2 -2
  39. data/package/index.js +1 -1
  40. data/package/loaders/file.js +4 -4
  41. data/package/loaders/style.js +2 -2
  42. data/package/loaders/vue.js +2 -2
  43. data/test/configuration_test.rb +5 -0
  44. data/test/manifest_test.rb +10 -2
  45. data/webpacker.gemspec +3 -1
  46. data/yarn.lock +5133 -0
  47. metadata +16 -8
  48. data/lib/install/bin/webpack-dev-server.tt +0 -68
  49. data/lib/install/bin/webpack.tt +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6509ab0499053e37d9af22b79262832b33f8cd91
4
- data.tar.gz: 869403b35f9178ea48884343782822282b91afde
3
+ metadata.gz: e29d1fa9bd905782462ea86943ac0f6c41bc610b
4
+ data.tar.gz: a8d0c7cc0b52389cdf3e3d4c65bb7b6a74b75b00
5
5
  SHA512:
6
- metadata.gz: 8fd1e44cf21efb3ab7cb0e581c09e7ace7e3cb73412b227592885db69b5ffb57379f4386635f3937d1211e52aca75e907b4a417c7f2d255b2419e75681716cbc
7
- data.tar.gz: 1c2cf1efddda9af825334f9e1cace219082ab6b24dbb1db307721c516533474b7451363c3b089819082adec696daea40967a0c55d4cfbe82d66d664b51b645a9
6
+ metadata.gz: 00202a0bca78706ba430c3e2475103cf78a38947d664c40ef00a64ccffbd4f7ef608d5f4dad4f1bbbcdd3a5b6f6317ce308543c41cdff9379a164a8ffd14a354
7
+ data.tar.gz: 9bcd5eb3dab53f78807b811d94efa673edee119eeb72d85d1830f89794c996583a1da502e6a8b81fd83c047617089587fb227f102f7cd13a2b618cbfd031b0a5
data/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ lib/*
2
+ node_modules/*
3
+ vendor/*
data/.gitignore CHANGED
@@ -4,5 +4,3 @@
4
4
  node_modules
5
5
  .byebug_history
6
6
  /test/test_app/tmp
7
- Gemfile.lock
8
- yarn.lock
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.6
5
- - 2.3.3
6
- - 2.4.1
4
+ - 2.2.8
5
+ - 2.3.5
6
+ - 2.4.2
7
7
  cache:
8
8
  bundler: true
9
9
  directories:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,45 @@
1
+ ## [3.0.2] - 2017-10-04
2
+
3
+ ### Added
4
+
5
+ - Allow dev server connect timeout (in seconds) to be configurable, default: 0.01
6
+
7
+ ```rb
8
+ # Change to 1s
9
+ Webpacker.dev_server.connect_timeout = 1
10
+ ```
11
+
12
+ - Restrict the source maps generated in production [#770](https://github.com/rails/webpacker/pull/770)
13
+
14
+ - Binstubs [#833](https://github.com/rails/webpacker/pull/833)
15
+
16
+ - Allow dev server settings to be overriden by env variables [#843](https://github.com/rails/webpacker/pull/843)
17
+
18
+ - A new `lookup` method to manifest to perform lookup without raise and return `nil`
19
+
20
+ ```rb
21
+ Webpacker.manifest.lookup('foo.js')
22
+ # => nil
23
+ Webpacker.manifest.lookup!('foo.js')
24
+ # => raises Webpacker::Manifest::MissingEntryError
25
+ ```
26
+
27
+ - Catch all exceptions in `DevServer.running?` and return false [#878](https://github.com/rails/webpacker/pull/878)
28
+
29
+ ### Removed
30
+
31
+ - Inline CLI args for dev server binstub, use env variables instead
32
+
33
+ - Coffeescript as core dependency. You have to manually add coffeescript now, if you are using
34
+ it in your app.
35
+
36
+ ```bash
37
+ yarn add coffeescript@1.12.7
38
+
39
+ # OR coffeescript 2.0
40
+ yarn add coffeescript
41
+ ```
42
+
1
43
  ## [3.0.1] - 2017-09-01
2
44
 
3
45
  ### Fixed
@@ -94,9 +136,11 @@ live reload when manifest changes. If you have applied this workaround from [#72
94
136
 
95
137
  ### Breaking changes
96
138
 
97
- - Add `compile` option to `config/webpacker.yml` for configuring lazy compilation of packs when a file under tracked paths is changed [#503](https://github.com/rails/webpacker/pull/503). To enable expected behavior, update `config/webpacker.yml`:
139
+ - Add `compile` and `cache_path` options to `config/webpacker.yml` for configuring lazy compilation of packs when a file under tracked paths is changed [#503](https://github.com/rails/webpacker/pull/503). To enable expected behavior, update `config/webpacker.yml`:
98
140
 
99
141
  ```yaml
142
+ default: &default
143
+ cache_path: tmp/cache/webpacker
100
144
  test:
101
145
  compile: true
102
146
 
data/Gemfile.lock ADDED
@@ -0,0 +1,144 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webpacker (3.0.2)
5
+ activesupport (>= 4.2)
6
+ rack-proxy (>= 0.6.1)
7
+ railties (>= 4.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.0.1)
13
+ actionpack (= 5.0.1)
14
+ nio4r (~> 1.2)
15
+ websocket-driver (~> 0.6.1)
16
+ actionmailer (5.0.1)
17
+ actionpack (= 5.0.1)
18
+ actionview (= 5.0.1)
19
+ activejob (= 5.0.1)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.0.1)
23
+ actionview (= 5.0.1)
24
+ activesupport (= 5.0.1)
25
+ rack (~> 2.0)
26
+ rack-test (~> 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.0.1)
30
+ activesupport (= 5.0.1)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
35
+ activejob (5.0.1)
36
+ activesupport (= 5.0.1)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.0.1)
39
+ activesupport (= 5.0.1)
40
+ activerecord (5.0.1)
41
+ activemodel (= 5.0.1)
42
+ activesupport (= 5.0.1)
43
+ arel (~> 7.0)
44
+ activesupport (5.0.1)
45
+ concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ i18n (~> 0.7)
47
+ minitest (~> 5.1)
48
+ tzinfo (~> 1.1)
49
+ arel (7.1.4)
50
+ ast (2.3.0)
51
+ builder (3.2.3)
52
+ byebug (9.0.6)
53
+ concurrent-ruby (1.0.5)
54
+ erubis (2.7.0)
55
+ globalid (0.3.7)
56
+ activesupport (>= 4.1.0)
57
+ i18n (0.8.1)
58
+ loofah (2.0.3)
59
+ nokogiri (>= 1.5.9)
60
+ mail (2.6.4)
61
+ mime-types (>= 1.16, < 4)
62
+ method_source (0.8.2)
63
+ mime-types (3.1)
64
+ mime-types-data (~> 3.2015)
65
+ mime-types-data (3.2016.0521)
66
+ mini_portile2 (2.1.0)
67
+ minitest (5.10.1)
68
+ nio4r (1.2.1)
69
+ nokogiri (1.7.0.1)
70
+ mini_portile2 (~> 2.1.0)
71
+ parallel (1.12.0)
72
+ parser (2.4.0.0)
73
+ ast (~> 2.2)
74
+ powerpack (0.1.1)
75
+ rack (2.0.1)
76
+ rack-proxy (0.6.1)
77
+ rack
78
+ rack-test (0.6.3)
79
+ rack (>= 1.0)
80
+ rails (5.0.1)
81
+ actioncable (= 5.0.1)
82
+ actionmailer (= 5.0.1)
83
+ actionpack (= 5.0.1)
84
+ actionview (= 5.0.1)
85
+ activejob (= 5.0.1)
86
+ activemodel (= 5.0.1)
87
+ activerecord (= 5.0.1)
88
+ activesupport (= 5.0.1)
89
+ bundler (>= 1.3.0, < 2.0)
90
+ railties (= 5.0.1)
91
+ sprockets-rails (>= 2.0.0)
92
+ rails-dom-testing (2.0.2)
93
+ activesupport (>= 4.2.0, < 6.0)
94
+ nokogiri (~> 1.6)
95
+ rails-html-sanitizer (1.0.3)
96
+ loofah (~> 2.0)
97
+ railties (5.0.1)
98
+ actionpack (= 5.0.1)
99
+ activesupport (= 5.0.1)
100
+ method_source
101
+ rake (>= 0.8.7)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rainbow (2.2.2)
104
+ rake
105
+ rake (12.0.0)
106
+ rubocop (0.49.1)
107
+ parallel (~> 1.10)
108
+ parser (>= 2.3.3.1, < 3.0)
109
+ powerpack (~> 0.1)
110
+ rainbow (>= 1.99.1, < 3.0)
111
+ ruby-progressbar (~> 1.7)
112
+ unicode-display_width (~> 1.0, >= 1.0.1)
113
+ ruby-progressbar (1.8.1)
114
+ sprockets (3.7.1)
115
+ concurrent-ruby (~> 1.0)
116
+ rack (> 1, < 3)
117
+ sprockets-rails (3.2.0)
118
+ actionpack (>= 4.0)
119
+ activesupport (>= 4.0)
120
+ sprockets (>= 3.0.0)
121
+ thor (0.19.4)
122
+ thread_safe (0.3.6)
123
+ tzinfo (1.2.2)
124
+ thread_safe (~> 0.1)
125
+ unicode-display_width (1.3.0)
126
+ websocket-driver (0.6.5)
127
+ websocket-extensions (>= 0.1.0)
128
+ websocket-extensions (0.1.2)
129
+
130
+ PLATFORMS
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ bundler (~> 1.12)
135
+ byebug
136
+ minitest (~> 5.0)
137
+ rack-proxy
138
+ rails
139
+ rake (>= 11.1)
140
+ rubocop (>= 0.49)
141
+ webpacker!
142
+
143
+ BUNDLED WITH
144
+ 1.15.4
data/README.md CHANGED
@@ -20,8 +20,10 @@ in which case you may not even need the asset pipeline. This is mostly relevant
20
20
  - [Prerequisites](#prerequisites)
21
21
  - [Features](#features)
22
22
  - [Installation](#installation)
23
+ - [Upgrading](#upgrading)
23
24
  - [Usage](#usage)
24
25
  - [Development](#development)
26
+ - [Webpack configuration](#webpack-configuration)
25
27
  - [Integrations](#integrations)
26
28
  - [React](#react)
27
29
  - [Angular with TypeScript](#angular-with-typescript)
@@ -90,6 +92,7 @@ bundle exec rails webpacker:install
90
92
  bundle exec rake webpacker:install
91
93
  ```
92
94
 
95
+
93
96
  ### Usage
94
97
 
95
98
  Once installed you can start writing modern ES6-flavored JavaScript app today:
@@ -124,6 +127,7 @@ can use `asset_pack_path` helper:
124
127
  **Note:** In order for your styles or static assets files to be available in your view,
125
128
  you would need to link them in your "pack" or entry file.
126
129
 
130
+
127
131
  ### Development
128
132
 
129
133
  Webpacker ships with two binstubs: `./bin/webpack` and `./bin/webpack-dev-server`.
@@ -155,24 +159,36 @@ Once you start this development server, Webpacker will automatically start proxy
155
159
  webpack asset requests to this server. When you stop the server, it'll revert to
156
160
  on-demand compilation again.
157
161
 
158
- You can also pass CLI options supported by [webpack-dev-server](https://webpack.js.org/configuration/dev-server/). Please note that inline options will always take
159
- precedence over the ones already set in the configuration file.
162
+ You can use environment variables as options supported by [webpack-dev-server](https://webpack.js.org/configuration/dev-server/) in the form `WEBPACKER_DEV_SERVER_<OPTION>`. Please note that these environment variables will always take precedence over the ones already set in the configuration file.
160
163
 
161
164
  ```bash
162
- ./bin/webpack-dev-server --host example.com --inline true --hot false
165
+ WEBPACKER_DEV_SERVER_HOST=example.com WEBPACKER_DEV_SERVER_INLINE=true WEBPACKER_DEV_SERVER_HOT=false ./bin/webpack-dev-server
163
166
  ```
164
167
 
165
168
  By default, webpack dev server listens on `localhost` in development for security
166
169
  but if you want your app to be available over local LAN IP or VM instance like vagrant
167
- you can pass an additional config option `--listen-host`
168
- when running `./bin/webpack-dev-server` binstub:
170
+ you can set the `host` when running `./bin/webpack-dev-server` binstub:
169
171
 
170
172
  ```bash
171
- ./bin/webpack-dev-server --listen-host 0.0.0.0
173
+ WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
172
174
  ```
173
175
 
174
176
  **Note:** Don't forget to prefix `ruby` when running these binstubs on windows
175
177
 
178
+ ### Webpack configuration
179
+
180
+ See [docs/Webpack](docs/webpack.md) for modifying webpack configuration and loaders.
181
+
182
+
183
+ ### Upgrading
184
+
185
+ You can run following commands to upgrade webpacker to the latest stable version, this involves upgrading the gem and npm module:
186
+
187
+ ```bash
188
+ bundle update webpacker
189
+ yarn upgrade @rails/webpacker --latest
190
+ ```
191
+
176
192
  ## Integrations
177
193
 
178
194
  Webpacker ships with basic out-of-the-box integration for React, Angular, Vue and Elm.
@@ -198,7 +214,7 @@ project in `app/javascript/packs` so that you can experiment with React right aw
198
214
 
199
215
  ### Angular with TypeScript
200
216
 
201
- To use Webpacker with [Angular](https://angularjs.org/), create a
217
+ To use Webpacker with [Angular](https://angular.io/), create a
202
218
  new Rails 5.1+ app using `--webpack=angular` option:
203
219
 
204
220
  ```bash
data/docs/deployment.md CHANGED
@@ -9,13 +9,10 @@ The `javascript_pack_tag` and `stylesheet_pack_tag` helper method will automatic
9
9
  By default the output will look like this in different environments:
10
10
 
11
11
  ```html
12
- <!-- In development mode -->
13
- <script src="/packs/calendar.js"></script>
14
- <link rel="stylesheet" media="screen" href="/packs/calendar.css">
15
12
  <!-- In development mode with webpack-dev-server -->
16
- <script src="http://localhost:8080/calendar.js"></script>
17
- <link rel="stylesheet" media="screen" href="http://localhost:8080/calendar.css">
18
- <!-- In production mode -->
13
+ <script src="http://localhost:8080/calendar-0bd141f6d9360cf4a7f5.js"></script>
14
+ <link rel="stylesheet" media="screen" href="http://localhost:8080/calendar-dc02976b5f94b507e3b6.css">
15
+ <!-- In production or development mode -->
19
16
  <script src="/packs/calendar-0bd141f6d9360cf4a7f5.js"></script>
20
17
  <link rel="stylesheet" media="screen" href="/packs/calendar-dc02976b5f94b507e3b6.css">
21
18
  ```
data/docs/env.md CHANGED
@@ -17,7 +17,7 @@ console.log(process.env.FOO) // Compiles to console.log("hello")
17
17
  You may want to store configuration in environment variables via `.env` files,
18
18
  similar to the [dotenv Ruby gem](https://github.com/bkeepers/dotenv).
19
19
 
20
- In development, if you use Foreman or [Invoker](http://invoker.codemancers.com)
20
+ In development, if you use [Foreman](http://ddollar.github.io/foreman) or [Invoker](http://invoker.codemancers.com)
21
21
  to launch the Webpack server, both of these tools have basic support for a
22
22
  `.env` file (Invoker also supports `.env.local`), so no further configuration
23
23
  is needed.
data/docs/misc.md CHANGED
@@ -14,7 +14,7 @@ and add `ignore-loader` to `config/webpack/environment.js`
14
14
  ```js
15
15
  // ignores vue~ swap files
16
16
  const { environment } = require('@rails/webpacker')
17
- environment.loaders.add('ignore', {
17
+ environment.loaders.set('ignore', {
18
18
  test: /.vue~$/,
19
19
  loader: 'ignore-loader'
20
20
  })
data/docs/props.md CHANGED
@@ -78,7 +78,7 @@ Now, modify your Vue app to expect the properties.
78
78
  props: ["message","name"],
79
79
  data: function () {
80
80
  return {
81
- test: 'This will display: ',
81
+ test: 'This will display: '
82
82
  }
83
83
  }
84
84
  }
@@ -103,3 +103,121 @@ document.addEventListener('DOMContentLoaded', () => {
103
103
  ```
104
104
 
105
105
  You can follow same steps for Angular too.
106
+
107
+
108
+ ## Elm
109
+
110
+ Just like with other implementations, we'll render our data inside a `data`
111
+ attribute:
112
+
113
+ ```erb
114
+ <%= content_tag :div,
115
+ id: "hello-elm",
116
+ data: {
117
+ message: "Hello",
118
+ name: "David"
119
+ }.to_json do %>
120
+ <% end %>
121
+ ```
122
+
123
+ We parse the JSON data and pass it to Elm as flags:
124
+
125
+ ```js
126
+ import Elm from '../Main'
127
+
128
+ document.addEventListener('DOMContentLoaded', () => {
129
+ const node = document.getElementById('hello-elm')
130
+ const data = JSON.parse(node.getAttribute('data'))
131
+ Elm.Main.embed(node, data)
132
+ })
133
+ ```
134
+
135
+ Defining `Flags` as a `type alias`, we instruct Elm to demand flags `message`
136
+ and `name` of type `String` on initialization.
137
+
138
+ Using `programWithFlags` we bring all the pieces together:
139
+
140
+
141
+ ```elm
142
+ module Main exposing (..)
143
+
144
+ import Html exposing (Html, programWithFlags, h1, text)
145
+ import Html.Attributes exposing (style)
146
+
147
+
148
+ -- MODEL
149
+
150
+
151
+ type alias Flags =
152
+ { message : String
153
+ , name : String
154
+ }
155
+
156
+
157
+ type alias Model =
158
+ { message : String
159
+ , name : String
160
+ }
161
+
162
+
163
+ type Msg
164
+ = NoOp
165
+
166
+
167
+
168
+ -- INIT
169
+
170
+
171
+ init : Flags -> ( Model, Cmd Msg )
172
+ init flags =
173
+ let
174
+ { message, name } =
175
+ flags
176
+ in
177
+ ( Model message name, Cmd.none )
178
+
179
+
180
+
181
+ -- UPDATE
182
+
183
+
184
+ update : Msg -> Model -> ( Model, Cmd Msg )
185
+ update msg model =
186
+ case msg of
187
+ NoOp ->
188
+ ( model, Cmd.none )
189
+
190
+
191
+
192
+ -- SUBSCRIPTIONS
193
+
194
+
195
+ subscriptions : Model -> Sub Msg
196
+ subscriptions model =
197
+ Sub.none
198
+
199
+
200
+
201
+ -- VIEW
202
+
203
+
204
+ view : Model -> Html Msg
205
+ view model =
206
+ h1 [ style [ ( "display", "flex" ), ( "justify-content", "center" ) ] ]
207
+ [ text (model.message ++ ", " ++ model.name ++ "!") ]
208
+
209
+
210
+
211
+ -- MAIN
212
+
213
+
214
+ main : Program Flags Model Msg
215
+ main =
216
+ programWithFlags
217
+ { view = view
218
+ , init = init
219
+ , update = update
220
+ , subscriptions = subscriptions
221
+ }
222
+
223
+ ```