shakapacker 7.2.3 → 8.0.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintignore +1 -1
- data/.eslintrc.js +29 -8
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -3
- data/.github/workflows/dummy.yml +5 -1
- data/.github/workflows/generator.yml +13 -18
- data/.github/workflows/node.yml +56 -0
- data/.github/workflows/ruby.yml +28 -17
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +52 -1
- data/README.md +88 -50
- data/Rakefile +1 -7
- data/docs/customizing_babel_config.md +2 -2
- data/docs/deployment.md +13 -6
- data/docs/react.md +6 -12
- data/docs/troubleshooting.md +4 -4
- data/docs/using_esbuild_loader.md +1 -1
- data/docs/using_swc_loader.md +1 -1
- data/docs/v8_upgrade.md +148 -0
- data/gemfiles/Gemfile-rails.7.1.x +12 -0
- data/jest.config.js +4 -0
- data/lib/install/config/shakapacker.yml +2 -2
- data/lib/install/template.rb +36 -30
- data/lib/shakapacker/base_strategy.rb +2 -1
- data/lib/shakapacker/compiler.rb +5 -20
- data/lib/shakapacker/configuration.rb +2 -46
- data/lib/shakapacker/deprecation_helper.rb +0 -78
- data/lib/shakapacker/dev_server.rb +1 -16
- data/lib/shakapacker/dev_server_runner.rb +2 -21
- data/lib/shakapacker/env.rb +1 -1
- data/lib/shakapacker/instance.rb +1 -3
- data/lib/shakapacker/manifest.rb +1 -1
- data/lib/shakapacker/railtie.rb +7 -0
- data/lib/shakapacker/runner.rb +4 -18
- data/lib/shakapacker/utils/manager.rb +58 -0
- data/lib/shakapacker/utils/misc.rb +0 -12
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +9 -30
- data/lib/shakapacker/webpack_runner.rb +2 -21
- data/lib/shakapacker.rb +0 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +12 -26
- data/lib/tasks/shakapacker/check_manager.rake +3 -8
- data/lib/tasks/shakapacker/info.rake +6 -15
- data/package/babel/preset.js +15 -15
- data/package/config.js +15 -17
- data/package/dev_server.js +4 -4
- data/package/env.js +19 -17
- data/package/environments/base.js +41 -24
- data/package/environments/development.js +6 -6
- data/package/environments/production.js +16 -16
- data/package/environments/test.js +1 -1
- data/package/esbuild/index.js +6 -6
- data/package/index.d.ts +0 -1
- data/package/index.js +17 -46
- data/package/rules/babel.js +6 -8
- data/package/rules/coffee.js +2 -2
- data/package/rules/css.js +1 -1
- data/package/rules/erb.js +4 -4
- data/package/rules/esbuild.js +5 -7
- data/package/rules/file.js +17 -7
- data/package/rules/index.js +11 -11
- data/package/rules/jscommon.js +5 -5
- data/package/rules/less.js +6 -6
- data/package/rules/raw.js +1 -1
- data/package/rules/sass.js +4 -4
- data/package/rules/stylus.js +6 -6
- data/package/rules/swc.js +5 -7
- data/package/swc/index.js +10 -10
- data/package/utils/configPath.js +3 -18
- data/package/utils/defaultConfigPath.js +1 -1
- data/package/utils/{get_style_rule.js → getStyleRule.js} +6 -6
- data/package/utils/helpers.js +2 -43
- data/package/utils/inliningCss.js +4 -3
- data/package/utils/snakeToCamelCase.js +5 -0
- data/package/webpackDevServerConfig.js +28 -25
- data/package.json +11 -17
- data/prettier.config.js +4 -0
- data/shakapacker.gemspec +1 -1
- data/spec/dummy/app/javascript/packs/application.js +1 -1
- data/spec/dummy/config/application.rb +3 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +2 -2
- data/spec/dummy/config/shakapacker.yml +3 -4
- data/spec/dummy/config/webpack/commonWebpackConfig.js +0 -1
- data/spec/dummy/config/webpack/webpack.config.js +1 -1
- data/spec/dummy/package.json +2 -1
- data/spec/dummy/yarn.lock +2 -3
- data/spec/generator_specs/e2e_template/template.rb +15 -28
- data/spec/generator_specs/generator_spec.rb +6 -136
- data/spec/mounted_app/test/dummy/config/webpacker.yml +0 -1
- data/spec/shakapacker/compiler_spec.rb +1 -3
- data/spec/shakapacker/configuration_spec.rb +4 -56
- data/spec/shakapacker/dev_server_runner_spec.rb +19 -102
- data/spec/shakapacker/dev_server_spec.rb +1 -16
- data/spec/shakapacker/engine_rake_tasks_spec.rb +1 -16
- data/spec/shakapacker/instance_spec.rb +1 -3
- data/spec/shakapacker/rake_tasks_spec.rb +2 -14
- data/spec/shakapacker/shakapacker_spec.rb +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +0 -1
- data/spec/shakapacker/test_app/package.json +2 -1
- data/spec/shakapacker/utils_manager_spec.rb +125 -0
- data/spec/shakapacker/version_checker_spec.rb +4 -4
- data/spec/shakapacker/webpack_runner_spec.rb +19 -28
- data/spec/support/package_json_helpers.rb +7 -4
- data/test/helpers.js +67 -0
- data/test/package/config.test.js +50 -0
- data/test/package/dev_server.test.js +44 -0
- data/test/package/development.test.js +43 -0
- data/test/package/env.test.js +57 -0
- data/test/package/environments/base.test.js +105 -0
- data/test/package/environments/development.test.js +50 -0
- data/test/package/environments/production.test.js +106 -0
- data/test/package/index.test.js +45 -0
- data/test/package/production.test.js +32 -0
- data/test/package/rules/babel.test.js +58 -0
- data/test/package/rules/esbuild.test.js +59 -0
- data/test/package/rules/file.test.js +81 -0
- data/test/package/rules/index.test.js +7 -0
- data/test/package/rules/raw.test.js +12 -0
- data/test/package/rules/swc.test.js +59 -0
- data/test/package/staging.test.js +31 -0
- data/test/package/test.test.js +28 -0
- data/yarn.lock +1278 -421
- metadata +52 -102
- data/.github/workflows/jest.yml +0 -34
- data/.github/workflows/js-lint.yml +0 -34
- data/.github/workflows/rubocop.yml +0 -29
- data/.github/workflows/ruby-backward-compatibility.yml +0 -52
- data/lib/install/package.json +0 -15
- data/lib/tasks/shakapacker/check_yarn.rake +0 -34
- data/lib/tasks/shakapacker/yarn_install.rake +0 -24
- data/lib/tasks/webpacker/binstubs.rake +0 -9
- data/lib/tasks/webpacker/check_binstubs.rake +0 -9
- data/lib/tasks/webpacker/check_node.rake +0 -9
- data/lib/tasks/webpacker/check_yarn.rake +0 -9
- data/lib/tasks/webpacker/clean.rake +0 -9
- data/lib/tasks/webpacker/clobber.rake +0 -11
- data/lib/tasks/webpacker/compile.rake +0 -9
- data/lib/tasks/webpacker/info.rake +0 -9
- data/lib/tasks/webpacker/install.rake +0 -9
- data/lib/tasks/webpacker/verify_config.rake +0 -9
- data/lib/tasks/webpacker/verify_install.rake +0 -9
- data/lib/tasks/webpacker/yarn_install.rake +0 -9
- data/lib/tasks/webpacker.rake +0 -20
- data/lib/webpacker/dev_server_runner.rb +0 -9
- data/lib/webpacker/webpack_runner.rb +0 -9
- data/lib/webpacker.rb +0 -4
- data/package/__tests__/config-bc.js +0 -27
- data/package/__tests__/config.js +0 -46
- data/package/__tests__/dev_server-bc.js +0 -46
- data/package/__tests__/dev_server.js +0 -46
- data/package/__tests__/development-bc.js +0 -66
- data/package/__tests__/development.js +0 -66
- data/package/__tests__/env-bc.js +0 -59
- data/package/__tests__/env.js +0 -59
- data/package/__tests__/index-bc.js +0 -22
- data/package/__tests__/index.js +0 -46
- data/package/__tests__/production-bc.js +0 -51
- data/package/__tests__/production.js +0 -51
- data/package/__tests__/staging-bc.js +0 -53
- data/package/__tests__/staging.js +0 -53
- data/package/__tests__/test-bc.js +0 -43
- data/package/__tests__/test.js +0 -43
- data/package/environments/__tests__/base-bc.js +0 -107
- data/package/environments/__tests__/base.js +0 -107
- data/package/environments/__tests__/development.js +0 -53
- data/package/environments/__tests__/production.js +0 -92
- data/package/rules/__tests__/__utils__/webpack.js +0 -50
- data/package/rules/__tests__/babel.js +0 -63
- data/package/rules/__tests__/esbuild.js +0 -64
- data/package/rules/__tests__/file.js +0 -62
- data/package/rules/__tests__/index.js +0 -7
- data/package/rules/__tests__/raw.js +0 -18
- data/package/rules/__tests__/swc.js +0 -63
- data/package/utils/snakeToCamelCase +0 -7
- data/spec/backward_compatibility_specs/command_spec.rb +0 -116
- data/spec/backward_compatibility_specs/compiler_spec.rb +0 -59
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +0 -24
- data/spec/backward_compatibility_specs/configuration_spec.rb +0 -294
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +0 -206
- data/spec/backward_compatibility_specs/dev_server_spec.rb +0 -47
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +0 -38
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +0 -67
- data/spec/backward_compatibility_specs/env_spec.rb +0 -23
- data/spec/backward_compatibility_specs/helper_spec.rb +0 -243
- data/spec/backward_compatibility_specs/instance_spec.rb +0 -31
- data/spec/backward_compatibility_specs/manifest_spec.rb +0 -100
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +0 -55
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +0 -41
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +0 -24
- data/spec/backward_compatibility_specs/webpack_runner_spec.rb +0 -86
- data/spec/backward_compatibility_specs/webpacker_spec.rb +0 -41
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +0 -2
- data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +0 -3
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/application.js +0 -10
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/generated/something.js +0 -2
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/multi_entry.css +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/multi_entry.js +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/bin/webpacker +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/bin/webpacker-dev-server +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +0 -11
- data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +0 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker.yml +0 -83
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_css_extract_ignore_order_warnings.yml +0 -84
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_defaults_fallback.yml +0 -11
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_manifest_path.yml +0 -80
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_nested_entries.yml +0 -83
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +0 -7
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml +0 -85
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_public_root.yml +0 -18
- data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +0 -5
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +0 -58
- data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +0 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +0 -11
data/package/rules/stylus.js
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
const path = require(
|
2
|
-
const { canProcess } = require(
|
3
|
-
const getStyleRule = require(
|
1
|
+
const path = require("path")
|
2
|
+
const { canProcess } = require("../utils/helpers")
|
3
|
+
const getStyleRule = require("../utils/getStyleRule")
|
4
4
|
|
5
5
|
const {
|
6
6
|
additional_paths: paths,
|
7
7
|
source_path: sourcePath
|
8
|
-
} = require(
|
8
|
+
} = require("../config")
|
9
9
|
|
10
|
-
module.exports = canProcess(
|
10
|
+
module.exports = canProcess("stylus-loader", (resolvedPath) =>
|
11
11
|
getStyleRule(/\.(styl(us)?)(\.erb)?$/i, [
|
12
12
|
{
|
13
13
|
loader: resolvedPath,
|
14
14
|
options: {
|
15
15
|
stylusOptions: {
|
16
16
|
include: [
|
17
|
-
path.resolve(__dirname,
|
17
|
+
path.resolve(__dirname, "node_modules"),
|
18
18
|
sourcePath,
|
19
19
|
...paths
|
20
20
|
]
|
data/package/rules/swc.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
const { loaderMatches } = require(
|
2
|
-
const { getSwcLoaderConfig } = require(
|
3
|
-
const {
|
4
|
-
|
5
|
-
} = require('../config')
|
6
|
-
const jscommon = require('./jscommon')
|
1
|
+
const { loaderMatches } = require("../utils/helpers")
|
2
|
+
const { getSwcLoaderConfig } = require("../swc")
|
3
|
+
const { webpack_loader: webpackLoader } = require("../config")
|
4
|
+
const jscommon = require("./jscommon")
|
7
5
|
|
8
|
-
module.exports = loaderMatches(webpackLoader,
|
6
|
+
module.exports = loaderMatches(webpackLoader, "swc", () => ({
|
9
7
|
test: /\.(ts|tsx|js|jsx|mjs|coffee)?(\.erb)?$/,
|
10
8
|
...jscommon,
|
11
9
|
use: ({ resource }) => getSwcLoaderConfig(resource)
|
data/package/swc/index.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
/* eslint import/no-dynamic-require: 0 */
|
3
3
|
|
4
|
-
const { resolve } = require(
|
5
|
-
const { existsSync } = require(
|
6
|
-
const { merge } = require(
|
4
|
+
const { resolve } = require("path")
|
5
|
+
const { existsSync } = require("fs")
|
6
|
+
const { merge } = require("webpack-merge")
|
7
7
|
|
8
8
|
const isJsxFile = (filename) => !!filename.match(/\.(jsx|tsx)?(\.erb)?$/)
|
9
9
|
|
10
10
|
const isTypescriptFile = (filename) => !!filename.match(/\.(ts|tsx)?(\.erb)?$/)
|
11
11
|
|
12
12
|
const getCustomConfig = () => {
|
13
|
-
const path = resolve(
|
13
|
+
const path = resolve("config", "swc.config.js")
|
14
14
|
if (existsSync(path)) {
|
15
15
|
return require(path)
|
16
16
|
}
|
@@ -20,15 +20,15 @@ const getCustomConfig = () => {
|
|
20
20
|
const getSwcLoaderConfig = (filenameToProcess) => {
|
21
21
|
const customConfig = getCustomConfig()
|
22
22
|
const defaultConfig = {
|
23
|
-
loader: require.resolve(
|
23
|
+
loader: require.resolve("swc-loader"),
|
24
24
|
options: {
|
25
25
|
jsc: {
|
26
26
|
parser: {
|
27
27
|
dynamicImport: true,
|
28
28
|
syntax: isTypescriptFile(filenameToProcess)
|
29
|
-
?
|
30
|
-
:
|
31
|
-
[isTypescriptFile(filenameToProcess) ?
|
29
|
+
? "typescript"
|
30
|
+
: "ecmascript",
|
31
|
+
[isTypescriptFile(filenameToProcess) ? "tsx" : "jsx"]:
|
32
32
|
isJsxFile(filenameToProcess)
|
33
33
|
},
|
34
34
|
loose: true
|
@@ -36,8 +36,8 @@ const getSwcLoaderConfig = (filenameToProcess) => {
|
|
36
36
|
sourceMaps: true,
|
37
37
|
env: {
|
38
38
|
coreJs: 3,
|
39
|
-
exclude: [
|
40
|
-
mode:
|
39
|
+
exclude: ["transform-typeof-symbol"],
|
40
|
+
mode: "entry"
|
41
41
|
}
|
42
42
|
}
|
43
43
|
}
|
data/package/utils/configPath.js
CHANGED
@@ -1,19 +1,4 @@
|
|
1
|
-
const
|
2
|
-
const { resolve } = require('path')
|
3
|
-
const { setShakapackerEnvVariablesForBackwardCompatibility } = require('./helpers')
|
1
|
+
const { resolve } = require("path")
|
4
2
|
|
5
|
-
|
6
|
-
|
7
|
-
// For backward compatibility
|
8
|
-
const resolveToPhysicalFilePath = () => {
|
9
|
-
const shakapackerConfigPath = resolve('config', 'shakapacker.yml')
|
10
|
-
const webpackerConfigPath = resolve('config', 'webpacker.yml')
|
11
|
-
|
12
|
-
if (fs.existsSync(shakapackerConfigPath)) return shakapackerConfigPath
|
13
|
-
if (fs.existsSync(webpackerConfigPath)) return webpackerConfigPath
|
14
|
-
|
15
|
-
// If neither of files exist, try to resolve to shakapacker.yml to get more relevant error
|
16
|
-
return shakapackerConfigPath
|
17
|
-
}
|
18
|
-
|
19
|
-
module.exports = process.env.SHAKAPACKER_CONFIG || resolveToPhysicalFilePath()
|
3
|
+
module.exports =
|
4
|
+
process.env.SHAKAPACKER_CONFIG || resolve("config", "shakapacker.yml")
|
@@ -1,2 +1,2 @@
|
|
1
|
-
const path = require.resolve(
|
1
|
+
const path = require.resolve("../../lib/install/config/shakapacker.yml")
|
2
2
|
module.exports = path
|
@@ -1,11 +1,11 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
|
-
const { canProcess, moduleExists } = require(
|
3
|
-
const inliningCss = require(
|
2
|
+
const { canProcess, moduleExists } = require("./helpers")
|
3
|
+
const inliningCss = require("./inliningCss")
|
4
4
|
|
5
5
|
const getStyleRule = (test, preprocessors = []) => {
|
6
|
-
if (moduleExists(
|
6
|
+
if (moduleExists("css-loader")) {
|
7
7
|
const tryPostcss = () =>
|
8
|
-
canProcess(
|
8
|
+
canProcess("postcss-loader", (loaderPath) => ({
|
9
9
|
loader: loaderPath,
|
10
10
|
options: { sourceMap: true }
|
11
11
|
}))
|
@@ -13,9 +13,9 @@ const getStyleRule = (test, preprocessors = []) => {
|
|
13
13
|
// style-loader is required when using css modules with HMR on the webpack-dev-server
|
14
14
|
|
15
15
|
const use = [
|
16
|
-
inliningCss ?
|
16
|
+
inliningCss ? "style-loader" : require("mini-css-extract-plugin").loader,
|
17
17
|
{
|
18
|
-
loader: require.resolve(
|
18
|
+
loader: require.resolve("css-loader"),
|
19
19
|
options: {
|
20
20
|
sourceMap: true,
|
21
21
|
importLoaders: 2,
|
data/package/utils/helpers.js
CHANGED
@@ -1,35 +1,12 @@
|
|
1
|
-
const isArray = (value) => Array.isArray(value)
|
2
1
|
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
3
|
-
const chdirTestApp = () => {
|
4
|
-
try {
|
5
|
-
return process.chdir('spec/shakapacker/test_app')
|
6
|
-
} catch (e) {
|
7
|
-
return null
|
8
|
-
}
|
9
|
-
}
|
10
2
|
|
11
|
-
|
12
|
-
const chdirWebpackerTestApp = () => {
|
13
|
-
try {
|
14
|
-
return process.chdir('spec/backward_compatibility_specs/webpacker_test_app')
|
15
|
-
} catch (e) {
|
16
|
-
return null
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
const chdirCwd = () => process.chdir(process.cwd())
|
21
|
-
|
22
|
-
const resetEnv = () => {
|
23
|
-
process.env = {}
|
24
|
-
}
|
25
|
-
|
26
|
-
const ensureTrailingSlash = (path) => (path.endsWith('/') ? path : `${path}/`)
|
3
|
+
const ensureTrailingSlash = (path) => (path.endsWith("/") ? path : `${path}/`)
|
27
4
|
|
28
5
|
const resolvedPath = (packageName) => {
|
29
6
|
try {
|
30
7
|
return require.resolve(packageName)
|
31
8
|
} catch (e) {
|
32
|
-
if (e.code !==
|
9
|
+
if (e.code !== "MODULE_NOT_FOUND") {
|
33
10
|
throw e
|
34
11
|
}
|
35
12
|
return null
|
@@ -64,28 +41,10 @@ const loaderMatches = (configLoader, loaderToCheck, fn) => {
|
|
64
41
|
return fn()
|
65
42
|
}
|
66
43
|
|
67
|
-
// For backward compatibility
|
68
|
-
// Set SHAKAPACKER_XYZ only if SHAKAPACKER_XYZ is not defined but WEBPACKER_XYZ is.
|
69
|
-
const setShakapackerEnvVariablesForBackwardCompatibility = () => {
|
70
|
-
const webpackerEnvVariables = Object.entries(process.env).filter((key) => /^WEBPACKER_/.test(key))
|
71
|
-
webpackerEnvVariables.forEach(([webpackerEnvKey, webpackerEnvValue]) => {
|
72
|
-
const shakapackerKey = webpackerEnvKey.replace(/^WEBPACKER/, 'SHAKAPACKER')
|
73
|
-
if (!process.env[shakapackerKey]) {
|
74
|
-
process.env[shakapackerKey] = webpackerEnvValue
|
75
|
-
}
|
76
|
-
})
|
77
|
-
}
|
78
|
-
|
79
44
|
module.exports = {
|
80
|
-
chdirTestApp,
|
81
|
-
chdirWebpackerTestApp,
|
82
|
-
setShakapackerEnvVariablesForBackwardCompatibility,
|
83
|
-
chdirCwd,
|
84
|
-
isArray,
|
85
45
|
isBoolean,
|
86
46
|
ensureTrailingSlash,
|
87
47
|
canProcess,
|
88
48
|
moduleExists,
|
89
|
-
resetEnv,
|
90
49
|
loaderMatches
|
91
50
|
}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
const { runningWebpackDevServer } = require(
|
2
|
-
const devServer = require(
|
1
|
+
const { runningWebpackDevServer } = require("../env")
|
2
|
+
const devServer = require("../dev_server")
|
3
3
|
|
4
4
|
// This logic is tied to lib/shakapacker/instance.rb
|
5
|
-
const inliningCss =
|
5
|
+
const inliningCss =
|
6
|
+
runningWebpackDevServer && devServer.hmr && devServer.inline_css !== false
|
6
7
|
|
7
8
|
module.exports = inliningCss
|
@@ -1,35 +1,38 @@
|
|
1
|
-
const shakapackerDevServerYamlConfig = require(
|
2
|
-
const snakeToCamelCase = require(
|
3
|
-
const { outputPath: contentBase, publicPath } = require(
|
1
|
+
const shakapackerDevServerYamlConfig = require("./dev_server")
|
2
|
+
const snakeToCamelCase = require("./utils/snakeToCamelCase")
|
3
|
+
const { outputPath: contentBase, publicPath } = require("./config")
|
4
4
|
|
5
5
|
const webpackDevServerMappedKeys = new Set([
|
6
6
|
// client, server, liveReload, devMiddleware are handled separately
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
7
|
+
"allowedHosts",
|
8
|
+
"bonjour",
|
9
|
+
"compress",
|
10
|
+
"headers",
|
11
|
+
"historyApiFallback",
|
12
|
+
"host",
|
13
|
+
"hot",
|
14
|
+
"http2",
|
15
|
+
"https",
|
16
|
+
"ipc",
|
17
|
+
"magicHtml",
|
18
|
+
"onAfterSetupMiddleware",
|
19
|
+
"onBeforeSetupMiddleware",
|
20
|
+
"open",
|
21
|
+
"port",
|
22
|
+
"proxy",
|
23
|
+
"server",
|
24
|
+
"setupExitSignals",
|
25
|
+
"setupMiddlewares",
|
26
|
+
"watchFiles",
|
27
|
+
"webSocketServer"
|
28
28
|
])
|
29
29
|
|
30
30
|
function createDevServerConfig() {
|
31
31
|
const devServerYamlConfig = { ...shakapackerDevServerYamlConfig }
|
32
|
-
const liveReload =
|
32
|
+
const liveReload =
|
33
|
+
devServerYamlConfig.live_reload !== undefined
|
34
|
+
? devServerYamlConfig.live_reload
|
35
|
+
: !devServerYamlConfig.hmr
|
33
36
|
delete devServerYamlConfig.live_reload
|
34
37
|
|
35
38
|
const config = {
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "
|
3
|
+
"version": "8.0.0-rc.1",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"homepage": "https://github.com/shakacode/shakapacker",
|
6
6
|
"bugs": {
|
@@ -19,21 +19,10 @@
|
|
19
19
|
"lib/install/config/shakapacker.yml"
|
20
20
|
],
|
21
21
|
"scripts": {
|
22
|
-
"lint": "eslint
|
22
|
+
"lint": "eslint .",
|
23
23
|
"test": "jest"
|
24
24
|
},
|
25
|
-
"jest": {
|
26
|
-
"roots": [
|
27
|
-
"<rootDir>/package"
|
28
|
-
],
|
29
|
-
"testPathIgnorePatterns": [
|
30
|
-
"/__fixtures__/",
|
31
|
-
"/__utils__/"
|
32
|
-
],
|
33
|
-
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$"
|
34
|
-
},
|
35
25
|
"dependencies": {
|
36
|
-
"glob": "^7.2.0",
|
37
26
|
"js-yaml": "^4.1.0",
|
38
27
|
"path-complete-extname": "^1.0.0"
|
39
28
|
},
|
@@ -41,14 +30,18 @@
|
|
41
30
|
"babel-loader": "^8.2.4",
|
42
31
|
"compression-webpack-plugin": "^9.0.0",
|
43
32
|
"esbuild-loader": "^2.18.0",
|
44
|
-
"eslint": "^
|
45
|
-
"eslint-config-airbnb": "^
|
46
|
-
"eslint-config-prettier": "^
|
33
|
+
"eslint": "^8.0.0",
|
34
|
+
"eslint-config-airbnb": "^19.0.0",
|
35
|
+
"eslint-config-prettier": "^9.0.0",
|
47
36
|
"eslint-plugin-import": "^2.24.2",
|
37
|
+
"eslint-plugin-jest": "^27.9.0",
|
48
38
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
39
|
+
"eslint-plugin-prettier": "^5.1.3",
|
49
40
|
"eslint-plugin-react": "^7.26.0",
|
41
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
50
42
|
"jest": "^28.1.3",
|
51
43
|
"memory-fs": "^0.5.0",
|
44
|
+
"prettier": "^3.2.5",
|
52
45
|
"swc-loader": "^0.1.15",
|
53
46
|
"thenify": "^3.3.1",
|
54
47
|
"webpack": "^5.72.0",
|
@@ -79,8 +72,9 @@
|
|
79
72
|
"optional": true
|
80
73
|
}
|
81
74
|
},
|
75
|
+
"packageManager": "yarn@1.22.22",
|
82
76
|
"engines": {
|
83
|
-
"node": "
|
77
|
+
"node": ">= 14",
|
84
78
|
"yarn": ">=1 <5"
|
85
79
|
},
|
86
80
|
"publishConfig": {
|
data/prettier.config.js
ADDED
data/shakapacker.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
"source_code_uri" => "https://github.com/shakacode/shakapacker/tree/v#{npm_version}",
|
16
16
|
}
|
17
17
|
|
18
|
-
s.required_ruby_version = ">= 2.
|
18
|
+
s.required_ruby_version = ">= 2.7.0"
|
19
19
|
|
20
20
|
s.add_dependency "activesupport", ">= 5.2"
|
21
21
|
s.add_dependency "package_json"
|
@@ -19,6 +19,9 @@ require "rails/test_unit/railtie"
|
|
19
19
|
# you've limited to :test, :development, or :production.
|
20
20
|
Bundler.require(*Rails.groups)
|
21
21
|
|
22
|
+
# Temp patch for dummy specs
|
23
|
+
Webpacker = Shakapacker
|
24
|
+
|
22
25
|
module TestReactOnRailsV12SsrV2
|
23
26
|
class Application < Rails::Application
|
24
27
|
# Initialize configuration defaults for originally generated Rails version.
|
@@ -24,8 +24,8 @@ ReactOnRails.configure do |config|
|
|
24
24
|
# to automatically refresh your webpack assets on every test run.
|
25
25
|
#
|
26
26
|
# Alternately, you can remove the `ReactOnRails::TestHelper.configure_rspec_to_compile_assets`
|
27
|
-
# and set the config/
|
28
|
-
config.build_test_command = "RAILS_ENV=test bin/
|
27
|
+
# and set the config/shakapacker.yml option for test to true.
|
28
|
+
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
|
29
29
|
|
30
30
|
################################################################################
|
31
31
|
################################################################################
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# Note: You must restart bin/
|
1
|
+
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
4
|
source_path: app/javascript
|
5
5
|
source_entry_path: packs
|
6
6
|
public_root_path: public
|
7
7
|
public_output_path: packs
|
8
|
-
cache_path: tmp/
|
8
|
+
cache_path: tmp/shakapacker
|
9
9
|
webpack_compile_output: true
|
10
10
|
|
11
11
|
# Additional paths webpack should lookup modules
|
@@ -17,12 +17,11 @@ default: &default
|
|
17
17
|
|
18
18
|
development:
|
19
19
|
<<: *default
|
20
|
-
# This is false since we're running `bin/
|
20
|
+
# This is false since we're running `bin/shakapacker -w` in Procfile.dev-setic
|
21
21
|
compile: false
|
22
22
|
|
23
23
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
24
24
|
dev_server:
|
25
|
-
https: false
|
26
25
|
host: localhost
|
27
26
|
port: 3035
|
28
27
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
@@ -1,6 +1,5 @@
|
|
1
1
|
// Common configuration applying to client and server configuration
|
2
2
|
|
3
|
-
// const { globalMutableWebpackConfig: baseClientWebpackConfig, merge } = require('shakapacker')
|
4
3
|
const { generateWebpackConfig, merge } = require('shakapacker')
|
5
4
|
const commonOptions = {
|
6
5
|
resolve: {
|
@@ -16,7 +16,7 @@ const webpackConfiguration = envSpecificConfig()
|
|
16
16
|
|
17
17
|
// To debug the webpack configuration
|
18
18
|
// 1. Uncomment debugger line below
|
19
|
-
// 2. Run `bin/
|
19
|
+
// 2. Run `bin/shakapacker --debug-shakapacker`
|
20
20
|
// 3. Examine the webpackConfiguration variable
|
21
21
|
// 4. Consider adding a 'debugger` line to the beginning of this file.
|
22
22
|
// debugger
|
data/spec/dummy/package.json
CHANGED
data/spec/dummy/yarn.lock
CHANGED
@@ -2571,7 +2571,7 @@ glob-to-regexp@^0.4.1:
|
|
2571
2571
|
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
|
2572
2572
|
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
|
2573
2573
|
|
2574
|
-
glob@^7.1.3, glob@^7.1.6
|
2574
|
+
glob@^7.1.3, glob@^7.1.6:
|
2575
2575
|
version "7.2.3"
|
2576
2576
|
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
|
2577
2577
|
integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==
|
@@ -4060,9 +4060,8 @@ setprototypeof@1.2.0:
|
|
4060
4060
|
integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==
|
4061
4061
|
|
4062
4062
|
"shakapacker@file:.yalc/shakapacker":
|
4063
|
-
version "7.
|
4063
|
+
version "7.2.3"
|
4064
4064
|
dependencies:
|
4065
|
-
glob "^7.2.0"
|
4066
4065
|
js-yaml "^4.1.0"
|
4067
4066
|
path-complete-extname "^1.0.0"
|
4068
4067
|
|
@@ -1,33 +1,20 @@
|
|
1
1
|
require "shakapacker/utils/misc"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
{ "babel" => babel }
|
19
|
-
end
|
20
|
-
else
|
21
|
-
# install react
|
22
|
-
system("yarn add react react-dom @babel/preset-react")
|
23
|
-
|
24
|
-
# update webpack presets for react
|
25
|
-
package_json_path = Rails.root.join("./package.json")
|
26
|
-
insert_into_file(
|
27
|
-
package_json_path,
|
28
|
-
%( "@babel/preset-react",\n),
|
29
|
-
after: /"presets": \[\n/
|
30
|
-
)
|
3
|
+
require "package_json"
|
4
|
+
|
5
|
+
package_json = PackageJson.new
|
6
|
+
|
7
|
+
# install react
|
8
|
+
package_json.manager.add(["react", "react-dom", "@babel/preset-react"])
|
9
|
+
|
10
|
+
# update webpack presets for react
|
11
|
+
package_json.merge! do |pj|
|
12
|
+
babel = pj.fetch("babel", {})
|
13
|
+
|
14
|
+
babel["presets"] ||= []
|
15
|
+
babel["presets"].unshift("@babel/preset-react")
|
16
|
+
|
17
|
+
{ "babel" => babel }
|
31
18
|
end
|
32
19
|
|
33
20
|
# install rspec-rails
|