shakapacker 9.3.1 → 9.3.2
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.
- checksums.yaml +4 -4
- data/.claude/commands/update-changelog.md +26 -18
- data/CHANGELOG.md +12 -4
- data/CONTRIBUTING.md +4 -17
- data/Gemfile.lock +1 -1
- data/README.md +16 -11
- data/docs/cdn_setup.md +3 -3
- data/docs/common-upgrades.md +6 -7
- data/docs/configuration.md +3 -3
- data/docs/deployment.md +3 -3
- data/docs/early_hints_manual_api.md +1 -1
- data/docs/feature_testing.md +3 -3
- data/docs/optional-peer-dependencies.md +2 -2
- data/docs/precompile_hook.md +15 -15
- data/docs/react.md +1 -1
- data/docs/releasing.md +7 -7
- data/docs/rspack_migration_guide.md +8 -14
- data/docs/troubleshooting.md +3 -3
- data/docs/v6_upgrade.md +2 -2
- data/docs/v9_upgrade.md +68 -2
- data/lib/shakapacker/bundler_switcher.rb +83 -18
- data/lib/shakapacker/doctor.rb +6 -6
- data/lib/shakapacker/runner.rb +1 -1
- data/lib/shakapacker/swc_migrator.rb +2 -2
- data/lib/shakapacker/version.rb +1 -1
- data/lib/tasks/shakapacker/binstubs.rake +4 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +2 -2
- data/lib/tasks/shakapacker/doctor.rake +3 -3
- data/lib/tasks/shakapacker/export_bundler_config.rake +5 -9
- data/lib/tasks/shakapacker/install.rake +4 -2
- data/lib/tasks/shakapacker/switch_bundler.rake +30 -40
- data/package/index.d.ts +1 -1
- data/package/index.d.ts.template +1 -1
- data/package/loaders.d.ts +1 -1
- data/package/webpack-types.d.ts +1 -1
- data/package.json +3 -3
- data/yarn.lock +1 -1
- metadata +2 -2
data/docs/v6_upgrade.md
CHANGED
|
@@ -80,7 +80,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
```bash
|
|
83
|
-
bundle exec
|
|
83
|
+
bundle exec rake webpacker:install
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Overwrite all files and check what changed.
|
|
@@ -181,7 +181,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
|
181
181
|
|
|
182
182
|
1. Make sure that you can run `bin/webpack` without errors.
|
|
183
183
|
|
|
184
|
-
1. Try running `RAILS_ENV=production
|
|
184
|
+
1. Try running `RAILS_ENV=production rake assets:precompile`. If all goes well, don't forget to clean the generated assets with `rake assets:clobber`.
|
|
185
185
|
|
|
186
186
|
1. Run `yarn add webpack-dev-server` if those are not already in your dev dependencies. Make sure you're using v4+.
|
|
187
187
|
|
data/docs/v9_upgrade.md
CHANGED
|
@@ -155,8 +155,74 @@ import * as styles from './Component.module.css';
|
|
|
155
155
|
This allows you to keep using default imports while migrating gradually
|
|
156
156
|
|
|
157
157
|
3. **Keep v8 behavior** using webpack configuration (Advanced):
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
|
|
159
|
+
If you need more control over the configuration, you can override the css-loader settings directly in your webpack config.
|
|
160
|
+
|
|
161
|
+
**Where to add this:** Create or modify `config/webpack/webpack.config.js`. If this file doesn't exist, create it and ensure your `config/webpacker.yml` or build process loads it. See [Webpack Configuration](./webpack.md) for details on customizing webpack.
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// config/webpack/webpack.config.js
|
|
165
|
+
const { generateWebpackConfig, merge } = require("shakapacker")
|
|
166
|
+
|
|
167
|
+
const customConfig = () => {
|
|
168
|
+
const config = merge({}, generateWebpackConfig())
|
|
169
|
+
|
|
170
|
+
// Override CSS Modules to use default exports (v8 behavior)
|
|
171
|
+
config.module.rules.forEach((rule) => {
|
|
172
|
+
if (
|
|
173
|
+
rule.test &&
|
|
174
|
+
(rule.test.test("example.module.scss") ||
|
|
175
|
+
rule.test.test("example.module.css"))
|
|
176
|
+
) {
|
|
177
|
+
if (Array.isArray(rule.use)) {
|
|
178
|
+
rule.use.forEach((loader) => {
|
|
179
|
+
if (
|
|
180
|
+
loader.loader &&
|
|
181
|
+
loader.loader.includes("css-loader") &&
|
|
182
|
+
loader.options &&
|
|
183
|
+
loader.options.modules
|
|
184
|
+
) {
|
|
185
|
+
// Disable named exports to support default imports
|
|
186
|
+
loader.options.modules.namedExport = false
|
|
187
|
+
loader.options.modules.exportLocalsConvention = "camelCase"
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
return config
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
module.exports = customConfig
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Key points:**
|
|
201
|
+
- Test both `.module.scss` and `.module.css` file extensions
|
|
202
|
+
- Validate all loader properties exist before accessing them
|
|
203
|
+
- Use `.includes('css-loader')` since the loader path may vary
|
|
204
|
+
- Set both `namedExport: false` and `exportLocalsConvention: 'camelCase'` for full v8 compatibility
|
|
205
|
+
|
|
206
|
+
**Debugging tip:** To verify the override is applied correctly, you can inspect the webpack config:
|
|
207
|
+
|
|
208
|
+
```javascript
|
|
209
|
+
// Add this temporarily to verify your changes
|
|
210
|
+
if (process.env.DEBUG_WEBPACK_CONFIG) {
|
|
211
|
+
const cssModuleRules = config.module.rules
|
|
212
|
+
.filter((r) => r.test?.test?.("example.module.css"))
|
|
213
|
+
.flatMap((r) => r.use?.filter((l) => l.loader?.includes("css-loader")))
|
|
214
|
+
console.log(
|
|
215
|
+
"CSS Module loader options:",
|
|
216
|
+
JSON.stringify(cssModuleRules, null, 2)
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Then run: `DEBUG_WEBPACK_CONFIG=true bin/shakapacker`
|
|
222
|
+
|
|
223
|
+
**Note:** This is a temporary solution. The recommended approach is to migrate your imports to use named exports as shown in the main documentation.
|
|
224
|
+
|
|
225
|
+
For detailed configuration options, see the [CSS Modules Export Mode documentation](./css-modules-export-mode.md)
|
|
160
226
|
|
|
161
227
|
**Benefits of the change:**
|
|
162
228
|
|
|
@@ -9,6 +9,9 @@ module Shakapacker
|
|
|
9
9
|
SHAKAPACKER_CONFIG = "config/shakapacker.yml"
|
|
10
10
|
CUSTOM_DEPS_CONFIG = ".shakapacker-switch-bundler-dependencies.yml"
|
|
11
11
|
|
|
12
|
+
# Regex pattern to detect assets_bundler key in config (only matches uncommented lines)
|
|
13
|
+
ASSETS_BUNDLER_PATTERN = /^[ \t]*assets_bundler:/
|
|
14
|
+
|
|
12
15
|
# Default dependencies for each bundler (package names only, no versions)
|
|
13
16
|
DEFAULT_RSPACK_DEPS = {
|
|
14
17
|
dev: %w[@rspack/cli @rspack/plugin-react-refresh],
|
|
@@ -37,18 +40,33 @@ module Shakapacker
|
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
current = current_bundler
|
|
40
|
-
|
|
43
|
+
config_content = File.read(config_path)
|
|
44
|
+
has_assets_bundler = config_content =~ ASSETS_BUNDLER_PATTERN
|
|
45
|
+
|
|
46
|
+
# Early exit if already using the target bundler
|
|
47
|
+
# For webpack: if current is webpack, we're done (key optional due to default)
|
|
48
|
+
# For rspack: requires explicit key to be present
|
|
49
|
+
already_configured = if bundler == "webpack"
|
|
50
|
+
current == bundler
|
|
51
|
+
else
|
|
52
|
+
current == bundler && has_assets_bundler
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if already_configured && !install_deps
|
|
41
56
|
puts "✅ Already using #{bundler}"
|
|
42
57
|
return
|
|
43
58
|
end
|
|
44
59
|
|
|
45
|
-
if
|
|
60
|
+
if already_configured && install_deps
|
|
46
61
|
puts "✅ Already using #{bundler} - reinstalling dependencies as requested"
|
|
47
62
|
manage_dependencies(bundler, install_deps, switching: false, no_uninstall: no_uninstall)
|
|
48
63
|
return
|
|
49
64
|
end
|
|
50
65
|
|
|
51
|
-
update_config(bundler)
|
|
66
|
+
successfully_updated = update_config(bundler, config_content, has_assets_bundler)
|
|
67
|
+
|
|
68
|
+
# Verify the update was successful (only if update reported success)
|
|
69
|
+
verify_config_update(bundler) if successfully_updated
|
|
52
70
|
|
|
53
71
|
puts "✅ Switched from #{current} to #{bundler}"
|
|
54
72
|
puts ""
|
|
@@ -95,22 +113,15 @@ module Shakapacker
|
|
|
95
113
|
puts "Current bundler: #{current}"
|
|
96
114
|
puts ""
|
|
97
115
|
puts "Usage:"
|
|
98
|
-
puts " rails shakapacker:switch_bundler [webpack|rspack] [OPTIONS]"
|
|
99
116
|
puts " rake shakapacker:switch_bundler [webpack|rspack] -- [OPTIONS]"
|
|
100
117
|
puts ""
|
|
101
118
|
puts "Options:"
|
|
102
119
|
puts " --install-deps Automatically install/uninstall dependencies"
|
|
103
|
-
puts " --no-uninstall Skip uninstalling old bundler packages
|
|
120
|
+
puts " --no-uninstall Skip uninstalling old bundler packages"
|
|
104
121
|
puts " --init-config Create #{CUSTOM_DEPS_CONFIG} with default dependencies"
|
|
105
122
|
puts " --help, -h Show this help message"
|
|
106
123
|
puts ""
|
|
107
124
|
puts "Examples:"
|
|
108
|
-
puts " # Using rails command"
|
|
109
|
-
puts " rails shakapacker:switch_bundler rspack --install-deps"
|
|
110
|
-
puts " rails shakapacker:switch_bundler webpack --install-deps --no-uninstall"
|
|
111
|
-
puts " rails shakapacker:switch_bundler --init-config"
|
|
112
|
-
puts ""
|
|
113
|
-
puts " # Using rake command (note the -- separator)"
|
|
114
125
|
puts " rake shakapacker:switch_bundler rspack -- --install-deps"
|
|
115
126
|
puts " rake shakapacker:switch_bundler webpack -- --install-deps --no-uninstall"
|
|
116
127
|
puts " rake shakapacker:switch_bundler -- --init-config"
|
|
@@ -150,20 +161,74 @@ module Shakapacker
|
|
|
150
161
|
end
|
|
151
162
|
end
|
|
152
163
|
|
|
153
|
-
def update_config(bundler)
|
|
154
|
-
|
|
164
|
+
def update_config(bundler, content, has_assets_bundler)
|
|
165
|
+
# Check if assets_bundler key exists (only uncommented lines)
|
|
166
|
+
unless has_assets_bundler
|
|
167
|
+
# Track whether we successfully added the key
|
|
168
|
+
added = false
|
|
169
|
+
|
|
170
|
+
# Add assets_bundler after javascript_transpiler if it exists (excluding commented lines)
|
|
171
|
+
if (match = content.match(/^[ \t]*(?![ \t]*#)javascript_transpiler:.*$/))
|
|
172
|
+
indent = match[0][/^[ \t]*/]
|
|
173
|
+
content.sub!(/^([ \t]*(?![ \t]*#)javascript_transpiler:.*$)/, "\\1\n#{assets_bundler_entry(bundler, indent)}")
|
|
174
|
+
added = true
|
|
175
|
+
# Otherwise, add it after source_path if it exists (excluding commented lines)
|
|
176
|
+
elsif (match = content.match(/^[ \t]*(?![ \t]*#)source_path:.*$/))
|
|
177
|
+
indent = match[0][/^[ \t]*/]
|
|
178
|
+
content.sub!(/^([ \t]*(?![ \t]*#)source_path:.*$)/, "\\1\n#{assets_bundler_entry(bundler, indent)}")
|
|
179
|
+
added = true
|
|
180
|
+
# Add it after default: &default if it exists
|
|
181
|
+
elsif content.match?(/^default:[ \t]*&default[ \t]*$/)
|
|
182
|
+
# Use default 2-space indentation for this case
|
|
183
|
+
content.sub!(/^(default:[ \t]*&default[ \t]*)$/, "\\1\n#{assets_bundler_entry(bundler, ' ')}")
|
|
184
|
+
added = true
|
|
185
|
+
# Fallback: add after "default:" with proper indentation detection (handles blank lines)
|
|
186
|
+
elsif (match = content.match(/^default:\s*\n\s*([ \t]+)/m))
|
|
187
|
+
# Extract indentation from first indented line after "default:"
|
|
188
|
+
indent = match[1]
|
|
189
|
+
content.sub!(/^(default:\s*)$/, "\\1\n#{assets_bundler_entry(bundler, indent)}")
|
|
190
|
+
added = true
|
|
191
|
+
end
|
|
155
192
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
193
|
+
unless added
|
|
194
|
+
puts "⚠️ Warning: Could not find appropriate location for assets_bundler in config"
|
|
195
|
+
puts " Please add 'assets_bundler: #{bundler}' to the default section manually"
|
|
196
|
+
end
|
|
197
|
+
else
|
|
198
|
+
# Replace existing assets_bundler value (handles spaces, tabs, and various quote styles)
|
|
199
|
+
# Only matches uncommented lines
|
|
200
|
+
content.gsub!(/^([ \t]*)(?![ \t]*#)(assets_bundler:[ \t]*['"]?)(webpack|rspack)(['"]?)/, "\\1\\2#{bundler}\\4")
|
|
201
|
+
added = true
|
|
202
|
+
end
|
|
159
203
|
|
|
160
204
|
# Update javascript_transpiler recommendation for rspack
|
|
161
205
|
# Only update if not already set to swc and only on uncommented lines
|
|
162
|
-
if bundler == "rspack" && content !~ /^[ \t]*javascript_transpiler:[ \t]*['"]?swc['"]?/
|
|
163
|
-
content.gsub!(/^([ \t]*javascript_transpiler:[ \t]*['"]?)\w+(['"]?)/,
|
|
206
|
+
if bundler == "rspack" && content !~ /^[ \t]*(?![ \t]*#)javascript_transpiler:[ \t]*['"]?swc['"]?/
|
|
207
|
+
content.gsub!(/^([ \t]*(?![ \t]*#)javascript_transpiler:[ \t]*['"]?)(\w+)(['"]?)/, '\1swc\3')
|
|
164
208
|
end
|
|
165
209
|
|
|
166
210
|
File.write(config_path, content)
|
|
211
|
+
added
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Verify that the config was updated successfully
|
|
215
|
+
def verify_config_update(bundler)
|
|
216
|
+
config = load_yaml_config(config_path)
|
|
217
|
+
actual_bundler = config.dig("default", "assets_bundler")
|
|
218
|
+
|
|
219
|
+
if actual_bundler != bundler
|
|
220
|
+
raise "Config update verification failed: expected assets_bundler to be '#{bundler}', but got '#{actual_bundler}'"
|
|
221
|
+
end
|
|
222
|
+
rescue Psych::SyntaxError => e
|
|
223
|
+
raise "Config update generated invalid YAML: #{e.message}"
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Generate the assets_bundler YAML entry with proper indentation
|
|
227
|
+
# @param bundler [String] The bundler name ('webpack' or 'rspack')
|
|
228
|
+
# @param indent [String] The indentation string to use (e.g., ' ' or '\t')
|
|
229
|
+
# @return [String] The formatted YAML entry
|
|
230
|
+
def assets_bundler_entry(bundler, indent)
|
|
231
|
+
"\n#{indent}# Select assets bundler to use\n#{indent}# Available options: 'webpack' (default) or 'rspack'\n#{indent}assets_bundler: \"#{bundler}\""
|
|
167
232
|
end
|
|
168
233
|
|
|
169
234
|
def manage_dependencies(bundler, install_deps, switching: true, no_uninstall: false)
|
data/lib/shakapacker/doctor.rb
CHANGED
|
@@ -54,7 +54,7 @@ module Shakapacker
|
|
|
54
54
|
Shakapacker Doctor - Diagnostic tool for Shakapacker configuration
|
|
55
55
|
|
|
56
56
|
Usage:
|
|
57
|
-
|
|
57
|
+
bundle exec rake shakapacker:doctor [options]
|
|
58
58
|
|
|
59
59
|
Options:
|
|
60
60
|
--help Show this help message
|
|
@@ -163,7 +163,7 @@ module Shakapacker
|
|
|
163
163
|
begin
|
|
164
164
|
manifest_content = JSON.parse(File.read(manifest_path))
|
|
165
165
|
if manifest_content.empty?
|
|
166
|
-
add_warning("Manifest file is empty - you may need to run '
|
|
166
|
+
add_warning("Manifest file is empty - you may need to run 'bundle exec rake assets:precompile'")
|
|
167
167
|
end
|
|
168
168
|
rescue JSON::ParserError
|
|
169
169
|
@issues << "Manifest file #{manifest_path} contains invalid JSON"
|
|
@@ -325,16 +325,16 @@ module Shakapacker
|
|
|
325
325
|
if source_files.any?
|
|
326
326
|
newest_source = source_files.map { |f| File.mtime(f) }.max
|
|
327
327
|
if newest_source > File.mtime(manifest_path)
|
|
328
|
-
add_warning("Source files have been modified after last asset compilation. Run '
|
|
328
|
+
add_warning("Source files have been modified after last asset compilation. Run 'bundle exec rake assets:precompile'")
|
|
329
329
|
end
|
|
330
330
|
end
|
|
331
331
|
else
|
|
332
332
|
rails_env = defined?(Rails) ? Rails.env : ENV["RAILS_ENV"]
|
|
333
333
|
if rails_env == "production"
|
|
334
|
-
@issues << "No compiled assets found (manifest.json missing). Run '
|
|
334
|
+
@issues << "No compiled assets found (manifest.json missing). Run 'bundle exec rake assets:precompile'"
|
|
335
335
|
elsif options[:verbose]
|
|
336
336
|
# Only show in verbose mode for non-production environments
|
|
337
|
-
@info << "Assets not yet compiled. Run '
|
|
337
|
+
@info << "Assets not yet compiled. Run 'bundle exec rake assets:precompile' or start the dev server"
|
|
338
338
|
end
|
|
339
339
|
end
|
|
340
340
|
end
|
|
@@ -402,7 +402,7 @@ module Shakapacker
|
|
|
402
402
|
|
|
403
403
|
unless missing_binstubs.empty?
|
|
404
404
|
add_action_required("Missing binstubs: #{missing_binstubs.join(', ')}.")
|
|
405
|
-
add_action_required(" Fix: Run '
|
|
405
|
+
add_action_required(" Fix: Run 'bundle exec rake shakapacker:binstubs' to create them.")
|
|
406
406
|
end
|
|
407
407
|
end
|
|
408
408
|
|
data/lib/shakapacker/runner.rb
CHANGED
|
@@ -302,7 +302,7 @@ module Shakapacker
|
|
|
302
302
|
def print_config_not_found_error(bundler_type, config_path, config_dir)
|
|
303
303
|
$stderr.puts "[Shakapacker] ERROR: #{bundler_type} config #{config_path} not found."
|
|
304
304
|
$stderr.puts ""
|
|
305
|
-
$stderr.puts "Please run 'bundle exec
|
|
305
|
+
$stderr.puts "Please run 'bundle exec rake shakapacker:install' to install Shakapacker with default configs,"
|
|
306
306
|
$stderr.puts "or create the missing config file."
|
|
307
307
|
$stderr.puts ""
|
|
308
308
|
$stderr.puts "If your config file is in a different location, you can configure it in config/shakapacker.yml:"
|
|
@@ -101,11 +101,11 @@ module Shakapacker
|
|
|
101
101
|
logger.info " - #{package}"
|
|
102
102
|
end
|
|
103
103
|
logger.info "\n To remove them, run:"
|
|
104
|
-
logger.info "
|
|
104
|
+
logger.info " bundle exec rake shakapacker:clean_babel_packages"
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
# Suggest running doctor to verify configuration
|
|
108
|
-
logger.info "\n🩺 Run '
|
|
108
|
+
logger.info "\n🩺 Run 'bundle exec rake shakapacker:doctor' to verify your configuration"
|
|
109
109
|
|
|
110
110
|
# Run package manager install if packages were added
|
|
111
111
|
if run_installer && results[:packages_installed].any?
|
data/lib/shakapacker/version.rb
CHANGED
|
@@ -7,9 +7,11 @@ namespace :shakapacker do
|
|
|
7
7
|
prefix = task.name.split(/#|shakapacker:binstubs/).first
|
|
8
8
|
|
|
9
9
|
if Rails::VERSION::MAJOR >= 5
|
|
10
|
-
|
|
10
|
+
system "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{binstubs_template_path}'" or
|
|
11
|
+
raise "Binstubs installation failed"
|
|
11
12
|
else
|
|
12
|
-
|
|
13
|
+
system "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{binstubs_template_path}'" or
|
|
14
|
+
raise "Binstubs installation failed"
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -11,8 +11,8 @@ def verify_file_existence(binstub_file)
|
|
|
11
11
|
puts <<~MSG
|
|
12
12
|
Couldn't find shakapacker binstubs!
|
|
13
13
|
Possible solutions:
|
|
14
|
-
- Ensure you have run `
|
|
15
|
-
- Run `
|
|
14
|
+
- Ensure you have run `bundle exec rake shakapacker:install`.
|
|
15
|
+
- Run `bundle exec rake shakapacker:binstubs` if you have already installed shakapacker.
|
|
16
16
|
- Ensure the `bin` directory, `bin/shakapacker`, and `bin/shakapacker-dev-server` are not included in .gitignore.
|
|
17
17
|
MSG
|
|
18
18
|
exit!
|
|
@@ -20,9 +20,9 @@ namespace :shakapacker do
|
|
|
20
20
|
--verbose Display additional diagnostic details (paths, versions, environment)
|
|
21
21
|
|
|
22
22
|
Examples:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
bundle exec rake shakapacker:doctor
|
|
24
|
+
bundle exec rake shakapacker:doctor -- --verbose
|
|
25
|
+
bundle exec rake shakapacker:doctor -- --help
|
|
26
26
|
|
|
27
27
|
Exit codes:
|
|
28
28
|
0 - No issues found
|
|
@@ -7,7 +7,6 @@ namespace :shakapacker do
|
|
|
7
7
|
client vs server bundle differences.
|
|
8
8
|
|
|
9
9
|
Usage:
|
|
10
|
-
rails shakapacker:export_bundler_config [OPTIONS]
|
|
11
10
|
rake shakapacker:export_bundler_config -- [OPTIONS]
|
|
12
11
|
|
|
13
12
|
Quick Start (Recommended):
|
|
@@ -28,22 +27,19 @@ namespace :shakapacker do
|
|
|
28
27
|
|
|
29
28
|
Examples:
|
|
30
29
|
# Export all configs for troubleshooting
|
|
31
|
-
|
|
30
|
+
bundle exec rake shakapacker:export_bundler_config -- --doctor
|
|
32
31
|
|
|
33
32
|
# Save production client config
|
|
34
|
-
|
|
33
|
+
bundle exec rake shakapacker:export_bundler_config -- --save --env=production --client-only
|
|
35
34
|
|
|
36
35
|
# View development config in terminal
|
|
37
|
-
|
|
36
|
+
bundle exec rake shakapacker:export_bundler_config
|
|
38
37
|
|
|
39
38
|
# Show detailed help
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Note: When using 'rake', you must use '--' to separate rake options from task arguments.
|
|
43
|
-
Example: rake shakapacker:export_bundler_config -- --doctor
|
|
39
|
+
bundle exec rake shakapacker:export_bundler_config -- --help
|
|
44
40
|
|
|
45
41
|
The task automatically falls back to the gem version if bin/shakapacker-config
|
|
46
|
-
binstub is not installed. To install all binstubs, run:
|
|
42
|
+
binstub is not installed. To install all binstubs, run: bundle exec rake shakapacker:binstubs
|
|
47
43
|
DESC
|
|
48
44
|
task :export_bundler_config do
|
|
49
45
|
# Try to use the binstub if it exists, otherwise use the gem's version
|
|
@@ -19,9 +19,11 @@ namespace :shakapacker do
|
|
|
19
19
|
prefix = task.name.split(/#|shakapacker:install/).first
|
|
20
20
|
|
|
21
21
|
if Rails::VERSION::MAJOR >= 5
|
|
22
|
-
|
|
22
|
+
system "#{RbConfig.ruby} '#{bin_path}/rails' #{prefix}app:template LOCATION='#{install_template_path}'" or
|
|
23
|
+
raise "Installation failed"
|
|
23
24
|
else
|
|
24
|
-
|
|
25
|
+
system "#{RbConfig.ruby} '#{bin_path}/rake' #{prefix}rails:template LOCATION='#{install_template_path}'" or
|
|
26
|
+
raise "Installation failed"
|
|
25
27
|
end
|
|
26
28
|
end
|
|
27
29
|
end
|
|
@@ -8,48 +8,26 @@ namespace :shakapacker do
|
|
|
8
8
|
This task updates config/shakapacker.yml and optionally manages npm dependencies.
|
|
9
9
|
|
|
10
10
|
Usage:
|
|
11
|
-
|
|
12
|
-
rake shakapacker:switch_bundler [webpack|rspack] -- [OPTIONS]
|
|
11
|
+
bin/rake shakapacker:switch_bundler [webpack|rspack] -- [OPTIONS]
|
|
13
12
|
|
|
14
13
|
Options:
|
|
15
14
|
--install-deps Automatically install/uninstall bundler dependencies
|
|
16
|
-
--no-uninstall Skip uninstalling old bundler packages
|
|
15
|
+
--no-uninstall Skip uninstalling old bundler packages
|
|
17
16
|
--init-config Create custom dependencies configuration file
|
|
18
17
|
--help, -h Show detailed help message
|
|
19
18
|
|
|
20
19
|
Examples:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
rake shakapacker:switch_bundler
|
|
24
|
-
|
|
25
|
-
# Fast switching without uninstalling (keeps both bundlers)
|
|
26
|
-
rails shakapacker:switch_bundler webpack --install-deps --no-uninstall
|
|
27
|
-
rake shakapacker:switch_bundler rspack -- --install-deps --no-uninstall
|
|
28
|
-
|
|
29
|
-
# Switch to rspack (manual dependency management)
|
|
30
|
-
rails shakapacker:switch_bundler rspack
|
|
31
|
-
rake shakapacker:switch_bundler rspack
|
|
32
|
-
|
|
33
|
-
# Switch back to webpack with dependency management
|
|
34
|
-
rails shakapacker:switch_bundler webpack --install-deps
|
|
35
|
-
rake shakapacker:switch_bundler webpack -- --install-deps
|
|
36
|
-
|
|
37
|
-
# Create custom dependencies config file
|
|
38
|
-
rails shakapacker:switch_bundler --init-config
|
|
39
|
-
rake shakapacker:switch_bundler -- --init-config
|
|
40
|
-
|
|
41
|
-
# Show current bundler and usage help
|
|
42
|
-
rails shakapacker:switch_bundler --help
|
|
43
|
-
rake shakapacker:switch_bundler -- --help
|
|
44
|
-
|
|
45
|
-
Note: When using 'rake', you must use '--' to separate rake options from task arguments.
|
|
20
|
+
bin/rake shakapacker:switch_bundler rspack -- --install-deps
|
|
21
|
+
bin/rake shakapacker:switch_bundler webpack -- --install-deps --no-uninstall
|
|
22
|
+
bin/rake shakapacker:switch_bundler -- --init-config
|
|
23
|
+
bin/rake shakapacker:switch_bundler -- --help
|
|
46
24
|
|
|
47
25
|
What it does:
|
|
48
26
|
- Updates 'assets_bundler' in config/shakapacker.yml
|
|
49
27
|
- Preserves YAML comments and structure
|
|
50
28
|
- Updates 'javascript_transpiler' to 'swc' when switching to rspack
|
|
51
29
|
- With --install-deps: installs/uninstalls npm dependencies automatically
|
|
52
|
-
- Without
|
|
30
|
+
- Without: shows manual installation commands
|
|
53
31
|
|
|
54
32
|
Custom Dependencies:
|
|
55
33
|
Create .shakapacker-switch-bundler-dependencies.yml to customize which
|
|
@@ -58,22 +36,34 @@ namespace :shakapacker do
|
|
|
58
36
|
See docs/rspack_migration_guide.md for more information.
|
|
59
37
|
DESC
|
|
60
38
|
task :switch_bundler do
|
|
39
|
+
# This task must be run with rake, not rails
|
|
40
|
+
# Check the actual command name, not just if the path contains "rails"
|
|
41
|
+
command_name = File.basename($0)
|
|
42
|
+
if command_name == "rails" || $0.end_with?("/rails")
|
|
43
|
+
puts "\nError: This task must be run with 'bin/rake', not 'bin/rails'"
|
|
44
|
+
puts "Usage: bin/rake shakapacker:switch_bundler [bundler] -- [options]"
|
|
45
|
+
puts "Run 'bin/rake shakapacker:switch_bundler -- --help' for more information"
|
|
46
|
+
exit 1
|
|
47
|
+
end
|
|
48
|
+
|
|
61
49
|
switcher = Shakapacker::BundlerSwitcher.new
|
|
62
50
|
|
|
63
|
-
|
|
51
|
+
# Parse command line arguments
|
|
52
|
+
# ARGV[0] is the task name, ARGV[1] would be the bundler name if provided
|
|
53
|
+
bundler = ARGV.length > 1 ? ARGV[1] : nil
|
|
54
|
+
install_deps = ARGV.include?("--install-deps")
|
|
55
|
+
no_uninstall = ARGV.include?("--no-uninstall")
|
|
56
|
+
init_config = ARGV.include?("--init-config")
|
|
57
|
+
show_help = ARGV.include?("--help") || ARGV.include?("-h")
|
|
58
|
+
|
|
59
|
+
if ARGV.empty? || show_help || (bundler.nil? && !init_config)
|
|
64
60
|
switcher.show_usage
|
|
65
|
-
elsif
|
|
61
|
+
elsif init_config
|
|
66
62
|
switcher.init_config
|
|
63
|
+
elsif bundler.nil? || bundler.start_with?("-")
|
|
64
|
+
switcher.show_usage
|
|
67
65
|
else
|
|
68
|
-
bundler
|
|
69
|
-
install_deps = ARGV.include?("--install-deps")
|
|
70
|
-
no_uninstall = ARGV.include?("--no-uninstall")
|
|
71
|
-
|
|
72
|
-
if bundler.nil? || bundler.start_with?("-")
|
|
73
|
-
switcher.show_usage
|
|
74
|
-
else
|
|
75
|
-
switcher.switch_to(bundler, install_deps: install_deps, no_uninstall: no_uninstall)
|
|
76
|
-
end
|
|
66
|
+
switcher.switch_to(bundler, install_deps: install_deps, no_uninstall: no_uninstall)
|
|
77
67
|
end
|
|
78
68
|
|
|
79
69
|
# Prevent rake from trying to execute arguments as tasks
|
data/package/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* When adding/modifying exports in index.ts, update this file accordingly.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
// @ts-
|
|
10
|
+
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
|
11
11
|
import type { Configuration, RuleSetRule } from "webpack"
|
|
12
12
|
import type { Config, DevServerConfig, Env } from "./types"
|
|
13
13
|
|
data/package/index.d.ts.template
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* When adding/modifying exports in index.ts, update this file accordingly.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
// @ts-
|
|
10
|
+
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
|
11
11
|
import type { Configuration, RuleSetRule } from "webpack"
|
|
12
12
|
import type { Config, DevServerConfig, Env } from "./types"
|
|
13
13
|
|
data/package/loaders.d.ts
CHANGED
data/package/webpack-types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @ts-
|
|
1
|
+
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
|
2
2
|
import type { Configuration, RuleSetRule, RuleSetUseItem } from "webpack"
|
|
3
3
|
|
|
4
4
|
export interface ShakapackerWebpackConfig extends Configuration {
|
data/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shakapacker",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.2",
|
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
|
5
5
|
"homepage": "https://github.com/shakacode/shakapacker",
|
|
6
6
|
"bugs": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"lint-staged": "^15.2.10",
|
|
83
83
|
"memory-fs": "^0.5.0",
|
|
84
84
|
"mini-css-extract-plugin": "^2.9.4",
|
|
85
|
-
"prettier": "^3.2
|
|
85
|
+
"prettier": "^3.6.2",
|
|
86
86
|
"rspack-manifest-plugin": "^5.0.3",
|
|
87
87
|
"sass-loader": "^16.0.5",
|
|
88
88
|
"swc-loader": "^0.1.15",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"babel-loader": "^8.2.4 || ^9.0.0 || ^10.0.0",
|
|
109
109
|
"compression-webpack-plugin": "^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
110
110
|
"css-loader": "^6.8.1 || ^7.0.0",
|
|
111
|
-
"esbuild": "^0.14.0 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0",
|
|
111
|
+
"esbuild": "^0.14.0 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.26.0 || ^0.27.0",
|
|
112
112
|
"esbuild-loader": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
113
113
|
"mini-css-extract-plugin": "^2.0.0",
|
|
114
114
|
"rspack-manifest-plugin": "^5.0.0",
|
data/yarn.lock
CHANGED
|
@@ -5440,7 +5440,7 @@ prelude-ls@^1.2.1:
|
|
|
5440
5440
|
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
|
|
5441
5441
|
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
|
|
5442
5442
|
|
|
5443
|
-
prettier@^3.2
|
|
5443
|
+
prettier@^3.6.2:
|
|
5444
5444
|
version "3.6.2"
|
|
5445
5445
|
resolved "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz#ccda02a1003ebbb2bfda6f83a074978f608b9393"
|
|
5446
5446
|
integrity sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shakapacker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 9.3.
|
|
4
|
+
version: 9.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -389,7 +389,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
|
389
389
|
licenses:
|
|
390
390
|
- MIT
|
|
391
391
|
metadata:
|
|
392
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.
|
|
392
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.2
|
|
393
393
|
rdoc_options: []
|
|
394
394
|
require_paths:
|
|
395
395
|
- lib
|