webpacker 4.0.7 → 5.4.4
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 +46 -0
- data/.node-version +1 -1
- data/.rubocop.yml +118 -14
- data/CHANGELOG.md +301 -138
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +123 -92
- data/README.md +86 -211
- data/docs/css.md +72 -6
- data/docs/deployment.md +40 -11
- data/docs/docker.md +33 -14
- data/docs/engines.md +53 -3
- data/docs/env.md +0 -2
- data/docs/es6.md +19 -1
- data/docs/integrations.md +220 -0
- data/docs/target.md +22 -0
- data/docs/testing.md +2 -3
- data/docs/troubleshooting.md +39 -9
- data/docs/typescript.md +93 -26
- data/docs/webpack-dev-server.md +2 -2
- data/docs/webpack.md +18 -3
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/gemfiles/{Gemfile-rails.4.2.x → Gemfile-rails.6.0.x} +1 -1
- data/lib/install/bin/webpack +0 -1
- data/lib/install/bin/webpack-dev-server +0 -1
- data/lib/install/coffee.rb +1 -1
- data/lib/install/config/babel.config.js +23 -13
- data/lib/install/config/webpacker.yml +3 -6
- data/lib/install/elm.rb +1 -1
- data/lib/install/erb.rb +2 -2
- data/lib/install/examples/angular/hello_angular/polyfills.ts +2 -2
- data/lib/install/examples/react/babel.config.js +28 -14
- data/lib/install/examples/react/tsconfig.json +2 -1
- data/lib/install/examples/svelte/app.svelte +11 -0
- data/lib/install/examples/svelte/hello_svelte.js +20 -0
- data/lib/install/examples/typescript/tsconfig.json +2 -1
- data/lib/install/loaders/elm.js +9 -6
- data/lib/install/loaders/svelte.js +9 -0
- data/lib/install/svelte.rb +29 -0
- data/lib/install/template.rb +14 -6
- data/lib/install/typescript.rb +6 -13
- data/lib/install/vue.rb +1 -1
- data/lib/tasks/installers.rake +1 -0
- data/lib/tasks/webpacker/check_node.rake +15 -8
- data/lib/tasks/webpacker/check_yarn.rake +16 -10
- data/lib/tasks/webpacker/clean.rake +25 -0
- data/lib/tasks/webpacker/clobber.rake +8 -4
- data/lib/tasks/webpacker/compile.rake +2 -10
- data/lib/tasks/webpacker/yarn_install.rake +11 -1
- data/lib/tasks/webpacker.rake +2 -0
- data/lib/webpacker/commands.rb +53 -1
- data/lib/webpacker/compiler.rb +21 -10
- data/lib/webpacker/configuration.rb +36 -13
- data/lib/webpacker/dev_server.rb +1 -1
- data/lib/webpacker/dev_server_proxy.rb +5 -9
- data/lib/webpacker/dev_server_runner.rb +6 -6
- data/lib/webpacker/env.rb +6 -2
- data/lib/webpacker/helper.rb +70 -25
- data/lib/webpacker/manifest.rb +4 -4
- data/lib/webpacker/railtie.rb +6 -43
- data/lib/webpacker/runner.rb +1 -0
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +2 -2
- data/lib/webpacker.rb +9 -1
- data/package/__tests__/config.js +12 -24
- data/package/__tests__/dev_server.js +2 -0
- data/package/__tests__/development.js +14 -1
- data/package/config.js +6 -11
- data/package/configPath.js +3 -0
- data/package/config_types/config_list.js +3 -3
- data/package/config_types/config_object.js +1 -1
- 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 +18 -8
- data/package/environments/development.js +39 -37
- data/package/environments/production.js +12 -2
- data/package/rules/babel.js +12 -5
- data/package/rules/file.js +3 -2
- data/package/rules/node_modules.js +3 -5
- data/package/rules/sass.js +11 -2
- data/package/utils/__tests__/get_style_rule.js +9 -0
- data/package/utils/deep_merge.js +5 -5
- data/package/utils/get_style_rule.js +7 -12
- data/package/utils/helpers.js +10 -10
- data/package.json +43 -43
- data/test/command_test.rb +6 -0
- data/test/compiler_test.rb +10 -6
- data/test/configuration_test.rb +40 -30
- data/test/dev_server_runner_test.rb +1 -1
- data/test/dev_server_test.rb +22 -0
- data/test/helper_test.rb +58 -9
- data/test/manifest_test.rb +37 -6
- data/test/rake_tasks_test.rb +17 -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/bin/webpack +0 -1
- data/test/test_app/bin/webpack-dev-server +0 -1
- data/test/test_app/config/application.rb +0 -1
- data/test/test_app/config/webpacker.yml +8 -1
- data/test/test_app/public/packs/manifest.json +4 -0
- data/test/webpack_runner_test.rb +1 -1
- data/webpacker.gemspec +6 -4
- data/yarn.lock +4350 -4099
- metadata +63 -23
- data/.travis.yml +0 -53
- 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
@@ -7,45 +7,47 @@ module.exports = class extends Base {
|
|
7
7
|
constructor() {
|
8
8
|
super()
|
9
9
|
|
10
|
-
if (devServer.hmr) {
|
11
|
-
this.plugins.append('HotModuleReplacement', new webpack.HotModuleReplacementPlugin())
|
12
|
-
this.config.output.filename = '[name]-[hash].js'
|
13
|
-
}
|
14
|
-
|
15
10
|
this.config.merge({
|
16
11
|
mode: 'development',
|
17
|
-
|
18
|
-
devtool: 'cheap-module-source-map',
|
19
|
-
output: {
|
20
|
-
pathinfo: true
|
21
|
-
},
|
22
|
-
devServer: {
|
23
|
-
clientLogLevel: 'none',
|
24
|
-
compress: devServer.compress,
|
25
|
-
quiet: devServer.quiet,
|
26
|
-
disableHostCheck: devServer.disable_host_check,
|
27
|
-
host: devServer.host,
|
28
|
-
port: devServer.port,
|
29
|
-
https: devServer.https,
|
30
|
-
hot: devServer.hmr,
|
31
|
-
contentBase,
|
32
|
-
inline: devServer.inline,
|
33
|
-
useLocalIp: devServer.use_local_ip,
|
34
|
-
public: devServer.public,
|
35
|
-
publicPath,
|
36
|
-
historyApiFallback: {
|
37
|
-
disableDotRule: true
|
38
|
-
},
|
39
|
-
headers: devServer.headers,
|
40
|
-
overlay: devServer.overlay,
|
41
|
-
stats: {
|
42
|
-
entrypoints: false,
|
43
|
-
errorDetails: false,
|
44
|
-
modules: false,
|
45
|
-
moduleTrace: false
|
46
|
-
},
|
47
|
-
watchOptions: devServer.watch_options
|
48
|
-
}
|
12
|
+
devtool: 'cheap-module-source-map'
|
49
13
|
})
|
14
|
+
|
15
|
+
if (process.env.WEBPACK_DEV_SERVER
|
16
|
+
&& process.env.WEBPACK_DEV_SERVER !== 'undefined') {
|
17
|
+
if (devServer.hmr) {
|
18
|
+
this.plugins.append('HotModuleReplacement', new webpack.HotModuleReplacementPlugin())
|
19
|
+
this.config.output.filename = '[name]-[hash].js'
|
20
|
+
}
|
21
|
+
|
22
|
+
this.config.merge({
|
23
|
+
devServer: {
|
24
|
+
clientLogLevel: 'none',
|
25
|
+
compress: devServer.compress,
|
26
|
+
quiet: devServer.quiet,
|
27
|
+
disableHostCheck: devServer.disable_host_check,
|
28
|
+
host: devServer.host,
|
29
|
+
port: devServer.port,
|
30
|
+
https: devServer.https,
|
31
|
+
hot: devServer.hmr,
|
32
|
+
contentBase,
|
33
|
+
inline: devServer.inline,
|
34
|
+
useLocalIp: devServer.use_local_ip,
|
35
|
+
public: devServer.public,
|
36
|
+
publicPath,
|
37
|
+
historyApiFallback: {
|
38
|
+
disableDotRule: true
|
39
|
+
},
|
40
|
+
headers: devServer.headers,
|
41
|
+
overlay: devServer.overlay,
|
42
|
+
stats: {
|
43
|
+
entrypoints: false,
|
44
|
+
errorDetails: true,
|
45
|
+
modules: false,
|
46
|
+
moduleTrace: false
|
47
|
+
},
|
48
|
+
watchOptions: devServer.watch_options
|
49
|
+
}
|
50
|
+
})
|
51
|
+
}
|
50
52
|
}
|
51
53
|
}
|
@@ -13,11 +13,21 @@ module.exports = class extends Base {
|
|
13
13
|
new CompressionPlugin({
|
14
14
|
filename: '[path].gz[query]',
|
15
15
|
algorithm: 'gzip',
|
16
|
-
cache: true,
|
17
16
|
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
|
18
17
|
})
|
19
18
|
)
|
20
19
|
|
20
|
+
if ('brotli' in process.versions) {
|
21
|
+
this.plugins.append(
|
22
|
+
'Compression Brotli',
|
23
|
+
new CompressionPlugin({
|
24
|
+
filename: '[path].br[query]',
|
25
|
+
algorithm: 'brotliCompress',
|
26
|
+
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
|
27
|
+
})
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
21
31
|
this.plugins.append(
|
22
32
|
'OptimizeCSSAssets',
|
23
33
|
new OptimizeCSSAssetsPlugin({
|
@@ -36,7 +46,7 @@ module.exports = class extends Base {
|
|
36
46
|
optimization: {
|
37
47
|
minimizer: [
|
38
48
|
new TerserPlugin({
|
39
|
-
parallel: true,
|
49
|
+
parallel: Number.parseInt(process.env.WEBPACKER_PARALLEL, 10) || true,
|
40
50
|
cache: true,
|
41
51
|
sourceMap: true,
|
42
52
|
terserOptions: {
|
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,20 +1,18 @@
|
|
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.
|
6
|
-
// Regex details for exclude: https://regex101.com/r/
|
4
|
+
// Regex details for exclude: https://regex101.com/r/SKPnnv/1
|
7
5
|
module.exports = {
|
8
6
|
test: /\.(js|mjs)$/,
|
9
7
|
include: /node_modules/,
|
10
|
-
exclude: /(?:@?babel(?:\/|\\{1,2}|-).+)|regenerator-runtime|core-js
|
8
|
+
exclude: /(?:@?babel(?:\/|\\{1,2}|-).+)|regenerator-runtime|core-js|^webpack$|^webpack-assets-manifest$|^webpack-cli$|^webpack-sources$|^@rails\/webpacker$/,
|
11
9
|
use: [
|
12
10
|
{
|
13
11
|
loader: 'babel-loader',
|
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
|
-
module.exports = getStyleRule(/\.(scss|sass)
|
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
|
])
|
@@ -44,6 +44,15 @@ describe('getStyleRule', () => {
|
|
44
44
|
expect(cssRule.use).toMatchObject(expect.arrayContaining(expectation))
|
45
45
|
})
|
46
46
|
|
47
|
+
test('adds style-loader when extract_css is true', () => {
|
48
|
+
const expectation = [{loader: 'style-loader'}]
|
49
|
+
|
50
|
+
require('../../config').extract_css = false
|
51
|
+
const cssRule = getStyleRule(/\.(css)$/i)
|
52
|
+
|
53
|
+
expect(cssRule.use).toMatchObject(expect.objectContaining(expectation))
|
54
|
+
})
|
55
|
+
|
47
56
|
test(`doesn't add mini-css-extract-plugin when extract_css is false`, () => {
|
48
57
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
49
58
|
const expectation = [MiniCssExtractPlugin.loader]
|
data/package/utils/deep_merge.js
CHANGED
@@ -10,11 +10,11 @@ const deepMerge = (target, source) => {
|
|
10
10
|
if (!(isObject(target) && isObject(source))) return source
|
11
11
|
|
12
12
|
return [...Object.keys(target), ...Object.keys(source)].reduce(
|
13
|
-
(result, key) => (
|
14
|
-
|
15
|
-
result,
|
16
|
-
|
17
|
-
)
|
13
|
+
(result, key) => ({
|
14
|
+
|
15
|
+
...result,
|
16
|
+
[key]: deepMerge(target[key], source[key])
|
17
|
+
}),
|
18
18
|
{}
|
19
19
|
)
|
20
20
|
}
|
@@ -1,17 +1,9 @@
|
|
1
1
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
2
2
|
const { resolve } = require('path')
|
3
|
-
const devServer = require('../dev_server')
|
4
3
|
const config = require('../config')
|
5
4
|
|
6
|
-
const inDevServer = process.argv.find(v => v.includes('webpack-dev-server'))
|
7
|
-
const isHMR = inDevServer && (devServer && devServer.hmr)
|
8
|
-
|
9
5
|
const styleLoader = {
|
10
|
-
loader: 'style-loader'
|
11
|
-
options: {
|
12
|
-
hmr: isHMR,
|
13
|
-
sourceMap: true
|
14
|
-
}
|
6
|
+
loader: 'style-loader'
|
15
7
|
}
|
16
8
|
|
17
9
|
const getStyleRule = (test, modules = false, preprocessors = []) => {
|
@@ -21,8 +13,9 @@ const getStyleRule = (test, modules = false, preprocessors = []) => {
|
|
21
13
|
options: {
|
22
14
|
sourceMap: true,
|
23
15
|
importLoaders: 2,
|
24
|
-
|
25
|
-
|
16
|
+
modules: modules ? {
|
17
|
+
localIdentName: '[name]__[local]___[hash:base64:5]'
|
18
|
+
} : false
|
26
19
|
}
|
27
20
|
},
|
28
21
|
{
|
@@ -44,7 +37,9 @@ const getStyleRule = (test, modules = false, preprocessors = []) => {
|
|
44
37
|
}
|
45
38
|
|
46
39
|
// sideEffects - See https://github.com/webpack/webpack/issues/6571
|
47
|
-
return
|
40
|
+
return {
|
41
|
+
test, use, sideEffects: !modules, ...options
|
42
|
+
}
|
48
43
|
}
|
49
44
|
|
50
45
|
module.exports = getStyleRule
|
data/package/utils/helpers.js
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
const { stringify } = require('flatted
|
1
|
+
const { stringify } = require('flatted')
|
2
2
|
|
3
|
-
const isObject = value => typeof value === 'object'
|
3
|
+
const isObject = (value) => typeof value === 'object'
|
4
4
|
&& value !== null
|
5
5
|
&& (value.length === undefined || value.length === null)
|
6
6
|
|
7
|
-
const isNotObject = value => !isObject(value)
|
7
|
+
const isNotObject = (value) => !isObject(value)
|
8
8
|
|
9
|
-
const isBoolean = str => /^true/.test(str) || /^false/.test(str)
|
9
|
+
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
10
10
|
|
11
|
-
const isEmpty = value => value === null || value === undefined
|
11
|
+
const isEmpty = (value) => value === null || value === undefined
|
12
12
|
|
13
|
-
const isString = key => key && typeof key === 'string'
|
13
|
+
const isString = (key) => key && typeof key === 'string'
|
14
14
|
|
15
15
|
const isStrPath = (key) => {
|
16
16
|
if (!isString(key)) throw new Error(`Key ${key} should be string`)
|
17
17
|
return isString(key) && key.includes('.')
|
18
18
|
}
|
19
19
|
|
20
|
-
const isArray = value => Array.isArray(value)
|
20
|
+
const isArray = (value) => Array.isArray(value)
|
21
21
|
|
22
22
|
const isEqual = (target, source) => stringify(target) === stringify(source)
|
23
23
|
|
24
|
-
const canMerge = value => isObject(value) || isArray(value)
|
24
|
+
const canMerge = (value) => isObject(value) || isArray(value)
|
25
25
|
|
26
|
-
const prettyPrint = obj => JSON.stringify(obj, null, 2)
|
26
|
+
const prettyPrint = (obj) => JSON.stringify(obj, null, 2)
|
27
27
|
|
28
28
|
const chdirTestApp = () => {
|
29
29
|
try {
|
@@ -39,7 +39,7 @@ const resetEnv = () => {
|
|
39
39
|
process.env = {}
|
40
40
|
}
|
41
41
|
|
42
|
-
const ensureTrailingSlash = path => (path.endsWith('/') ? path : `${path}/`)
|
42
|
+
const ensureTrailingSlash = (path) => (path.endsWith('/') ? path : `${path}/`)
|
43
43
|
|
44
44
|
module.exports = {
|
45
45
|
chdirTestApp,
|
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.
|
26
|
-
"babel-plugin-macros": "^2.
|
27
|
-
"case-sensitive-paths-webpack-plugin": "^2.
|
28
|
-
"compression-webpack-plugin": "^
|
29
|
-
"core-js": "^3.
|
30
|
-
"css-loader": "^
|
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.1",
|
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
|
-
"postcss-preset-env": "^6.
|
44
|
-
"postcss-safe-parser": "^4.0.
|
45
|
-
"regenerator-runtime": "^0.13.
|
46
|
-
"sass
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"webpack": "^4.
|
42
|
+
"postcss-preset-env": "^6.7.0",
|
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.
|
52
|
-
"webpack-sources": "^1.3
|
51
|
+
"webpack-cli": "^3.3.12",
|
52
|
+
"webpack-sources": "^1.4.3"
|
53
53
|
},
|
54
54
|
"devDependencies": {
|
55
|
-
"eslint": "^
|
56
|
-
"eslint-config-airbnb": "^
|
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/command_test.rb
CHANGED
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/**/*",
|
29
|
-
"/etc/yarn/**/*",
|
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
|
|
@@ -49,14 +54,13 @@ class CompilerTest < Minitest::Test
|
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
52
|
-
def
|
57
|
+
def test_freshness_on_compile_fail
|
53
58
|
status = OpenStruct.new(success?: false)
|
54
59
|
|
55
60
|
assert Webpacker.compiler.stale?
|
56
61
|
Open3.stub :capture3, [:sterr, :stdout, status] do
|
57
|
-
|
58
62
|
Webpacker.compiler.compile
|
59
|
-
assert Webpacker.compiler.
|
63
|
+
assert Webpacker.compiler.fresh?
|
60
64
|
end
|
61
65
|
end
|
62
66
|
|
data/test/configuration_test.rb
CHANGED
@@ -14,11 +14,21 @@ class ConfigurationTest < Webpacker::Test
|
|
14
14
|
assert_equal source_path, @config.source_path.to_s
|
15
15
|
end
|
16
16
|
|
17
|
+
def test_source_path_globbed
|
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,.elm}"
|
20
|
+
end
|
21
|
+
|
17
22
|
def test_source_entry_path
|
18
23
|
source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s
|
19
24
|
assert_equal @config.source_entry_path.to_s, source_entry_path
|
20
25
|
end
|
21
26
|
|
27
|
+
def test_public_root_path
|
28
|
+
public_root_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public").to_s
|
29
|
+
assert_equal @config.public_path.to_s, public_root_path
|
30
|
+
end
|
31
|
+
|
22
32
|
def test_public_output_path
|
23
33
|
public_output_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/public/packs").to_s
|
24
34
|
assert_equal @config.public_output_path.to_s, public_output_path
|
@@ -43,12 +53,16 @@ class ConfigurationTest < Webpacker::Test
|
|
43
53
|
assert_equal @config.cache_path.to_s, cache_path
|
44
54
|
end
|
45
55
|
|
46
|
-
def
|
47
|
-
assert_equal @config.
|
56
|
+
def test_additional_paths
|
57
|
+
assert_equal @config.additional_paths, ["app/assets", "/etc/yarn", "app/elm"]
|
48
58
|
end
|
49
59
|
|
50
|
-
def
|
51
|
-
assert_equal @config.
|
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}"
|
65
|
+
]
|
52
66
|
end
|
53
67
|
|
54
68
|
def test_extensions
|
@@ -60,40 +74,36 @@ class ConfigurationTest < Webpacker::Test
|
|
60
74
|
def test_cache_manifest?
|
61
75
|
assert @config.cache_manifest?
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
env: "development"
|
67
|
-
)
|
68
|
-
|
69
|
-
refute @config.cache_manifest?
|
70
|
-
|
71
|
-
@config = Webpacker::Configuration.new(
|
72
|
-
root_path: @config.root_path,
|
73
|
-
config_path: @config.config_path,
|
74
|
-
env: "test"
|
75
|
-
)
|
77
|
+
with_rails_env("development") do
|
78
|
+
refute Webpacker.config.cache_manifest?
|
79
|
+
end
|
76
80
|
|
77
|
-
|
81
|
+
with_rails_env("test") do
|
82
|
+
refute Webpacker.config.cache_manifest?
|
83
|
+
end
|
78
84
|
end
|
79
85
|
|
80
86
|
def test_compile?
|
81
87
|
refute @config.compile?
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
env: "development"
|
87
|
-
)
|
89
|
+
with_rails_env("development") do
|
90
|
+
assert Webpacker.config.compile?
|
91
|
+
end
|
88
92
|
|
89
|
-
|
93
|
+
with_rails_env("test") do
|
94
|
+
assert Webpacker.config.compile?
|
95
|
+
end
|
96
|
+
end
|
90
97
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
98
|
+
def test_extract_css?
|
99
|
+
assert @config.extract_css?
|
100
|
+
|
101
|
+
with_rails_env("development") do
|
102
|
+
refute Webpacker.config.extract_css?
|
103
|
+
end
|
96
104
|
|
97
|
-
|
105
|
+
with_rails_env("test") do
|
106
|
+
refute Webpacker.config.extract_css?
|
107
|
+
end
|
98
108
|
end
|
99
109
|
end
|
@@ -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/dev_server_test.rb
CHANGED
@@ -22,4 +22,26 @@ class DevServerTest < Webpacker::Test
|
|
22
22
|
assert_equal Webpacker.dev_server.https?, false
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
def test_protocol
|
27
|
+
with_rails_env("development") do
|
28
|
+
assert_equal Webpacker.dev_server.protocol, "http"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_host_with_port
|
33
|
+
with_rails_env("development") do
|
34
|
+
assert_equal Webpacker.dev_server.host_with_port, "localhost:3035"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_pretty?
|
39
|
+
with_rails_env("development") do
|
40
|
+
refute Webpacker.dev_server.pretty?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_default_env_prefix
|
45
|
+
assert_equal Webpacker::DevServer::DEFAULT_ENV_PREFIX, "WEBPACKER_DEV_SERVER"
|
46
|
+
end
|
25
47
|
end
|