webpacker 5.4.4 → 6.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -1
- data/.github/workflows/ruby.yml +28 -4
- data/.gitignore +2 -0
- data/.node-version +1 -1
- data/.rubocop.yml +3 -111
- data/6_0_upgrade.md +43 -0
- data/CHANGELOG.md +19 -26
- data/Gemfile.lock +91 -94
- data/README.md +215 -98
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/lib/install/config/webpack/base.js +3 -0
- data/lib/install/config/webpack/development.js +2 -2
- data/lib/install/config/webpack/production.js +2 -2
- data/lib/install/config/webpack/test.js +2 -2
- data/lib/install/config/webpacker.yml +8 -37
- data/lib/install/javascript/packs/application.css +9 -0
- data/lib/install/javascript/packs/application.js +3 -1
- data/lib/install/template.rb +33 -27
- data/lib/tasks/webpacker/binstubs.rake +6 -4
- data/lib/tasks/webpacker/check_binstubs.rake +4 -4
- data/lib/tasks/webpacker/check_yarn.rake +1 -1
- data/lib/tasks/webpacker/compile.rake +4 -2
- data/lib/tasks/webpacker/info.rake +12 -10
- data/lib/tasks/webpacker/install.rake +6 -4
- data/lib/tasks/webpacker/verify_install.rake +2 -1
- data/lib/tasks/webpacker/yarn_install.rake +9 -7
- data/lib/tasks/webpacker.rake +2 -11
- data/lib/webpacker/compiler.rb +15 -8
- data/lib/webpacker/configuration.rb +10 -45
- data/lib/webpacker/dev_server_runner.rb +21 -2
- data/lib/webpacker/env.rb +1 -5
- data/lib/webpacker/helper.rb +22 -32
- data/lib/webpacker/manifest.rb +1 -1
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +5 -0
- data/package/__tests__/config.js +5 -37
- data/package/__tests__/development.js +9 -11
- data/package/__tests__/env.js +12 -4
- data/package/__tests__/production.js +6 -6
- data/package/__tests__/staging.js +7 -6
- data/package/__tests__/test.js +4 -5
- data/package/babel/preset.js +55 -0
- data/package/config.js +3 -11
- data/package/env.js +8 -2
- data/package/environments/__tests__/base.js +15 -47
- data/package/environments/base.js +62 -125
- data/package/environments/development.js +45 -44
- data/package/environments/production.js +63 -68
- data/package/environments/test.js +2 -2
- data/package/index.js +13 -8
- data/package/rules/babel.js +9 -7
- data/package/rules/coffee.js +6 -0
- data/package/rules/erb.js +15 -0
- data/package/rules/file.js +19 -19
- data/package/rules/index.js +15 -18
- data/package/rules/less.js +22 -0
- data/package/rules/sass.js +10 -10
- data/package/rules/svg.js +20 -0
- data/package/utils/get_style_rule.js +26 -36
- data/package/utils/helpers.js +26 -35
- data/package.json +29 -45
- data/test/compiler_test.rb +0 -12
- data/test/configuration_test.rb +1 -32
- data/test/dev_server_runner_test.rb +24 -5
- data/test/engine_rake_tasks_test.rb +39 -0
- data/test/helper_test.rb +24 -30
- data/test/mounted_app/Rakefile +4 -0
- data/test/mounted_app/test/dummy/Rakefile +3 -0
- data/test/mounted_app/test/dummy/bin/rails +3 -0
- data/test/mounted_app/test/dummy/bin/rake +3 -0
- data/test/mounted_app/test/dummy/config/application.rb +10 -0
- data/test/mounted_app/test/dummy/config/environment.rb +3 -0
- data/test/mounted_app/test/dummy/config/webpacker.yml +75 -0
- data/test/mounted_app/test/dummy/config.ru +5 -0
- data/test/mounted_app/test/dummy/package.json +7 -0
- data/test/rake_tasks_test.rb +1 -10
- data/test/test_app/config/webpacker.yml +1 -25
- data/test/test_app/config/webpacker_public_root.yml +0 -1
- data/test/test_app/public/packs/manifest.json +17 -13
- data/test/test_app/some.config.js +0 -0
- data/test/webpack_runner_test.rb +9 -3
- data/yarn.lock +2505 -4943
- metadata +37 -82
- data/docs/assets.md +0 -119
- data/docs/cloud9.md +0 -310
- data/docs/css.md +0 -308
- data/docs/deployment.md +0 -130
- data/docs/docker.md +0 -68
- data/docs/engines.md +0 -213
- data/docs/env.md +0 -63
- data/docs/es6.md +0 -72
- data/docs/folder-structure.md +0 -66
- data/docs/integrations.md +0 -220
- data/docs/misc.md +0 -23
- data/docs/props.md +0 -223
- data/docs/target.md +0 -22
- data/docs/testing.md +0 -136
- data/docs/troubleshooting.md +0 -158
- data/docs/typescript.md +0 -190
- data/docs/v4-upgrade.md +0 -142
- data/docs/webpack-dev-server.md +0 -92
- data/docs/webpack.md +0 -364
- data/docs/yarn.md +0 -23
- data/lib/install/angular.rb +0 -23
- data/lib/install/coffee.rb +0 -25
- data/lib/install/config/.browserslistrc +0 -1
- data/lib/install/config/babel.config.js +0 -82
- data/lib/install/config/postcss.config.js +0 -12
- data/lib/install/config/webpack/environment.js +0 -3
- data/lib/install/elm.rb +0 -39
- data/lib/install/erb.rb +0 -25
- data/lib/install/examples/angular/hello_angular/app/app.component.ts +0 -9
- data/lib/install/examples/angular/hello_angular/app/app.module.ts +0 -16
- data/lib/install/examples/angular/hello_angular/index.ts +0 -8
- data/lib/install/examples/angular/hello_angular/polyfills.ts +0 -73
- data/lib/install/examples/angular/hello_angular.js +0 -7
- data/lib/install/examples/coffee/hello_coffee.coffee +0 -4
- data/lib/install/examples/elm/Main.elm +0 -55
- data/lib/install/examples/elm/hello_elm.js +0 -16
- data/lib/install/examples/erb/hello_erb.js.erb +0 -6
- data/lib/install/examples/react/babel.config.js +0 -99
- data/lib/install/examples/react/hello_react.jsx +0 -26
- data/lib/install/examples/react/tsconfig.json +0 -21
- data/lib/install/examples/stimulus/application.js +0 -1
- data/lib/install/examples/stimulus/controllers/hello_controller.js +0 -18
- data/lib/install/examples/stimulus/controllers/index.js +0 -9
- data/lib/install/examples/svelte/app.svelte +0 -11
- data/lib/install/examples/svelte/hello_svelte.js +0 -20
- data/lib/install/examples/typescript/hello_typescript.ts +0 -4
- data/lib/install/examples/typescript/tsconfig.json +0 -24
- data/lib/install/examples/vue/app.vue +0 -22
- data/lib/install/examples/vue/hello_vue.js +0 -72
- data/lib/install/loaders/coffee.js +0 -6
- data/lib/install/loaders/elm.js +0 -25
- data/lib/install/loaders/erb.js +0 -11
- data/lib/install/loaders/svelte.js +0 -9
- data/lib/install/loaders/vue.js +0 -6
- data/lib/install/react.rb +0 -18
- data/lib/install/stimulus.rb +0 -12
- data/lib/install/svelte.rb +0 -29
- data/lib/install/typescript.rb +0 -39
- data/lib/install/vue.rb +0 -49
- data/lib/tasks/installers.rake +0 -42
- data/package/config_types/__tests__/config_list.js +0 -118
- data/package/config_types/__tests__/config_object.js +0 -43
- data/package/config_types/config_list.js +0 -75
- data/package/config_types/config_object.js +0 -55
- data/package/config_types/index.js +0 -7
- data/package/rules/module.css.js +0 -3
- data/package/rules/module.sass.js +0 -8
- data/package/rules/node_modules.js +0 -22
- data/package/utils/__tests__/deep_assign.js +0 -32
- data/package/utils/__tests__/deep_merge.js +0 -10
- data/package/utils/__tests__/get_style_rule.js +0 -65
- data/package/utils/__tests__/objectify.js +0 -9
- data/package/utils/deep_assign.js +0 -22
- data/package/utils/deep_merge.js +0 -22
- data/package/utils/objectify.js +0 -3
@@ -1,77 +1,72 @@
|
|
1
|
-
|
1
|
+
/* eslint global-require: 0 */
|
2
|
+
/* eslint import/no-dynamic-require: 0 */
|
3
|
+
|
4
|
+
const { merge } = require('webpack-merge')
|
2
5
|
const CompressionPlugin = require('compression-webpack-plugin')
|
3
|
-
const
|
4
|
-
const
|
5
|
-
const
|
6
|
+
const TerserPlugin = require('terser-webpack-plugin')
|
7
|
+
const baseConfig = require('./base')
|
8
|
+
const { moduleExists } = require('../utils/helpers')
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
+
const getPlugins = () => {
|
11
|
+
let compressionPlugin = new CompressionPlugin({
|
12
|
+
filename: '[path].gz[query]',
|
13
|
+
algorithm: 'gzip',
|
14
|
+
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
|
15
|
+
})
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
17
|
+
if ('brotli' in process.versions) {
|
18
|
+
compressionPlugin = new CompressionPlugin({
|
19
|
+
filename: '[path].br[query]',
|
20
|
+
algorithm: 'brotliCompress',
|
21
|
+
test: /\.(js|css|html|json|ico|svg|eot|otf|ttf|map)$/
|
22
|
+
})
|
23
|
+
}
|
19
24
|
|
20
|
-
|
21
|
-
|
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
|
-
}
|
25
|
+
return [compressionPlugin]
|
26
|
+
}
|
30
27
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
const productionConfig = {
|
29
|
+
devtool: 'source-map',
|
30
|
+
stats: 'normal',
|
31
|
+
bail: true,
|
32
|
+
plugins: getPlugins(),
|
33
|
+
optimization: {
|
34
|
+
minimizer: [
|
35
|
+
() => {
|
36
|
+
if (
|
37
|
+
moduleExists('css-loader') &&
|
38
|
+
moduleExists('css-minimizer-webpack-plugin')
|
39
|
+
) {
|
40
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
41
|
+
return new CssMinimizerPlugin({ sourceMap: true })
|
38
42
|
}
|
39
|
-
})
|
40
|
-
)
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
ecma: 5,
|
68
|
-
comments: false,
|
69
|
-
ascii_only: true
|
70
|
-
}
|
71
|
-
}
|
72
|
-
})
|
73
|
-
]
|
74
|
-
}
|
75
|
-
})
|
44
|
+
return false
|
45
|
+
},
|
46
|
+
|
47
|
+
new TerserPlugin({
|
48
|
+
parallel: Number.parseInt(process.env.WEBPACKER_PARALLEL, 10) || true,
|
49
|
+
terserOptions: {
|
50
|
+
parse: {
|
51
|
+
// Let terser parse ecma 8 code but always output
|
52
|
+
// ES5 compliant code for older browsers
|
53
|
+
ecma: 8
|
54
|
+
},
|
55
|
+
compress: {
|
56
|
+
ecma: 5,
|
57
|
+
warnings: false,
|
58
|
+
comparisons: false
|
59
|
+
},
|
60
|
+
mangle: { safari10: true },
|
61
|
+
output: {
|
62
|
+
ecma: 5,
|
63
|
+
comments: false,
|
64
|
+
ascii_only: true
|
65
|
+
}
|
66
|
+
}
|
67
|
+
})
|
68
|
+
].filter(Boolean)
|
76
69
|
}
|
77
70
|
}
|
71
|
+
|
72
|
+
module.exports = merge(baseConfig, productionConfig)
|
@@ -1,3 +1,3 @@
|
|
1
|
-
const
|
1
|
+
const baseConfig = require('./base')
|
2
2
|
|
3
|
-
module.exports =
|
3
|
+
module.exports = baseConfig
|
data/package/index.js
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
/* eslint import/no-dynamic-require: 0 */
|
3
3
|
|
4
|
+
const { merge } = require('webpack-merge')
|
4
5
|
const { resolve } = require('path')
|
5
6
|
const { existsSync } = require('fs')
|
6
|
-
const
|
7
|
-
const
|
7
|
+
const baseConfig = require('./environments/base')
|
8
|
+
const rules = require('./rules')
|
8
9
|
const config = require('./config')
|
9
10
|
const devServer = require('./dev_server')
|
10
11
|
const { nodeEnv } = require('./env')
|
12
|
+
const { moduleExists, canProcess } = require('./utils/helpers')
|
11
13
|
|
12
|
-
const
|
14
|
+
const webpackConfig = () => {
|
13
15
|
const path = resolve(__dirname, 'environments', `${nodeEnv}.js`)
|
14
|
-
const
|
15
|
-
return
|
16
|
+
const environmentConfig = existsSync(path) ? require(path) : baseConfig
|
17
|
+
return environmentConfig
|
16
18
|
}
|
17
19
|
|
18
20
|
module.exports = {
|
19
21
|
config,
|
20
22
|
devServer,
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
webpackConfig: webpackConfig(),
|
24
|
+
baseConfig,
|
25
|
+
rules,
|
26
|
+
merge,
|
27
|
+
moduleExists,
|
28
|
+
canProcess
|
24
29
|
}
|
data/package/rules/babel.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
const { resolve } = require('path')
|
2
2
|
const { realpathSync } = require('fs')
|
3
|
-
const { source_path: sourcePath, additional_paths: additionalPaths } = require('../config')
|
4
|
-
const { nodeEnv } = require('../env')
|
5
3
|
|
6
|
-
|
7
|
-
|
4
|
+
const {
|
5
|
+
source_path: sourcePath,
|
6
|
+
additional_paths: additionalPaths
|
7
|
+
} = require('../config')
|
8
|
+
const { isProduction } = require('../env')
|
9
|
+
|
8
10
|
module.exports = {
|
9
11
|
test: /\.(js|jsx|mjs|ts|tsx)?(\.erb)?$/,
|
10
12
|
include: [sourcePath, ...additionalPaths].map((p) => {
|
@@ -17,11 +19,11 @@ module.exports = {
|
|
17
19
|
exclude: /node_modules/,
|
18
20
|
use: [
|
19
21
|
{
|
20
|
-
loader: 'babel-loader',
|
22
|
+
loader: require.resolve('babel-loader'),
|
21
23
|
options: {
|
22
24
|
cacheDirectory: true,
|
23
|
-
cacheCompression:
|
24
|
-
compact:
|
25
|
+
cacheCompression: isProduction,
|
26
|
+
compact: isProduction
|
25
27
|
}
|
26
28
|
}
|
27
29
|
]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const { canProcess } = require('../utils/helpers')
|
2
|
+
|
3
|
+
const runner = /^win/.test(process.platform) ? 'ruby ' : ''
|
4
|
+
|
5
|
+
module.exports = canProcess('rails-erb-loader', (resolvedPath) => ({
|
6
|
+
test: /\.erb$/,
|
7
|
+
enforce: 'pre',
|
8
|
+
exclude: /node_modules/,
|
9
|
+
use: [
|
10
|
+
{
|
11
|
+
loader: resolvedPath,
|
12
|
+
options: { runner: `${runner}bin/rails runner` }
|
13
|
+
}
|
14
|
+
]
|
15
|
+
}))
|
data/package/rules/file.js
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
const { join, normalize } = require('path')
|
2
|
-
const { source_path: sourcePath, static_assets_extensions: fileExtensions } = require('../config')
|
3
|
-
|
4
1
|
module.exports = {
|
5
|
-
test:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
test: [
|
3
|
+
/\.bmp$/,
|
4
|
+
/\.gif$/,
|
5
|
+
/\.jpe?g$/,
|
6
|
+
/\.png$/,
|
7
|
+
/\.tiff$/,
|
8
|
+
/\.ico$/,
|
9
|
+
/\.avif$/,
|
10
|
+
/\.webp$/,
|
11
|
+
/\.eot$/,
|
12
|
+
/\.otf$/,
|
13
|
+
/\.ttf$/,
|
14
|
+
/\.woff$/,
|
15
|
+
/\.woff2$/,
|
16
|
+
/\.html$/,
|
17
|
+
/\.json$/
|
18
|
+
],
|
19
|
+
exclude: [/\.(js|mjs|jsx|ts|tsx)$/],
|
20
|
+
type: 'asset/resource'
|
21
21
|
}
|
data/package/rules/index.js
CHANGED
@@ -1,20 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
const css = require('./css')
|
4
|
-
const sass = require('./sass')
|
5
|
-
const moduleCss = require('./module.css')
|
6
|
-
const moduleSass = require('./module.sass')
|
7
|
-
const nodeModules = require('./node_modules')
|
1
|
+
/* eslint global-require: 0 */
|
2
|
+
/* eslint import/no-dynamic-require: 0 */
|
8
3
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
nodeModules,
|
19
|
-
babel
|
4
|
+
const rules = {
|
5
|
+
file: require('./file'),
|
6
|
+
svg: require('./svg'),
|
7
|
+
css: require('./css'),
|
8
|
+
sass: require('./sass'),
|
9
|
+
babel: require('./babel'),
|
10
|
+
erb: require('./erb'),
|
11
|
+
coffee: require('./coffee'),
|
12
|
+
less: require('./less')
|
20
13
|
}
|
14
|
+
|
15
|
+
module.exports = Object.keys(rules)
|
16
|
+
.filter((key) => !!rules[key])
|
17
|
+
.map((key) => rules[key])
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const path = require('path')
|
2
|
+
const { canProcess } = require('../utils/helpers')
|
3
|
+
const getStyleRule = require('../utils/get_style_rule')
|
4
|
+
|
5
|
+
const {
|
6
|
+
additional_paths: paths,
|
7
|
+
source_path: sourcePath
|
8
|
+
} = require('../config')
|
9
|
+
|
10
|
+
module.exports = canProcess('less-loader', (resolvedPath) =>
|
11
|
+
getStyleRule(/\.(less)(\.erb)?$/i, [
|
12
|
+
{
|
13
|
+
loader: resolvedPath,
|
14
|
+
options: {
|
15
|
+
lessOptions: {
|
16
|
+
paths: [path.resolve(__dirname, 'node_modules'), sourcePath, ...paths]
|
17
|
+
},
|
18
|
+
sourceMap: true
|
19
|
+
}
|
20
|
+
}
|
21
|
+
])
|
22
|
+
)
|
data/package/rules/sass.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
|
3
3
|
const getStyleRule = require('../utils/get_style_rule')
|
4
|
+
const { canProcess } = require('../utils/helpers')
|
4
5
|
const { additional_paths: includePaths } = require('../config')
|
5
6
|
|
6
|
-
module.exports =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
includePaths
|
7
|
+
module.exports = canProcess('sass-loader', (resolvedPath) =>
|
8
|
+
getStyleRule(/\.(scss|sass)(\.erb)?$/i, [
|
9
|
+
{
|
10
|
+
loader: resolvedPath,
|
11
|
+
options: {
|
12
|
+
sassOptions: { includePaths },
|
13
|
+
implementation: require('sass')
|
14
14
|
}
|
15
15
|
}
|
16
|
-
|
17
|
-
|
16
|
+
])
|
17
|
+
)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/* eslint global-require: 0 */
|
2
|
+
/* eslint import/no-dynamic-require: 0 */
|
3
|
+
const { moduleExists } = require('../utils/helpers')
|
4
|
+
|
5
|
+
module.exports = {
|
6
|
+
test: /\.svg$/i,
|
7
|
+
type: 'asset/inline',
|
8
|
+
generator: {
|
9
|
+
dataUrl: (content) => {
|
10
|
+
let optimisedContent = content
|
11
|
+
|
12
|
+
if (moduleExists('mini-svg-data-uri')) {
|
13
|
+
const svgToMiniDataURI = require('mini-svg-data-uri')
|
14
|
+
optimisedContent = svgToMiniDataURI(content.toString())
|
15
|
+
}
|
16
|
+
|
17
|
+
return optimisedContent
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -1,45 +1,35 @@
|
|
1
|
-
|
2
|
-
const { resolve } = require('path')
|
3
|
-
const config = require('../config')
|
1
|
+
/* eslint global-require: 0 */
|
4
2
|
|
5
|
-
const
|
6
|
-
loader: 'style-loader'
|
7
|
-
}
|
3
|
+
const { canProcess, moduleExists } = require('./helpers')
|
8
4
|
|
9
|
-
const getStyleRule = (test,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
sourceMap: true
|
15
|
-
|
16
|
-
modules: modules ? {
|
17
|
-
localIdentName: '[name]__[local]___[hash:base64:5]'
|
18
|
-
} : false
|
19
|
-
}
|
20
|
-
},
|
21
|
-
{
|
22
|
-
loader: 'postcss-loader',
|
23
|
-
options: {
|
24
|
-
config: { path: resolve() },
|
25
|
-
sourceMap: true
|
26
|
-
}
|
27
|
-
},
|
28
|
-
...preprocessors
|
29
|
-
]
|
5
|
+
const getStyleRule = (test, preprocessors = []) => {
|
6
|
+
if (moduleExists('css-loader')) {
|
7
|
+
const tryPostcss = () =>
|
8
|
+
canProcess('postcss-loader', (loaderPath) => ({
|
9
|
+
loader: loaderPath,
|
10
|
+
options: { sourceMap: true }
|
11
|
+
}))
|
30
12
|
|
31
|
-
|
13
|
+
const use = [
|
14
|
+
{ loader: require('mini-css-extract-plugin').loader },
|
15
|
+
{
|
16
|
+
loader: require.resolve('css-loader'),
|
17
|
+
options: {
|
18
|
+
sourceMap: true,
|
19
|
+
importLoaders: 2
|
20
|
+
}
|
21
|
+
},
|
22
|
+
tryPostcss(),
|
23
|
+
...preprocessors
|
24
|
+
].filter(Boolean)
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
return {
|
27
|
+
test,
|
28
|
+
use
|
29
|
+
}
|
37
30
|
}
|
38
31
|
|
39
|
-
|
40
|
-
return {
|
41
|
-
test, use, sideEffects: !modules, ...options
|
42
|
-
}
|
32
|
+
return null
|
43
33
|
}
|
44
34
|
|
45
35
|
module.exports = getStyleRule
|
data/package/utils/helpers.js
CHANGED
@@ -1,30 +1,5 @@
|
|
1
|
-
const { stringify } = require('flatted')
|
2
|
-
|
3
|
-
const isObject = (value) => typeof value === 'object'
|
4
|
-
&& value !== null
|
5
|
-
&& (value.length === undefined || value.length === null)
|
6
|
-
|
7
|
-
const isNotObject = (value) => !isObject(value)
|
8
|
-
|
9
|
-
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
10
|
-
|
11
|
-
const isEmpty = (value) => value === null || value === undefined
|
12
|
-
|
13
|
-
const isString = (key) => key && typeof key === 'string'
|
14
|
-
|
15
|
-
const isStrPath = (key) => {
|
16
|
-
if (!isString(key)) throw new Error(`Key ${key} should be string`)
|
17
|
-
return isString(key) && key.includes('.')
|
18
|
-
}
|
19
|
-
|
20
1
|
const isArray = (value) => Array.isArray(value)
|
21
|
-
|
22
|
-
const isEqual = (target, source) => stringify(target) === stringify(source)
|
23
|
-
|
24
|
-
const canMerge = (value) => isObject(value) || isArray(value)
|
25
|
-
|
26
|
-
const prettyPrint = (obj) => JSON.stringify(obj, null, 2)
|
27
|
-
|
2
|
+
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
28
3
|
const chdirTestApp = () => {
|
29
4
|
try {
|
30
5
|
return process.chdir('test/test_app')
|
@@ -41,18 +16,34 @@ const resetEnv = () => {
|
|
41
16
|
|
42
17
|
const ensureTrailingSlash = (path) => (path.endsWith('/') ? path : `${path}/`)
|
43
18
|
|
19
|
+
const moduleExists = (packageName) => {
|
20
|
+
try {
|
21
|
+
return require.resolve(packageName)
|
22
|
+
} catch (e) {
|
23
|
+
if (e.code !== 'MODULE_NOT_FOUND') {
|
24
|
+
throw e
|
25
|
+
}
|
26
|
+
return null
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
const canProcess = (rule, fn) => {
|
31
|
+
const modulePath = moduleExists(rule)
|
32
|
+
|
33
|
+
if (modulePath) {
|
34
|
+
return fn(modulePath)
|
35
|
+
}
|
36
|
+
|
37
|
+
return null
|
38
|
+
}
|
39
|
+
|
44
40
|
module.exports = {
|
45
41
|
chdirTestApp,
|
46
42
|
chdirCwd,
|
47
|
-
ensureTrailingSlash,
|
48
|
-
isObject,
|
49
|
-
isNotObject,
|
50
|
-
isBoolean,
|
51
43
|
isArray,
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
prettyPrint,
|
44
|
+
isBoolean,
|
45
|
+
ensureTrailingSlash,
|
46
|
+
canProcess,
|
47
|
+
moduleExists,
|
57
48
|
resetEnv
|
58
49
|
}
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rails/webpacker",
|
3
|
-
"version": "
|
3
|
+
"version": "6.0.0-beta",
|
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,40 @@
|
|
8
8
|
"lib/install/config/webpacker.yml"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
|
-
"node": ">=10.
|
12
|
-
"yarn": ">=1 <
|
11
|
+
"node": ">=10.22.1 || ^12 || >=14",
|
12
|
+
"yarn": ">=1 <3"
|
13
13
|
},
|
14
14
|
"dependencies": {
|
15
|
-
"@babel/core": "^7.
|
16
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
17
|
-
"@babel/plugin-
|
18
|
-
"@babel/
|
19
|
-
"@babel/
|
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",
|
15
|
+
"@babel/core": "^7.12.9",
|
16
|
+
"@babel/plugin-proposal-class-properties": "^7.12.1",
|
17
|
+
"@babel/plugin-transform-runtime": "^7.12.1",
|
18
|
+
"@babel/preset-env": "^7.12.11",
|
19
|
+
"@babel/runtime": "^7.12.5",
|
24
20
|
"babel-loader": "^8.2.2",
|
25
|
-
"babel-plugin-
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"
|
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",
|
21
|
+
"babel-plugin-macros": "^3.0.1",
|
22
|
+
"case-sensitive-paths-webpack-plugin": "^2.3.0",
|
23
|
+
"compression-webpack-plugin": "^7.1.0",
|
24
|
+
"core-js": "^3.8.0",
|
25
|
+
"glob": "^7.1.6",
|
26
|
+
"js-yaml": "^3.14.0",
|
37
27
|
"path-complete-extname": "^1.0.0",
|
38
|
-
"pnp-webpack-plugin": "^1.
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
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
|
-
"webpack-assets-manifest": "^3.1.1",
|
51
|
-
"webpack-cli": "^3.3.12",
|
52
|
-
"webpack-sources": "^1.4.3"
|
28
|
+
"pnp-webpack-plugin": "^1.6.4",
|
29
|
+
"regenerator-runtime": "^0.13.7",
|
30
|
+
"terser-webpack-plugin": "^5.0.3",
|
31
|
+
"webpack": "^5.11.0",
|
32
|
+
"webpack-assets-manifest": "^5.0.0",
|
33
|
+
"webpack-cli": "^4.2.0",
|
34
|
+
"webpack-merge": "^5.7.2",
|
35
|
+
"webpack-sources": "^2.2.0"
|
53
36
|
},
|
54
37
|
"devDependencies": {
|
55
|
-
"eslint": "^7.
|
56
|
-
"eslint-config-airbnb": "^18.2.
|
57
|
-
"eslint-
|
58
|
-
"eslint-plugin-
|
59
|
-
"eslint-plugin-
|
60
|
-
"
|
38
|
+
"eslint": "^7.16.0",
|
39
|
+
"eslint-config-airbnb": "^18.2.0",
|
40
|
+
"eslint-config-prettier": "^7.1.0",
|
41
|
+
"eslint-plugin-import": "^2.22.1",
|
42
|
+
"eslint-plugin-jsx-a11y": "^6.3.1",
|
43
|
+
"eslint-plugin-react": "^7.21.4",
|
44
|
+
"jest": "^26.5.3"
|
61
45
|
},
|
62
46
|
"jest": {
|
63
47
|
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
|
data/test/compiler_test.rb
CHANGED
@@ -23,18 +23,6 @@ class CompilerTest < Minitest::Test
|
|
23
23
|
Webpacker.compiler.env = {}
|
24
24
|
end
|
25
25
|
|
26
|
-
def test_default_watched_paths
|
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,.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}",
|
32
|
-
"yarn.lock",
|
33
|
-
"package.json",
|
34
|
-
"config/webpack/**/*"
|
35
|
-
]
|
36
|
-
end
|
37
|
-
|
38
26
|
def test_freshness
|
39
27
|
assert Webpacker.compiler.stale?
|
40
28
|
assert !Webpacker.compiler.fresh?
|