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
@@ -0,0 +1,91 @@
1
+ /* eslint global-require: 0 */
2
+ const { warn } = require("./debug")
3
+
4
+ /**
5
+ * Validates CSS modules configuration and warns about potential issues
6
+ * with v9 defaults or conflicting settings.
7
+ */
8
+ const validateCssModulesConfig = (cssLoaderOptions) => {
9
+ // Skip validation in production by default for performance
10
+ if (
11
+ process.env.NODE_ENV === "production" &&
12
+ process.env.SHAKAPACKER_VALIDATE_CSS_MODULES !== "true"
13
+ ) {
14
+ return
15
+ }
16
+
17
+ if (!cssLoaderOptions || !cssLoaderOptions.modules) {
18
+ return
19
+ }
20
+
21
+ const { modules } = cssLoaderOptions
22
+
23
+ // Check for conflicting namedExport and esModule settings
24
+ if (modules.namedExport === true && modules.esModule === false) {
25
+ warn(
26
+ "⚠️ CSS Modules Configuration Warning:\n" +
27
+ " namedExport: true with esModule: false may cause issues.\n" +
28
+ " Consider setting esModule: true or removing it (defaults to true)."
29
+ )
30
+ }
31
+
32
+ // Check for v8-style configuration with v9
33
+ if (modules.namedExport === false) {
34
+ warn(
35
+ "ℹ️ CSS Modules Configuration Note:\n" +
36
+ " You are using namedExport: false (v8 behavior).\n" +
37
+ " Shakapacker v9 defaults to namedExport: true for better tree-shaking.\n" +
38
+ " See docs/css-modules-export-mode.md for migration instructions."
39
+ )
40
+ }
41
+
42
+ // Check for inconsistent exportLocalsConvention with namedExport
43
+ if (
44
+ modules.namedExport === true &&
45
+ modules.exportLocalsConvention === "asIs"
46
+ ) {
47
+ warn(
48
+ "⚠️ CSS Modules Configuration Warning:\n" +
49
+ " Using namedExport: true with exportLocalsConvention: 'asIs' may cause issues\n" +
50
+ " with kebab-case class names (e.g., 'my-button').\n" +
51
+ " Consider using exportLocalsConvention: 'camelCase' (v9 default)."
52
+ )
53
+ }
54
+
55
+ // Check for deprecated localIdentName pattern
56
+ if (
57
+ modules.localIdentName &&
58
+ modules.localIdentName.includes("[hash:base64]")
59
+ ) {
60
+ warn(
61
+ "⚠️ CSS Modules Configuration Warning:\n" +
62
+ " [hash:base64] is deprecated in css-loader v6+.\n" +
63
+ " Use [hash] instead for better compatibility."
64
+ )
65
+ }
66
+
67
+ // Check for potential TypeScript issues
68
+ if (
69
+ modules.namedExport === true &&
70
+ process.env.SHAKAPACKER_ASSET_COMPILER_TYPESCRIPT === "true"
71
+ ) {
72
+ warn(
73
+ "ℹ️ TypeScript CSS Modules Note:\n" +
74
+ " With namedExport: true, TypeScript projects should use:\n" +
75
+ " import * as styles from './styles.module.css'\n" +
76
+ " instead of: import styles from './styles.module.css'\n" +
77
+ " See docs/css-modules-export-mode.md for TypeScript setup."
78
+ )
79
+ }
80
+
81
+ // Check for auto: true with getLocalIdent (potential conflict)
82
+ if (modules.auto === true && modules.getLocalIdent) {
83
+ warn(
84
+ "⚠️ CSS Modules Configuration Warning:\n" +
85
+ " Using both 'auto: true' and 'getLocalIdent' may cause conflicts.\n" +
86
+ " The 'auto' option determines which files are treated as CSS modules."
87
+ )
88
+ }
89
+ }
90
+
91
+ module.exports = { validateCssModulesConfig }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Validates that required dependencies are installed for the selected bundler
3
+ */
4
+
5
+ const { moduleExists } = require("./helpers")
6
+ const { error } = require("./debug")
7
+
8
+ const validateRspackDependencies = () => {
9
+ const requiredDependencies = ["@rspack/core", "rspack-manifest-plugin"]
10
+
11
+ const missingDependencies = requiredDependencies.filter(
12
+ (dep) => !moduleExists(dep)
13
+ )
14
+
15
+ if (missingDependencies.length > 0) {
16
+ error(
17
+ `Missing required dependencies for RSpack:\n${missingDependencies
18
+ .map((dep) => ` - ${dep}`)
19
+ .join(
20
+ "\n"
21
+ )}\n\nPlease install them with:\n npm install ${missingDependencies.join(
22
+ " "
23
+ )}`
24
+ )
25
+ throw new Error(
26
+ `Missing RSpack dependencies: ${missingDependencies.join(", ")}`
27
+ )
28
+ }
29
+ }
30
+
31
+ const validateWebpackDependencies = () => {
32
+ const requiredDependencies = [
33
+ "webpack",
34
+ "webpack-cli",
35
+ "webpack-assets-manifest"
36
+ ]
37
+
38
+ const missingDependencies = requiredDependencies.filter(
39
+ (dep) => !moduleExists(dep)
40
+ )
41
+
42
+ if (missingDependencies.length > 0) {
43
+ error(
44
+ `Missing required dependencies for Webpack:\n${missingDependencies
45
+ .map((dep) => ` - ${dep}`)
46
+ .join(
47
+ "\n"
48
+ )}\n\nPlease install them with:\n npm install ${missingDependencies.join(
49
+ " "
50
+ )}`
51
+ )
52
+ throw new Error(
53
+ `Missing Webpack dependencies: ${missingDependencies.join(", ")}`
54
+ )
55
+ }
56
+ }
57
+
58
+ module.exports = {
59
+ validateRspackDependencies,
60
+ validateWebpackDependencies
61
+ }
@@ -39,6 +39,7 @@ function createDevServerConfig() {
39
39
  devMiddleware: {
40
40
  publicPath
41
41
  },
42
+ hot: devServerYamlConfig.hmr,
42
43
  liveReload,
43
44
  historyApiFallback: {
44
45
  disableDotRule: true
@@ -47,6 +48,7 @@ function createDevServerConfig() {
47
48
  publicPath: contentBase
48
49
  }
49
50
  }
51
+ delete devServerYamlConfig.hmr
50
52
 
51
53
  if (devServerYamlConfig.static) {
52
54
  config.static = { ...config.static, ...devServerYamlConfig.static }