webpacker 4.0.7 → 5.4.4

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 (114) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.js +8 -8
  3. data/.github/workflows/jest.yml +38 -0
  4. data/.github/workflows/js-lint.yml +39 -0
  5. data/.github/workflows/rubocop.yml +39 -0
  6. data/.github/workflows/ruby.yml +46 -0
  7. data/.node-version +1 -1
  8. data/.rubocop.yml +118 -14
  9. data/CHANGELOG.md +301 -138
  10. data/CONTRIBUTING.md +1 -1
  11. data/Gemfile +1 -0
  12. data/Gemfile.lock +123 -92
  13. data/README.md +86 -211
  14. data/docs/css.md +72 -6
  15. data/docs/deployment.md +40 -11
  16. data/docs/docker.md +33 -14
  17. data/docs/engines.md +53 -3
  18. data/docs/env.md +0 -2
  19. data/docs/es6.md +19 -1
  20. data/docs/integrations.md +220 -0
  21. data/docs/target.md +22 -0
  22. data/docs/testing.md +2 -3
  23. data/docs/troubleshooting.md +39 -9
  24. data/docs/typescript.md +93 -26
  25. data/docs/webpack-dev-server.md +2 -2
  26. data/docs/webpack.md +18 -3
  27. data/gemfiles/Gemfile-rails-edge +1 -1
  28. data/gemfiles/{Gemfile-rails.4.2.x → Gemfile-rails.6.0.x} +1 -1
  29. data/lib/install/bin/webpack +0 -1
  30. data/lib/install/bin/webpack-dev-server +0 -1
  31. data/lib/install/coffee.rb +1 -1
  32. data/lib/install/config/babel.config.js +23 -13
  33. data/lib/install/config/webpacker.yml +3 -6
  34. data/lib/install/elm.rb +1 -1
  35. data/lib/install/erb.rb +2 -2
  36. data/lib/install/examples/angular/hello_angular/polyfills.ts +2 -2
  37. data/lib/install/examples/react/babel.config.js +28 -14
  38. data/lib/install/examples/react/tsconfig.json +2 -1
  39. data/lib/install/examples/svelte/app.svelte +11 -0
  40. data/lib/install/examples/svelte/hello_svelte.js +20 -0
  41. data/lib/install/examples/typescript/tsconfig.json +2 -1
  42. data/lib/install/loaders/elm.js +9 -6
  43. data/lib/install/loaders/svelte.js +9 -0
  44. data/lib/install/svelte.rb +29 -0
  45. data/lib/install/template.rb +14 -6
  46. data/lib/install/typescript.rb +6 -13
  47. data/lib/install/vue.rb +1 -1
  48. data/lib/tasks/installers.rake +1 -0
  49. data/lib/tasks/webpacker/check_node.rake +15 -8
  50. data/lib/tasks/webpacker/check_yarn.rake +16 -10
  51. data/lib/tasks/webpacker/clean.rake +25 -0
  52. data/lib/tasks/webpacker/clobber.rake +8 -4
  53. data/lib/tasks/webpacker/compile.rake +2 -10
  54. data/lib/tasks/webpacker/yarn_install.rake +11 -1
  55. data/lib/tasks/webpacker.rake +2 -0
  56. data/lib/webpacker/commands.rb +53 -1
  57. data/lib/webpacker/compiler.rb +21 -10
  58. data/lib/webpacker/configuration.rb +36 -13
  59. data/lib/webpacker/dev_server.rb +1 -1
  60. data/lib/webpacker/dev_server_proxy.rb +5 -9
  61. data/lib/webpacker/dev_server_runner.rb +6 -6
  62. data/lib/webpacker/env.rb +6 -2
  63. data/lib/webpacker/helper.rb +70 -25
  64. data/lib/webpacker/manifest.rb +4 -4
  65. data/lib/webpacker/railtie.rb +6 -43
  66. data/lib/webpacker/runner.rb +1 -0
  67. data/lib/webpacker/version.rb +1 -1
  68. data/lib/webpacker/webpack_runner.rb +2 -2
  69. data/lib/webpacker.rb +9 -1
  70. data/package/__tests__/config.js +12 -24
  71. data/package/__tests__/dev_server.js +2 -0
  72. data/package/__tests__/development.js +14 -1
  73. data/package/config.js +6 -11
  74. data/package/configPath.js +3 -0
  75. data/package/config_types/config_list.js +3 -3
  76. data/package/config_types/config_object.js +1 -1
  77. data/package/dev_server.js +1 -1
  78. data/package/env.js +1 -2
  79. data/package/environments/__tests__/base.js +29 -2
  80. data/package/environments/base.js +18 -8
  81. data/package/environments/development.js +39 -37
  82. data/package/environments/production.js +12 -2
  83. data/package/rules/babel.js +12 -5
  84. data/package/rules/file.js +3 -2
  85. data/package/rules/node_modules.js +3 -5
  86. data/package/rules/sass.js +11 -2
  87. data/package/utils/__tests__/get_style_rule.js +9 -0
  88. data/package/utils/deep_merge.js +5 -5
  89. data/package/utils/get_style_rule.js +7 -12
  90. data/package/utils/helpers.js +10 -10
  91. data/package.json +43 -43
  92. data/test/command_test.rb +6 -0
  93. data/test/compiler_test.rb +10 -6
  94. data/test/configuration_test.rb +40 -30
  95. data/test/dev_server_runner_test.rb +1 -1
  96. data/test/dev_server_test.rb +22 -0
  97. data/test/helper_test.rb +58 -9
  98. data/test/manifest_test.rb +37 -6
  99. data/test/rake_tasks_test.rb +17 -0
  100. data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  101. data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  102. data/test/test_app/bin/webpack +0 -1
  103. data/test/test_app/bin/webpack-dev-server +0 -1
  104. data/test/test_app/config/application.rb +0 -1
  105. data/test/test_app/config/webpacker.yml +8 -1
  106. data/test/test_app/public/packs/manifest.json +4 -0
  107. data/test/webpack_runner_test.rb +1 -1
  108. data/webpacker.gemspec +6 -4
  109. data/yarn.lock +4350 -4099
  110. metadata +63 -23
  111. data/.travis.yml +0 -53
  112. data/gemfiles/Gemfile-rails.5.0.x +0 -9
  113. data/gemfiles/Gemfile-rails.5.1.x +0 -9
  114. data/lib/install/loaders/typescript.js +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60145540340af7d04e9ad62a395b3b6a282585d2d470a7b23427da53c8784fa4
4
- data.tar.gz: b7b9fe64a3b2481733e40e198506c9a75d65feac46b1eb5b9cd2cc752a86c943
3
+ metadata.gz: 0370a980c6e40b16b54b814c08883722bd218a9dcfc8a7d6678cb2d93bba9a46
4
+ data.tar.gz: caa8625ecc6fd35bd5906007574671c542232d1fc899304d0de5dec507afbaf2
5
5
  SHA512:
6
- metadata.gz: 8f35a4d16a608ef7ec30ab763a743b0664cc49c339bc3f4afe7e96fbc9ffa474dd38eb11020c994621407354399a9a309c839be4801dcfeac841a126e5834c83
7
- data.tar.gz: c325bbf4849a5fbc9f09e459d77d05011621afb8bcc11704697d53e9950b90ae222b5fa97d69990ffc3ddc66227f37b5d283b12bc5844eebb946611b0fba8915
6
+ metadata.gz: 2a189c9360243cd577442a4373e2d10c98262730a0539dbfb35ea24f9fab45b365964b53f9184c3ee3c261bd561b2aa1bb504057318400b5bf94a87441ce1d1e
7
+ data.tar.gz: 53e0c0fcd2bd906ea5099c5d10bbccd6ef0e462c398b12345730dab201362e008d858c22bae89377144e4ddee18ae0942927f9c94b334816a137e79111581fa1
data/.eslintrc.js CHANGED
@@ -1,14 +1,14 @@
1
1
  module.exports = {
2
- 'extends': 'airbnb',
3
- 'rules': {
2
+ extends: 'airbnb',
3
+ rules: {
4
4
  'comma-dangle': ['error', 'never'],
5
5
  'import/no-unresolved': 'off',
6
6
  'import/no-extraneous-dependencies': 'off',
7
7
  'import/extensions': 'off',
8
- semi: ['error', 'never'],
8
+ semi: ['error', 'never']
9
9
  },
10
- 'env': {
11
- 'browser': true,
12
- 'node': true,
13
- },
14
- };
10
+ env: {
11
+ browser: true,
12
+ node: true
13
+ }
14
+ }
@@ -0,0 +1,38 @@
1
+ name: Jest specs
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: Jest specs
8
+ strategy:
9
+ matrix:
10
+ os: [ubuntu-latest]
11
+ node: [10.x, 12.x, 14.x]
12
+
13
+ runs-on: ${{ matrix.os }}
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Get yarn cache directory path
18
+ id: yarn-cache-dir-path
19
+ run: echo "::set-output name=dir::$(yarn cache dir)"
20
+
21
+ - uses: actions/cache@v2
22
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
23
+ with:
24
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
25
+ key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
26
+ restore-keys: |
27
+ ${{ runner.os }}-${{ matrix.node }}-yarn-
28
+
29
+ - name: Use Node.js ${{ matrix.node }}
30
+ uses: actions/setup-node@v1
31
+ with:
32
+ node-version: ${{ matrix.node }}
33
+
34
+ - name: Install dependencies
35
+ run: yarn --frozen-lockfile
36
+
37
+ - name: Jest Specs
38
+ run: yarn test
@@ -0,0 +1,39 @@
1
+ name: JS lint
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: JS Lint
8
+
9
+ strategy:
10
+ matrix:
11
+ os: [ubuntu-latest]
12
+ node: [12.x]
13
+
14
+ runs-on: ${{ matrix.os }}
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Get yarn cache directory path
19
+ id: yarn-cache-dir-path
20
+ run: echo "::set-output name=dir::$(yarn cache dir)"
21
+
22
+ - uses: actions/cache@v2
23
+ id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
24
+ with:
25
+ path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
26
+ key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
27
+ restore-keys: |
28
+ ${{ runner.os }}-yarn-
29
+
30
+ - name: Use Node.js ${{ matrix.node }}
31
+ uses: actions/setup-node@v1
32
+ with:
33
+ node-version: ${{ matrix.node }}
34
+
35
+ - name: Install dependencies
36
+ run: yarn --frozen-lockfile
37
+
38
+ - name: Lint
39
+ run: yarn lint
@@ -0,0 +1,39 @@
1
+ name: Rubocop
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: Rubocop
8
+ runs-on: ${{ matrix.os }}
9
+ env:
10
+ BUNDLE_JOBS: 4
11
+ BUNDLE_RETRY: 3
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest]
15
+ ruby: [
16
+ 2.7
17
+ ]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - uses: actions/cache@v2
22
+ with:
23
+ path: /home/runner/bundle
24
+ key: bundle-use-ruby-gems-${{ hashFiles('**/Gemfile.lock') }}
25
+ restore-keys: |
26
+ bundle-use-ruby-gems-
27
+
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+
32
+ - name: Bundle install
33
+ run: |
34
+ gem install bundler -v 2.1.4
35
+ bundle config path /home/runner/bundle
36
+ bundle install
37
+
38
+ - name: Ruby linter
39
+ run: bundle exec rubocop
@@ -0,0 +1,46 @@
1
+ name: Ruby specs
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: Ruby specs
8
+ runs-on: ${{ matrix.os }}
9
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' || matrix.experimental }}
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ os: [ubuntu-latest]
14
+ ruby: [
15
+ 2.4,
16
+ 2.5,
17
+ 2.6,
18
+ 2.7
19
+ ]
20
+ gemfile: [
21
+ "gemfiles/Gemfile-rails.5.2.x",
22
+ "gemfiles/Gemfile-rails.6.0.x"
23
+ ]
24
+ exclude:
25
+ - ruby: "2.4"
26
+ gemfile: gemfiles/Gemfile-rails.6.0.x
27
+ experimental: [false]
28
+ include:
29
+ - ruby: 2.7
30
+ os: ubuntu-latest
31
+ gemfile: gemfiles/Gemfile-rails-edge
32
+ experimental: true
33
+
34
+ env:
35
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+
39
+ - uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: ${{ matrix.ruby }}
42
+ bundler-cache: true
43
+ rubygems: ${{ matrix.ruby < '2.6' && 'default' || 'latest' }}
44
+
45
+ - name: Ruby specs
46
+ run: bundle exec rake test
data/.node-version CHANGED
@@ -1 +1 @@
1
- 6.14.4
1
+ 10.17.0
data/.rubocop.yml CHANGED
@@ -1,5 +1,6 @@
1
+ require: rubocop-performance
1
2
  AllCops:
2
- TargetRubyVersion: 2.2
3
+ TargetRubyVersion: 2.4
3
4
  # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
5
  # to ignore them, so only the ones explicitly set in this file are enabled.
5
6
  DisabledByDefault: true
@@ -12,11 +13,6 @@ AllCops:
12
13
  Style/AndOr:
13
14
  Enabled: true
14
15
 
15
- # Do not use braces for hash literals when they are the last argument of a
16
- # method call.
17
- Style/BracesAroundHashParameters:
18
- Enabled: true
19
-
20
16
  # Align `when` with `case`.
21
17
  Layout/CaseIndentation:
22
18
  Enabled: true
@@ -49,7 +45,11 @@ Style/HashSyntax:
49
45
  # extra level of indentation.
50
46
  Layout/IndentationConsistency:
51
47
  Enabled: true
52
- EnforcedStyle: rails
48
+ EnforcedStyle: indented_internal_methods
49
+
50
+ # Detect hard tabs, no hard tabs.
51
+ Layout/IndentationStyle:
52
+ Enabled: true
53
53
 
54
54
  # Two spaces, no tabs (for indentation).
55
55
  Layout/IndentationWidth:
@@ -71,7 +71,7 @@ Layout/SpaceAroundOperators:
71
71
  Enabled: true
72
72
 
73
73
  Layout/SpaceBeforeFirstArg:
74
- Enabled: true
74
+ Enabled: true
75
75
 
76
76
  # Defining a method with parameters needs parentheses.
77
77
  Style/MethodDefParentheses:
@@ -97,12 +97,8 @@ Style/StringLiterals:
97
97
  Enabled: true
98
98
  EnforcedStyle: double_quotes
99
99
 
100
- # Detect hard tabs, no hard tabs.
101
- Layout/Tab:
102
- Enabled: true
103
-
104
100
  # Blank lines should not have any spaces.
105
- Layout/TrailingBlankLines:
101
+ Layout/TrailingEmptyLines:
106
102
  Enabled: true
107
103
 
108
104
  # No trailing whitespace.
@@ -110,7 +106,10 @@ Layout/TrailingWhitespace:
110
106
  Enabled: true
111
107
 
112
108
  # Use quotes for string literals when they are enough.
113
- Style/UnneededPercentQ:
109
+ Style/RedundantPercentQ:
110
+ Enabled: true
111
+
112
+ Lint/DeprecatedClassMethods:
114
113
  Enabled: true
115
114
 
116
115
  # Align `end` with the matching keyword or starting expression except for
@@ -122,3 +121,108 @@ Layout/EndAlignment:
122
121
  # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
123
122
  Lint/RequireParentheses:
124
123
  Enabled: true
124
+
125
+ # Use `bind_call(obj, args, ...)` instead of `bind(obj).call(args, ...)`.
126
+ Performance/BindCall:
127
+ Enabled: true
128
+
129
+ # Use `caller(n..n)` instead of `caller`.
130
+ Performance/Caller:
131
+ Enabled: true
132
+
133
+ # Use `casecmp` for case comparison.
134
+ Performance/Casecmp:
135
+ Enabled: true
136
+
137
+ # Extract Array and Hash literals outside of loops into local variables or constants.
138
+ Performance/CollectionLiteralInLoop:
139
+ Enabled: true
140
+
141
+ # Prefer `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.
142
+ Performance/CompareWithBlock:
143
+ Enabled: true
144
+
145
+ # Use `count` instead of `{select,find_all,filter,reject}...{size,count,length}`.
146
+ Performance/Count:
147
+ Enabled: true
148
+
149
+ # Use `delete_prefix` instead of `gsub`.
150
+ Performance/DeletePrefix:
151
+ Enabled: true
152
+
153
+ # Use `delete_suffix` instead of `gsub`.
154
+ Performance/DeleteSuffix:
155
+ Enabled: true
156
+
157
+ # Use `detect` instead of `select.first`, `find_all.first`, `filter.first`, `select.last`, `find_all.last`, and `filter.last`.
158
+ Performance/Detect:
159
+ Enabled: true
160
+
161
+ # Use `str.{start,end}_with?(x, ..., y, ...)` instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
162
+ Performance/DoubleStartEndWith:
163
+ Enabled: true
164
+
165
+ # Use `end_with?` instead of a regex match anchored to the end of a string.
166
+ Performance/EndWith:
167
+ Enabled: true
168
+
169
+ # Do not compute the size of statically sized objects except in constants.
170
+ Performance/FixedSize:
171
+ Enabled: true
172
+
173
+ # Use `Enumerable#flat_map` instead of `Enumerable#map...Array#flatten(1).
174
+ Performance/FlatMap:
175
+ Enabled: true
176
+
177
+ # Use `key?` or `value?` instead of `keys.include?` or `values.include?`.
178
+ Performance/InefficientHashSearch:
179
+ Enabled: true
180
+
181
+ # Use `Range#cover?` instead of `Range#include?` (or `Range#member?`).
182
+ Performance/RangeInclude:
183
+ Enabled: true
184
+
185
+ # Use `yield` instead of `block.call`.
186
+ Performance/RedundantBlockCall:
187
+ Enabled: true
188
+
189
+ # Use `=~` instead of `String#match` or `Regexp#match` in a context where the returned `MatchData` is not needed.
190
+ Performance/RedundantMatch:
191
+ Enabled: true
192
+
193
+ # Use Hash#[]=, rather than Hash#merge! with a single key-value pair.
194
+ Performance/RedundantMerge:
195
+ Enabled: true
196
+
197
+ # Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===`, or `=~` when `MatchData` is not used.
198
+ Performance/RegexpMatch:
199
+ Enabled: true
200
+
201
+ # Use `reverse_each` instead of `reverse.each`.
202
+ Performance/ReverseEach:
203
+ Enabled: true
204
+
205
+ # Use `size` instead of `count` for counting the number of elements in `Array` and `Hash`.
206
+ Performance/Size:
207
+ Enabled: true
208
+
209
+ # Use `start_with?` instead of a regex match anchored to the beginning of a string.
210
+ Performance/StartWith:
211
+ Enabled: true
212
+
213
+ # Use `tr` instead of `gsub` when you are replacing the same number of characters.
214
+ # Use `delete` instead of `gsub` when you are deleting characters.
215
+ Performance/StringReplacement:
216
+ Enabled: true
217
+
218
+ # Checks for .times.map calls.
219
+ Performance/TimesMap:
220
+ Enabled: true
221
+
222
+ # Use unary plus to get an unfrozen string literal.
223
+ Performance/UnfreezeString:
224
+ Enabled: true
225
+
226
+ # Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.
227
+ Performance/UriDefaultParser:
228
+ Enabled: true