webpacker 6.0.0.rc.2 → 6.0.0.rc.6
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/jest.yml +6 -17
- data/.github/workflows/js-lint.yml +6 -17
- data/.github/workflows/ruby.yml +13 -38
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +15 -3
- data/CONTRIBUTING.md +19 -0
- data/Gemfile.lock +84 -84
- data/README.md +30 -21
- data/docs/troubleshooting.md +5 -1
- data/docs/v6_upgrade.md +70 -32
- data/lib/install/{packs/entrypoints/application.js → application.js} +3 -7
- data/lib/install/bin/webpack +4 -7
- data/lib/install/config/webpacker.yml +16 -13
- data/lib/install/package.json +0 -2
- data/lib/install/template.rb +10 -1
- data/lib/tasks/yarn.rake +22 -20
- data/lib/webpacker/commands.rb +19 -15
- data/lib/webpacker/dev_server_runner.rb +1 -1
- data/lib/webpacker/railtie.rb +7 -0
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +27 -7
- data/package/__tests__/development.js +4 -11
- data/package/config.js +3 -3
- data/package/env.js +3 -6
- data/package/environments/base.js +1 -1
- data/package/environments/development.js +34 -32
- data/package/rules/file.js +1 -1
- data/package.json +15 -15
- data/test/command_test.rb +76 -0
- data/test/dev_server_runner_test.rb +1 -1
- data/test/test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/test/webpacker_test.rb +4 -0
- data/webpacker.gemspec +2 -2
- data/yarn.lock +1392 -2825
- metadata +13 -11
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rails/webpacker",
|
3
|
-
"version": "6.0.0-rc.
|
3
|
+
"version": "6.0.0-rc.6",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
@@ -8,36 +8,36 @@
|
|
8
8
|
"lib/install/config/webpacker.yml"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
|
-
"node": "
|
11
|
+
"node": ">= 12.13.0 || >=14",
|
12
12
|
"yarn": ">=1 <4"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"@babel/core": "^7.15.
|
15
|
+
"@babel/core": "^7.15.5",
|
16
16
|
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
17
17
|
"@babel/plugin-transform-runtime": "^7.15.0",
|
18
|
-
"@babel/preset-env": "^7.15.
|
19
|
-
"@babel/runtime": "^7.15.
|
18
|
+
"@babel/preset-env": "^7.15.6",
|
19
|
+
"@babel/runtime": "^7.15.4",
|
20
20
|
"babel-loader": "^8.2.2",
|
21
|
-
"compression-webpack-plugin": "^
|
22
|
-
"glob": "^7.
|
23
|
-
"js-yaml": "^
|
21
|
+
"compression-webpack-plugin": "^9.0.0",
|
22
|
+
"glob": "^7.2.0",
|
23
|
+
"js-yaml": "^4.1.0",
|
24
24
|
"path-complete-extname": "^1.0.0",
|
25
25
|
"pnp-webpack-plugin": "^1.7.0",
|
26
|
-
"terser-webpack-plugin": "^5.
|
27
|
-
"webpack": "^5.
|
26
|
+
"terser-webpack-plugin": "^5.2.4",
|
27
|
+
"webpack": "^5.53.0",
|
28
28
|
"webpack-assets-manifest": "^5.0.6",
|
29
29
|
"webpack-cli": "^4.8.0",
|
30
30
|
"webpack-merge": "^5.8.0",
|
31
|
-
"webpack-sources": "^3.2.
|
31
|
+
"webpack-sources": "^3.2.1"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"eslint": "^7.32.0",
|
35
35
|
"eslint-config-airbnb": "^18.2.1",
|
36
|
-
"eslint-config-prettier": "^
|
37
|
-
"eslint-plugin-import": "^2.24.
|
36
|
+
"eslint-config-prettier": "^8.3.0",
|
37
|
+
"eslint-plugin-import": "^2.24.2",
|
38
38
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
39
|
-
"eslint-plugin-react": "^7.
|
40
|
-
"jest": "^
|
39
|
+
"eslint-plugin-react": "^7.26.0",
|
40
|
+
"jest": "^27.2.1"
|
41
41
|
},
|
42
42
|
"jest": {
|
43
43
|
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
|
data/test/command_test.rb
CHANGED
@@ -31,3 +31,79 @@ class CommandTest < Minitest::Test
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
class ClearCommandVersioningTest < Minitest::Test
|
36
|
+
def setup
|
37
|
+
@now = Time.parse("2021-01-01 12:34:56 UTC")
|
38
|
+
# Test assets to be kept and deleted, path and mtime
|
39
|
+
@prev_files = {
|
40
|
+
# recent versions to be kept with Webpacker.commands.clean(count = 2)
|
41
|
+
"js/application-deadbeef.js" => @now - 4000,
|
42
|
+
"js/common-deadbeee.js" => @now - 4002,
|
43
|
+
"css/common-deadbeed.css" => @now - 4004,
|
44
|
+
"media/images/logo-deadbeeb.css" => @now - 4006,
|
45
|
+
"js/application-1eadbeef.js" => @now - 8000,
|
46
|
+
"js/common-1eadbeee.js" => @now - 8002,
|
47
|
+
"css/common-1eadbeed.css" => @now - 8004,
|
48
|
+
"media/images/logo-1eadbeeb.css" => @now - 8006,
|
49
|
+
# new files to be kept with Webpacker.commands.clean(age = 3600)
|
50
|
+
"js/brandnew-0001.js" => @now,
|
51
|
+
"js/brandnew-0002.js" => @now - 10,
|
52
|
+
"js/brandnew-0003.js" => @now - 20,
|
53
|
+
"js/brandnew-0004.js" => @now - 40,
|
54
|
+
}.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
|
55
|
+
@expired_files = {
|
56
|
+
# old files that are outside count = 2 or age = 3600 and to be deleted
|
57
|
+
"js/application-0eadbeef.js" => @now - 9000,
|
58
|
+
"js/common-0eadbeee.js" => @now - 9002,
|
59
|
+
"css/common-0eadbeed.css" => @now - 9004,
|
60
|
+
"js/brandnew-0005.js" => @now - 3640,
|
61
|
+
}.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
|
62
|
+
@all_files = @prev_files.merge(@expired_files)
|
63
|
+
@dir_glob_stub = Proc.new { |arg|
|
64
|
+
case arg
|
65
|
+
when "#{Webpacker.config.public_output_path}/**/*"
|
66
|
+
@all_files.keys
|
67
|
+
else
|
68
|
+
[]
|
69
|
+
end
|
70
|
+
}
|
71
|
+
@file_mtime_stub = Proc.new { |longpath|
|
72
|
+
@all_files[longpath]
|
73
|
+
}
|
74
|
+
@file_delete_mock = Minitest::Mock.new
|
75
|
+
@expired_files.keys.each do |longpath|
|
76
|
+
@file_delete_mock.expect(:delete, 1, [longpath])
|
77
|
+
end
|
78
|
+
@file_delete_stub = Proc.new { |longpath|
|
79
|
+
if @prev_files.has_key?(longpath)
|
80
|
+
flunk "#{longpath} should not be deleted"
|
81
|
+
else
|
82
|
+
@file_delete_mock.delete(longpath)
|
83
|
+
end
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def time_and_files_stub(&proc)
|
88
|
+
Time.stub :now, @now do
|
89
|
+
Dir.stub :glob, @dir_glob_stub do
|
90
|
+
File.stub :directory?, false do
|
91
|
+
File.stub :file?, true do
|
92
|
+
File.stub :mtime, @file_mtime_stub do
|
93
|
+
File.stub :delete, @file_delete_stub do
|
94
|
+
yield proc
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
@file_delete_mock.verify
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_clean_command_with_versioned_files
|
105
|
+
time_and_files_stub do
|
106
|
+
assert Webpacker.commands.clean
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -50,7 +50,7 @@ class DevServerRunnerTest < Webpacker::Test
|
|
50
50
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
|
51
51
|
env = Webpacker::Compiler.env.dup
|
52
52
|
ENV["WEBPACKER_CONFIG"] = env["WEBPACKER_CONFIG"] = "#{test_app_path}/config/webpacker_other_location.yml"
|
53
|
-
env["
|
53
|
+
env["WEBPACK_SERVE"] = "true"
|
54
54
|
verify_command(cmd, env: env)
|
55
55
|
end
|
56
56
|
|
@@ -0,0 +1 @@
|
|
1
|
+
$test_app_autoload_paths_in_initializer = ActiveSupport::Dependencies.autoload_paths
|
data/test/webpacker_test.rb
CHANGED
data/webpacker.gemspec
CHANGED
@@ -15,7 +15,7 @@ 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.
|
18
|
+
s.required_ruby_version = ">= 2.7.0"
|
19
19
|
|
20
20
|
s.add_dependency "activesupport", ">= 5.2"
|
21
21
|
s.add_dependency "railties", ">= 5.2"
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "semantic_range", ">= 2.3.0"
|
24
24
|
|
25
25
|
s.add_development_dependency "bundler", ">= 1.3.0"
|
26
|
-
s.add_development_dependency "rubocop"
|
26
|
+
s.add_development_dependency "rubocop"
|
27
27
|
s.add_development_dependency "rubocop-performance"
|
28
28
|
|
29
29
|
s.files = `git ls-files`.split("\n")
|