webpacker 4.0.2 → 5.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +8 -8
  3. data/.github/workflows/jest.yml +38 -0
  4. data/.github/workflows/js-lint.yml +39 -0
  5. data/.github/workflows/rubocop.yml +39 -0
  6. data/.github/workflows/ruby.yml +58 -0
  7. data/.gitignore +1 -0
  8. data/.node-version +1 -1
  9. data/.rubocop.yml +115 -14
  10. data/.travis.yml +16 -18
  11. data/CHANGELOG.md +329 -130
  12. data/Gemfile +1 -1
  13. data/Gemfile.lock +127 -105
  14. data/README.md +84 -217
  15. data/docs/assets.md +20 -10
  16. data/docs/css.md +126 -7
  17. data/docs/deployment.md +55 -10
  18. data/docs/docker.md +33 -14
  19. data/docs/engines.md +60 -2
  20. data/docs/env.md +0 -2
  21. data/docs/es6.md +24 -5
  22. data/docs/integrations.md +220 -0
  23. data/docs/target.md +22 -0
  24. data/docs/testing.md +2 -3
  25. data/docs/troubleshooting.md +46 -7
  26. data/docs/typescript.md +93 -26
  27. data/docs/v4-upgrade.md +12 -2
  28. data/docs/webpack-dev-server.md +2 -2
  29. data/docs/webpack.md +21 -7
  30. data/gemfiles/Gemfile-rails-edge +2 -3
  31. data/gemfiles/Gemfile-rails.5.2.x +1 -2
  32. data/gemfiles/Gemfile-rails.6.0.x +9 -0
  33. data/lib/install/bin/webpack +0 -1
  34. data/lib/install/bin/webpack-dev-server +0 -1
  35. data/lib/install/coffee.rb +1 -1
  36. data/lib/install/config/babel.config.js +24 -12
  37. data/lib/install/config/webpacker.yml +3 -6
  38. data/lib/install/elm.rb +3 -3
  39. data/lib/install/erb.rb +2 -2
  40. data/lib/install/examples/angular/hello_angular/polyfills.ts +2 -2
  41. data/lib/install/examples/react/babel.config.js +31 -15
  42. data/lib/install/examples/react/tsconfig.json +2 -1
  43. data/lib/install/examples/svelte/app.svelte +11 -0
  44. data/lib/install/examples/svelte/hello_svelte.js +20 -0
  45. data/lib/install/examples/typescript/tsconfig.json +2 -1
  46. data/lib/install/examples/vue/hello_vue.js +2 -3
  47. data/lib/install/loaders/elm.js +9 -6
  48. data/lib/install/loaders/svelte.js +9 -0
  49. data/lib/install/svelte.rb +29 -0
  50. data/lib/install/template.rb +12 -4
  51. data/lib/install/typescript.rb +6 -13
  52. data/lib/install/vue.rb +1 -1
  53. data/lib/tasks/installers.rake +1 -0
  54. data/lib/tasks/webpacker/check_node.rake +15 -8
  55. data/lib/tasks/webpacker/check_yarn.rake +16 -10
  56. data/lib/tasks/webpacker/clean.rake +25 -0
  57. data/lib/tasks/webpacker/clobber.rake +8 -4
  58. data/lib/tasks/webpacker/compile.rake +10 -15
  59. data/lib/tasks/webpacker/yarn_install.rake +11 -1
  60. data/lib/tasks/webpacker.rake +2 -0
  61. data/lib/webpacker/commands.rb +53 -1
  62. data/lib/webpacker/compiler.rb +24 -9
  63. data/lib/webpacker/configuration.rb +36 -13
  64. data/lib/webpacker/dev_server.rb +1 -1
  65. data/lib/webpacker/dev_server_proxy.rb +5 -9
  66. data/lib/webpacker/dev_server_runner.rb +10 -4
  67. data/lib/webpacker/env.rb +6 -2
  68. data/lib/webpacker/helper.rb +71 -26
  69. data/lib/webpacker/manifest.rb +4 -4
  70. data/lib/webpacker/railtie.rb +6 -43
  71. data/lib/webpacker/runner.rb +1 -0
  72. data/lib/webpacker/version.rb +1 -1
  73. data/lib/webpacker/webpack_runner.rb +6 -0
  74. data/lib/webpacker.rb +9 -1
  75. data/package/__tests__/config.js +12 -24
  76. data/package/__tests__/dev_server.js +2 -0
  77. data/package/__tests__/development.js +14 -1
  78. data/package/config.js +6 -11
  79. data/package/configPath.js +3 -0
  80. data/package/config_types/config_list.js +3 -3
  81. data/package/config_types/config_object.js +1 -1
  82. data/package/dev_server.js +1 -1
  83. data/package/env.js +1 -2
  84. data/package/environments/__tests__/base.js +30 -3
  85. data/package/environments/base.js +20 -10
  86. data/package/environments/development.js +39 -37
  87. data/package/environments/production.js +12 -2
  88. data/package/rules/babel.js +12 -5
  89. data/package/rules/file.js +3 -2
  90. data/package/rules/node_modules.js +3 -4
  91. data/package/rules/sass.js +11 -2
  92. data/package/utils/__tests__/get_style_rule.js +9 -0
  93. data/package/utils/deep_merge.js +5 -5
  94. data/package/utils/get_style_rule.js +7 -12
  95. data/package/utils/helpers.js +10 -10
  96. data/package.json +43 -42
  97. data/test/command_test.rb +6 -0
  98. data/test/compiler_test.rb +10 -6
  99. data/test/configuration_test.rb +40 -30
  100. data/test/dev_server_runner_test.rb +1 -1
  101. data/test/dev_server_test.rb +22 -0
  102. data/test/helper_test.rb +58 -9
  103. data/test/manifest_test.rb +37 -6
  104. data/test/rake_tasks_test.rb +17 -0
  105. data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  106. data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  107. data/test/test_app/bin/webpack +0 -1
  108. data/test/test_app/bin/webpack-dev-server +0 -1
  109. data/test/test_app/config/application.rb +0 -1
  110. data/test/test_app/config/webpacker.yml +8 -1
  111. data/test/test_app/public/packs/manifest.json +4 -0
  112. data/test/webpack_runner_test.rb +1 -1
  113. data/webpacker.gemspec +7 -4
  114. data/yarn.lock +4552 -4077
  115. metadata +73 -19
  116. data/gemfiles/Gemfile-rails.4.2.x +0 -10
  117. data/gemfiles/Gemfile-rails.5.0.x +0 -10
  118. data/gemfiles/Gemfile-rails.5.1.x +0 -10
  119. data/lib/install/loaders/typescript.js +0 -11
@@ -25,9 +25,10 @@ class CompilerTest < Minitest::Test
25
25
 
26
26
  def test_default_watched_paths
27
27
  assert_equal Webpacker.compiler.send(:default_watched_paths), [
28
- "app/assets/**/*",
29
- "/etc/yarn/**/*",
30
- "app/javascript/**/*",
28
+ "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
29
+ "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
30
+ "app/elm/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
31
+ "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
31
32
  "yarn.lock",
32
33
  "package.json",
33
34
  "config/webpack/**/*"
@@ -39,6 +40,10 @@ class CompilerTest < Minitest::Test
39
40
  assert !Webpacker.compiler.fresh?
40
41
  end
41
42
 
43
+ def test_compile
44
+ assert !Webpacker.compiler.compile
45
+ end
46
+
42
47
  def test_freshness_on_compile_success
43
48
  status = OpenStruct.new(success?: true)
44
49
 
@@ -49,14 +54,13 @@ class CompilerTest < Minitest::Test
49
54
  end
50
55
  end
51
56
 
52
- def test_staleness_on_compile_fail
57
+ def test_freshness_on_compile_fail
53
58
  status = OpenStruct.new(success?: false)
54
59
 
55
60
  assert Webpacker.compiler.stale?
56
61
  Open3.stub :capture3, [:sterr, :stdout, status] do
57
-
58
62
  Webpacker.compiler.compile
59
- assert Webpacker.compiler.stale?
63
+ assert Webpacker.compiler.fresh?
60
64
  end
61
65
  end
62
66
 
@@ -14,11 +14,21 @@ class ConfigurationTest < Webpacker::Test
14
14
  assert_equal source_path, @config.source_path.to_s
15
15
  end
16
16
 
17
+ def test_source_path_globbed
18
+ assert_equal @config.source_path_globbed,
19
+ "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
20
+ end
21
+
17
22
  def test_source_entry_path
18
23
  source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s
19
24
  assert_equal @config.source_entry_path.to_s, source_entry_path
20
25
  end
21
26
 
27
+ def test_public_root_path
28
+ public_root_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public").to_s
29
+ assert_equal @config.public_path.to_s, public_root_path
30
+ end
31
+
22
32
  def test_public_output_path
23
33
  public_output_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs").to_s
24
34
  assert_equal @config.public_output_path.to_s, public_output_path
@@ -43,12 +53,16 @@ class ConfigurationTest < Webpacker::Test
43
53
  assert_equal @config.cache_path.to_s, cache_path
44
54
  end
45
55
 
46
- def test_resolved_paths
47
- assert_equal @config.resolved_paths, ["app/assets", "/etc/yarn"]
56
+ def test_additional_paths
57
+ assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "app/elm"]
48
58
  end
49
59
 
50
- def test_resolved_paths_globbed
51
- assert_equal @config.resolved_paths_globbed, ["app/assets/**/*", "/etc/yarn/**/*"]
60
+ def test_additional_paths_globbed
61
+ assert_equal @config.additional_paths_globbed, [
62
+ "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
63
+ "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
64
+ "app/elm/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
65
+ ]
52
66
  end
53
67
 
54
68
  def test_extensions
@@ -60,40 +74,36 @@ class ConfigurationTest < Webpacker::Test
60
74
  def test_cache_manifest?
61
75
  assert @config.cache_manifest?
62
76
 
63
- @config = Webpacker::Configuration.new(
64
- root_path: @config.root_path,
65
- config_path: @config.config_path,
66
- env: "development"
67
- )
68
-
69
- refute @config.cache_manifest?
70
-
71
- @config = Webpacker::Configuration.new(
72
- root_path: @config.root_path,
73
- config_path: @config.config_path,
74
- env: "test"
75
- )
77
+ with_rails_env("development") do
78
+ refute Webpacker.config.cache_manifest?
79
+ end
76
80
 
77
- refute @config.cache_manifest?
81
+ with_rails_env("test") do
82
+ refute Webpacker.config.cache_manifest?
83
+ end
78
84
  end
79
85
 
80
86
  def test_compile?
81
87
  refute @config.compile?
82
88
 
83
- @config = Webpacker::Configuration.new(
84
- root_path: @config.root_path,
85
- config_path: @config.config_path,
86
- env: "development"
87
- )
89
+ with_rails_env("development") do
90
+ assert Webpacker.config.compile?
91
+ end
88
92
 
89
- assert @config.compile?
93
+ with_rails_env("test") do
94
+ assert Webpacker.config.compile?
95
+ end
96
+ end
90
97
 
91
- @config = Webpacker::Configuration.new(
92
- root_path: @config.root_path,
93
- config_path: @config.config_path,
94
- env: "test"
95
- )
98
+ def test_extract_css?
99
+ assert @config.extract_css?
100
+
101
+ with_rails_env("development") do
102
+ refute Webpacker.config.extract_css?
103
+ end
96
104
 
97
- assert @config.compile?
105
+ with_rails_env("test") do
106
+ refute Webpacker.config.extract_css?
107
+ end
98
108
  end
99
109
  end
@@ -36,7 +36,7 @@ class DevServerRunnerTest < Webpacker::Test
36
36
  klass = Webpacker::DevServerRunner
37
37
  instance = klass.new([])
38
38
  mock = Minitest::Mock.new
39
- mock.expect(:call, nil, [{}, *cmd])
39
+ mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
40
 
41
41
  klass.stub(:new, instance) do
42
42
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
@@ -22,4 +22,26 @@ class DevServerTest < Webpacker::Test
22
22
  assert_equal Webpacker.dev_server.https?, false
23
23
  end
24
24
  end
25
+
26
+ def test_protocol
27
+ with_rails_env("development") do
28
+ assert_equal Webpacker.dev_server.protocol, "http"
29
+ end
30
+ end
31
+
32
+ def test_host_with_port
33
+ with_rails_env("development") do
34
+ assert_equal Webpacker.dev_server.host_with_port, "localhost:3035"
35
+ end
36
+ end
37
+
38
+ def test_pretty?
39
+ with_rails_env("development") do
40
+ refute Webpacker.dev_server.pretty?
41
+ end
42
+ end
43
+
44
+ def test_default_env_prefix
45
+ assert_equal Webpacker::DevServer::DEFAULT_ENV_PREFIX, "WEBPACKER_DEV_SERVER"
46
+ end
25
47
  end
data/test/helper_test.rb CHANGED
@@ -50,6 +50,27 @@ class HelperTest < ActionView::TestCase
50
50
  assert_equal \
51
51
  "<img alt=\"Edit Entry\" src=\"/packs/media/images/nested/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
52
52
  image_pack_tag("media/images/nested/image.jpg", size: "16x10", alt: "Edit Entry")
53
+ assert_equal \
54
+ "<img srcset=\"/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg 2x\" src=\"/packs/media/images/image-c38deda30895059837cf.jpg\" />",
55
+ image_pack_tag("media/images/image.jpg", srcset: { "media/images/image-2x.jpg" => "2x" })
56
+ end
57
+
58
+ def test_favicon_pack_tag
59
+ assert_equal \
60
+ "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/application-k344a6d59eef8632c9d1.png\" />",
61
+ favicon_pack_tag("application.png", rel: "apple-touch-icon", type: "image/png")
62
+ assert_equal \
63
+ "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/media/images/mb-icon-c38deda30895059837cf.png\" />",
64
+ favicon_pack_tag("mb-icon.png", rel: "apple-touch-icon", type: "image/png")
65
+ assert_equal \
66
+ "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/media/images/mb-icon-c38deda30895059837cf.png\" />",
67
+ favicon_pack_tag("media/images/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
68
+ assert_equal \
69
+ "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/media/images/nested/mb-icon-c38deda30895059837cf.png\" />",
70
+ favicon_pack_tag("nested/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
71
+ assert_equal \
72
+ "<link rel=\"apple-touch-icon\" type=\"image/png\" href=\"/packs/media/images/nested/mb-icon-c38deda30895059837cf.png\" />",
73
+ favicon_pack_tag("media/images/nested/mb-icon.png", rel: "apple-touch-icon", type: "image/png")
53
74
  end
54
75
 
55
76
  def test_javascript_pack_tag
@@ -79,30 +100,58 @@ class HelperTest < ActionView::TestCase
79
100
  javascript_packs_with_chunks_tag("application")
80
101
  end
81
102
 
103
+ def test_preload_pack_asset
104
+ if self.class.method_defined?(:preload_link_tag)
105
+ assert_equal \
106
+ %(<link rel="preload" href="/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2" as="font" type="font/woff2" crossorigin="anonymous">),
107
+ preload_pack_asset("fonts/fa-regular-400.woff2")
108
+ else
109
+ error = assert_raises do
110
+ preload_pack_asset("fonts/fa-regular-400.woff2")
111
+ end
112
+
113
+ assert_equal \
114
+ "You need Rails >= 5.2 to use this tag.",
115
+ error.message
116
+ end
117
+ end
118
+
82
119
  def test_stylesheet_pack_tag_split_chunks
83
- assert_equal \
84
- %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
120
+ assert_equal stylesheet_packs_with_chunks_tag("application", "hello_stimulus").in?([
121
+ %(<link rel="stylesheet" href="/packs/1-c20632e7baf2c81200d3.chunk.css" media="screen" />\n) +
122
+ %(<link rel="stylesheet" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" media="screen" />\n) +
123
+ %(<link rel="stylesheet" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" media="screen" />),
124
+
125
+ %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
85
126
  %(<link rel="stylesheet" media="screen" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" />\n) +
86
127
  %(<link rel="stylesheet" media="screen" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" />),
87
- stylesheet_packs_with_chunks_tag("application", "hello_stimulus")
128
+ ]),
129
+ true
88
130
  end
89
131
 
90
132
  def test_stylesheet_pack_tag
91
- assert_equal \
133
+ assert_equal stylesheet_pack_tag("bootstrap.css").in?([
134
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
135
+
92
136
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
93
- stylesheet_pack_tag("bootstrap.css")
137
+ ]), true
94
138
  end
95
139
 
96
140
  def test_stylesheet_pack_tag_symbol
97
- assert_equal \
141
+ assert_equal stylesheet_pack_tag(:bootstrap).in?([
142
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
143
+
98
144
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
99
- stylesheet_pack_tag(:bootstrap)
145
+ ]), true
100
146
  end
101
147
 
102
148
  def test_stylesheet_pack_tag_splat
103
- assert_equal \
149
+ assert_equal stylesheet_pack_tag("bootstrap.css", "application.css", media: "all").in?([
150
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="all" />\n) +
151
+ %(<link rel="stylesheet" href="/packs/application-dd6b1cd38bfa093df600.css" media="all" />),
152
+
104
153
  %(<link rel="stylesheet" media="all" href="/packs/bootstrap-c38deda30895059837cf.css" />\n) +
105
154
  %(<link rel="stylesheet" media="all" href="/packs/application-dd6b1cd38bfa093df600.css" />),
106
- stylesheet_pack_tag("bootstrap.css", "application.css", media: "all")
155
+ ]), true
107
156
  end
108
157
  end
@@ -2,16 +2,23 @@ require "test_helper"
2
2
 
3
3
  class ManifestTest < Minitest::Test
4
4
  def test_lookup_exception!
5
- manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
6
5
  asset_file = "calendar.js"
7
6
 
8
- Webpacker.config.stub :compile?, false do
9
- error = assert_raises Webpacker::Manifest::MissingEntryError do
10
- Webpacker.manifest.lookup!(asset_file)
11
- end
7
+ error = assert_raises_manifest_missing_entry_error do
8
+ Webpacker.manifest.lookup!(asset_file)
9
+ end
10
+
11
+ assert_match "Webpacker can't find #{asset_file} in #{manifest_path}", error.message
12
+ end
13
+
14
+ def test_lookup_with_type_exception!
15
+ asset_file = "calendar"
12
16
 
13
- assert_match "Webpacker can't find #{asset_file} in #{manifest_path}", error.message
17
+ error = assert_raises_manifest_missing_entry_error do
18
+ Webpacker.manifest.lookup!(asset_file, type: :javascript)
14
19
  end
20
+
21
+ assert_match "Webpacker can't find #{asset_file}.js in #{manifest_path}", error.message
15
22
  end
16
23
 
17
24
  def test_lookup_success!
@@ -30,6 +37,16 @@ class ManifestTest < Minitest::Test
30
37
  assert_equal Webpacker.manifest.lookup("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
31
38
  end
32
39
 
40
+ def test_lookup_entrypoint_exception!
41
+ asset_file = "calendar"
42
+
43
+ error = assert_raises_manifest_missing_entry_error do
44
+ Webpacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
45
+ end
46
+
47
+ assert_match "Webpacker can't find #{asset_file}.js in #{manifest_path}", error.message
48
+ end
49
+
33
50
  def test_lookup_entrypoint
34
51
  application_entrypoints = [
35
52
  "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
@@ -39,4 +56,18 @@ class ManifestTest < Minitest::Test
39
56
 
40
57
  assert_equal Webpacker.manifest.lookup_pack_with_chunks!("application", type: :javascript), application_entrypoints
41
58
  end
59
+
60
+ private
61
+
62
+ def assert_raises_manifest_missing_entry_error(&block)
63
+ error = nil
64
+ Webpacker.config.stub :compile?, false do
65
+ error = assert_raises Webpacker::Manifest::MissingEntryError, &block
66
+ end
67
+ error
68
+ end
69
+
70
+ def manifest_path
71
+ File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
72
+ end
42
73
  end
@@ -7,12 +7,18 @@ class RakeTasksTest < Minitest::Test
7
7
  assert_includes output, "webpacker:check_binstubs"
8
8
  assert_includes output, "webpacker:check_node"
9
9
  assert_includes output, "webpacker:check_yarn"
10
+ assert_includes output, "webpacker:clean"
10
11
  assert_includes output, "webpacker:clobber"
11
12
  assert_includes output, "webpacker:compile"
12
13
  assert_includes output, "webpacker:install"
13
14
  assert_includes output, "webpacker:install:angular"
15
+ assert_includes output, "webpacker:install:coffee"
14
16
  assert_includes output, "webpacker:install:elm"
17
+ assert_includes output, "webpacker:install:erb"
15
18
  assert_includes output, "webpacker:install:react"
19
+ assert_includes output, "webpacker:install:svelte"
20
+ assert_includes output, "webpacker:install:stimulus"
21
+ assert_includes output, "webpacker:install:typescript"
16
22
  assert_includes output, "webpacker:install:vue"
17
23
  assert_includes output, "webpacker:verify_install"
18
24
  end
@@ -22,6 +28,17 @@ class RakeTasksTest < Minitest::Test
22
28
  refute_includes output, "webpack binstubs not found."
23
29
  end
24
30
 
31
+ def test_check_node_version
32
+ output = Dir.chdir(test_app_path) { `rake webpacker:check_node 2>&1` }
33
+ refute_includes output, "Webpacker requires Node.js"
34
+ end
35
+
36
+ def test_check_yarn_version
37
+ output = Dir.chdir(test_app_path) { `rake webpacker:check_yarn 2>&1` }
38
+ refute_includes output, "Yarn not installed"
39
+ refute_includes output, "Webpacker requires Yarn"
40
+ end
41
+
25
42
  def test_rake_webpacker_yarn_install_in_non_production_environments
26
43
  assert_includes test_app_dev_dependencies, "right-pad"
27
44
 
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Dummy file #1 for Multi File Entry points: https://webpack.js.org/guides/entry-advanced/
3
+ * This file must be named the same
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Dummy file #2 for Multi File Entry points: https://webpack.js.org/guides/entry-advanced/
3
+ * This file must be named the same
4
+ */
@@ -7,7 +7,6 @@ require "pathname"
7
7
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
8
  Pathname.new(__FILE__).realpath)
9
9
 
10
- require "rubygems"
11
10
  require "bundler/setup"
12
11
 
13
12
  require "webpacker"
@@ -7,7 +7,6 @@ require "pathname"
7
7
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
8
8
  Pathname.new(__FILE__).realpath)
9
9
 
10
- require "rubygems"
11
10
  require "bundler/setup"
12
11
 
13
12
  require "webpacker"
@@ -6,7 +6,6 @@ module TestApp
6
6
  class Application < ::Rails::Application
7
7
  config.secret_key_base = "abcdef"
8
8
  config.eager_load = true
9
- config.webpacker.check_yarn_integrity = false
10
9
  config.active_support.test_order = :sorted
11
10
  end
12
11
  end
@@ -10,10 +10,15 @@ default: &default
10
10
 
11
11
  # Additional paths webpack should lookup modules
12
12
  # ['app/assets', 'engine/foo/app/assets']
13
- resolved_paths:
13
+ additional_paths:
14
14
  - app/assets
15
15
  - /etc/yarn
16
16
 
17
+ # This configuration option is deprecated and is only here for testing, to
18
+ # ensure backwards-compatibility. Please use `additional_paths`.
19
+ resolved_paths:
20
+ - app/elm
21
+
17
22
  # Reload manifest.json on all requests so we reload latest compiled packs
18
23
  cache_manifest: false
19
24
 
@@ -43,6 +48,7 @@ default: &default
43
48
  - .gif
44
49
  - .jpeg
45
50
  - .jpg
51
+ - .elm
46
52
 
47
53
  development:
48
54
  <<: *default
@@ -60,6 +66,7 @@ development:
60
66
  overlay: true
61
67
  disable_host_check: true
62
68
  use_local_ip: false
69
+ pretty: false
63
70
 
64
71
  test:
65
72
  <<: *default
@@ -4,8 +4,12 @@
4
4
  "bootstrap.js": "/packs/bootstrap-300631c4f0e0f9c865bc.js",
5
5
  "application.js": "/packs/application-k344a6d59eef8632c9d1.js",
6
6
  "application.png": "/packs/application-k344a6d59eef8632c9d1.png",
7
+ "fonts/fa-regular-400.woff2": "/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2",
7
8
  "media/images/image.jpg": "/packs/media/images/image-c38deda30895059837cf.jpg",
9
+ "media/images/image-2x.jpg": "/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg",
8
10
  "media/images/nested/image.jpg": "/packs/media/images/nested/image-c38deda30895059837cf.jpg",
11
+ "media/images/mb-icon.png": "/packs/media/images/mb-icon-c38deda30895059837cf.png",
12
+ "media/images/nested/mb-icon.png": "/packs/media/images/nested/mb-icon-c38deda30895059837cf.png",
9
13
  "entrypoints": {
10
14
  "application": {
11
15
  "js": [
@@ -36,7 +36,7 @@ class WebpackRunnerTest < Webpacker::Test
36
36
  klass = Webpacker::WebpackRunner
37
37
  instance = klass.new([])
38
38
  mock = Minitest::Mock.new
39
- mock.expect(:call, nil, [{}, *cmd])
39
+ mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
40
 
41
41
  klass.stub(:new, instance) do
42
42
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
data/webpacker.gemspec CHANGED
@@ -15,13 +15,16 @@ Gem::Specification.new do |s|
15
15
  "changelog_uri" => "https://github.com/rails/webpacker/blob/v#{Webpacker::VERSION}/CHANGELOG.md"
16
16
  }
17
17
 
18
- s.required_ruby_version = ">= 2.2.0"
18
+ s.required_ruby_version = ">= 2.4.0"
19
19
 
20
- s.add_dependency "activesupport", ">= 4.2"
21
- s.add_dependency "railties", ">= 4.2"
20
+ s.add_dependency "activesupport", ">= 5.2"
21
+ s.add_dependency "railties", ">= 5.2"
22
22
  s.add_dependency "rack-proxy", ">= 0.6.1"
23
+ s.add_dependency "semantic_range", ">= 2.3.0"
23
24
 
24
- s.add_development_dependency "bundler", "~> 1.12"
25
+ s.add_development_dependency "bundler", ">= 1.3.0"
26
+ s.add_development_dependency "rubocop", "0.93.1"
27
+ s.add_development_dependency "rubocop-performance"
25
28
 
26
29
  s.files = `git ls-files`.split("\n")
27
30
  s.test_files = `git ls-files -- test/*`.split("\n")