webpacker 3.2.2 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -1
  3. data/Gemfile.lock +38 -38
  4. data/README.md +48 -49
  5. data/docs/css.md +31 -1
  6. data/docs/docker.md +1 -1
  7. data/docs/typescript.md +36 -1
  8. data/{exe → lib/install/bin}/webpack +7 -0
  9. data/{exe → lib/install/bin}/webpack-dev-server +7 -0
  10. data/lib/install/binstubs.rb +4 -0
  11. data/lib/install/config/webpacker.yml +3 -0
  12. data/lib/install/loaders/erb.js +1 -1
  13. data/lib/install/template.rb +1 -2
  14. data/lib/install/typescript.rb +1 -1
  15. data/lib/tasks/webpacker.rake +1 -0
  16. data/lib/tasks/webpacker/binstubs.rake +12 -0
  17. data/lib/tasks/webpacker/check_binstubs.rake +1 -1
  18. data/lib/webpacker.rb +1 -0
  19. data/lib/webpacker/compiler.rb +4 -2
  20. data/lib/webpacker/dev_server_runner.rb +1 -1
  21. data/lib/webpacker/env.rb +39 -0
  22. data/lib/webpacker/instance.rb +1 -12
  23. data/lib/webpacker/version.rb +1 -1
  24. data/package.json +2 -2
  25. data/package/__tests__/config.js +7 -4
  26. data/package/__tests__/dev_server.js +26 -0
  27. data/package/__tests__/env.js +28 -0
  28. data/package/__tests__/index.js +31 -0
  29. data/package/config.js +14 -30
  30. data/package/config_types/__tests__/config_list.js +0 -5
  31. data/package/config_types/config_list.js +0 -9
  32. data/package/dev_server.js +23 -0
  33. data/package/env.js +23 -0
  34. data/package/{__tests__/environment.js → environments/__tests__/base.js} +6 -6
  35. data/package/{environment.js → environments/base.js} +4 -4
  36. data/package/environments/development.js +4 -3
  37. data/package/environments/production.js +31 -25
  38. data/package/environments/test.js +2 -2
  39. data/package/index.js +10 -6
  40. data/package/rules/babel.js +8 -6
  41. data/package/rules/css.js +2 -38
  42. data/package/rules/file.js +9 -7
  43. data/package/rules/index.js +4 -0
  44. data/package/rules/module.css.js +3 -0
  45. data/package/rules/module.sass.js +8 -0
  46. data/package/rules/sass.js +5 -12
  47. data/package/utils/__tests__/get_style_rule.js +36 -0
  48. data/package/utils/get_style_rule.js +62 -0
  49. data/package/utils/helpers.js +17 -3
  50. data/test/env_test.rb +19 -0
  51. data/test/test_app/bin/webpack +15 -0
  52. data/test/test_app/bin/webpack-dev-server +15 -0
  53. data/test/test_app/config/webpacker.yml +3 -0
  54. data/test/test_helper.rb +3 -1
  55. data/webpacker.gemspec +0 -2
  56. data/yarn.lock +8 -4
  57. metadata +26 -10
@@ -1,10 +1,11 @@
1
- const isObject = value => (
1
+ const isObject = value =>
2
2
  typeof value === 'object' &&
3
3
  value !== null &&
4
4
  (value.length === undefined || value.length === null)
5
- )
6
5
 
7
- const isEmpty = value => (value === null || value === undefined)
6
+ const isBoolean = str => /^true/.test(str) || /^false/.test(str)
7
+
8
+ const isEmpty = value => value === null || value === undefined
8
9
 
9
10
  const isString = key => key && typeof key === 'string'
10
11
 
@@ -21,8 +22,21 @@ const canMerge = value => isObject(value) || isArray(value)
21
22
 
22
23
  const prettyPrint = obj => JSON.stringify(obj, null, 2)
23
24
 
25
+ const chdirTestApp = () => {
26
+ try {
27
+ return process.chdir('test/test_app')
28
+ } catch (e) {
29
+ return null
30
+ }
31
+ }
32
+
33
+ const chdirCwd = () => process.chdir(process.cwd())
34
+
24
35
  module.exports = {
36
+ chdirTestApp,
37
+ chdirCwd,
25
38
  isObject,
39
+ isBoolean,
26
40
  isArray,
27
41
  isEqual,
28
42
  isEmpty,
data/test/env_test.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "test_helper"
2
+
3
+ class EnvTest < Webpacker::Test
4
+ def test_current
5
+ reloaded_config
6
+ assert_equal Webpacker.env, "production"
7
+ end
8
+
9
+ def test_custom
10
+ with_node_env("default") do
11
+ reloaded_config
12
+ assert_equal Webpacker.env, "default"
13
+ end
14
+ end
15
+
16
+ def test_default
17
+ assert_equal Webpacker::Env::DEFAULT, "production"
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= ENV["RAILS_ENV"]
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/webpack_runner"
15
+ Webpacker::WebpackRunner.run(ARGV)
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
4
+ ENV["NODE_ENV"] ||= ENV["RAILS_ENV"]
5
+
6
+ require "pathname"
7
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
+ Pathname.new(__FILE__).realpath)
9
+
10
+ require "rubygems"
11
+ require "bundler/setup"
12
+
13
+ require "webpacker"
14
+ require "webpacker/dev_server_runner"
15
+ Webpacker::DevServerRunner.run(ARGV)
@@ -20,6 +20,9 @@ default: &default
20
20
  - .sass
21
21
  - .scss
22
22
  - .css
23
+ - .module.sass
24
+ - .module.scss
25
+ - .module.css
23
26
  - .png
24
27
  - .svg
25
28
  - .gif
data/test/test_helper.rb CHANGED
@@ -6,7 +6,7 @@ require "byebug"
6
6
 
7
7
  require_relative "test_app/config/environment"
8
8
 
9
- ENV["NODE_ENV"] ||= "production"
9
+ ENV["NODE_ENV"] = "production"
10
10
 
11
11
  Webpacker.instance = Webpacker::Instance.new \
12
12
  root_path: Pathname.new(File.expand_path("test_app", __dir__)),
@@ -15,7 +15,9 @@ Webpacker.instance = Webpacker::Instance.new \
15
15
  class Webpacker::Test < Minitest::Test
16
16
  private
17
17
  def reloaded_config
18
+ Webpacker.instance.instance_variable_set(:@env, nil)
18
19
  Webpacker.instance.instance_variable_set(:@config, nil)
20
+ Webpacker.env
19
21
  Webpacker.config
20
22
  end
21
23
 
data/webpacker.gemspec CHANGED
@@ -9,8 +9,6 @@ Gem::Specification.new do |s|
9
9
  s.summary = "Use webpack to manage app-like JavaScript modules in Rails"
10
10
  s.homepage = "https://github.com/rails/webpacker"
11
11
  s.license = "MIT"
12
- s.bindir = "exe"
13
- s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
14
12
 
15
13
  s.required_ruby_version = ">= 2.2.0"
16
14
 
data/yarn.lock CHANGED
@@ -1299,13 +1299,13 @@ commondir@^1.0.1:
1299
1299
  version "1.0.1"
1300
1300
  resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
1301
1301
 
1302
- compression-webpack-plugin@^1.1.6:
1303
- version "1.1.6"
1304
- resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-1.1.6.tgz#450808fe143b4c5216a14f0c315c47bec3d83cec"
1302
+ compression-webpack-plugin@^1.1.10:
1303
+ version "1.1.10"
1304
+ resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-1.1.10.tgz#dbc2d2d65729a89f7b195668211d38ea0883df98"
1305
1305
  dependencies:
1306
- async "^2.4.1"
1307
1306
  cacache "^10.0.1"
1308
1307
  find-cache-dir "^1.0.0"
1308
+ neo-async "^2.5.0"
1309
1309
  serialize-javascript "^1.4.0"
1310
1310
  webpack-sources "^1.0.1"
1311
1311
 
@@ -3746,6 +3746,10 @@ natural-compare@^1.4.0:
3746
3746
  version "1.4.0"
3747
3747
  resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
3748
3748
 
3749
+ neo-async@^2.5.0:
3750
+ version "2.5.0"
3751
+ resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.5.0.tgz#76b1c823130cca26acfbaccc8fbaf0a2fa33b18f"
3752
+
3749
3753
  node-fetch@^1.0.1:
3750
3754
  version "1.7.3"
3751
3755
  resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  - Gaurav Tiwari
9
9
  autorequire:
10
- bindir: exe
10
+ bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-11 00:00:00.000000000 Z
12
+ date: 2018-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -71,9 +71,7 @@ description:
71
71
  email:
72
72
  - david@basecamp.com
73
73
  - gaurav@gauravtiwari.co.uk
74
- executables:
75
- - webpack
76
- - webpack-dev-server
74
+ executables: []
77
75
  extensions: []
78
76
  extra_rdoc_files: []
79
77
  files:
@@ -104,13 +102,14 @@ files:
104
102
  - docs/webpack-dev-server.md
105
103
  - docs/webpack.md
106
104
  - docs/yarn.md
107
- - exe/webpack
108
- - exe/webpack-dev-server
109
105
  - gemfiles/Gemfile-rails-edge
110
106
  - gemfiles/Gemfile-rails.4.2.x
111
107
  - gemfiles/Gemfile-rails.5.0.x
112
108
  - gemfiles/Gemfile-rails.5.1.x
113
109
  - lib/install/angular.rb
110
+ - lib/install/bin/webpack
111
+ - lib/install/bin/webpack-dev-server
112
+ - lib/install/binstubs.rb
114
113
  - lib/install/coffee.rb
115
114
  - lib/install/config/.babelrc
116
115
  - lib/install/config/.postcssrc.yml
@@ -152,6 +151,7 @@ files:
152
151
  - lib/install/vue.rb
153
152
  - lib/tasks/installers.rake
154
153
  - lib/tasks/webpacker.rake
154
+ - lib/tasks/webpacker/binstubs.rake
155
155
  - lib/tasks/webpacker/check_binstubs.rake
156
156
  - lib/tasks/webpacker/check_node.rake
157
157
  - lib/tasks/webpacker/check_yarn.rake
@@ -167,6 +167,7 @@ files:
167
167
  - lib/webpacker/dev_server.rb
168
168
  - lib/webpacker/dev_server_proxy.rb
169
169
  - lib/webpacker/dev_server_runner.rb
170
+ - lib/webpacker/env.rb
170
171
  - lib/webpacker/helper.rb
171
172
  - lib/webpacker/instance.rb
172
173
  - lib/webpacker/manifest.rb
@@ -176,14 +177,19 @@ files:
176
177
  - lib/webpacker/webpack_runner.rb
177
178
  - package.json
178
179
  - package/__tests__/config.js
179
- - package/__tests__/environment.js
180
+ - package/__tests__/dev_server.js
181
+ - package/__tests__/env.js
182
+ - package/__tests__/index.js
180
183
  - package/config.js
181
184
  - package/config_types/__tests__/config_list.js
182
185
  - package/config_types/__tests__/config_object.js
183
186
  - package/config_types/config_list.js
184
187
  - package/config_types/config_object.js
185
188
  - package/config_types/index.js
186
- - package/environment.js
189
+ - package/dev_server.js
190
+ - package/env.js
191
+ - package/environments/__tests__/base.js
192
+ - package/environments/base.js
187
193
  - package/environments/development.js
188
194
  - package/environments/production.js
189
195
  - package/environments/test.js
@@ -192,23 +198,30 @@ files:
192
198
  - package/rules/css.js
193
199
  - package/rules/file.js
194
200
  - package/rules/index.js
201
+ - package/rules/module.css.js
202
+ - package/rules/module.sass.js
195
203
  - package/rules/sass.js
196
204
  - package/utils/__tests__/deep_assign.js
197
205
  - package/utils/__tests__/deep_merge.js
206
+ - package/utils/__tests__/get_style_rule.js
198
207
  - package/utils/__tests__/objectify.js
199
208
  - package/utils/deep_assign.js
200
209
  - package/utils/deep_merge.js
210
+ - package/utils/get_style_rule.js
201
211
  - package/utils/helpers.js
202
212
  - package/utils/objectify.js
203
213
  - test/command_test.rb
204
214
  - test/compiler_test.rb
205
215
  - test/configuration_test.rb
206
216
  - test/dev_server_test.rb
217
+ - test/env_test.rb
207
218
  - test/helper_test.rb
208
219
  - test/manifest_test.rb
209
220
  - test/rake_tasks_test.rb
210
221
  - test/test_app/Rakefile
211
222
  - test/test_app/app/javascript/packs/application.js
223
+ - test/test_app/bin/webpack
224
+ - test/test_app/bin/webpack-dev-server
212
225
  - test/test_app/config/application.rb
213
226
  - test/test_app/config/environment.rb
214
227
  - test/test_app/config/webpacker.yml
@@ -245,11 +258,14 @@ test_files:
245
258
  - test/compiler_test.rb
246
259
  - test/configuration_test.rb
247
260
  - test/dev_server_test.rb
261
+ - test/env_test.rb
248
262
  - test/helper_test.rb
249
263
  - test/manifest_test.rb
250
264
  - test/rake_tasks_test.rb
251
265
  - test/test_app/Rakefile
252
266
  - test/test_app/app/javascript/packs/application.js
267
+ - test/test_app/bin/webpack
268
+ - test/test_app/bin/webpack-dev-server
253
269
  - test/test_app/config/application.rb
254
270
  - test/test_app/config/environment.rb
255
271
  - test/test_app/config/webpacker.yml