shakapacker 9.0.0.beta.0 → 9.0.0.beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/claude-code-review.yml +54 -0
  3. data/.github/workflows/claude.yml +50 -0
  4. data/.github/workflows/dummy.yml +3 -3
  5. data/.github/workflows/test-bundlers.yml +152 -0
  6. data/.rubocop.yml +1 -0
  7. data/CHANGELOG.md +15 -3
  8. data/CLAUDE.md +29 -0
  9. data/Gemfile.lock +1 -1
  10. data/README.md +42 -1
  11. data/Rakefile +39 -4
  12. data/TODO.md +51 -0
  13. data/TODO_v9.md +84 -0
  14. data/conductor-setup.sh +58 -0
  15. data/conductor.json +7 -0
  16. data/docs/cdn_setup.md +379 -0
  17. data/docs/css-modules-export-mode.md +216 -86
  18. data/docs/deployment.md +10 -1
  19. data/docs/rspack.md +7 -7
  20. data/docs/rspack_migration_guide.md +202 -0
  21. data/docs/using_esbuild_loader.md +3 -3
  22. data/docs/using_swc_loader.md +5 -3
  23. data/docs/v6_upgrade.md +10 -0
  24. data/docs/v9_upgrade.md +185 -0
  25. data/lib/install/bin/shakapacker +3 -17
  26. data/lib/install/config/shakapacker.yml +9 -4
  27. data/lib/shakapacker/configuration.rb +75 -3
  28. data/lib/shakapacker/dev_server_runner.rb +19 -9
  29. data/lib/shakapacker/manifest.rb +4 -3
  30. data/lib/shakapacker/rspack_runner.rb +4 -42
  31. data/lib/shakapacker/runner.rb +105 -11
  32. data/lib/shakapacker/utils/manager.rb +2 -0
  33. data/lib/shakapacker/version.rb +1 -1
  34. data/lib/shakapacker/version_checker.rb +1 -1
  35. data/lib/shakapacker/webpack_runner.rb +4 -42
  36. data/lib/tasks/shakapacker/install.rake +6 -2
  37. data/package/config.js +24 -0
  38. data/package/environments/base.js +12 -2
  39. data/package/environments/development.js +52 -12
  40. data/package/environments/production.js +8 -3
  41. data/package/environments/test.js +5 -3
  42. data/package/index.d.ts +69 -30
  43. data/package/index.js +1 -1
  44. data/package/optimization/rspack.js +9 -5
  45. data/package/plugins/rspack.js +12 -28
  46. data/package/rspack/index.js +57 -0
  47. data/package/rules/babel.js +2 -2
  48. data/package/rules/esbuild.js +2 -2
  49. data/package/rules/raw.js +5 -5
  50. data/package/rules/rspack.js +77 -7
  51. data/package/rules/swc.js +2 -2
  52. data/package/utils/debug.js +49 -0
  53. data/package/utils/getStyleRule.js +19 -10
  54. data/package/utils/requireOrError.js +1 -1
  55. data/package/utils/validateCssModulesConfig.js +91 -0
  56. data/package/utils/validateDependencies.js +61 -0
  57. data/package/webpackDevServerConfig.js +2 -0
  58. data/package-lock.json +11966 -0
  59. data/package.json +9 -2
  60. data/test/package/rules/esbuild.test.js +1 -1
  61. data/test/package/rules/swc.test.js +1 -1
  62. data/tools/README.md +124 -0
  63. data/tools/css-modules-v9-codemod.js +179 -0
  64. data/yarn.lock +199 -81
  65. metadata +20 -3
  66. data/lib/install/bin/shakapacker-rspack +0 -13
@@ -108,16 +108,17 @@ class Shakapacker::Manifest
108
108
  end
109
109
 
110
110
  def missing_file_from_manifest_error(bundle_name)
111
+ bundler_name = config.assets_bundler
111
112
  <<-MSG
112
113
  Shakapacker can't find #{bundle_name} in #{config.manifest_path}. Possible causes:
113
114
  1. You forgot to install javascript packages or are running an incompatible javascript runtime version
114
115
  2. Your app has code with a non-standard extension (like a `.jsx` file) but the extension is not in the `extensions` config in `config/shakapacker.yml`
115
116
  3. You have set compile: false (see `config/shakapacker.yml`) for this environment
116
117
  (unless you are using the `bin/shakapacker -w` or the `bin/shakapacker-dev-server`, in which case maybe you aren't running the dev server in the background?)
117
- 4. Your bundler (webpack/rspack) has not yet FINISHED running to reflect updates.
118
+ 4. Your #{bundler_name} has not yet FINISHED running to reflect updates.
118
119
  5. You have misconfigured Shakapacker's `config/shakapacker.yml` file.
119
- 6. Your bundler configuration is not creating a manifest with the expected structure.
120
- 7. There's a mismatch between your bundler choice (webpack vs rspack) and the manifest format.
120
+ 6. Your #{bundler_name} configuration is not creating a manifest with the expected structure.
121
+ 7. Ensure the 'assets_bundler' in config/shakapacker.yml is set correctly (currently: #{bundler_name}).
121
122
 
122
123
  Your manifest contains:
123
124
  #{JSON.pretty_generate(@data)}
@@ -4,48 +4,10 @@ require_relative "runner"
4
4
 
5
5
  module Shakapacker
6
6
  class RspackRunner < Shakapacker::Runner
7
- RSPACK_COMMANDS = [
8
- "help",
9
- "h",
10
- "--help",
11
- "-h",
12
- "version",
13
- "v",
14
- "--version",
15
- "-v",
16
- "info",
17
- "i"
18
- ].freeze
19
-
20
- def run
21
- env = Shakapacker::Compiler.env
22
- env["SHAKAPACKER_CONFIG"] = @shakapacker_config
23
- env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""
24
-
25
- cmd = build_cmd
26
-
27
- if @argv.delete("--debug-shakapacker")
28
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --inspect-brk"
29
- end
30
-
31
- if @argv.delete "--trace-deprecation"
32
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --trace-deprecation"
33
- end
34
-
35
- if @argv.delete "--no-deprecation"
36
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --no-deprecation"
37
- end
38
-
39
- # Rspack commands are not compatible with --config option.
40
- if (@argv & RSPACK_COMMANDS).empty?
41
- cmd += ["--config", @webpack_config]
42
- end
43
-
44
- cmd += @argv
45
-
46
- Dir.chdir(@app_path) do
47
- Kernel.exec env, *cmd
48
- end
7
+ def self.run(argv)
8
+ $stdout.sync = true
9
+ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "development"
10
+ new(argv).run
49
11
  end
50
12
 
51
13
  private
@@ -7,10 +7,54 @@ require "pathname"
7
7
 
8
8
  module Shakapacker
9
9
  class Runner
10
+ attr_reader :config
11
+
12
+ # Common commands that don't work with --config option
13
+ BASE_COMMANDS = [
14
+ "help",
15
+ "h",
16
+ "--help",
17
+ "-h",
18
+ "version",
19
+ "v",
20
+ "--version",
21
+ "-v",
22
+ "info",
23
+ "i"
24
+ ].freeze
10
25
  def self.run(argv)
11
26
  $stdout.sync = true
12
27
  ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "development"
13
- new(argv).run
28
+
29
+ # Create a single runner instance to avoid loading configuration twice.
30
+ # We extend it with the appropriate build command based on the bundler type.
31
+ runner = new(argv)
32
+
33
+ if runner.config.rspack?
34
+ require_relative "rspack_runner"
35
+ # Extend the runner instance with rspack-specific methods
36
+ # This avoids creating a new RspackRunner which would reload the configuration
37
+ runner.extend(Module.new do
38
+ def build_cmd
39
+ package_json.manager.native_exec_command("rspack")
40
+ end
41
+
42
+ def assets_bundler_commands
43
+ BASE_COMMANDS + %w[build watch]
44
+ end
45
+ end)
46
+ runner.run
47
+ else
48
+ require_relative "webpack_runner"
49
+ # Extend the runner instance with webpack-specific methods
50
+ # This avoids creating a new WebpackRunner which would reload the configuration
51
+ runner.extend(Module.new do
52
+ def build_cmd
53
+ package_json.manager.native_exec_command("webpack")
54
+ end
55
+ end)
56
+ runner.run
57
+ end
14
58
  end
15
59
 
16
60
  def initialize(argv)
@@ -23,7 +67,7 @@ module Shakapacker
23
67
  config_path: Pathname.new(@shakapacker_config),
24
68
  env: ENV["RAILS_ENV"] || ENV["NODE_ENV"] || "development"
25
69
  )
26
- @webpack_config = find_bundler_config
70
+ @webpack_config = find_assets_bundler_config
27
71
 
28
72
  Shakapacker::Utils::Manager.error_unless_package_manager_is_obvious!
29
73
  end
@@ -32,8 +76,55 @@ module Shakapacker
32
76
  @package_json ||= PackageJson.read(@app_path)
33
77
  end
34
78
 
79
+ def run
80
+ puts "[Shakapacker] Preparing environment for assets bundler execution..."
81
+ env = Shakapacker::Compiler.env
82
+ env["SHAKAPACKER_CONFIG"] = @shakapacker_config
83
+ env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""
84
+
85
+ cmd = build_cmd
86
+ puts "[Shakapacker] Base command: #{cmd.join(" ")}"
87
+
88
+ if @argv.delete("--debug-shakapacker")
89
+ puts "[Shakapacker] Debug mode enabled (--debug-shakapacker)"
90
+ env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --inspect-brk"
91
+ end
92
+
93
+ if @argv.delete "--trace-deprecation"
94
+ puts "[Shakapacker] Trace deprecation enabled (--trace-deprecation)"
95
+ env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --trace-deprecation"
96
+ end
97
+
98
+ if @argv.delete "--no-deprecation"
99
+ puts "[Shakapacker] Deprecation warnings disabled (--no-deprecation)"
100
+ env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --no-deprecation"
101
+ end
102
+
103
+ # Commands are not compatible with --config option.
104
+ if (@argv & assets_bundler_commands).empty?
105
+ puts "[Shakapacker] Adding config file: #{@webpack_config}"
106
+ cmd += ["--config", @webpack_config]
107
+ else
108
+ puts "[Shakapacker] Skipping config file (running assets bundler command: #{(@argv & assets_bundler_commands).join(", ")})"
109
+ end
110
+
111
+ cmd += @argv
112
+ puts "[Shakapacker] Final command: #{cmd.join(" ")}"
113
+ puts "[Shakapacker] Working directory: #{@app_path}"
114
+
115
+ Dir.chdir(@app_path) do
116
+ Kernel.exec env, *cmd
117
+ end
118
+ end
119
+
120
+ protected
121
+
122
+ def assets_bundler_commands
123
+ BASE_COMMANDS
124
+ end
125
+
35
126
  private
36
- def find_bundler_config
127
+ def find_assets_bundler_config
37
128
  if @config.rspack?
38
129
  find_rspack_config_with_fallback
39
130
  else
@@ -41,34 +132,35 @@ module Shakapacker
41
132
  end
42
133
  end
43
134
 
44
- def get_bundler_type
45
- @config.bundler
46
- end
47
-
48
135
  def find_rspack_config_with_fallback
49
136
  # First try rspack-specific paths
50
137
  rspack_paths = %w[ts js].map do |ext|
51
138
  File.join(@app_path, "config/rspack/rspack.config.#{ext}")
52
139
  end
53
140
 
141
+ puts "[Shakapacker] Looking for Rspack config in: #{rspack_paths.join(", ")}"
54
142
  rspack_path = rspack_paths.find { |f| File.exist?(f) }
55
- return rspack_path if rspack_path
143
+ if rspack_path
144
+ puts "[Shakapacker] Found Rspack config: #{rspack_path}"
145
+ return rspack_path
146
+ end
56
147
 
57
148
  # Fallback to webpack config with deprecation warning
58
149
  webpack_paths = %w[ts js].map do |ext|
59
150
  File.join(@app_path, "config/webpack/webpack.config.#{ext}")
60
151
  end
61
152
 
153
+ puts "[Shakapacker] Rspack config not found, checking for webpack config fallback..."
62
154
  webpack_path = webpack_paths.find { |f| File.exist?(f) }
63
155
  if webpack_path
64
- $stderr.puts "⚠️ DEPRECATION WARNING: Using webpack config file for Rspack bundler."
156
+ $stderr.puts "⚠️ DEPRECATION WARNING: Using webpack config file for Rspack assets bundler."
65
157
  $stderr.puts " Please create config/rspack/rspack.config.js and migrate your configuration."
66
158
  $stderr.puts " Using: #{webpack_path}"
67
159
  return webpack_path
68
160
  end
69
161
 
70
162
  # No config found
71
- $stderr.puts "rspack config #{rspack_paths.last} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or create the missing config file."
163
+ $stderr.puts "[Shakapacker] ERROR: rspack config #{rspack_paths.last} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or create the missing config file."
72
164
  exit(1)
73
165
  end
74
166
 
@@ -76,11 +168,13 @@ module Shakapacker
76
168
  possible_paths = %w[ts js].map do |ext|
77
169
  File.join(@app_path, "config/webpack/webpack.config.#{ext}")
78
170
  end
171
+ puts "[Shakapacker] Looking for Webpack config in: #{possible_paths.join(", ")}"
79
172
  path = possible_paths.find { |f| File.exist?(f) }
80
173
  unless path
81
- $stderr.puts "webpack config #{possible_paths.last} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or add the missing config file for your custom environment."
174
+ $stderr.puts "[Shakapacker] ERROR: webpack config #{possible_paths.last} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or add the missing config file for your custom environment."
82
175
  exit(1)
83
176
  end
177
+ puts "[Shakapacker] Found Webpack config: #{path}"
84
178
  path
85
179
  end
86
180
  end
@@ -58,6 +58,8 @@ module Shakapacker
58
58
  def self.rails_root
59
59
  if defined?(APP_ROOT)
60
60
  Pathname.new(APP_ROOT)
61
+ elsif ENV["APP_ROOT"]
62
+ Pathname.new(ENV["APP_ROOT"])
61
63
  elsif defined?(Rails)
62
64
  Rails.root
63
65
  else
@@ -1,4 +1,4 @@
1
1
  module Shakapacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "9.0.0.beta.0".freeze
3
+ VERSION = "9.0.0.beta.3".freeze
4
4
  end
@@ -126,7 +126,7 @@ module Shakapacker
126
126
  end
127
127
 
128
128
  def relative_path?
129
- raw.match(%r{(\.\.|\Afile:///)}).present?
129
+ raw.match(%r{(\.\.|\Afile:)}).present?
130
130
  end
131
131
 
132
132
  def git_url?
@@ -4,48 +4,10 @@ require_relative "runner"
4
4
 
5
5
  module Shakapacker
6
6
  class WebpackRunner < Shakapacker::Runner
7
- WEBPACK_COMMANDS = [
8
- "help",
9
- "h",
10
- "--help",
11
- "-h",
12
- "version",
13
- "v",
14
- "--version",
15
- "-v",
16
- "info",
17
- "i"
18
- ].freeze
19
-
20
- def run
21
- env = Shakapacker::Compiler.env
22
- env["SHAKAPACKER_CONFIG"] = @shakapacker_config
23
- env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""
24
-
25
- cmd = build_cmd
26
-
27
- if @argv.delete("--debug-shakapacker")
28
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --inspect-brk"
29
- end
30
-
31
- if @argv.delete "--trace-deprecation"
32
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --trace-deprecation"
33
- end
34
-
35
- if @argv.delete "--no-deprecation"
36
- env["NODE_OPTIONS"] = "#{env["NODE_OPTIONS"]} --no-deprecation"
37
- end
38
-
39
- # Webpack commands are not compatible with --config option.
40
- if (@argv & WEBPACK_COMMANDS).empty?
41
- cmd += ["--config", @webpack_config]
42
- end
43
-
44
- cmd += @argv
45
-
46
- Dir.chdir(@app_path) do
47
- Kernel.exec env, *cmd
48
- end
7
+ def self.run(argv)
8
+ $stdout.sync = true
9
+ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "development"
10
+ new(argv).run
49
11
  end
50
12
 
51
13
  private
@@ -2,10 +2,14 @@ install_template_path = File.expand_path("../../install/template.rb", __dir__).f
2
2
  bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
3
3
 
4
4
  namespace :shakapacker do
5
- desc "Install Shakapacker in this application"
6
- task install: [:check_node] do |task|
5
+ desc "Install Shakapacker in this application (use ASSETS_BUNDLER=rspack for Rspack)"
6
+ task :install, [:bundler] => [:check_node] do |task, args|
7
7
  Shakapacker::Configuration.installing = true
8
8
 
9
+ if args[:bundler] == "rspack" || ENV["ASSETS_BUNDLER"] == "rspack"
10
+ ENV["SHAKAPACKER_ASSETS_BUNDLER"] = "rspack"
11
+ end
12
+
9
13
  prefix = task.name.split(/#|shakapacker:install/).first
10
14
 
11
15
  if Rails::VERSION::MAJOR >= 5
data/package/config.js CHANGED
@@ -53,4 +53,28 @@ if (config.manifest_path) {
53
53
  // Ensure no duplicate hash functions exist in the returned config object
54
54
  config.integrity.hash_functions = [...new Set(config.integrity.hash_functions)]
55
55
 
56
+ // Allow ENV variable to override assets_bundler
57
+ if (process.env.SHAKAPACKER_ASSETS_BUNDLER) {
58
+ config.assets_bundler = process.env.SHAKAPACKER_ASSETS_BUNDLER
59
+ }
60
+
61
+ // Define clear defaults
62
+ const DEFAULT_JAVASCRIPT_TRANSPILER =
63
+ config.assets_bundler === "rspack" ? "swc" : "babel"
64
+
65
+ // Backward compatibility: Add webpack_loader property that maps to javascript_transpiler
66
+ // Show deprecation warning if webpack_loader is used
67
+ if (config.webpack_loader && !config.javascript_transpiler) {
68
+ console.warn(
69
+ "⚠️ DEPRECATION WARNING: The 'webpack_loader' configuration option is deprecated. Please use 'javascript_transpiler' instead as it better reflects its purpose of configuring JavaScript transpilation regardless of the bundler used."
70
+ )
71
+ config.javascript_transpiler = config.webpack_loader
72
+ } else if (!config.javascript_transpiler) {
73
+ config.javascript_transpiler =
74
+ config.webpack_loader || DEFAULT_JAVASCRIPT_TRANSPILER
75
+ }
76
+
77
+ // Ensure webpack_loader is always available for backward compatibility
78
+ config.webpack_loader = config.javascript_transpiler
79
+
56
80
  module.exports = config
@@ -7,9 +7,19 @@ const extname = require("path-complete-extname")
7
7
  const config = require("../config")
8
8
  const { isProduction } = require("../env")
9
9
 
10
- const pluginsPath = resolve(__dirname, "..", "plugins", `${config.bundler}.js`)
10
+ const pluginsPath = resolve(
11
+ __dirname,
12
+ "..",
13
+ "plugins",
14
+ `${config.assets_bundler}.js`
15
+ )
11
16
  const { getPlugins } = require(pluginsPath)
12
- const rulesPath = resolve(__dirname, "..", "rules", `${config.bundler}.js`)
17
+ const rulesPath = resolve(
18
+ __dirname,
19
+ "..",
20
+ "rules",
21
+ `${config.assets_bundler}.js`
22
+ )
13
23
  const rules = require(rulesPath)
14
24
 
15
25
  // Don't use contentHash except for production for performance
@@ -3,26 +3,66 @@ const config = require("../config")
3
3
  const baseConfig = require("./base")
4
4
  const webpackDevServerConfig = require("../webpackDevServerConfig")
5
5
  const { runningWebpackDevServer } = require("../env")
6
+ const { moduleExists } = require("../utils/helpers")
6
7
 
7
- const webpackDevConfig = {
8
+ const baseDevConfig = {
8
9
  mode: "development",
9
- devtool: "cheap-module-source-map",
10
- ...(runningWebpackDevServer && { devServer: webpackDevServerConfig() })
10
+ devtool: "cheap-module-source-map"
11
11
  }
12
12
 
13
- const rspackDevConfig = {
14
- mode: "development",
15
- devtool: "cheap-module-source-map",
16
- // Force writing assets to disk in development for Rails compatibility
17
- devServer: {
18
- ...webpackDevServerConfig(),
19
- devMiddleware: {
20
- writeToDisk: true
13
+ const webpackDevConfig = () => {
14
+ const webpackConfig = {
15
+ ...baseDevConfig,
16
+ ...(runningWebpackDevServer && { devServer: webpackDevServerConfig() })
17
+ }
18
+
19
+ const devServerConfig = webpackDevServerConfig()
20
+ if (
21
+ runningWebpackDevServer &&
22
+ devServerConfig.hot &&
23
+ moduleExists("@pmmmwh/react-refresh-webpack-plugin")
24
+ ) {
25
+ // eslint-disable-next-line global-require
26
+ const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin")
27
+ webpackConfig.plugins = [
28
+ ...(webpackConfig.plugins || []),
29
+ new ReactRefreshWebpackPlugin()
30
+ ]
31
+ }
32
+
33
+ return webpackConfig
34
+ }
35
+
36
+ const rspackDevConfig = () => {
37
+ const devServerConfig = webpackDevServerConfig()
38
+ const rspackConfig = {
39
+ ...baseDevConfig,
40
+ devServer: {
41
+ ...devServerConfig,
42
+ devMiddleware: {
43
+ ...devServerConfig.devMiddleware,
44
+ writeToDisk: (filePath) => !filePath.includes(".hot-update.")
45
+ }
21
46
  }
22
47
  }
48
+
49
+ if (
50
+ runningWebpackDevServer &&
51
+ devServerConfig.hot &&
52
+ moduleExists("@rspack/plugin-react-refresh")
53
+ ) {
54
+ // eslint-disable-next-line global-require
55
+ const ReactRefreshPlugin = require("@rspack/plugin-react-refresh")
56
+ rspackConfig.plugins = [
57
+ ...(rspackConfig.plugins || []),
58
+ new ReactRefreshPlugin()
59
+ ]
60
+ }
61
+
62
+ return rspackConfig
23
63
  }
24
64
 
25
65
  const bundlerConfig =
26
- config.bundler === "rspack" ? rspackDevConfig : webpackDevConfig
66
+ config.assets_bundler === "rspack" ? rspackDevConfig() : webpackDevConfig()
27
67
 
28
68
  module.exports = merge(baseConfig, bundlerConfig)
@@ -1,14 +1,19 @@
1
1
  /* eslint global-require: 0 */
2
2
  /* eslint import/no-dynamic-require: 0 */
3
3
 
4
- const { merge } = require("webpack-merge")
5
4
  const { resolve } = require("path")
5
+ const { merge } = require("webpack-merge")
6
6
  const baseConfig = require("./base")
7
7
  const { moduleExists } = require("../utils/helpers")
8
8
  const config = require("../config")
9
9
 
10
- const path = resolve(__dirname, "..", "optimization", `${config.bundler}.js`)
11
- const { getOptimization } = require(path)
10
+ const optimizationPath = resolve(
11
+ __dirname,
12
+ "..",
13
+ "optimization",
14
+ `${config.assets_bundler}.js`
15
+ )
16
+ const { getOptimization } = require(optimizationPath)
12
17
 
13
18
  let CompressionPlugin = null
14
19
  if (moduleExists("compression-webpack-plugin")) {
@@ -2,16 +2,18 @@ const { merge } = require("webpack-merge")
2
2
  const config = require("../config")
3
3
  const baseConfig = require("./base")
4
4
 
5
- const rspackTestConfig = {
5
+ const rspackTestConfig = () => ({
6
6
  mode: "development",
7
7
  devtool: "cheap-module-source-map",
8
8
  // Disable file watching in test mode
9
9
  watchOptions: {
10
10
  ignored: /node_modules/
11
11
  }
12
- }
12
+ })
13
+
14
+ const webpackTestConfig = () => ({})
13
15
 
14
16
  const bundlerConfig =
15
- config.bundler === "rspack" ? rspackTestConfig : baseConfig
17
+ config.assets_bundler === "rspack" ? rspackTestConfig() : webpackTestConfig()
16
18
 
17
19
  module.exports = merge(baseConfig, bundlerConfig)