shakapacker 9.3.0.beta.0 → 9.3.0.beta.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.
data/docs/v9_upgrade.md CHANGED
@@ -4,6 +4,15 @@ This guide outlines new features, breaking changes, and migration steps for upgr
4
4
 
5
5
  **📖 For detailed configuration options, see the [Configuration Guide](./configuration.md)**
6
6
 
7
+ > **⚠️ Important:** Shakapacker is both a Ruby gem AND an npm package. **You must update BOTH**:
8
+ >
9
+ > - Update the version in `Gemfile`
10
+ > - Update the version in `package.json`
11
+ > - Run `bundle update shakapacker`
12
+ > - Run your package manager install command (`yarn install`, `npm install`, or `pnpm install`)
13
+ >
14
+ > See [Migration Steps](#migration-steps) below for detailed instructions including version format differences and testing.
15
+
7
16
  > **⚠️ Important for v9.1.0 Users:** If you're upgrading to v9.1.0 or later, please note the [SWC Configuration Breaking Change](#swc-loose-mode-breaking-change-v910) below. This affects users who previously configured SWC in v9.0.0.
8
17
 
9
18
  ## New Features
@@ -264,15 +273,49 @@ You won't get warnings about missing Babel, Rspack, or esbuild packages.
264
273
 
265
274
  ## Migration Steps
266
275
 
267
- ### Step 1: Update Dependencies
276
+ > **💡 Tip:** For general upgrade instructions applicable to all Shakapacker versions, see [Upgrading Shakapacker](./common-upgrades.md#upgrading-shakapacker) in the Common Upgrades guide.
277
+
278
+ ### Step 1: Update Gemfile
279
+
280
+ Update the shakapacker version in your `Gemfile`:
281
+
282
+ ```ruby
283
+ # Gemfile
284
+ gem "shakapacker", "9.3.0" # or latest version
285
+ ```
286
+
287
+ **Note:** Ruby gems use dot notation for pre-release versions (e.g., `9.3.0.beta.1`), while npm uses hyphen notation (e.g., `9.3.0-beta.1`). See [Version Format Differences](#version-format-differences) below.
288
+
289
+ ### Step 2: Update package.json
290
+
291
+ Update the shakapacker version in your `package.json`:
292
+
293
+ ```json
294
+ {
295
+ "dependencies": {
296
+ "shakapacker": "9.3.0"
297
+ }
298
+ }
299
+ ```
300
+
301
+ **Note:** For pre-release versions, npm uses hyphen notation (e.g., `"shakapacker": "9.3.0-beta.1"`).
302
+
303
+ ### Step 3: Install Updates
304
+
305
+ Run both bundler and your package manager:
268
306
 
269
307
  ```bash
270
- npm update shakapacker@^9.0.0
271
- # or
272
- yarn upgrade shakapacker@^9.0.0
308
+ # Update Ruby gem
309
+ bundle update shakapacker
310
+
311
+ # Update npm package (choose one based on your package manager)
312
+ yarn install # if using Yarn
313
+ npm install # if using npm
314
+ pnpm install # if using pnpm
315
+ bun install # if using Bun
273
316
  ```
274
317
 
275
- ### Step 2: Update CSS Module Imports
318
+ ### Step 4: Update CSS Module Imports
276
319
 
277
320
  #### For each CSS module import:
278
321
 
@@ -299,7 +342,7 @@ declare module "*.module.css" {
299
342
  }
300
343
  ```
301
344
 
302
- ### Step 3: Handle Kebab-Case Class Names
345
+ ### Step 5: Handle Kebab-Case Class Names
303
346
 
304
347
  v9 automatically converts kebab-case to camelCase with `exportLocalsConvention: 'camelCaseOnly'`:
305
348
 
@@ -340,7 +383,7 @@ const buttonClass = styles['my-button'];
340
383
 
341
384
  **Note:** With `'camelCaseOnly'` (default) or `'dashesOnly'`, only one version is exported. If you need both the original and camelCase versions, you would need to use `'camelCase'` instead, but this requires `namedExport: false` (v8 behavior). See the [CSS Modules Export Mode documentation](./css-modules-export-mode.md) for details on reverting to v8 behavior.
342
385
 
343
- ### Step 4: Update Configuration Files
386
+ ### Step 6: Update Configuration Files
344
387
 
345
388
  If you have `webpack_loader` in your configuration:
346
389
 
@@ -353,7 +396,7 @@ If you have `webpack_loader` in your configuration:
353
396
  javascript_transpiler: "babel"
354
397
  ```
355
398
 
356
- ### Step 5: Run Tests
399
+ ### Step 7: Run Tests
357
400
 
358
401
  ```bash
359
402
  # Run your test suite
@@ -366,6 +409,45 @@ bin/shakapacker
366
409
  bin/shakapacker-dev-server
367
410
  ```
368
411
 
412
+ ## Version Format Differences
413
+
414
+ Shakapacker version numbers differ between the Ruby gem and npm package for pre-release versions:
415
+
416
+ | Version Type | Ruby Gem (Gemfile) | npm Package (package.json) |
417
+ | ------------ | ------------------ | -------------------------- |
418
+ | Stable | `"9.3.0"` | `"9.3.0"` |
419
+ | Pre-release | `"9.3.0.beta.1"` | `"9.3.0-beta.1"` |
420
+
421
+ **Examples:**
422
+
423
+ ```ruby
424
+ # Gemfile - uses dots for pre-release versions
425
+ gem "shakapacker", "9.3.0" # stable
426
+ gem "shakapacker", "9.3.0.beta.1" # pre-release
427
+ ```
428
+
429
+ Stable version in package.json:
430
+
431
+ ```json
432
+ {
433
+ "dependencies": {
434
+ "shakapacker": "9.3.0"
435
+ }
436
+ }
437
+ ```
438
+
439
+ Pre-release version in package.json:
440
+
441
+ ```json
442
+ {
443
+ "dependencies": {
444
+ "shakapacker": "9.3.0-beta.1"
445
+ }
446
+ }
447
+ ```
448
+
449
+ This is due to different versioning conventions between RubyGems (which uses dots) and npm (which follows semantic versioning with hyphens for pre-release identifiers).
450
+
369
451
  ## Troubleshooting
370
452
 
371
453
  ### CSS Classes Not Applying
data/eslint.config.js CHANGED
@@ -14,11 +14,16 @@ module.exports = [
14
14
  // Global ignores (replaces .eslintignore)
15
15
  {
16
16
  ignores: [
17
- "lib/**",
18
- "**/node_modules/**",
19
- "vendor/**",
20
- "spec/**",
21
- "package/**" // TODO: Remove after issue #644 is resolved (lints package/ TS source files)
17
+ "lib/**", // Ruby files, not JavaScript
18
+ "**/node_modules/**", // Third-party dependencies
19
+ "vendor/**", // Vendored dependencies
20
+ "spec/**", // Ruby specs, not JavaScript
21
+ "package/**/*.js", // Generated/compiled JavaScript from TypeScript
22
+ "package/**/*.d.ts", // Generated TypeScript declaration files
23
+ // Temporarily ignore TypeScript files until technical debt is resolved
24
+ // See ESLINT_TECHNICAL_DEBT.md for tracking
25
+ // TODO: Remove this once ESLint issues are fixed (tracked in #723)
26
+ "package/**/*.ts"
22
27
  ]
23
28
  },
24
29
 
@@ -52,7 +57,11 @@ module.exports = [
52
57
  "import/no-extraneous-dependencies": "off",
53
58
  // TypeScript handles extensions, not needed for JS imports
54
59
  "import/extensions": "off",
55
- indent: ["error", 2]
60
+ indent: ["error", 2],
61
+ // Allow for...of loops - modern JS syntax, won't pollute client code
62
+ "no-restricted-syntax": "off",
63
+ // Allow console statements - used for debugging/logging throughout
64
+ "no-console": "off"
56
65
  },
57
66
  settings: {
58
67
  react: {
@@ -131,7 +140,114 @@ module.exports = [
131
140
  // Strict: no 'any' types allowed - use 'unknown' or specific types instead
132
141
  "@typescript-eslint/no-explicit-any": "error",
133
142
  // Allow implicit return types - TypeScript can infer them
134
- "@typescript-eslint/explicit-module-boundary-types": "off"
143
+ "@typescript-eslint/explicit-module-boundary-types": "off",
144
+ // Disable no-undef for TypeScript - TypeScript compiler handles this
145
+ // This prevents false positives for ambient types like NodeJS.ProcessEnv
146
+ "no-undef": "off"
147
+ }
148
+ },
149
+
150
+ // Temporary overrides for files with remaining errors
151
+ // See ESLINT_TECHNICAL_DEBT.md for detailed documentation
152
+ //
153
+ // These overrides suppress ~172 errors that require either:
154
+ // 1. Major type refactoring (any/unsafe-* rules)
155
+ // 2. Potential breaking changes (module system)
156
+ // 3. Significant code restructuring
157
+ //
158
+ // GitHub Issues tracking this technical debt:
159
+ // - #707: TypeScript: Refactor configExporter module for type safety
160
+ // - #708: Module System: Modernize to ES6 modules with codemod
161
+ // - #709: Code Style: Fix remaining ESLint style issues
162
+ {
163
+ // Consolidated override for package/config.ts and package/babel/preset.ts
164
+ // Combines rules from both previous override blocks to avoid duplication
165
+ files: ["package/babel/preset.ts", "package/config.ts"],
166
+ rules: {
167
+ // From first override block
168
+ "@typescript-eslint/no-require-imports": "off",
169
+ "@typescript-eslint/no-unused-vars": "off",
170
+ "@typescript-eslint/no-unsafe-call": "off",
171
+ "import/order": "off",
172
+ "import/newline-after-import": "off",
173
+ "import/first": "off",
174
+ // Additional rules that were in the second override for config.ts
175
+ "@typescript-eslint/no-unsafe-assignment": "off",
176
+ "@typescript-eslint/no-unsafe-member-access": "off",
177
+ "@typescript-eslint/no-unsafe-argument": "off",
178
+ "@typescript-eslint/no-explicit-any": "off",
179
+ "no-useless-escape": "off",
180
+ "no-continue": "off",
181
+ "no-nested-ternary": "off"
182
+ }
183
+ },
184
+ {
185
+ files: ["package/configExporter/**/*.ts"],
186
+ rules: {
187
+ "@typescript-eslint/no-explicit-any": "off",
188
+ "@typescript-eslint/no-unsafe-assignment": "off",
189
+ "@typescript-eslint/no-unsafe-member-access": "off",
190
+ "@typescript-eslint/no-unsafe-call": "off",
191
+ "@typescript-eslint/no-unsafe-return": "off",
192
+ "@typescript-eslint/no-unsafe-argument": "off",
193
+ "@typescript-eslint/no-unsafe-function-type": "off",
194
+ "@typescript-eslint/no-unused-vars": "off",
195
+ "@typescript-eslint/require-await": "off",
196
+ "no-param-reassign": "off",
197
+ "no-await-in-loop": "off",
198
+ "no-nested-ternary": "off",
199
+ "import/prefer-default-export": "off",
200
+ "global-require": "off",
201
+ "no-underscore-dangle": "off"
202
+ }
203
+ },
204
+ {
205
+ // Remaining utils files (removed package/config.ts from this block)
206
+ files: [
207
+ "package/utils/inliningCss.ts",
208
+ "package/utils/errorCodes.ts",
209
+ "package/utils/errorHelpers.ts",
210
+ "package/utils/pathValidation.ts"
211
+ ],
212
+ rules: {
213
+ "@typescript-eslint/no-unsafe-assignment": "off",
214
+ "@typescript-eslint/no-unsafe-member-access": "off",
215
+ "@typescript-eslint/no-unsafe-argument": "off",
216
+ "@typescript-eslint/no-explicit-any": "off",
217
+ "no-useless-escape": "off",
218
+ "no-continue": "off",
219
+ "no-nested-ternary": "off"
220
+ }
221
+ },
222
+ {
223
+ files: ["package/plugins/**/*.ts", "package/optimization/**/*.ts"],
224
+ rules: {
225
+ "@typescript-eslint/no-unsafe-assignment": "off",
226
+ "@typescript-eslint/no-unsafe-call": "off",
227
+ "@typescript-eslint/no-redundant-type-constituents": "off",
228
+ "import/prefer-default-export": "off"
229
+ }
230
+ },
231
+ {
232
+ files: [
233
+ "package/environments/**/*.ts",
234
+ "package/index.ts",
235
+ "package/rspack/index.ts",
236
+ "package/rules/**/*.ts",
237
+ "package/swc/index.ts",
238
+ "package/esbuild/index.ts",
239
+ "package/dev_server.ts",
240
+ "package/env.ts"
241
+ ],
242
+ rules: {
243
+ "@typescript-eslint/no-unsafe-assignment": "off",
244
+ "@typescript-eslint/no-unsafe-call": "off",
245
+ "@typescript-eslint/no-unsafe-return": "off",
246
+ "@typescript-eslint/no-redundant-type-constituents": "off",
247
+ "@typescript-eslint/no-unused-vars": "off",
248
+ "@typescript-eslint/no-unsafe-function-type": "off",
249
+ "import/prefer-default-export": "off",
250
+ "no-underscore-dangle": "off"
135
251
  }
136
252
  },
137
253
 
data/jest.config.js CHANGED
@@ -1,5 +1,12 @@
1
1
  module.exports = {
2
2
  roots: ["<rootDir>/test"],
3
3
  testPathIgnorePatterns: ["/__fixtures__/", "/__utils__/"],
4
- resolver: "<rootDir>/test/resolver"
4
+ resolver: "<rootDir>/test/resolver",
5
+ preset: "ts-jest",
6
+ testEnvironment: "node",
7
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
8
+ transform: {
9
+ "^.+\\.tsx?$": "ts-jest"
10
+ },
11
+ transformIgnorePatterns: ["node_modules/(?!(.*\\.mjs$))"]
5
12
  }
@@ -379,7 +379,7 @@ module Shakapacker
379
379
  return rspack_path
380
380
  end
381
381
 
382
- # Fallback to webpack config with deprecation warning
382
+ # Fallback to webpack config in the configured directory
383
383
  webpack_paths = %w[ts js].map do |ext|
384
384
  File.join(@app_path, config_dir, "webpack.config.#{ext}")
385
385
  end
@@ -393,6 +393,29 @@ module Shakapacker
393
393
  return webpack_path
394
394
  end
395
395
 
396
+ # Backward compatibility: Check config/webpack/ if we were looking in config/rspack/
397
+ # This supports upgrades from versions where rspack used config/webpack/
398
+ if config_dir == "config/rspack"
399
+ webpack_dir_paths = %w[ts js].map do |ext|
400
+ File.join(@app_path, "config/webpack", "webpack.config.#{ext}")
401
+ end
402
+
403
+ puts "[Shakapacker] Checking config/webpack/ for backward compatibility..."
404
+ webpack_dir_path = webpack_dir_paths.find { |f| File.exist?(f) }
405
+ if webpack_dir_path
406
+ $stderr.puts "⚠️ DEPRECATION WARNING: Found webpack config in config/webpack/ but assets_bundler is set to 'rspack'."
407
+ $stderr.puts " For rspack, configs should be in config/rspack/ directory."
408
+ $stderr.puts " "
409
+ $stderr.puts " To fix this, either:"
410
+ $stderr.puts " 1. Move your config: mv config/webpack config/rspack"
411
+ $stderr.puts " 2. Set assets_bundler_config_path in config/shakapacker.yml:"
412
+ $stderr.puts " assets_bundler_config_path: config/webpack"
413
+ $stderr.puts " "
414
+ $stderr.puts " Using: #{webpack_dir_path}"
415
+ return webpack_dir_path
416
+ end
417
+ end
418
+
396
419
  # No config found
397
420
  print_config_not_found_error("rspack", rspack_paths.last, config_dir)
398
421
  exit(1)
@@ -1,4 +1,4 @@
1
1
  module Shakapacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "9.3.0.beta.0".freeze
3
+ VERSION = "9.3.0.beta.2".freeze
4
4
  end