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.
- checksums.yaml +4 -4
- data/.github/workflows/dummy.yml +4 -2
- data/.github/workflows/generator.yml +4 -2
- data/.github/workflows/jest.yml +5 -3
- data/.github/workflows/js-lint.yml +5 -3
- data/.github/workflows/rubocop.yml +4 -2
- data/.github/workflows/ruby-backward-compatibility.yml +5 -3
- data/.github/workflows/ruby.yml +5 -3
- data/CHANGELOG.md +15 -1
- data/CONTRIBUTING.md +3 -4
- data/README.md +37 -23
- data/docs/deployment.md +1 -1
- data/docs/react.md +4 -4
- data/docs/troubleshooting.md +4 -8
- data/docs/using_esbuild_loader.md +3 -5
- data/docs/v6_upgrade.md +1 -1
- data/docs/v7_upgrade.md +2 -2
- data/lib/install/template.rb +2 -2
- data/lib/shakapacker/compiler.rb +1 -1
- data/lib/shakapacker/deprecation_helper.rb +1 -1
- data/lib/shakapacker/dev_server_runner.rb +2 -1
- data/lib/shakapacker/utils/misc.rb +1 -1
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +35 -2
- data/lib/shakapacker/webpack_runner.rb +4 -3
- data/lib/tasks/shakapacker/binstubs.rake +2 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +7 -2
- data/lib/tasks/shakapacker/install.rake +2 -2
- data/package/__tests__/index.js +24 -0
- data/package/environments/__tests__/base-bc.js +1 -1
- data/package/environments/__tests__/development.js +9 -9
- data/package/environments/__tests__/production.js +12 -12
- data/package/index.d.ts +61 -0
- data/package/index.js +8 -2
- data/package.json +12 -1
- data/rakelib/release.rake +1 -1
- data/spec/backward_compatibility_specs/compiler_spec.rb +2 -2
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +5 -3
- data/spec/backward_compatibility_specs/configuration_spec.rb +16 -8
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +17 -16
- data/spec/backward_compatibility_specs/dev_server_spec.rb +1 -1
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +2 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +2 -1
- data/spec/backward_compatibility_specs/helper_spec.rb +20 -20
- data/spec/backward_compatibility_specs/instance_spec.rb +3 -3
- data/spec/backward_compatibility_specs/manifest_spec.rb +12 -12
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +3 -3
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +9 -5
- data/spec/backward_compatibility_specs/webpack_runner_spec.rb +14 -18
- data/spec/dummy/config/webpack/commonWebpackConfig.js +1 -1
- data/spec/fixtures/beta_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/beta_pnpm-lock.v8.yaml +2537 -0
- data/spec/fixtures/git_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/git_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/github_url_pnpm-lock.v7.yaml +126 -0
- data/spec/fixtures/github_url_pnpm-lock.v8.yaml +3728 -0
- data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +18 -0
- data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +22 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +117 -0
- data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +116 -0
- data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +2558 -0
- data/spec/fixtures/without_pnpm-lock.v7.yaml +23 -0
- data/spec/fixtures/without_pnpm-lock.v8.yaml +27 -0
- data/spec/generator_specs/generator_spec.rb +11 -7
- data/spec/shakapacker/compiler_spec.rb +2 -2
- data/spec/shakapacker/compiler_strategy_spec.rb +5 -3
- data/spec/shakapacker/configuration_spec.rb +16 -6
- data/spec/shakapacker/dev_server_runner_spec.rb +22 -16
- data/spec/shakapacker/dev_server_spec.rb +1 -1
- data/spec/shakapacker/digest_strategy_spec.rb +2 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +2 -1
- data/spec/shakapacker/helper_spec.rb +20 -20
- data/spec/shakapacker/instance_spec.rb +2 -2
- data/spec/shakapacker/manifest_spec.rb +12 -12
- data/spec/shakapacker/mtime_strategy_spec.rb +3 -3
- data/spec/shakapacker/rake_tasks_spec.rb +6 -3
- data/spec/shakapacker/shakapacker_spec.rb +4 -4
- data/spec/shakapacker/version_checker_spec.rb +470 -123
- data/spec/shakapacker/webpack_runner_spec.rb +14 -18
- 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!
|
|
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!
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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!
|
|
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
|
|
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
|
|
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/
|
|
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
|
|
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
|
|
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
|
|
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 "
|
|
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
|