jetpacker 0.4.2 → 0.6.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 (90) 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 +58 -0
  7. data/.gitignore +1 -0
  8. data/.node-version +1 -1
  9. data/.rubocop.yml +113 -13
  10. data/.travis.yml +8 -21
  11. data/CHANGELOG.jetpacker.md +5 -0
  12. data/CHANGELOG.md +68 -2
  13. data/Gemfile +1 -0
  14. data/README.md +23 -649
  15. data/docs/css.md +58 -3
  16. data/docs/deployment.md +2 -2
  17. data/docs/docker.md +17 -17
  18. data/docs/engines.md +13 -0
  19. data/docs/env.md +0 -2
  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 +3 -1
  24. data/docs/typescript.md +92 -28
  25. data/docs/webpack-dev-server.md +1 -1
  26. data/gemfiles/Gemfile-rails-edge +1 -1
  27. data/jetpacker.gemspec +4 -3
  28. data/lib/install/config/babel.config.js +13 -3
  29. data/lib/install/config/webpacker.yml +1 -4
  30. data/lib/install/examples/react/babel.config.js +12 -0
  31. data/lib/install/examples/react/tsconfig.json +2 -1
  32. data/lib/install/examples/typescript/tsconfig.json +2 -1
  33. data/lib/install/loaders/svelte.js +2 -2
  34. data/lib/install/template.rb +11 -3
  35. data/lib/install/typescript.rb +6 -2
  36. data/lib/jetpacker/version.rb +1 -1
  37. data/lib/tasks/webpacker/check_node.rake +15 -8
  38. data/lib/tasks/webpacker/check_yarn.rake +16 -10
  39. data/lib/tasks/webpacker/clean.rake +12 -8
  40. data/lib/tasks/webpacker/clobber.rake +8 -4
  41. data/lib/tasks/webpacker/yarn_install.rake +11 -16
  42. data/lib/webpacker/commands.rb +33 -9
  43. data/lib/webpacker/compiler.rb +9 -5
  44. data/lib/webpacker/configuration.rb +28 -13
  45. data/lib/webpacker/dev_server_proxy.rb +3 -1
  46. data/lib/webpacker/dev_server_runner.rb +2 -2
  47. data/lib/webpacker/env.rb +5 -1
  48. data/lib/webpacker/helper.rb +37 -18
  49. data/lib/webpacker/manifest.rb +4 -4
  50. data/lib/webpacker/railtie.rb +0 -43
  51. data/lib/webpacker/runner.rb +1 -0
  52. data/lib/webpacker/turbine.rb +0 -41
  53. data/lib/webpacker/version.rb +1 -1
  54. data/lib/webpacker/webpack_runner.rb +2 -2
  55. data/package/__tests__/config.js +12 -1
  56. data/package/__tests__/dev_server.js +2 -0
  57. data/package/__tests__/development.js +14 -1
  58. data/package/config.js +4 -1
  59. data/package/configPath.js +3 -0
  60. data/package/dev_server.js +1 -1
  61. data/package/env.js +1 -2
  62. data/package/environments/__tests__/base.js +29 -2
  63. data/package/environments/base.js +17 -7
  64. data/package/environments/development.js +39 -37
  65. data/package/environments/production.js +1 -3
  66. data/package/rules/babel.js +12 -5
  67. data/package/rules/file.js +3 -2
  68. data/package/rules/node_modules.js +1 -3
  69. data/package/rules/sass.js +10 -1
  70. data/package/utils/helpers.js +1 -1
  71. data/package.json +41 -41
  72. data/test/compiler_test.rb +8 -3
  73. data/test/configuration_test.rb +8 -7
  74. data/test/dev_server_runner_test.rb +1 -1
  75. data/test/helper_test.rb +24 -9
  76. data/test/manifest_test.rb +37 -6
  77. data/test/rake_tasks_test.rb +11 -0
  78. data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
  79. data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
  80. data/test/test_app/config/application.rb +0 -1
  81. data/test/test_app/config/webpacker.yml +7 -1
  82. data/test/test_app/public/packs/manifest.json +1 -0
  83. data/test/webpack_runner_test.rb +1 -1
  84. data/yarn.lock +3895 -3945
  85. metadata +35 -15
  86. data/Gemfile.lock +0 -171
  87. data/gemfiles/Gemfile-rails.4.2.x +0 -9
  88. data/gemfiles/Gemfile-rails.5.0.x +0 -9
  89. data/gemfiles/Gemfile-rails.5.1.x +0 -9
  90. data/lib/install/loaders/typescript.js +0 -11
@@ -1,18 +1,25 @@
1
- const { join, resolve } = require('path')
2
- const { cache_path: cachePath, source_path: sourcePath, resolved_paths: resolvedPaths } = require('../config')
1
+ const { resolve } = require('path')
2
+ const { realpathSync } = require('fs')
3
+ const { source_path: sourcePath, additional_paths: additionalPaths } = require('../config')
3
4
  const { nodeEnv } = require('../env')
4
5
 
5
6
  // Process application Javascript code with Babel.
6
7
  // Uses application .babelrc to apply any transformations
7
8
  module.exports = {
8
- test: /\.(js|jsx|mjs)?(\.erb)?$/,
9
- include: [sourcePath, ...resolvedPaths].map((p) => resolve(p)),
9
+ test: /\.(js|jsx|mjs|ts|tsx)?(\.erb)?$/,
10
+ include: [sourcePath, ...additionalPaths].map((p) => {
11
+ try {
12
+ return realpathSync(p)
13
+ } catch (e) {
14
+ return resolve(p)
15
+ }
16
+ }),
10
17
  exclude: /node_modules/,
11
18
  use: [
12
19
  {
13
20
  loader: 'babel-loader',
14
21
  options: {
15
- cacheDirectory: join(cachePath, 'babel-loader-node-modules'),
22
+ cacheDirectory: true,
16
23
  cacheCompression: nodeEnv === 'production',
17
24
  compact: nodeEnv === 'production'
18
25
  }
@@ -1,4 +1,4 @@
1
- const { join } = require('path')
1
+ const { join, normalize } = require('path')
2
2
  const { source_path: sourcePath, static_assets_extensions: fileExtensions } = require('../config')
3
3
 
4
4
  module.exports = {
@@ -8,11 +8,12 @@ module.exports = {
8
8
  loader: 'file-loader',
9
9
  options: {
10
10
  name(file) {
11
- if (file.includes(sourcePath)) {
11
+ if (file.includes(normalize(sourcePath))) {
12
12
  return 'media/[path][name]-[hash].[ext]'
13
13
  }
14
14
  return 'media/[folder]/[name]-[hash:8].[ext]'
15
15
  },
16
+ esModule: false,
16
17
  context: join(sourcePath)
17
18
  }
18
19
  }
@@ -1,5 +1,3 @@
1
- const { join } = require('path')
2
- const { cache_path: cachePath } = require('../config')
3
1
  const { nodeEnv } = require('../env')
4
2
 
5
3
  // Compile standard ES features for JS in node_modules with Babel.
@@ -14,7 +12,7 @@ module.exports = {
14
12
  options: {
15
13
  babelrc: false,
16
14
  presets: [['@babel/preset-env', { modules: false }]],
17
- cacheDirectory: join(cachePath, 'babel-loader-node-modules'),
15
+ cacheDirectory: true,
18
16
  cacheCompression: nodeEnv === 'production',
19
17
  compact: false,
20
18
  sourceMaps: false
@@ -1,8 +1,17 @@
1
+ /* eslint global-require: 0 */
2
+
1
3
  const getStyleRule = require('../utils/get_style_rule')
4
+ const { additional_paths: includePaths } = require('../config')
2
5
 
3
6
  module.exports = getStyleRule(/\.(scss|sass)(\.erb)?$/i, false, [
4
7
  {
5
8
  loader: 'sass-loader',
6
- options: { sourceMap: true }
9
+ options: {
10
+ sourceMap: true,
11
+ implementation: require('sass'),
12
+ sassOptions: {
13
+ includePaths
14
+ }
15
+ }
7
16
  }
8
17
  ])
@@ -1,4 +1,4 @@
1
- const { stringify } = require('flatted/cjs')
1
+ const { stringify } = require('flatted')
2
2
 
3
3
  const isObject = (value) => typeof value === 'object'
4
4
  && value !== null
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "4.2.2",
3
+ "version": "5.4.3",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -8,56 +8,56 @@
8
8
  "lib/install/config/webpacker.yml"
9
9
  ],
10
10
  "engines": {
11
- "node": ">=8.16.0",
12
- "yarn": ">=1.0.0"
11
+ "node": ">=10.17.0",
12
+ "yarn": ">=1 <4"
13
13
  },
14
14
  "dependencies": {
15
- "@babel/core": "^7.7.2",
16
- "@babel/plugin-proposal-class-properties": "^7.7.0",
17
- "@babel/plugin-proposal-object-rest-spread": "^7.6.2",
18
- "@babel/plugin-syntax-dynamic-import": "^7.2.0",
19
- "@babel/plugin-transform-destructuring": "^7.6.0",
20
- "@babel/plugin-transform-regenerator": "^7.7.0",
21
- "@babel/plugin-transform-runtime": "^7.6.2",
22
- "@babel/preset-env": "^7.7.1",
23
- "@babel/runtime": "^7.7.2",
24
- "babel-loader": "^8.0.6",
25
- "babel-plugin-dynamic-import-node": "^2.3.0",
26
- "babel-plugin-macros": "^2.6.1",
27
- "case-sensitive-paths-webpack-plugin": "^2.2.0",
28
- "compression-webpack-plugin": "^3.0.1",
29
- "core-js": "^3.4.0",
30
- "css-loader": "^3.2.0",
31
- "file-loader": "^4.2.0",
32
- "flatted": "^2.0.1",
33
- "glob": "^7.1.6",
34
- "js-yaml": "^3.13.1",
35
- "mini-css-extract-plugin": "^0.8.0",
36
- "node-sass": "^4.13.0",
37
- "optimize-css-assets-webpack-plugin": "^5.0.3",
15
+ "@babel/core": "^7.15.0",
16
+ "@babel/plugin-proposal-class-properties": "^7.14.5",
17
+ "@babel/plugin-proposal-object-rest-spread": "^7.14.7",
18
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
19
+ "@babel/plugin-transform-destructuring": "^7.14.7",
20
+ "@babel/plugin-transform-regenerator": "^7.14.5",
21
+ "@babel/plugin-transform-runtime": "^7.15.0",
22
+ "@babel/preset-env": "^7.15.0",
23
+ "@babel/runtime": "^7.15.3",
24
+ "babel-loader": "^8.2.2",
25
+ "babel-plugin-dynamic-import-node": "^2.3.3",
26
+ "babel-plugin-macros": "^2.8.0",
27
+ "case-sensitive-paths-webpack-plugin": "^2.4.0",
28
+ "compression-webpack-plugin": "^4.0.1",
29
+ "core-js": "^3.16.2",
30
+ "css-loader": "^3.6.0",
31
+ "file-loader": "^6.2.0",
32
+ "flatted": "^3.2.2",
33
+ "glob": "^7.1.7",
34
+ "js-yaml": "^3.14.1",
35
+ "mini-css-extract-plugin": "^0.9.0",
36
+ "optimize-css-assets-webpack-plugin": "^5.0.8",
38
37
  "path-complete-extname": "^1.0.0",
39
- "pnp-webpack-plugin": "^1.5.0",
40
- "postcss-flexbugs-fixes": "^4.1.0",
38
+ "pnp-webpack-plugin": "^1.7.0",
39
+ "postcss-flexbugs-fixes": "^4.2.1",
41
40
  "postcss-import": "^12.0.1",
42
41
  "postcss-loader": "^3.0.0",
43
42
  "postcss-preset-env": "^6.7.0",
44
- "postcss-safe-parser": "^4.0.1",
45
- "regenerator-runtime": "^0.13.3",
46
- "sass-loader": "7.3.1",
47
- "style-loader": "^1.0.0",
48
- "terser-webpack-plugin": "^2.3.1",
49
- "webpack": "^4.41.3",
43
+ "postcss-safe-parser": "^4.0.2",
44
+ "regenerator-runtime": "^0.13.9",
45
+ "sass": "^1.38.0",
46
+ "sass-loader": "10.1.1",
47
+ "style-loader": "^1.3.0",
48
+ "terser-webpack-plugin": "^4.2.3",
49
+ "webpack": "^4.46.0",
50
50
  "webpack-assets-manifest": "^3.1.1",
51
- "webpack-cli": "^3.3.10",
51
+ "webpack-cli": "^3.3.12",
52
52
  "webpack-sources": "^1.4.3"
53
53
  },
54
54
  "devDependencies": {
55
- "eslint": "^6.6.0",
56
- "eslint-config-airbnb": "^18.0.1",
57
- "eslint-plugin-import": "^2.18.2",
58
- "eslint-plugin-jsx-a11y": "^6.2.3",
59
- "eslint-plugin-react": "^7.16.0",
60
- "jest": "^24.9.0"
55
+ "eslint": "^7.32.0",
56
+ "eslint-config-airbnb": "^18.2.1",
57
+ "eslint-plugin-import": "^2.24.0",
58
+ "eslint-plugin-jsx-a11y": "^6.4.1",
59
+ "eslint-plugin-react": "^7.24.0",
60
+ "jest": "^27.0.6"
61
61
  },
62
62
  "jest": {
63
63
  "testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
@@ -25,9 +25,10 @@ class CompilerTest < Minitest::Test
25
25
 
26
26
  def test_default_watched_paths
27
27
  assert_equal Webpacker.compiler.send(:default_watched_paths), [
28
- "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}",
29
- "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}",
30
- "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}",
28
+ "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
29
+ "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
30
+ "app/elm/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
31
+ "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
31
32
  "yarn.lock",
32
33
  "package.json",
33
34
  "config/webpack/**/*"
@@ -39,6 +40,10 @@ class CompilerTest < Minitest::Test
39
40
  assert !Webpacker.compiler.fresh?
40
41
  end
41
42
 
43
+ def test_compile
44
+ assert !Webpacker.compiler.compile
45
+ end
46
+
42
47
  def test_freshness_on_compile_success
43
48
  status = OpenStruct.new(success?: true)
44
49
 
@@ -16,7 +16,7 @@ class ConfigurationTest < Webpacker::Test
16
16
 
17
17
  def test_source_path_globbed
18
18
  assert_equal @config.source_path_globbed,
19
- "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}"
19
+ "app/javascript/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
20
20
  end
21
21
 
22
22
  def test_source_entry_path
@@ -53,14 +53,15 @@ class ConfigurationTest < Webpacker::Test
53
53
  assert_equal @config.cache_path.to_s, cache_path
54
54
  end
55
55
 
56
- def test_resolved_paths
57
- assert_equal @config.resolved_paths, ["app/assets", "/etc/yarn"]
56
+ def test_additional_paths
57
+ assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "app/elm"]
58
58
  end
59
59
 
60
- def test_resolved_paths_globbed
61
- assert_equal @config.resolved_paths_globbed, [
62
- "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}",
63
- "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg}"
60
+ def test_additional_paths_globbed
61
+ assert_equal @config.additional_paths_globbed, [
62
+ "app/assets/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
63
+ "/etc/yarn/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}",
64
+ "app/elm/**/*{.mjs,.js,.sass,.scss,.css,.module.sass,.module.scss,.module.css,.png,.svg,.gif,.jpeg,.jpg,.elm}"
64
65
  ]
65
66
  end
66
67
 
@@ -36,7 +36,7 @@ class DevServerRunnerTest < Webpacker::Test
36
36
  klass = Webpacker::DevServerRunner
37
37
  instance = klass.new([])
38
38
  mock = Minitest::Mock.new
39
- mock.expect(:call, nil, [{}, *cmd])
39
+ mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
40
 
41
41
  klass.stub(:new, instance) do
42
42
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
data/test/helper_test.rb CHANGED
@@ -50,6 +50,9 @@ class HelperTest < ActionView::TestCase
50
50
  assert_equal \
51
51
  "<img alt=\"Edit Entry\" src=\"/packs/media/images/nested/image-c38deda30895059837cf.jpg\" width=\"16\" height=\"10\" />",
52
52
  image_pack_tag("media/images/nested/image.jpg", size: "16x10", alt: "Edit Entry")
53
+ assert_equal \
54
+ "<img srcset=\"/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg 2x\" src=\"/packs/media/images/image-c38deda30895059837cf.jpg\" />",
55
+ image_pack_tag("media/images/image.jpg", srcset: { "media/images/image-2x.jpg" => "2x" })
53
56
  end
54
57
 
55
58
  def test_favicon_pack_tag
@@ -114,29 +117,41 @@ class HelperTest < ActionView::TestCase
114
117
  end
115
118
 
116
119
  def test_stylesheet_pack_tag_split_chunks
117
- assert_equal \
118
- %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
120
+ assert_equal stylesheet_packs_with_chunks_tag("application", "hello_stimulus").in?([
121
+ %(<link rel="stylesheet" href="/packs/1-c20632e7baf2c81200d3.chunk.css" media="screen" />\n) +
122
+ %(<link rel="stylesheet" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" media="screen" />\n) +
123
+ %(<link rel="stylesheet" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" media="screen" />),
124
+
125
+ %(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
119
126
  %(<link rel="stylesheet" media="screen" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" />\n) +
120
127
  %(<link rel="stylesheet" media="screen" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" />),
121
- stylesheet_packs_with_chunks_tag("application", "hello_stimulus")
128
+ ]),
129
+ true
122
130
  end
123
131
 
124
132
  def test_stylesheet_pack_tag
125
- assert_equal \
133
+ assert_equal stylesheet_pack_tag("bootstrap.css").in?([
134
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
135
+
126
136
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
127
- stylesheet_pack_tag("bootstrap.css")
137
+ ]), true
128
138
  end
129
139
 
130
140
  def test_stylesheet_pack_tag_symbol
131
- assert_equal \
141
+ assert_equal stylesheet_pack_tag(:bootstrap).in?([
142
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),
143
+
132
144
  %(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
133
- stylesheet_pack_tag(:bootstrap)
145
+ ]), true
134
146
  end
135
147
 
136
148
  def test_stylesheet_pack_tag_splat
137
- assert_equal \
149
+ assert_equal stylesheet_pack_tag("bootstrap.css", "application.css", media: "all").in?([
150
+ %(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="all" />\n) +
151
+ %(<link rel="stylesheet" href="/packs/application-dd6b1cd38bfa093df600.css" media="all" />),
152
+
138
153
  %(<link rel="stylesheet" media="all" href="/packs/bootstrap-c38deda30895059837cf.css" />\n) +
139
154
  %(<link rel="stylesheet" media="all" href="/packs/application-dd6b1cd38bfa093df600.css" />),
140
- stylesheet_pack_tag("bootstrap.css", "application.css", media: "all")
155
+ ]), true
141
156
  end
142
157
  end
@@ -2,16 +2,23 @@ require "test_helper"
2
2
 
3
3
  class ManifestTest < Minitest::Test
4
4
  def test_lookup_exception!
5
- manifest_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
6
5
  asset_file = "calendar.js"
7
6
 
8
- Webpacker.config.stub :compile?, false do
9
- error = assert_raises Webpacker::Manifest::MissingEntryError do
10
- Webpacker.manifest.lookup!(asset_file)
11
- end
7
+ error = assert_raises_manifest_missing_entry_error do
8
+ Webpacker.manifest.lookup!(asset_file)
9
+ end
10
+
11
+ assert_match "Webpacker can't find #{asset_file} in #{manifest_path}", error.message
12
+ end
13
+
14
+ def test_lookup_with_type_exception!
15
+ asset_file = "calendar"
12
16
 
13
- assert_match "Webpacker can't find #{asset_file} in #{manifest_path}", error.message
17
+ error = assert_raises_manifest_missing_entry_error do
18
+ Webpacker.manifest.lookup!(asset_file, type: :javascript)
14
19
  end
20
+
21
+ assert_match "Webpacker can't find #{asset_file}.js in #{manifest_path}", error.message
15
22
  end
16
23
 
17
24
  def test_lookup_success!
@@ -30,6 +37,16 @@ class ManifestTest < Minitest::Test
30
37
  assert_equal Webpacker.manifest.lookup("bootstrap.js"), "/packs/bootstrap-300631c4f0e0f9c865bc.js"
31
38
  end
32
39
 
40
+ def test_lookup_entrypoint_exception!
41
+ asset_file = "calendar"
42
+
43
+ error = assert_raises_manifest_missing_entry_error do
44
+ Webpacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
45
+ end
46
+
47
+ assert_match "Webpacker can't find #{asset_file}.js in #{manifest_path}", error.message
48
+ end
49
+
33
50
  def test_lookup_entrypoint
34
51
  application_entrypoints = [
35
52
  "/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js",
@@ -39,4 +56,18 @@ class ManifestTest < Minitest::Test
39
56
 
40
57
  assert_equal Webpacker.manifest.lookup_pack_with_chunks!("application", type: :javascript), application_entrypoints
41
58
  end
59
+
60
+ private
61
+
62
+ def assert_raises_manifest_missing_entry_error(&block)
63
+ error = nil
64
+ Webpacker.config.stub :compile?, false do
65
+ error = assert_raises Webpacker::Manifest::MissingEntryError, &block
66
+ end
67
+ error
68
+ end
69
+
70
+ def manifest_path
71
+ File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs", "manifest.json").to_s
72
+ end
42
73
  end
@@ -28,6 +28,17 @@ class RakeTasksTest < Minitest::Test
28
28
  refute_includes output, "webpack binstubs not found."
29
29
  end
30
30
 
31
+ def test_check_node_version
32
+ output = Dir.chdir(test_app_path) { `rake webpacker:check_node 2>&1` }
33
+ refute_includes output, "Webpacker requires Node.js"
34
+ end
35
+
36
+ def test_check_yarn_version
37
+ output = Dir.chdir(test_app_path) { `rake webpacker:check_yarn 2>&1` }
38
+ refute_includes output, "Yarn not installed"
39
+ refute_includes output, "Webpacker requires Yarn"
40
+ end
41
+
31
42
  def test_rake_webpacker_yarn_install_in_non_production_environments
32
43
  assert_includes test_app_dev_dependencies, "right-pad"
33
44
 
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Dummy file #1 for Multi File Entry points: https://webpack.js.org/guides/entry-advanced/
3
+ * This file must be named the same
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ * Dummy file #2 for Multi File Entry points: https://webpack.js.org/guides/entry-advanced/
3
+ * This file must be named the same
4
+ */
@@ -6,7 +6,6 @@ module TestApp
6
6
  class Application < ::Rails::Application
7
7
  config.secret_key_base = "abcdef"
8
8
  config.eager_load = true
9
- config.webpacker.check_yarn_integrity = false
10
9
  config.active_support.test_order = :sorted
11
10
  end
12
11
  end
@@ -10,10 +10,15 @@ default: &default
10
10
 
11
11
  # Additional paths webpack should lookup modules
12
12
  # ['app/assets', 'engine/foo/app/assets']
13
- resolved_paths:
13
+ additional_paths:
14
14
  - app/assets
15
15
  - /etc/yarn
16
16
 
17
+ # This configuration option is deprecated and is only here for testing, to
18
+ # ensure backwards-compatibility. Please use `additional_paths`.
19
+ resolved_paths:
20
+ - app/elm
21
+
17
22
  # Reload manifest.json on all requests so we reload latest compiled packs
18
23
  cache_manifest: false
19
24
 
@@ -43,6 +48,7 @@ default: &default
43
48
  - .gif
44
49
  - .jpeg
45
50
  - .jpg
51
+ - .elm
46
52
 
47
53
  development:
48
54
  <<: *default
@@ -6,6 +6,7 @@
6
6
  "application.png": "/packs/application-k344a6d59eef8632c9d1.png",
7
7
  "fonts/fa-regular-400.woff2": "/packs/fonts/fa-regular-400-944fb546bd7018b07190a32244f67dc9.woff2",
8
8
  "media/images/image.jpg": "/packs/media/images/image-c38deda30895059837cf.jpg",
9
+ "media/images/image-2x.jpg": "/packs/media/images/image-2x-7cca48e6cae66ec07b8e.jpg",
9
10
  "media/images/nested/image.jpg": "/packs/media/images/nested/image-c38deda30895059837cf.jpg",
10
11
  "media/images/mb-icon.png": "/packs/media/images/mb-icon-c38deda30895059837cf.png",
11
12
  "media/images/nested/mb-icon.png": "/packs/media/images/nested/mb-icon-c38deda30895059837cf.png",
@@ -36,7 +36,7 @@ class WebpackRunnerTest < Webpacker::Test
36
36
  klass = Webpacker::WebpackRunner
37
37
  instance = klass.new([])
38
38
  mock = Minitest::Mock.new
39
- mock.expect(:call, nil, [{}, *cmd])
39
+ mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
40
40
 
41
41
  klass.stub(:new, instance) do
42
42
  instance.stub(:node_modules_bin_exist?, use_node_modules) do