shakapacker 9.0.0 → 9.2.0

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +108 -11
  4. data/Gemfile.lock +1 -1
  5. data/README.md +182 -107
  6. data/bin/export-bundler-config +11 -0
  7. data/docs/common-upgrades.md +615 -0
  8. data/docs/deployment.md +52 -8
  9. data/docs/releasing.md +197 -0
  10. data/docs/rspack_migration_guide.md +120 -17
  11. data/docs/transpiler-migration.md +21 -0
  12. data/docs/troubleshooting.md +124 -23
  13. data/docs/typescript-migration.md +2 -1
  14. data/docs/using_swc_loader.md +108 -8
  15. data/docs/v9_upgrade.md +45 -0
  16. data/lib/install/bin/export-bundler-config +11 -0
  17. data/lib/install/bin/shakapacker +1 -1
  18. data/lib/install/bin/shakapacker-dev-server +1 -1
  19. data/lib/shakapacker/bundler_switcher.rb +329 -0
  20. data/lib/shakapacker/configuration.rb +28 -2
  21. data/lib/shakapacker/doctor.rb +65 -4
  22. data/lib/shakapacker/rspack_runner.rb +1 -1
  23. data/lib/shakapacker/runner.rb +1 -1
  24. data/lib/shakapacker/swc_migrator.rb +14 -6
  25. data/lib/shakapacker/version.rb +1 -1
  26. data/lib/shakapacker/webpack_runner.rb +1 -1
  27. data/lib/shakapacker.rb +10 -0
  28. data/lib/tasks/shakapacker/export_bundler_config.rake +72 -0
  29. data/lib/tasks/shakapacker/switch_bundler.rake +82 -0
  30. data/lib/tasks/shakapacker.rake +2 -1
  31. data/package/configExporter/cli.ts +683 -0
  32. data/package/configExporter/configDocs.ts +102 -0
  33. data/package/configExporter/fileWriter.ts +92 -0
  34. data/package/configExporter/index.ts +5 -0
  35. data/package/configExporter/types.ts +36 -0
  36. data/package/configExporter/yamlSerializer.ts +266 -0
  37. data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +30 -0
  38. data/package/environments/types.ts +22 -14
  39. data/package/index.ts +12 -9
  40. data/package/swc/index.ts +5 -3
  41. data/package/types/README.md +2 -1
  42. data/package/types/index.ts +1 -0
  43. data/package/utils/debug.ts +5 -5
  44. data/package-lock.json +13047 -0
  45. data/package.json +7 -1
  46. data/yarn.lock +261 -389
  47. metadata +17 -2
@@ -0,0 +1,82 @@
1
+ require "shakapacker/bundler_switcher"
2
+
3
+ namespace :shakapacker do
4
+ desc <<~DESC
5
+ Switch between webpack and rspack bundlers
6
+
7
+ Easily switch your Shakapacker configuration between webpack and rspack bundlers.
8
+ This task updates config/shakapacker.yml and optionally manages npm dependencies.
9
+
10
+ Usage:
11
+ rails shakapacker:switch_bundler [webpack|rspack] [OPTIONS]
12
+ rake shakapacker:switch_bundler [webpack|rspack] -- [OPTIONS]
13
+
14
+ Options:
15
+ --install-deps Automatically install/uninstall bundler dependencies
16
+ --no-uninstall Skip uninstalling old bundler packages (faster, keeps both bundlers)
17
+ --init-config Create custom dependencies configuration file
18
+ --help, -h Show detailed help message
19
+
20
+ Examples:
21
+ # Switch to rspack with automatic dependency management
22
+ rails shakapacker:switch_bundler rspack --install-deps
23
+ rake shakapacker:switch_bundler rspack -- --install-deps
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.
46
+
47
+ What it does:
48
+ - Updates 'assets_bundler' in config/shakapacker.yml
49
+ - Preserves YAML comments and structure
50
+ - Updates 'javascript_transpiler' to 'swc' when switching to rspack
51
+ - With --install-deps: installs/uninstalls npm dependencies automatically
52
+ - Without --install-deps: shows manual installation commands
53
+
54
+ Custom Dependencies:
55
+ Create .shakapacker-switch-bundler-dependencies.yml to customize which
56
+ npm packages are installed/uninstalled during bundler switching.
57
+
58
+ See docs/rspack_migration_guide.md for more information.
59
+ DESC
60
+ task :switch_bundler do
61
+ switcher = Shakapacker::BundlerSwitcher.new
62
+
63
+ if ARGV.empty? || ARGV.include?("--help") || ARGV.include?("-h")
64
+ switcher.show_usage
65
+ elsif ARGV.include?("--init-config")
66
+ switcher.init_config
67
+ else
68
+ bundler = ARGV[1]
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
77
+ end
78
+
79
+ # Prevent rake from trying to execute arguments as tasks
80
+ ARGV.each { |arg| task arg.to_sym {} }
81
+ end
82
+ end
@@ -9,7 +9,8 @@ tasks = {
9
9
  "shakapacker:check_binstubs" => "Verifies that bin/shakapacker is present",
10
10
  "shakapacker:binstubs" => "Installs Shakapacker binstubs in this application",
11
11
  "shakapacker:verify_install" => "Verifies if Shakapacker is installed",
12
- "shakapacker:doctor" => "Checks for configuration issues and missing dependencies"
12
+ "shakapacker:doctor" => "Checks for configuration issues and missing dependencies",
13
+ "shakapacker:switch_bundler" => "Switch between webpack and rspack bundlers"
13
14
  }.freeze
14
15
 
15
16
  desc "Lists all available tasks in Shakapacker"