shakapacker 7.0.2 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dummy.yml +4 -2
  3. data/.github/workflows/generator.yml +4 -2
  4. data/.github/workflows/jest.yml +5 -3
  5. data/.github/workflows/js-lint.yml +5 -3
  6. data/.github/workflows/rubocop.yml +4 -2
  7. data/.github/workflows/ruby-backward-compatibility.yml +5 -3
  8. data/.github/workflows/ruby.yml +5 -3
  9. data/CHANGELOG.md +15 -1
  10. data/CONTRIBUTING.md +3 -4
  11. data/README.md +37 -23
  12. data/docs/deployment.md +1 -1
  13. data/docs/react.md +4 -4
  14. data/docs/troubleshooting.md +4 -8
  15. data/docs/using_esbuild_loader.md +3 -5
  16. data/docs/v6_upgrade.md +1 -1
  17. data/docs/v7_upgrade.md +2 -2
  18. data/lib/install/template.rb +2 -2
  19. data/lib/shakapacker/compiler.rb +1 -1
  20. data/lib/shakapacker/deprecation_helper.rb +1 -1
  21. data/lib/shakapacker/dev_server_runner.rb +2 -1
  22. data/lib/shakapacker/utils/misc.rb +1 -1
  23. data/lib/shakapacker/version.rb +1 -1
  24. data/lib/shakapacker/version_checker.rb +35 -2
  25. data/lib/shakapacker/webpack_runner.rb +4 -3
  26. data/lib/tasks/shakapacker/binstubs.rake +2 -2
  27. data/lib/tasks/shakapacker/check_binstubs.rake +7 -2
  28. data/lib/tasks/shakapacker/install.rake +2 -2
  29. data/package/__tests__/index.js +24 -0
  30. data/package/environments/__tests__/base-bc.js +1 -1
  31. data/package/environments/__tests__/development.js +9 -9
  32. data/package/environments/__tests__/production.js +12 -12
  33. data/package/index.d.ts +61 -0
  34. data/package/index.js +8 -2
  35. data/package.json +12 -1
  36. data/rakelib/release.rake +1 -1
  37. data/spec/backward_compatibility_specs/compiler_spec.rb +2 -2
  38. data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
  39. data/spec/backward_compatibility_specs/configuration_spec.rb +16 -8
  40. data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +17 -16
  41. data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
  42. data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
  43. data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +2 -1
  44. data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
  45. data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
  46. data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
  47. data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
  48. data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
  49. data/spec/backward_compatibility_specs/webpack_runner_spec.rb +14 -18
  50. data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
  51. data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
  52. data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
  53. data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
  54. data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
  55. data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
  56. data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
  57. data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
  58. data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
  59. data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
  60. data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
  61. data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
  62. data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
  63. data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
  64. data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
  65. data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
  66. data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
  67. data/spec/generator_specs/generator_spec.rb +11 -7
  68. data/spec/shakapacker/compiler_spec.rb +2 -2
  69. data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
  70. data/spec/shakapacker/configuration_spec.rb +16 -6
  71. data/spec/shakapacker/dev_server_runner_spec.rb +22 -16
  72. data/spec/shakapacker/dev_server_spec.rb +1 -1
  73. data/spec/shakapacker/digest_strategy_spec.rb +2 -0
  74. data/spec/shakapacker/engine_rake_tasks_spec.rb +2 -1
  75. data/spec/shakapacker/helper_spec.rb +20 -20
  76. data/spec/shakapacker/instance_spec.rb +2 -2
  77. data/spec/shakapacker/manifest_spec.rb +12 -12
  78. data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
  79. data/spec/shakapacker/rake_tasks_spec.rb +6 -3
  80. data/spec/shakapacker/shakapacker_spec.rb +4 -4
  81. data/spec/shakapacker/version_checker_spec.rb +470 -123
  82. data/spec/shakapacker/webpack_runner_spec.rb +14 -18
  83. metadata +20 -3
@@ -3,7 +3,7 @@ require_relative "spec_helper_initializer"
3
3
  describe "Shakapacker::Manifest" do
4
4
  let(:manifest_path) { File.expand_path File.join(File.dirname(__FILE__), "./test_app/public/packs", "manifest.json").to_s }
5
5
 
6
- it "#lookup! throws exception for a non-existing asset file" do
6
+ it "#lookup! raises an exception for a non-existing asset file" do
7
7
  asset_file = "calendar.js"
8
8
  expected_error_message = "Shakapacker can't find #{asset_file} in #{manifest_path}"
9
9
 
@@ -14,7 +14,7 @@ describe "Shakapacker::Manifest" do
14
14
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
15
15
  end
16
16
 
17
- it "#lookup! throws exception for a non-existing asset file with type and without extension" do
17
+ it "#lookup! raises an exception for a non-existing asset file with type and without an extension" do
18
18
  asset_file = "calendar"
19
19
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
20
20
 
@@ -25,57 +25,57 @@ describe "Shakapacker::Manifest" do
25
25
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
26
26
  end
27
27
 
28
- it "#lookup! returns path to bundled bootstrap.js" do
28
+ it "#lookup! returns the path to the bundled bootstrap.js" do
29
29
  actual = Shakapacker.manifest.lookup!("bootstrap.js")
30
30
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
31
31
 
32
32
  expect(actual).to eq expected
33
33
  end
34
34
 
35
- it "#lookup_pack_with_chunks! returns array of path to bundled bootstrap with type of javascript" do
35
+ it "#lookup_pack_with_chunks! returns an array of paths to the bundled bootstrap of type javascript" do
36
36
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap", type: :javascript)
37
37
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
38
38
 
39
39
  expect(actual).to eq expected
40
40
  end
41
41
 
42
- it "#lookup_with_chunks! returns array of path to bundled bootstrap.js with type of javascript" do
42
+ it "#lookup_with_chunks! returns an array of paths to the bundled bootstrap.js of type javascript" do
43
43
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("bootstrap.js", type: :javascript)
44
44
  expected = ["/packs/bootstrap-300631c4f0e0f9c865bc.js"]
45
45
 
46
46
  expect(actual).to eq expected
47
47
  end
48
48
 
49
- it "#lookup_with_chunks! returns array of path to bundled 'print/application' without extension and in a sub-directory" do
49
+ it "#lookup_with_chunks! returns an array of paths to the bundled 'print/application' without an extension and in a sub-directory" do
50
50
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application", type: :css)
51
51
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
52
52
 
53
53
  expect(actual).to eq expected
54
54
  end
55
55
 
56
- it "#lookup_with_chunks! returns array of path to bundled 'print/application.css' in a sub-directory" do
56
+ it "#lookup_with_chunks! returns an array of paths to the bundled 'print/application.css' in a sub-directory" do
57
57
  actual = Shakapacker.manifest.lookup_pack_with_chunks!("print/application.css", type: :css)
58
58
  expected = ["/packs/print/application-983b6c164a47f7ed49cd.css"]
59
59
 
60
60
  expect(actual).to eq expected
61
61
  end
62
62
 
63
- it "#lookup returns nil for non-existing asset file" do
63
+ it "#lookup returns nil for non-existing asset files" do
64
64
  expect(Shakapacker.manifest.lookup("foo.js")).to be nil
65
65
  end
66
66
 
67
- it "#lookup_pack_with_chunks returns nil for non-existing asset file" do
67
+ it "#lookup_pack_with_chunks returns nil for non-existing asset files" do
68
68
  expect(Shakapacker.manifest.lookup_pack_with_chunks("foo.js")).to be nil
69
69
  end
70
70
 
71
- it "#lookup returns path for bootstrap.js" do
71
+ it "#lookup returns the path for bootstrap.js" do
72
72
  actual = Shakapacker.manifest.lookup("bootstrap.js")
73
73
  expected = "/packs/bootstrap-300631c4f0e0f9c865bc.js"
74
74
 
75
75
  expect(actual).to eq expected
76
76
  end
77
77
 
78
- it "#lookup_pack_with_chunks! throws exception for a non-existing asset file" do
78
+ it "#lookup_pack_with_chunks! raises an exception for non-existing asset files" do
79
79
  asset_file = "calendar"
80
80
 
81
81
  expected_error_message = "Shakapacker can't find #{asset_file}.js in #{manifest_path}"
@@ -87,7 +87,7 @@ describe "Shakapacker::Manifest" do
87
87
  }.to raise_error(Shakapacker::Manifest::MissingEntryError, /#{expected_error_message}/)
88
88
  end
89
89
 
90
- it "#lookup_pack_with_chunks! returns array of paths to bundled js files with 'application' in their name" do
90
+ it "#lookup_pack_with_chunks! returns an array of paths to bundled js files with 'application' in their name" do
91
91
  actual_application_entrypoints = Shakapacker.manifest.lookup_pack_with_chunks!("application", type: :javascript)
92
92
  expected_application_entrypoints = [
93
93
  "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
@@ -5,7 +5,7 @@ describe "Shakapacker::MtimeStrategy" do
5
5
  let(:manifest_timestamp) { Time.parse("2021-01-01 12:34:56 UTC") }
6
6
 
7
7
  describe "#fresh?" do
8
- it "returns false when manifest is missing" do
8
+ it "returns false when the manifest is missing" do
9
9
  latest_timestamp = manifest_timestamp + 3600
10
10
 
11
11
  with_stubs(latest_timestamp: latest_timestamp.to_i, manifest_exists: false) do
@@ -13,7 +13,7 @@ describe "Shakapacker::MtimeStrategy" do
13
13
  end
14
14
  end
15
15
 
16
- it "returns false when manifest is older" do
16
+ it "returns false when the manifest is older" do
17
17
  latest_timestamp = manifest_timestamp + 3600
18
18
 
19
19
  with_stubs(latest_timestamp: latest_timestamp.to_i) do
@@ -21,7 +21,7 @@ describe "Shakapacker::MtimeStrategy" do
21
21
  end
22
22
  end
23
23
 
24
- it "returns true when manifest is new" do
24
+ it "returns true when the manifest is new" do
25
25
  latest_timestamp = manifest_timestamp - 3600
26
26
 
27
27
  with_stubs(latest_timestamp: latest_timestamp.to_i) do
@@ -18,22 +18,25 @@ describe "RakeTasks" do
18
18
 
19
19
  it "`shakapacker:check_binstubs` doesn't get 'webpack binstub not found' error" do
20
20
  output = Dir.chdir(TEST_APP_PATH) { `rake shakapacker:check_binstubs 2>&1` }
21
+
21
22
  expect(output).to_not include "webpack binstub not found."
22
23
  end
23
24
 
24
25
  it "`shakapacker:check_node` doesn't get 'shakapacker requires Node.js' error" do
25
26
  output = Dir.chdir(TEST_APP_PATH) { `rake shakapacker:check_node 2>&1` }
27
+
26
28
  expect(output).to_not include "Shakapacker requires Node.js"
27
29
  end
28
30
 
29
- it "`shakapacker:check_yarn` doesn't get error related to yarn" do
31
+ it "`shakapacker:check_yarn` doesn't get errors related to yarn" do
30
32
  output = Dir.chdir(TEST_APP_PATH) { `rake shakapacker:check_yarn 2>&1` }
33
+
31
34
  expect(output).to_not include "Yarn not installed"
32
35
  expect(output).to_not include "Shakapacker requires Yarn"
33
36
  end
34
37
 
35
38
  describe "`shakapacker:check_binstubs`" do
36
- def with_temporary_file(file_name, &block)
39
+ def with_temporary_file(file_name)
37
40
  FileUtils.touch(file_name, verbose: false)
38
41
  yield if block_given?
39
42
  ensure
@@ -44,7 +47,7 @@ describe "RakeTasks" do
44
47
  Dir.chdir(TEST_APP_PATH)
45
48
  end
46
49
 
47
- context "with existing `./bin/shapapacker` and `./bin/shapapacker-dev-server`" do
50
+ context "with existing `./bin/shakapacker` and `./bin/shakapacker-dev-server`" do
48
51
  it "passes" do
49
52
  expect { system("bundle exec rake shakapacker:check_binstubs") }.to output("").to_stdout_from_any_process
50
53
  end
@@ -12,11 +12,11 @@ describe "Shakapacker" do
12
12
  allow(dev_server).to receive(:running?).and_return(true)
13
13
  end
14
14
 
15
- it "returns nil with disabled dev_server" do
15
+ it "returns nil when the dev server is disabled" do
16
16
  expect(Shakapacker.inlining_css?).to be nil
17
17
  end
18
18
 
19
- it "returns true with enabled hmr" do
19
+ it "returns true when hmr is enabled" do
20
20
  allow(dev_server).to receive(:hmr?).and_return(true)
21
21
  allow(dev_server).to receive(:inline_css?).and_return(true)
22
22
 
@@ -25,7 +25,7 @@ describe "Shakapacker" do
25
25
  expect(Shakapacker.inlining_css?).to be true
26
26
  end
27
27
 
28
- it "returns false with enabled hmr and explicitly setting inline_css to false" do
28
+ it "returns false when hmr is enabled and inline_css is explicitly set to false" do
29
29
  allow(dev_server).to receive(:hmr?).and_return(true)
30
30
  allow(dev_server).to receive(:inline_css?).and_return(false)
31
31
 
@@ -35,7 +35,7 @@ describe "Shakapacker" do
35
35
  end
36
36
  end
37
37
 
38
- it "has app_autoload_paths cleanup" do
38
+ it "automatically cleans up app_autoload_paths" do
39
39
  expect($test_app_autoload_paths_in_initializer).to eq []
40
40
  end
41
41
  end