shakapacker 6.6.0 → 7.0.0.rc.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/ruby-backward-compatibility.yml +43 -0
- data/CHANGELOG.md +50 -4
- data/CONTRIBUTING.md +4 -4
- data/Gemfile.development_dependencies +1 -1
- data/README.md +113 -88
- data/Rakefile +5 -0
- data/config/shakapacker.yml +1 -0
- data/docs/deployment.md +12 -10
- data/docs/developing_webpacker.md +5 -5
- data/docs/react.md +10 -6
- data/docs/style_loader_vs_mini_css.md +2 -2
- data/docs/troubleshooting.md +22 -18
- data/docs/using_esbuild_loader.md +5 -3
- data/docs/using_swc_loader.md +2 -2
- data/docs/v6_upgrade.md +2 -2
- data/docs/v7_upgrade.md +56 -0
- data/lib/install/bin/shakapacker +13 -0
- data/lib/install/bin/shakapacker-dev-server +13 -0
- data/lib/install/config/{webpacker.yml → shakapacker.yml} +13 -8
- data/lib/install/template.rb +7 -7
- data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
- data/lib/{webpacker → shakapacker}/commands.rb +4 -4
- data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
- data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
- data/lib/shakapacker/deprecation_helper.rb +88 -0
- data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
- data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
- data/lib/shakapacker/dev_server_runner.rb +104 -0
- data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/env.rb +8 -8
- data/lib/{webpacker → shakapacker}/helper.rb +20 -20
- data/lib/{webpacker → shakapacker}/instance.rb +13 -10
- data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
- data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
- data/lib/shakapacker/railtie.rb +70 -0
- data/lib/shakapacker/runner.rb +28 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
- data/lib/{webpacker → shakapacker}/version.rb +2 -2
- data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
- data/lib/shakapacker/webpack_runner.rb +67 -0
- data/lib/shakapacker.rb +51 -1
- data/lib/tasks/shakapacker/binstubs.rake +15 -0
- data/lib/tasks/shakapacker/check_binstubs.rake +25 -0
- data/lib/tasks/shakapacker/check_node.rake +31 -0
- data/lib/tasks/shakapacker/check_yarn.rake +33 -0
- data/lib/tasks/shakapacker/clean.rake +23 -0
- data/lib/tasks/shakapacker/clobber.rake +18 -0
- data/lib/tasks/shakapacker/compile.rake +31 -0
- data/lib/tasks/shakapacker/info.rake +21 -0
- data/lib/tasks/shakapacker/install.rake +17 -0
- data/lib/tasks/shakapacker/verify_config.rake +12 -0
- data/lib/tasks/shakapacker/verify_install.rake +4 -0
- data/lib/tasks/shakapacker/yarn_install.rake +24 -0
- data/lib/tasks/shakapacker.rake +18 -0
- data/lib/tasks/webpacker/binstubs.rake +5 -11
- data/lib/tasks/webpacker/check_binstubs.rake +6 -9
- data/lib/tasks/webpacker/check_node.rake +5 -27
- data/lib/tasks/webpacker/check_yarn.rake +5 -29
- data/lib/tasks/webpacker/clean.rake +5 -19
- data/lib/tasks/webpacker/clobber.rake +6 -13
- data/lib/tasks/webpacker/compile.rake +5 -33
- data/lib/tasks/webpacker/info.rake +5 -17
- data/lib/tasks/webpacker/install.rake +5 -13
- data/lib/tasks/webpacker/verify_config.rake +6 -11
- data/lib/tasks/webpacker/verify_install.rake +7 -2
- data/lib/tasks/webpacker/yarn_install.rake +5 -20
- data/lib/tasks/webpacker.rake +15 -13
- data/lib/webpacker/dev_server_runner.rb +9 -96
- data/lib/webpacker/webpack_runner.rb +9 -58
- data/lib/webpacker.rb +3 -47
- data/package/__tests__/config-bc.js +27 -0
- data/package/__tests__/config.js +6 -5
- data/package/__tests__/dev_server-bc.js +46 -0
- data/package/__tests__/dev_server.js +9 -8
- data/package/__tests__/development-bc.js +66 -0
- data/package/__tests__/development.js +36 -5
- data/package/__tests__/env-bc.js +59 -0
- data/package/__tests__/env.js +3 -2
- data/package/__tests__/index.js +13 -0
- data/package/__tests__/production-bc.js +51 -0
- data/package/__tests__/production.js +25 -3
- data/package/__tests__/staging-bc.js +53 -0
- data/package/__tests__/staging.js +27 -4
- data/package/__tests__/test-bc.js +43 -0
- data/package/__tests__/test.js +22 -4
- data/package/babel/preset.js +1 -4
- data/package/config.js +25 -7
- data/package/dev_server.js +7 -4
- data/package/env.js +22 -3
- data/package/environments/__tests__/base-bc.js +107 -0
- data/package/environments/__tests__/base.js +13 -13
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +1 -1
- data/package/index.js +11 -4
- data/package/rules/__tests__/__utils__/webpack.js +1 -1
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/swc.js +1 -2
- data/package/rules/file.js +2 -2
- data/package/utils/configPath.js +19 -0
- data/package/utils/defaultConfigPath.js +2 -0
- data/package/utils/get_style_rule.js +5 -2
- data/package/utils/helpers.js +24 -1
- data/package/utils/inliningCss.js +7 -0
- data/package/utils/snakeToCamelCase +7 -0
- data/package/webpackDevServerConfig.js +68 -0
- data/package.json +2 -2
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/backward_compatibility_specs/command_spec_bc.rb +116 -0
- data/spec/backward_compatibility_specs/compiler_spec_bc.rb +59 -0
- data/spec/backward_compatibility_specs/compiler_strategy_spec_bc.rb +22 -0
- data/spec/backward_compatibility_specs/configuration_spec_bc.rb +286 -0
- data/spec/backward_compatibility_specs/dev_server_runner_spec_bc.rb +79 -0
- data/spec/backward_compatibility_specs/dev_server_spec_bc.rb +47 -0
- data/spec/backward_compatibility_specs/digest_strategy_spec_bc.rb +35 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec_bc.rb +44 -0
- data/spec/backward_compatibility_specs/env_spec_bc.rb +23 -0
- data/spec/backward_compatibility_specs/helper_spec_bc.rb +243 -0
- data/spec/backward_compatibility_specs/instance_spec_bc.rb +31 -0
- data/spec/backward_compatibility_specs/manifest_spec_bc.rb +100 -0
- data/spec/backward_compatibility_specs/mtime_strategy_spec_bc.rb +55 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec_bc.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/spec/backward_compatibility_specs/webpack_runner_spec_bc.rb +56 -0
- data/spec/backward_compatibility_specs/webpacker_spec_bc.rb +41 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +3 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
- data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +4 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_other_location.yml +1 -1
- data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +5 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +58 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +11 -0
- data/spec/command_spec.rb +18 -16
- data/spec/compiler_spec.rb +19 -17
- data/spec/compiler_strategy_spec.rb +9 -7
- data/spec/configuration_spec.rb +108 -66
- data/spec/dev_server_runner_spec.rb +9 -8
- data/spec/dev_server_spec.rb +97 -9
- data/spec/digest_strategy_spec.rb +4 -2
- data/spec/engine_rake_tasks_spec.rb +12 -16
- data/spec/env_spec.rb +7 -5
- data/spec/helper_spec.rb +4 -2
- data/spec/instance_spec.rb +31 -0
- data/spec/manifest_spec.rb +21 -19
- data/spec/mounted_app/test/dummy/config/application.rb +1 -1
- data/spec/mounted_app/test/dummy/config/webpacker.yml +3 -3
- data/spec/mtime_strategy_spec.rb +4 -2
- data/spec/rake_tasks_spec.rb +20 -18
- data/spec/spec_helper.rb +0 -25
- data/spec/spec_helper_initializer.rb +24 -0
- data/spec/test_app/.gitignore +2 -0
- data/spec/test_app/app/javascript/entrypoints/application.js +10 -0
- data/spec/test_app/app/javascript/entrypoints/generated/something.js +2 -0
- data/spec/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
- data/spec/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
- data/spec/test_app/bin/{webpacker-dev-server → shakapacker} +3 -3
- data/spec/test_app/bin/{webpacker → shakapacker-dev-server} +3 -3
- data/spec/test_app/config/application.rb +1 -1
- data/spec/test_app/config/shakapacker.yml +82 -0
- data/spec/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
- data/spec/test_app/config/shakapacker_defaults_fallback.yml +11 -0
- data/spec/test_app/config/shakapacker_manifest_path.yml +80 -0
- data/spec/test_app/config/shakapacker_nested_entries.yml +83 -0
- data/spec/test_app/config/shakapacker_no_precompile.yml +7 -0
- data/spec/test_app/config/shakapacker_other_location.yml +85 -0
- data/spec/test_app/config/shakapacker_public_root.yml +18 -0
- data/spec/version_checker_spec.rb +16 -15
- data/spec/webpack_runner_spec.rb +4 -3
- data/spec/webpacker_spec.rb +9 -29
- metadata +119 -44
- data/config/webpacker.yml +0 -1
- data/lib/webpacker/railtie.rb +0 -70
- data/lib/webpacker/runner.rb +0 -23
- data/package/configPath.js +0 -3
- data/package/inliningCss.js +0 -7
- data/spec/test_app/config/webpacker_no_precompile.yml +0 -7
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
- /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
- /data/spec/{test_app → backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /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
|
data/spec/manifest_spec.rb
CHANGED
|
@@ -1,73 +1,75 @@
|
|
|
1
|
-
|
|
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(
|
|
10
|
+
allow(Shakapacker.config).to receive(:compile?).and_return(false)
|
|
9
11
|
|
|
10
12
|
expect {
|
|
11
|
-
|
|
12
|
-
}.to raise_error(
|
|
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(
|
|
21
|
+
allow(Shakapacker.config).to receive(:compile?).and_return(false)
|
|
20
22
|
|
|
21
23
|
expect {
|
|
22
|
-
|
|
23
|
-
}.to raise_error(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
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 =
|
|
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(
|
|
83
|
+
allow(Shakapacker.config).to receive(:compile?).and_return(false)
|
|
82
84
|
|
|
83
85
|
expect {
|
|
84
|
-
|
|
85
|
-
}.to raise_error(
|
|
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 =
|
|
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,10 +1,10 @@
|
|
|
1
|
-
# Note: You must restart bin/
|
|
1
|
+
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
|
|
2
2
|
|
|
3
3
|
default: &default
|
|
4
|
-
source_path: app/
|
|
4
|
+
source_path: app/javascript
|
|
5
5
|
source_entry_path: entrypoints
|
|
6
6
|
public_output_path: packs
|
|
7
|
-
cache_path: tmp/
|
|
7
|
+
cache_path: tmp/shakapacker
|
|
8
8
|
webpack_loader: babel
|
|
9
9
|
|
|
10
10
|
# Additional paths webpack should look up modules
|
data/spec/mtime_strategy_spec.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
data/spec/rake_tasks_spec.rb
CHANGED
|
@@ -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
|
|
6
|
+
it "`rake -T` lists Shakapacker tasks" do
|
|
5
7
|
output = Dir.chdir(test_app_path) { `rake -T` }
|
|
6
|
-
expect(output).to include "
|
|
7
|
-
expect(output).to include "
|
|
8
|
-
expect(output).to include "
|
|
9
|
-
expect(output).to include "
|
|
10
|
-
expect(output).to include "
|
|
11
|
-
expect(output).to include "
|
|
12
|
-
expect(output).to include "
|
|
13
|
-
expect(output).to include "
|
|
14
|
-
expect(output).to include "
|
|
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 "`
|
|
18
|
-
output = Dir.chdir(test_app_path) { `rake
|
|
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 "`
|
|
23
|
-
output = Dir.chdir(test_app_path) { `rake
|
|
24
|
-
expect(output).to_not include "
|
|
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 "`
|
|
28
|
-
output = Dir.chdir(test_app_path) { `rake
|
|
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 "
|
|
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,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')
|
|
@@ -9,6 +9,6 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
|
9
9
|
|
|
10
10
|
require "bundler/setup"
|
|
11
11
|
|
|
12
|
-
require "
|
|
13
|
-
require "
|
|
14
|
-
|
|
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 "
|
|
13
|
-
require "
|
|
14
|
-
|
|
12
|
+
require "shakapacker"
|
|
13
|
+
require "shakapacker/dev_server_runner"
|
|
14
|
+
Shakapacker::DevServerRunner.run(ARGV)
|
|
@@ -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,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
|