jetpacker 0.4.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +8 -8
- data/.github/workflows/jest.yml +38 -0
- data/.github/workflows/js-lint.yml +39 -0
- data/.github/workflows/rubocop.yml +39 -0
- data/.github/workflows/ruby.yml +58 -0
- data/.gitignore +1 -0
- data/.node-version +1 -1
- data/.rubocop.yml +113 -13
- data/.travis.yml +8 -21
- data/CHANGELOG.jetpacker.md +5 -0
- data/CHANGELOG.md +68 -2
- data/Gemfile +1 -0
- data/README.md +23 -649
- data/docs/css.md +58 -3
- data/docs/deployment.md +2 -2
- data/docs/docker.md +17 -17
- data/docs/engines.md +13 -0
- data/docs/env.md +0 -2
- data/docs/integrations.md +220 -0
- data/docs/target.md +22 -0
- data/docs/testing.md +2 -3
- data/docs/troubleshooting.md +3 -1
- data/docs/typescript.md +92 -28
- data/docs/webpack-dev-server.md +1 -1
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/jetpacker.gemspec +4 -3
- data/lib/install/config/babel.config.js +13 -3
- data/lib/install/config/webpacker.yml +1 -4
- data/lib/install/examples/react/babel.config.js +12 -0
- data/lib/install/examples/react/tsconfig.json +2 -1
- data/lib/install/examples/typescript/tsconfig.json +2 -1
- data/lib/install/loaders/svelte.js +2 -2
- data/lib/install/template.rb +11 -3
- data/lib/install/typescript.rb +6 -2
- data/lib/jetpacker/version.rb +1 -1
- data/lib/tasks/webpacker/check_node.rake +15 -8
- data/lib/tasks/webpacker/check_yarn.rake +16 -10
- data/lib/tasks/webpacker/clean.rake +12 -8
- data/lib/tasks/webpacker/clobber.rake +8 -4
- data/lib/tasks/webpacker/yarn_install.rake +11 -16
- data/lib/webpacker/commands.rb +33 -9
- data/lib/webpacker/compiler.rb +9 -5
- data/lib/webpacker/configuration.rb +28 -13
- data/lib/webpacker/dev_server_proxy.rb +3 -1
- data/lib/webpacker/dev_server_runner.rb +2 -2
- data/lib/webpacker/env.rb +5 -1
- data/lib/webpacker/helper.rb +37 -18
- data/lib/webpacker/manifest.rb +4 -4
- data/lib/webpacker/railtie.rb +0 -43
- data/lib/webpacker/runner.rb +1 -0
- data/lib/webpacker/turbine.rb +0 -41
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +2 -2
- data/package/__tests__/config.js +12 -1
- data/package/__tests__/dev_server.js +2 -0
- data/package/__tests__/development.js +14 -1
- data/package/config.js +4 -1
- data/package/configPath.js +3 -0
- data/package/dev_server.js +1 -1
- data/package/env.js +1 -2
- data/package/environments/__tests__/base.js +29 -2
- data/package/environments/base.js +17 -7
- data/package/environments/development.js +39 -37
- data/package/environments/production.js +1 -3
- data/package/rules/babel.js +12 -5
- data/package/rules/file.js +3 -2
- data/package/rules/node_modules.js +1 -3
- data/package/rules/sass.js +10 -1
- data/package/utils/helpers.js +1 -1
- data/package.json +41 -41
- data/test/compiler_test.rb +8 -3
- data/test/configuration_test.rb +8 -7
- data/test/dev_server_runner_test.rb +1 -1
- data/test/helper_test.rb +24 -9
- data/test/manifest_test.rb +37 -6
- data/test/rake_tasks_test.rb +11 -0
- data/test/test_app/app/javascript/packs/multi_entry.css +4 -0
- data/test/test_app/app/javascript/packs/multi_entry.js +4 -0
- data/test/test_app/config/application.rb +0 -1
- data/test/test_app/config/webpacker.yml +7 -1
- data/test/test_app/public/packs/manifest.json +1 -0
- data/test/webpack_runner_test.rb +1 -1
- data/yarn.lock +3895 -3945
- metadata +35 -15
- data/Gemfile.lock +0 -171
- data/gemfiles/Gemfile-rails.4.2.x +0 -9
- data/gemfiles/Gemfile-rails.5.0.x +0 -9
- data/gemfiles/Gemfile-rails.5.1.x +0 -9
- data/lib/install/loaders/typescript.js +0 -11
data/package/rules/babel.js
CHANGED
@@ -1,18 +1,25 @@
|
|
1
|
-
const {
|
2
|
-
const {
|
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, ...
|
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:
|
22
|
+
cacheDirectory: true,
|
16
23
|
cacheCompression: nodeEnv === 'production',
|
17
24
|
compact: nodeEnv === 'production'
|
18
25
|
}
|
data/package/rules/file.js
CHANGED
@@ -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:
|
15
|
+
cacheDirectory: true,
|
18
16
|
cacheCompression: nodeEnv === 'production',
|
19
17
|
compact: false,
|
20
18
|
sourceMaps: false
|
data/package/rules/sass.js
CHANGED
@@ -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: {
|
9
|
+
options: {
|
10
|
+
sourceMap: true,
|
11
|
+
implementation: require('sass'),
|
12
|
+
sassOptions: {
|
13
|
+
includePaths
|
14
|
+
}
|
15
|
+
}
|
7
16
|
}
|
8
17
|
])
|
data/package/utils/helpers.js
CHANGED
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rails/webpacker",
|
3
|
-
"version": "4.
|
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": ">=
|
12
|
-
"yarn": ">=1
|
11
|
+
"node": ">=10.17.0",
|
12
|
+
"yarn": ">=1 <4"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"@babel/core": "^7.
|
16
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
17
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
18
|
-
"@babel/plugin-syntax-dynamic-import": "^7.
|
19
|
-
"@babel/plugin-transform-destructuring": "^7.
|
20
|
-
"@babel/plugin-transform-regenerator": "^7.
|
21
|
-
"@babel/plugin-transform-runtime": "^7.
|
22
|
-
"@babel/preset-env": "^7.
|
23
|
-
"@babel/runtime": "^7.
|
24
|
-
"babel-loader": "^8.
|
25
|
-
"babel-plugin-dynamic-import-node": "^2.3.
|
26
|
-
"babel-plugin-macros": "^2.
|
27
|
-
"case-sensitive-paths-webpack-plugin": "^2.
|
28
|
-
"compression-webpack-plugin": "^
|
29
|
-
"core-js": "^3.
|
30
|
-
"css-loader": "^3.
|
31
|
-
"file-loader": "^
|
32
|
-
"flatted": "^2.
|
33
|
-
"glob": "^7.1.
|
34
|
-
"js-yaml": "^3.
|
35
|
-
"mini-css-extract-plugin": "^0.
|
36
|
-
"
|
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.
|
40
|
-
"postcss-flexbugs-fixes": "^4.1
|
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.
|
45
|
-
"regenerator-runtime": "^0.13.
|
46
|
-
"sass
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"webpack": "^4.
|
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.
|
51
|
+
"webpack-cli": "^3.3.12",
|
52
52
|
"webpack-sources": "^1.4.3"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
|
-
"eslint": "^
|
56
|
-
"eslint-config-airbnb": "^18.
|
57
|
-
"eslint-plugin-import": "^2.
|
58
|
-
"eslint-plugin-jsx-a11y": "^6.
|
59
|
-
"eslint-plugin-react": "^7.
|
60
|
-
"jest": "^
|
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?$",
|
data/test/compiler_test.rb
CHANGED
@@ -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/
|
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
|
|
data/test/configuration_test.rb
CHANGED
@@ -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
|
57
|
-
assert_equal @config.
|
56
|
+
def test_additional_paths
|
57
|
+
assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "app/elm"]
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
assert_equal @config.
|
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, [
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
155
|
+
]), true
|
141
156
|
end
|
142
157
|
end
|
data/test/manifest_test.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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
|
data/test/rake_tasks_test.rb
CHANGED
@@ -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
|
|
@@ -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
|
-
|
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",
|
data/test/webpack_runner_test.rb
CHANGED
@@ -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, [
|
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
|