shakapacker 6.6.0 → 7.0.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby-backward-compatibility.yml +43 -0
  3. data/CHANGELOG.md +50 -4
  4. data/CONTRIBUTING.md +4 -4
  5. data/Gemfile.development_dependencies +1 -1
  6. data/README.md +113 -88
  7. data/Rakefile +5 -0
  8. data/config/shakapacker.yml +1 -0
  9. data/docs/deployment.md +12 -10
  10. data/docs/developing_webpacker.md +5 -5
  11. data/docs/react.md +10 -6
  12. data/docs/style_loader_vs_mini_css.md +2 -2
  13. data/docs/troubleshooting.md +22 -18
  14. data/docs/using_esbuild_loader.md +5 -3
  15. data/docs/using_swc_loader.md +2 -2
  16. data/docs/v6_upgrade.md +2 -2
  17. data/docs/v7_upgrade.md +56 -0
  18. data/lib/install/bin/shakapacker +13 -0
  19. data/lib/install/bin/shakapacker-dev-server +13 -0
  20. data/lib/install/config/{webpacker.yml → shakapacker.yml} +13 -8
  21. data/lib/install/template.rb +7 -7
  22. data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
  23. data/lib/{webpacker → shakapacker}/commands.rb +4 -4
  24. data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
  25. data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
  26. data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
  27. data/lib/shakapacker/deprecation_helper.rb +88 -0
  28. data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
  29. data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
  30. data/lib/shakapacker/dev_server_runner.rb +104 -0
  31. data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
  32. data/lib/{webpacker → shakapacker}/env.rb +8 -8
  33. data/lib/{webpacker → shakapacker}/helper.rb +20 -20
  34. data/lib/{webpacker → shakapacker}/instance.rb +13 -10
  35. data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
  36. data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
  37. data/lib/shakapacker/railtie.rb +70 -0
  38. data/lib/shakapacker/runner.rb +28 -0
  39. data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
  40. data/lib/{webpacker → shakapacker}/version.rb +2 -2
  41. data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
  42. data/lib/shakapacker/webpack_runner.rb +67 -0
  43. data/lib/shakapacker.rb +51 -1
  44. data/lib/tasks/shakapacker/binstubs.rake +15 -0
  45. data/lib/tasks/shakapacker/check_binstubs.rake +25 -0
  46. data/lib/tasks/shakapacker/check_node.rake +31 -0
  47. data/lib/tasks/shakapacker/check_yarn.rake +33 -0
  48. data/lib/tasks/shakapacker/clean.rake +23 -0
  49. data/lib/tasks/shakapacker/clobber.rake +18 -0
  50. data/lib/tasks/shakapacker/compile.rake +31 -0
  51. data/lib/tasks/shakapacker/info.rake +21 -0
  52. data/lib/tasks/shakapacker/install.rake +17 -0
  53. data/lib/tasks/shakapacker/verify_config.rake +12 -0
  54. data/lib/tasks/shakapacker/verify_install.rake +4 -0
  55. data/lib/tasks/shakapacker/yarn_install.rake +24 -0
  56. data/lib/tasks/shakapacker.rake +18 -0
  57. data/lib/tasks/webpacker/binstubs.rake +5 -11
  58. data/lib/tasks/webpacker/check_binstubs.rake +6 -9
  59. data/lib/tasks/webpacker/check_node.rake +5 -27
  60. data/lib/tasks/webpacker/check_yarn.rake +5 -29
  61. data/lib/tasks/webpacker/clean.rake +5 -19
  62. data/lib/tasks/webpacker/clobber.rake +6 -13
  63. data/lib/tasks/webpacker/compile.rake +5 -33
  64. data/lib/tasks/webpacker/info.rake +5 -17
  65. data/lib/tasks/webpacker/install.rake +5 -13
  66. data/lib/tasks/webpacker/verify_config.rake +6 -11
  67. data/lib/tasks/webpacker/verify_install.rake +7 -2
  68. data/lib/tasks/webpacker/yarn_install.rake +5 -20
  69. data/lib/tasks/webpacker.rake +15 -13
  70. data/lib/webpacker/dev_server_runner.rb +9 -96
  71. data/lib/webpacker/webpack_runner.rb +9 -58
  72. data/lib/webpacker.rb +3 -47
  73. data/package/__tests__/config-bc.js +27 -0
  74. data/package/__tests__/config.js +6 -5
  75. data/package/__tests__/dev_server-bc.js +46 -0
  76. data/package/__tests__/dev_server.js +9 -8
  77. data/package/__tests__/development-bc.js +66 -0
  78. data/package/__tests__/development.js +36 -5
  79. data/package/__tests__/env-bc.js +59 -0
  80. data/package/__tests__/env.js +3 -2
  81. data/package/__tests__/index.js +13 -0
  82. data/package/__tests__/production-bc.js +51 -0
  83. data/package/__tests__/production.js +25 -3
  84. data/package/__tests__/staging-bc.js +53 -0
  85. data/package/__tests__/staging.js +27 -4
  86. data/package/__tests__/test-bc.js +43 -0
  87. data/package/__tests__/test.js +22 -4
  88. data/package/babel/preset.js +1 -4
  89. data/package/config.js +25 -7
  90. data/package/dev_server.js +7 -4
  91. data/package/env.js +22 -3
  92. data/package/environments/__tests__/base-bc.js +107 -0
  93. data/package/environments/__tests__/base.js +13 -13
  94. data/package/environments/base.js +1 -1
  95. data/package/environments/development.js +4 -46
  96. data/package/environments/production.js +1 -1
  97. data/package/index.js +11 -4
  98. data/package/rules/__tests__/__utils__/webpack.js +1 -1
  99. data/package/rules/__tests__/file.js +27 -0
  100. data/package/rules/__tests__/swc.js +1 -2
  101. data/package/rules/file.js +2 -2
  102. data/package/utils/configPath.js +19 -0
  103. data/package/utils/defaultConfigPath.js +2 -0
  104. data/package/utils/get_style_rule.js +5 -2
  105. data/package/utils/helpers.js +24 -1
  106. data/package/utils/inliningCss.js +7 -0
  107. data/package/utils/snakeToCamelCase +7 -0
  108. data/package/webpackDevServerConfig.js +68 -0
  109. data/package.json +2 -2
  110. data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
  111. data/spec/backward_compatibility_specs/command_spec_bc.rb +116 -0
  112. data/spec/backward_compatibility_specs/compiler_spec_bc.rb +59 -0
  113. data/spec/backward_compatibility_specs/compiler_strategy_spec_bc.rb +22 -0
  114. data/spec/backward_compatibility_specs/configuration_spec_bc.rb +286 -0
  115. data/spec/backward_compatibility_specs/dev_server_runner_spec_bc.rb +79 -0
  116. data/spec/backward_compatibility_specs/dev_server_spec_bc.rb +47 -0
  117. data/spec/backward_compatibility_specs/digest_strategy_spec_bc.rb +35 -0
  118. data/spec/backward_compatibility_specs/engine_rake_tasks_spec_bc.rb +44 -0
  119. data/spec/backward_compatibility_specs/env_spec_bc.rb +23 -0
  120. data/spec/backward_compatibility_specs/helper_spec_bc.rb +243 -0
  121. data/spec/backward_compatibility_specs/instance_spec_bc.rb +31 -0
  122. data/spec/backward_compatibility_specs/manifest_spec_bc.rb +100 -0
  123. data/spec/backward_compatibility_specs/mtime_strategy_spec_bc.rb +55 -0
  124. data/spec/backward_compatibility_specs/rake_tasks_spec_bc.rb +37 -0
  125. data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
  126. data/spec/backward_compatibility_specs/webpack_runner_spec_bc.rb +56 -0
  127. data/spec/backward_compatibility_specs/webpacker_spec_bc.rb +41 -0
  128. data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
  129. data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +3 -0
  130. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
  131. data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
  132. data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
  133. data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +4 -0
  134. data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +1 -0
  135. data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
  136. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
  137. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
  138. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
  139. data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
  140. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
  141. data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
  142. data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +5 -0
  143. data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
  144. data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +58 -0
  145. data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
  146. data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
  147. data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +11 -0
  148. data/spec/command_spec.rb +18 -16
  149. data/spec/compiler_spec.rb +19 -17
  150. data/spec/compiler_strategy_spec.rb +9 -7
  151. data/spec/configuration_spec.rb +108 -66
  152. data/spec/dev_server_runner_spec.rb +9 -8
  153. data/spec/dev_server_spec.rb +97 -9
  154. data/spec/digest_strategy_spec.rb +4 -2
  155. data/spec/engine_rake_tasks_spec.rb +12 -16
  156. data/spec/env_spec.rb +7 -5
  157. data/spec/helper_spec.rb +4 -2
  158. data/spec/instance_spec.rb +31 -0
  159. data/spec/manifest_spec.rb +21 -19
  160. data/spec/mounted_app/test/dummy/config/application.rb +1 -1
  161. data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
  162. data/spec/mtime_strategy_spec.rb +4 -2
  163. data/spec/rake_tasks_spec.rb +20 -18
  164. data/spec/spec_helper.rb +0 -25
  165. data/spec/spec_helper_initializer.rb +24 -0
  166. data/spec/test_app/.gitignore +2 -0
  167. data/spec/test_app/app/javascript/entrypoints/application.js +10 -0
  168. data/spec/test_app/app/javascript/entrypoints/generated/something.js +2 -0
  169. data/spec/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
  170. data/spec/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
  171. data/spec/test_app/bin/{webpacker-dev-server → shakapacker} +3 -3
  172. data/spec/test_app/bin/{webpacker → shakapacker-dev-server} +3 -3
  173. data/spec/test_app/config/application.rb +1 -1
  174. data/spec/test_app/config/shakapacker.yml +82 -0
  175. data/spec/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
  176. data/spec/test_app/config/shakapacker_defaults_fallback.yml +11 -0
  177. data/spec/test_app/config/shakapacker_manifest_path.yml +80 -0
  178. data/spec/test_app/config/shakapacker_nested_entries.yml +83 -0
  179. data/spec/test_app/config/shakapacker_no_precompile.yml +7 -0
  180. data/spec/test_app/config/shakapacker_other_location.yml +85 -0
  181. data/spec/test_app/config/shakapacker_public_root.yml +18 -0
  182. data/spec/version_checker_spec.rb +16 -15
  183. data/spec/webpack_runner_spec.rb +4 -3
  184. data/spec/webpacker_spec.rb +9 -29
  185. metadata +119 -44
  186. data/config/webpacker.yml +0 -1
  187. data/lib/webpacker/railtie.rb +0 -70
  188. data/lib/webpacker/runner.rb +0 -23
  189. data/package/configPath.js +0 -3
  190. data/package/inliningCss.js +0 -7
  191. data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
  192. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
  193. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
  194. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
  195. /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
  196. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
  197. /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
@@ -0,0 +1,31 @@
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "Shakapacker::Instance" do
4
+ before :each do
5
+ ENV.delete("WEBPACKER_CONFIG")
6
+ ENV.delete("SHAKAPACKER_CONFIG")
7
+ Shakapacker.instance = Shakapacker::Instance.new
8
+ end
9
+
10
+ after :each do
11
+ ENV.delete("WEBPACKER_CONFIG")
12
+ ENV.delete("SHAKAPACKER_CONFIG")
13
+ Shakapacker.instance = Shakapacker::Instance.new
14
+ end
15
+
16
+ it "uses default config path if no env variable defined" do
17
+ actual_config_path = Rails.root.join("config/shakapacker.yml")
18
+ expected_config_path = Shakapacker.config.config_path
19
+
20
+ expect(expected_config_path).to eq(actual_config_path)
21
+ end
22
+
23
+ it "uses SHAKAPACKER_CONFIG env variable for config file" do
24
+ ENV["SHAKAPACKER_CONFIG"] = "/some/random/path.yml"
25
+
26
+ actual_config_path = "/some/random/path.yml"
27
+ expected_config_path = Shakapacker.config.config_path.to_s
28
+
29
+ expect(expected_config_path).to eq(actual_config_path)
30
+ end
31
+ end
@@ -1,73 +1,75 @@
1
- describe "Webpacker::Manifest" do
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "Shakapacker::Manifest" do
2
4
  let(:manifest_path) { File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s }
3
5
 
4
6
  it "#lookup! throws exception for a non-existing asset file" do
5
7
  asset_file = "calendar.js"
6
8
  expected_error_message = "Shakapacker can't find #{asset_file} in #{manifest_path}"
7
9
 
8
- allow(Webpacker.config).to receive(:compile?).and_return(false)
10
+ allow(Shakapacker.config).to receive(:compile?).and_return(false)
9
11
 
10
12
  expect {
11
- Webpacker.manifest.lookup!(asset_file)
12
- }.to raise_error(Webpacker::Manifest::MissingEntryError, /#{expected_error_message}/)
13
+ Shakapacker.manifest.lookup!(asset_file)
14
+ }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
13
15
  end
14
16
 
15
17
  it "#lookup! throws exception for a non-existing asset file with type and without extension" do
16
18
  asset_file = "calendar"
17
19
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
18
20
 
19
- allow(Webpacker.config).to receive(:compile?).and_return(false)
21
+ allow(Shakapacker.config).to receive(:compile?).and_return(false)
20
22
 
21
23
  expect {
22
- Webpacker.manifest.lookup!(asset_file, type: :javascript)
23
- }.to raise_error(Webpacker::Manifest::MissingEntryError, /#{expected_error_message}/)
24
+ Shakapacker.manifest.lookup!(asset_file, type: :javascript)
25
+ }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
24
26
  end
25
27
 
26
28
  it "#lookup! returns path to bundled bootstrap.js" do
27
- actual = Webpacker.manifest.lookup!("bootstrap.js")
29
+ actual = Shakapacker.manifest.lookup!("bootstrap.js")
28
30
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
29
31
 
30
32
  expect(actual).to eq expected
31
33
  end
32
34
 
33
35
  it "#lookup_pack_with_chunks! returns array of path to bundled bootstrap with type of javascript" do
34
- actual = Webpacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript)
36
+ actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript)
35
37
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
36
38
 
37
39
  expect(actual).to eq expected
38
40
  end
39
41
 
40
42
  it "#lookup_with_chunks! returns array of path to bundled bootstrap.js with type of javascript" do
41
- actual = Webpacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript)
43
+ actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript)
42
44
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
43
45
 
44
46
  expect(actual).to eq expected
45
47
  end
46
48
 
47
49
  it "#lookup_with_chunks! returns array of path to bundled 'print/application' without extension and in a sub-directory" do
48
- actual = Webpacker.manifest.lookup_pack_with_chunks!("print/application", type: :css)
50
+ actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application", type: :css)
49
51
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
50
52
 
51
53
  expect(actual).to eq expected
52
54
  end
53
55
 
54
56
  it "#lookup_with_chunks! returns array of path to bundled 'print/application.css' in a sub-directory" do
55
- actual = Webpacker.manifest.lookup_pack_with_chunks!("print/application.css", type: :css)
57
+ actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application.css", type: :css)
56
58
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
57
59
 
58
60
  expect(actual).to eq expected
59
61
  end
60
62
 
61
63
  it "#lookup returns nil for non-existing asset file" do
62
- expect(Webpacker.manifest.lookup("foo.js")).to be nil
64
+ expect(Shakapacker.manifest.lookup("foo.js")).to be nil
63
65
  end
64
66
 
65
67
  it "#lookup_pack_with_chunks returns nil for non-existing asset file" do
66
- expect(Webpacker.manifest.lookup_pack_with_chunks("foo.js")).to be nil
68
+ expect(Shakapacker.manifest.lookup_pack_with_chunks("foo.js")).to be nil
67
69
  end
68
70
 
69
71
  it "#lookup returns path for bootstrap.js" do
70
- actual = Webpacker.manifest.lookup("bootstrap.js")
72
+ actual = Shakapacker.manifest.lookup("bootstrap.js")
71
73
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
72
74
 
73
75
  expect(actual).to eq expected
@@ -78,15 +80,15 @@ describe "Webpacker::Manifest" do
78
80
 
79
81
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
80
82
 
81
- allow(Webpacker.config).to receive(:compile?).and_return(false)
83
+ allow(Shakapacker.config).to receive(:compile?).and_return(false)
82
84
 
83
85
  expect {
84
- Webpacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
85
- }.to raise_error(Webpacker::Manifest::MissingEntryError, /#{expected_error_message}/)
86
+ Shakapacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
87
+ }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
86
88
  end
87
89
 
88
90
  it "#lookup_pack_with_chunks! returns array of paths to bundled js files with 'application' in their name" do
89
- actual_application_entrypoints = Webpacker.manifest.lookup_pack_with_chunks!("application", type: :javascript)
91
+ actual_application_entrypoints = Shakapacker.manifest.lookup_pack_with_chunks!("application", type: :javascript)
90
92
  expected_application_entrypoints = [
91
93
  "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
92
94
  "/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js",
@@ -1,6 +1,6 @@
1
1
  require "action_controller/railtie"
2
2
  require "action_view/railtie"
3
- require "webpacker"
3
+ require "shakapacker"
4
4
 
5
5
  module TestDummyApp
6
6
  class Application < Rails::Application
@@ -1,10 +1,10 @@
1
- # Note: You must restart bin/webpacker-dev-server for changes to take effect
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
- source_path: app/packs
4
+ source_path: app/javascript
5
5
  source_entry_path: entrypoints
6
6
  public_output_path: packs
7
- cache_path: tmp/webpacker
7
+ cache_path: tmp/shakapacker
8
8
  webpack_loader: babel
9
9
 
10
10
  # Additional paths webpack should look up modules
@@ -1,5 +1,7 @@
1
- describe "Webpacker::MtimeStrategy" do
2
- let(:mtime_strategy) { Webpacker::MtimeStrategy.new }
1
+ require_relative "spec_helper_initializer"
2
+
3
+ describe "Shakapacker::MtimeStrategy" do
4
+ let(:mtime_strategy) { Shakapacker::MtimeStrategy.new }
3
5
  let(:manifest_timestamp) { Time.parse("2021-01-01 12:34:56 UTC") }
4
6
 
5
7
  describe "#fresh?" do
@@ -1,32 +1,34 @@
1
+ require_relative "spec_helper_initializer"
2
+
1
3
  describe "RakeTasks" do
2
4
  let(:test_app_path) { File.expand_path("test_app", __dir__) }
3
5
 
4
- it "`rake -T` lists webpacker tasks" do
6
+ it "`rake -T` lists Shakapacker tasks" do
5
7
  output = Dir.chdir(test_app_path) { `rake -T` }
6
- expect(output).to include "webpacker"
7
- expect(output).to include "webpacker:check_binstubs"
8
- expect(output).to include "webpacker:check_node"
9
- expect(output).to include "webpacker:check_yarn"
10
- expect(output).to include "webpacker:clean"
11
- expect(output).to include "webpacker:clobber"
12
- expect(output).to include "webpacker:compile"
13
- expect(output).to include "webpacker:install"
14
- expect(output).to include "webpacker:verify_install"
8
+ expect(output).to include "shakapacker"
9
+ expect(output).to include "shakapacker:check_binstubs"
10
+ expect(output).to include "shakapacker:check_node"
11
+ expect(output).to include "shakapacker:check_yarn"
12
+ expect(output).to include "shakapacker:clean"
13
+ expect(output).to include "shakapacker:clobber"
14
+ expect(output).to include "shakapacker:compile"
15
+ expect(output).to include "shakapacker:install"
16
+ expect(output).to include "shakapacker:verify_install"
15
17
  end
16
18
 
17
- it "`webpacker:check_binstubs` doesn't get 'webpack binstub not found' error" do
18
- output = Dir.chdir(test_app_path) { `rake webpacker:check_binstubs 2>&1` }
19
+ it "`shakapacker:check_binstubs` doesn't get 'webpack binstub not found' error" do
20
+ output = Dir.chdir(test_app_path) { `rake shakapacker:check_binstubs 2>&1` }
19
21
  expect(output).to_not include "webpack binstub not found."
20
22
  end
21
23
 
22
- it "`webpacker:check_node` doesn't get 'Webpacker requires Node.js' error" do
23
- output = Dir.chdir(test_app_path) { `rake webpacker:check_node 2>&1` }
24
- expect(output).to_not include "Webpacker requires Node.js"
24
+ it "`shakapacker:check_node` doesn't get 'shakapacker requires Node.js' error" do
25
+ output = Dir.chdir(test_app_path) { `rake shakapacker:check_node 2>&1` }
26
+ expect(output).to_not include "Shakapacker requires Node.js"
25
27
  end
26
28
 
27
- it "`webpacker:check_yarn` doesn't get error related to yarn" do
28
- output = Dir.chdir(test_app_path) { `rake webpacker:check_yarn 2>&1` }
29
+ it "`shakapacker:check_yarn` doesn't get error related to yarn" do
30
+ output = Dir.chdir(test_app_path) { `rake shakapacker:check_yarn 2>&1` }
29
31
  expect(output).to_not include "Yarn not installed"
30
- expect(output).to_not include "Webpacker requires Yarn"
32
+ expect(output).to_not include "Shakapacker requires Yarn"
31
33
  end
32
34
  end
data/spec/spec_helper.rb CHANGED
@@ -96,28 +96,3 @@ RSpec.configure do |config|
96
96
  Kernel.srand config.seed
97
97
  =end
98
98
  end
99
-
100
- require_relative "test_app/config/environment"
101
-
102
- Rails.env = "production"
103
-
104
- Webpacker.instance = ::Webpacker::Instance.new
105
-
106
- def reloaded_config
107
- Webpacker.instance.instance_variable_set(:@env, nil)
108
- Webpacker.instance.instance_variable_set(:@config, nil)
109
- Webpacker.instance.instance_variable_set(:@dev_server, nil)
110
- Webpacker.env
111
- Webpacker.config
112
- Webpacker.dev_server
113
- end
114
-
115
- def with_rails_env(env)
116
- original = Rails.env
117
- Rails.env = ActiveSupport::StringInquirer.new(env)
118
- reloaded_config
119
- yield
120
- ensure
121
- Rails.env = ActiveSupport::StringInquirer.new(original)
122
- reloaded_config
123
- end
@@ -0,0 +1,24 @@
1
+ require_relative "test_app/config/environment"
2
+
3
+ Rails.env = "production"
4
+
5
+ Shakapacker.instance = ::Shakapacker::Instance.new
6
+
7
+ def reloaded_config
8
+ Shakapacker.instance.instance_variable_set(:@env, nil)
9
+ Shakapacker.instance.instance_variable_set(:@config, nil)
10
+ Shakapacker.instance.instance_variable_set(:@dev_server, nil)
11
+ Shakapacker.env
12
+ Shakapacker.config
13
+ Shakapacker.dev_server
14
+ end
15
+
16
+ def with_rails_env(env)
17
+ original = Rails.env
18
+ Rails.env = ActiveSupport::StringInquirer.new(env)
19
+ reloaded_config
20
+ yield
21
+ ensure
22
+ Rails.env = ActiveSupport::StringInquirer.new(original)
23
+ reloaded_config
24
+ end
@@ -0,0 +1,2 @@
1
+ log/
2
+ tmp/
@@ -0,0 +1,10 @@
1
+ /* eslint no-console:0 */
2
+ // This file is automatically compiled by Webpack, along with any other files
3
+ // present in this directory. You're encouraged to place your actual application logic in
4
+ // a relevant structure within app/javascript and only use these pack files to reference
5
+ // that code so it'll be compiled.
6
+ //
7
+ // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
+ // layout file, like app/views/layouts/application.html.erb
9
+
10
+ console.log('Hello World from shakapacker')
@@ -0,0 +1,2 @@
1
+ /* eslint no-console:0 */
2
+ console.log('entrypoints/nested/something')
@@ -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
+ */
@@ -9,6 +9,6 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
9
9
 
10
10
  require "bundler/setup"
11
11
 
12
- require "webpacker"
13
- require "webpacker/dev_server_runner"
14
- Webpacker::DevServerRunner.run(ARGV)
12
+ require "shakapacker"
13
+ require "shakapacker/webpack_runner"
14
+ Shakapacker::WebpackRunner.run(ARGV)
@@ -9,6 +9,6 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
9
9
 
10
10
  require "bundler/setup"
11
11
 
12
- require "webpacker"
13
- require "webpacker/webpack_runner"
14
- Webpacker::WebpackRunner.run(ARGV)
12
+ require "shakapacker"
13
+ require "shakapacker/dev_server_runner"
14
+ Shakapacker::DevServerRunner.run(ARGV)
@@ -1,6 +1,6 @@
1
1
  require "action_controller/railtie"
2
2
  require "action_view/railtie"
3
- require "webpacker"
3
+ require "shakapacker"
4
4
 
5
5
  module TestApp
6
6
  class Application < ::Rails::Application
@@ -0,0 +1,82 @@
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: entrypoints
6
+ nested_entries: false
7
+ public_root_path: public
8
+ public_output_path: packs
9
+ cache_path: tmp/shakapacker
10
+ webpack_compile_output: false
11
+ webpack_loader: babel
12
+
13
+ # Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
14
+ # manifest_path: public/packs/manifest.json
15
+
16
+ # Additional paths webpack should look up modules
17
+ # ['app/assets', 'engine/foo/app/assets']
18
+ additional_paths:
19
+ - app/assets
20
+ - /etc/yarn
21
+ - some.config.js
22
+ - app/elm
23
+
24
+ # Reload manifest.json on all requests so we reload latest compiled packs
25
+ cache_manifest: false
26
+
27
+ static_assets_extensions:
28
+ - .jpg
29
+ - .jpeg
30
+ - .png
31
+ - .gif
32
+ - .tiff
33
+ - .ico
34
+ - .svg
35
+
36
+ extensions:
37
+ - .mjs
38
+ - .js
39
+
40
+ development:
41
+ <<: *default
42
+ compile: true
43
+ ensure_consistent_versioning: true
44
+
45
+ # Reference: https://webpack.js.org/configuration/dev-server/
46
+ dev_server:
47
+ host: localhost
48
+ port: 3035
49
+ public: localhost:3035
50
+ hmr: false
51
+ overlay: true
52
+ disable_host_check: true
53
+ use_local_ip: false
54
+ pretty: false
55
+
56
+ test:
57
+ <<: *default
58
+ compile: true
59
+
60
+ # Compile test packs to a separate directory
61
+ public_output_path: packs-test
62
+
63
+ production:
64
+ <<: *default
65
+
66
+ # Production depends on precompilation of packs prior to booting for performance.
67
+ compile: false
68
+
69
+ # Cache manifest.json for performance
70
+ cache_manifest: true
71
+
72
+ staging:
73
+ <<: *default
74
+
75
+ # Production depends on precompilation of packs prior to booting for performance.
76
+ compile: false
77
+
78
+ # Cache manifest.json for performance
79
+ cache_manifest: true
80
+
81
+ # Compile staging packs to a separate directory
82
+ public_output_path: packs-staging
@@ -0,0 +1,84 @@
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: entrypoints
6
+ nested_entries: true
7
+ public_root_path: public
8
+ public_output_path: packs
9
+ cache_path: tmp/shakapacker
10
+ webpack_compile_output: false
11
+ webpack_loader: babel
12
+ css_extract_ignore_order_warnings: true
13
+
14
+ # Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
15
+ # manifest_path: public/packs/manifest.json
16
+
17
+ # Additional paths webpack should look up modules
18
+ # ['app/assets', 'engine/foo/app/assets']
19
+ additional_paths:
20
+ - app/assets
21
+ - /etc/yarn
22
+ - some.config.js
23
+ - app/elm
24
+
25
+ # Reload manifest.json on all requests so we reload latest compiled packs
26
+ cache_manifest: false
27
+
28
+ static_assets_extensions:
29
+ - .jpg
30
+ - .jpeg
31
+ - .png
32
+ - .gif
33
+ - .tiff
34
+ - .ico
35
+ - .svg
36
+
37
+ extensions:
38
+ - .mjs
39
+ - .js
40
+
41
+ development:
42
+ <<: *default
43
+ compile: true
44
+ ensure_consistent_versioning: true
45
+
46
+ # Reference: https://webpack.js.org/configuration/dev-server/
47
+ dev_server:
48
+ https: false
49
+ host: localhost
50
+ port: 3035
51
+ public: localhost:3035
52
+ hmr: false
53
+ overlay: true
54
+ disable_host_check: true
55
+ use_local_ip: false
56
+ pretty: false
57
+
58
+ test:
59
+ <<: *default
60
+ compile: true
61
+
62
+ # Compile test packs to a separate directory
63
+ public_output_path: packs-test
64
+
65
+ production:
66
+ <<: *default
67
+
68
+ # Production depends on precompilation of packs prior to booting for performance.
69
+ compile: false
70
+
71
+ # Cache manifest.json for performance
72
+ cache_manifest: true
73
+
74
+ staging:
75
+ <<: *default
76
+
77
+ # Production depends on precompilation of packs prior to booting for performance.
78
+ compile: false
79
+
80
+ # Cache manifest.json for performance
81
+ cache_manifest: true
82
+
83
+ # Compile staging packs to a separate directory
84
+ public_output_path: packs-staging
@@ -0,0 +1,11 @@
1
+ # Note: You must restart bin/shakapacker-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ # cache_manifest will be fetched from bundled defaults
5
+ shakapacker_precompile: false
6
+
7
+ staging:
8
+ <<: *default
9
+
10
+ production:
11
+ <<: *default
@@ -0,0 +1,80 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: entrypoints
6
+ public_root_path: public
7
+ public_output_path: packs
8
+ cache_path: tmp/shakapacker
9
+ webpack_compile_output: false
10
+
11
+ # Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
12
+ manifest_path: app/javascript/manifest.json
13
+
14
+ # Additional paths webpack should look up modules
15
+ # ['app/assets', 'engine/foo/app/assets']
16
+ additional_paths:
17
+ - app/assets
18
+ - /etc/yarn
19
+ - some.config.js
20
+ - app/elm
21
+
22
+ # Reload manifest.json on all requests so we reload latest compiled packs
23
+ cache_manifest: false
24
+
25
+ static_assets_extensions:
26
+ - .jpg
27
+ - .jpeg
28
+ - .png
29
+ - .gif
30
+ - .tiff
31
+ - .ico
32
+ - .svg
33
+
34
+ extensions:
35
+ - .mjs
36
+ - .js
37
+
38
+ development:
39
+ <<: *default
40
+ compile: true
41
+
42
+ # Reference: https://webpack.js.org/configuration/dev-server/
43
+ dev_server:
44
+ https: false
45
+ host: localhost
46
+ port: 3035
47
+ public: localhost:3035
48
+ hmr: false
49
+ overlay: true
50
+ disable_host_check: true
51
+ use_local_ip: false
52
+ pretty: false
53
+
54
+ test:
55
+ <<: *default
56
+ compile: true
57
+
58
+ # Compile test packs to a separate directory
59
+ public_output_path: packs-test
60
+
61
+ production:
62
+ <<: *default
63
+
64
+ # Production depends on precompilation of packs prior to booting for performance.
65
+ compile: false
66
+
67
+ # Cache manifest.json for performance
68
+ cache_manifest: true
69
+
70
+ staging:
71
+ <<: *default
72
+
73
+ # Production depends on precompilation of packs prior to booting for performance.
74
+ compile: false
75
+
76
+ # Cache manifest.json for performance
77
+ cache_manifest: true
78
+
79
+ # Compile staging packs to a separate directory
80
+ public_output_path: packs-staging