shakapacker 9.3.0.beta.6 → 9.3.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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -105
  3. data/ESLINT_TECHNICAL_DEBT.md +8 -2
  4. data/Gemfile.lock +1 -1
  5. data/README.md +53 -2
  6. data/docs/configuration.md +28 -0
  7. data/docs/rspack_migration_guide.md +238 -2
  8. data/docs/troubleshooting.md +21 -21
  9. data/eslint.config.fast.js +8 -0
  10. data/eslint.config.js +47 -10
  11. data/knip.ts +8 -1
  12. data/lib/install/config/shakapacker.yml +6 -6
  13. data/lib/shakapacker/configuration.rb +227 -4
  14. data/lib/shakapacker/dev_server.rb +88 -1
  15. data/lib/shakapacker/doctor.rb +129 -72
  16. data/lib/shakapacker/instance.rb +85 -1
  17. data/lib/shakapacker/manifest.rb +85 -11
  18. data/lib/shakapacker/runner.rb +12 -8
  19. data/lib/shakapacker/swc_migrator.rb +7 -7
  20. data/lib/shakapacker/version.rb +1 -1
  21. data/lib/shakapacker.rb +143 -3
  22. data/lib/tasks/shakapacker/doctor.rake +1 -1
  23. data/lib/tasks/shakapacker/export_bundler_config.rake +4 -4
  24. data/package/config.ts +0 -1
  25. data/package/configExporter/buildValidator.ts +53 -29
  26. data/package/configExporter/cli.ts +152 -118
  27. data/package/configExporter/configFile.ts +33 -26
  28. data/package/configExporter/fileWriter.ts +3 -3
  29. data/package/configExporter/types.ts +64 -0
  30. data/package/configExporter/yamlSerializer.ts +147 -36
  31. data/package/dev_server.ts +2 -1
  32. data/package/env.ts +1 -1
  33. data/package/environments/base.ts +4 -4
  34. data/package/environments/development.ts +7 -6
  35. data/package/environments/production.ts +6 -7
  36. data/package/environments/test.ts +2 -1
  37. data/package/index.ts +28 -4
  38. data/package/loaders.d.ts +2 -2
  39. data/package/optimization/webpack.ts +29 -31
  40. data/package/plugins/webpack.ts +2 -1
  41. data/package/rspack/index.ts +2 -1
  42. data/package/rules/file.ts +1 -0
  43. data/package/rules/jscommon.ts +1 -0
  44. data/package/utils/helpers.ts +0 -1
  45. data/package/utils/pathValidation.ts +68 -7
  46. data/package/utils/requireOrError.ts +10 -2
  47. data/package/utils/typeGuards.ts +43 -46
  48. data/package/webpack-types.d.ts +2 -2
  49. data/package/webpackDevServerConfig.ts +1 -0
  50. data/package.json +2 -3
  51. data/test/configExporter/integration.test.js +8 -8
  52. data/test/package/configExporter/cli.test.js +440 -0
  53. data/test/package/configExporter/types.test.js +163 -0
  54. data/test/package/configExporter.test.js +271 -7
  55. data/test/package/yamlSerializer.test.js +204 -0
  56. data/test/typescript/pathValidation.test.js +44 -0
  57. data/test/typescript/requireOrError.test.js +49 -0
  58. data/yarn.lock +0 -32
  59. metadata +11 -6
  60. data/.eslintrc.fast.js +0 -40
  61. data/.eslintrc.js +0 -84
  62. data/package-lock.json +0 -13047
@@ -11,7 +11,9 @@
11
11
  - [Server-Side Rendering (SSR) Considerations](#server-side-rendering-ssr-considerations)
12
12
  - [Key Differences from Webpack](#key-differences-from-webpack)
13
13
  - [Migration Steps](#migration-steps)
14
+ - [Build Verification](#build-verification)
14
15
  - [Configuration Best Practices](#configuration-best-practices)
16
+ - [Common Migration Issues](#common-migration-issues)
15
17
  - [Common Issues and Solutions](#common-issues-and-solutions)
16
18
  - [Performance Tips](#performance-tips)
17
19
  - [Debugging Configuration](#debugging-configuration)
@@ -312,6 +314,73 @@ bin/shakapacker --mode production
312
314
  - [ ] Deploy to staging
313
315
  - [ ] Monitor performance improvements
314
316
 
317
+ ## Build Verification
318
+
319
+ After completing your migration, verify that everything works correctly:
320
+
321
+ ### Basic Build Verification
322
+
323
+ ```bash
324
+ # Clean previous build artifacts
325
+ rm -rf public/packs public/packs-test
326
+
327
+ # Test development build
328
+ bin/shakapacker
329
+
330
+ # Test production build
331
+ RAILS_ENV=production bin/shakapacker
332
+
333
+ # Verify assets were generated
334
+ ls -la public/packs/
335
+ ```
336
+
337
+ ### SSR Build Verification
338
+
339
+ If your application uses Server-Side Rendering, perform these additional checks:
340
+
341
+ ```bash
342
+ # 1. Verify server bundle was created
343
+ ls -la public/packs/*-server-bundle.js
344
+
345
+ # 2. Test SSR rendering in Rails console
346
+ bundle exec rails console
347
+ # In console:
348
+ ReactOnRails::ServerRenderingPool.reset_pool
349
+ # Then visit a page that uses SSR and check for errors
350
+
351
+ # 3. Run full test suite (watch for SSR-related failures)
352
+ bundle exec rspec
353
+
354
+ # 4. Check for CSS extraction issues in SSR
355
+ # Look for "Cannot read properties of undefined" errors in tests
356
+ # or intermittent test failures related to styling
357
+ ```
358
+
359
+ ### Common Verification Issues
360
+
361
+ **Silent SSR failures**: If your SSR pages render without errors but components appear unstyled or with missing data, check:
362
+
363
+ - Server bundle is being generated correctly
364
+ - CSS extraction is disabled for server bundle (see [Common Migration Issues](#common-migration-issues))
365
+ - React runtime configuration is compatible with your SSR framework
366
+
367
+ **Error patterns to watch for**:
368
+
369
+ - `Cannot read properties of undefined (reading 'className')` - CSS Modules configuration issue
370
+ - `Invalid call to renderToString` - React runtime compatibility issue
371
+ - `Module not found: Can't resolve './Module.bs.js'` - File extension resolution issue
372
+ - Intermittent/flaky tests - CSS extraction leaking into server bundle
373
+
374
+ ### Testing Strategy for SSR
375
+
376
+ For applications with SSR, follow this verification order:
377
+
378
+ 1. Test client-only pages first (verify basic Rspack build works)
379
+ 2. Test SSR pages without CSS modules (verify SSR configuration)
380
+ 3. Test SSR pages with CSS modules (verify CSS extraction + SSR work together)
381
+ 4. Run full test suite multiple times to catch flaky tests
382
+ 5. Test in production mode (some issues only appear with minification)
383
+
315
384
  ## Configuration Best Practices
316
385
 
317
386
  ### Configuration Organization
@@ -390,6 +459,173 @@ When upgrading to Shakapacker 9 with Rspack:
390
459
  4. **Check Node version compatibility**: Verify your Node version meets all dependency requirements
391
460
  5. **Don't make empty commits**: If CI fails but local passes, investigate the root cause - don't try to "trigger CI re-run" with empty commits
392
461
 
462
+ ## Common Migration Issues
463
+
464
+ This section highlights the most critical configuration issues that cause build failures during webpack-to-Rspack migration. These issues are especially important for applications using Server-Side Rendering (SSR), CSS Modules, or non-standard file extensions.
465
+
466
+ ### 1. SWC React Runtime for SSR (CRITICAL for React on Rails)
467
+
468
+ **Problem**: React on Rails SSR detection expects specific function signatures that may not work with SWC's automatic React runtime.
469
+
470
+ **Symptoms**:
471
+
472
+ - Error: `Invalid call to renderToString. Possibly you have a renderFunction...`
473
+ - SSR pages fail to render or render without React hydration
474
+
475
+ **Solution**: Configure SWC to use classic React runtime instead of automatic:
476
+
477
+ ```javascript
478
+ // config/swc.config.js
479
+ const customConfig = {
480
+ options: {
481
+ jsc: {
482
+ transform: {
483
+ react: {
484
+ runtime: "classic", // Use 'classic' instead of 'automatic' for SSR
485
+ refresh: env.isDevelopment && env.runningWebpackDevServer
486
+ }
487
+ }
488
+ }
489
+ }
490
+ }
491
+ ```
492
+
493
+ **Why this matters**: The automatic runtime changes how React imports work (`import { jsx as _jsx }` vs `import React`), which breaks React on Rails' SSR function detection logic. This is a silent failure that only manifests at runtime.
494
+
495
+ **Implementation checklist for SSR users**:
496
+
497
+ - [ ] Locate your SWC configuration file (typically `config/swc.config.js`)
498
+ - [ ] Change `runtime: 'automatic'` to `runtime: 'classic'`
499
+ - [ ] Test SSR rendering in development and production modes
500
+ - [ ] Verify React hydration works correctly on client side
501
+ - [ ] Run full test suite to catch any related issues
502
+
503
+ ### 2. CSS Modules Configuration for Server Bundles (CRITICAL for SSR + CSS Modules)
504
+
505
+ **Problem**: When configuring server bundles, you must preserve Shakapacker 9's CSS Modules settings (`namedExport: true`) while adding SSR-specific settings. Simply setting `exportOnlyLocals: true` will override the base configuration and break CSS imports.
506
+
507
+ **Symptoms**:
508
+
509
+ - Error: `export 'default' (imported as 'css') was not found`
510
+ - CSS classes return undefined in SSR
511
+ - Client-side CSS works but SSR fails
512
+ - Intermittent/flaky test failures
513
+
514
+ **Solution**: Use spread operator to merge CSS Modules options instead of replacing them:
515
+
516
+ ```javascript
517
+ // config/webpack/serverWebpackConfig.js
518
+ if (cssLoader && cssLoader.options && cssLoader.options.modules) {
519
+ // ✅ CORRECT - Preserves namedExport and other settings
520
+ cssLoader.options.modules = {
521
+ ...cssLoader.options.modules,
522
+ exportOnlyLocals: true
523
+ }
524
+
525
+ // ❌ INCORRECT - Overwrites all settings
526
+ // cssLoader.options.modules.exportOnlyLocals = true
527
+ }
528
+ ```
529
+
530
+ **Why this matters**: Shakapacker 9 changed the default CSS Modules configuration to use named exports. If you only set `exportOnlyLocals: true` without preserving the base config, you'll lose the `namedExport: true` setting, causing import/export mismatches between client and server bundles.
531
+
532
+ **Related configuration**: You must also filter out CSS extraction loaders in server bundles:
533
+
534
+ ```javascript
535
+ // config/webpack/serverWebpackConfig.js
536
+ rule.use = rule.use.filter((item) => {
537
+ let testValue
538
+ if (typeof item === "string") {
539
+ testValue = item
540
+ } else if (typeof item.loader === "string") {
541
+ testValue = item.loader
542
+ }
543
+ // Handle both Webpack and Rspack CSS extract loaders
544
+ return !(
545
+ testValue?.match(/mini-css-extract-plugin/) ||
546
+ testValue?.includes("cssExtractLoader") || // Rspack uses this path
547
+ testValue === "style-loader"
548
+ )
549
+ })
550
+ ```
551
+
552
+ **Implementation checklist for SSR + CSS Modules users**:
553
+
554
+ - [ ] Update server bundle config to use spread operator for CSS Modules options
555
+ - [ ] Ensure CSS extraction loaders are filtered for both webpack and Rspack paths
556
+ - [ ] Test SSR pages with CSS Modules imports
557
+ - [ ] Verify CSS classes are defined (not undefined) during SSR
558
+ - [ ] Run tests multiple times to catch flaky failures
559
+
560
+ ### 3. ReScript File Resolution (CRITICAL for ReScript users)
561
+
562
+ **Problem**: Rspack requires explicit configuration to resolve `.bs.js` extensions (ReScript compiled output), while webpack handled this automatically.
563
+
564
+ **Symptoms**:
565
+
566
+ - Error: `Module not found: Can't resolve './Module.bs.js'`
567
+ - ReScript modules fail to import
568
+ - Build fails with missing module errors
569
+
570
+ **Solution**: Add `.bs.js` to resolve extensions:
571
+
572
+ ```javascript
573
+ // config/webpack/webpack.config.js (works for both webpack and rspack)
574
+ const commonOptions = {
575
+ resolve: {
576
+ extensions: [".css", ".ts", ".tsx", ".bs.js"] // Add .bs.js for ReScript
577
+ }
578
+ }
579
+
580
+ module.exports = merge({}, baseConfig, commonOptions)
581
+ ```
582
+
583
+ **Why this matters**: ReScript compiles `.res` source files to `.bs.js` JavaScript files. If your bundler can't resolve these extensions, all ReScript imports will fail, even though the compiled files exist.
584
+
585
+ **Additional consideration - Missing compiled files**: Some ReScript npm packages ship only `.res` source files without compiled `.bs.js` files. If you encounter this, use `patch-package` to fix the dependency's `bsconfig.json` (see detailed solution in [Common Issues and Solutions](#issue-rescript-dependencies-missing-compiled-files)).
586
+
587
+ **Implementation checklist for ReScript users**:
588
+
589
+ - [ ] Add `.bs.js` to resolve extensions in webpack/rspack config
590
+ - [ ] Verify all ReScript modules can be imported
591
+ - [ ] Check if any ReScript dependencies are missing compiled files
592
+ - [ ] If needed, patch broken dependencies with `patch-package`
593
+ - [ ] Test build with all ReScript code paths
594
+
595
+ ### 4. Build Verification Steps (IMPORTANT for all migrations)
596
+
597
+ **Problem**: The migration documentation lacked practical verification procedures, leaving developers without guidance on testing SSR functionality or identifying configuration errors.
598
+
599
+ **Solution**: Follow the comprehensive verification steps in the [Build Verification](#build-verification) section above, which includes:
600
+
601
+ - Basic build verification commands
602
+ - SSR-specific testing procedures
603
+ - Error pattern identification
604
+ - Testing strategy for SSR applications
605
+
606
+ **Why this matters**: Silent SSR failures and configuration issues often only manifest in specific scenarios (production mode, certain page types, race conditions in tests). Without systematic verification, these issues may slip into production.
607
+
608
+ **Implementation checklist for all users**:
609
+
610
+ - [ ] Clean build artifacts before testing
611
+ - [ ] Test both development and production builds
612
+ - [ ] Verify generated assets in `public/packs/`
613
+ - [ ] For SSR: verify server bundle generation
614
+ - [ ] For SSR: test rendering in Rails console
615
+ - [ ] Run full test suite multiple times
616
+ - [ ] Check for error patterns listed in Build Verification
617
+
618
+ ### Configuration Differences: webpack vs Rspack Summary
619
+
620
+ Quick reference for the key differences that cause migration issues:
621
+
622
+ | Area | Webpack | Rspack | Migration Action |
623
+ | -------------------------- | ------------------------- | ----------------------------------- | ------------------------------------------- |
624
+ | CSS Extraction Loader Path | `mini-css-extract-plugin` | `cssExtractLoader.js` | Filter both paths in SSR config |
625
+ | React Runtime (SSR) | Works with both | Classic required for React on Rails | Use `runtime: 'classic'` |
626
+ | ReScript Extensions | Auto-resolves `.bs.js` | Requires explicit config | Add to `resolve.extensions` |
627
+ | CSS Modules Default | `namedExport: true` (v9+) | Same | Preserve with spread operator in SSR config |
628
+
393
629
  ## Common Issues and Solutions
394
630
 
395
631
  ### Issue: CSS Modules Returning Undefined (CRITICAL)
@@ -601,13 +837,13 @@ To compare your webpack and rspack configurations during migration:
601
837
 
602
838
  ```bash
603
839
  # Export webpack configs before switching
604
- bin/export-bundler-config --doctor
840
+ bin/shakapacker-config --doctor
605
841
 
606
842
  # Switch to rspack
607
843
  rails shakapacker:switch_bundler rspack --install-deps
608
844
 
609
845
  # Export rspack configs to compare
610
- bin/export-bundler-config --doctor
846
+ bin/shakapacker-config --doctor
611
847
 
612
848
  # Compare the files in shakapacker-config-exports/
613
849
  diff shakapacker-config-exports/webpack-production-client.yaml \
@@ -21,7 +21,7 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
21
21
 
22
22
  4. You can also pass additional options to the command to run the webpack-dev-server and start the webpack-dev-server with the option `--debug-shakapacker`
23
23
 
24
- 5. **Export your full webpack/rspack configuration for analysis**: Use the `bin/export-bundler-config` utility to export your complete resolved configuration. This is especially helpful for:
24
+ 5. **Export your full webpack/rspack configuration for analysis**: Use the `bin/shakapacker-config` utility to export your complete resolved configuration. This is especially helpful for:
25
25
  - **Migrations**: Comparing configurations before and after migrating between webpack and rspack, or between different Shakapacker versions
26
26
  - **Debugging**: Inspecting the exact configuration webpack/rspack is using, including all merged settings
27
27
  - **AI Analysis**: Uploading the exported config to ChatGPT or other AI tools for troubleshooting
@@ -35,7 +35,7 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
35
35
  rake shakapacker:binstubs
36
36
 
37
37
  # Export EVERYTHING for troubleshooting (dev + prod, annotated YAML)
38
- bin/export-bundler-config --doctor
38
+ bin/shakapacker-config --doctor
39
39
  # Creates: webpack-development-client.yaml, webpack-development-server.yaml,
40
40
  # webpack-production-client.yaml, webpack-production-server.yaml
41
41
  ```
@@ -44,28 +44,28 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
44
44
 
45
45
  ```bash
46
46
  # Save current environment configs with auto-generated names
47
- bin/export-bundler-config --save
47
+ bin/shakapacker-config --save
48
48
  # Creates: webpack-development-client.yaml, webpack-development-server.yaml
49
49
 
50
50
  # Save to specific directory
51
- bin/export-bundler-config --save --save-dir=./debug-configs
51
+ bin/shakapacker-config --save --save-dir=./debug-configs
52
52
 
53
53
  # Export only client config for production
54
- bin/export-bundler-config --save --env=production --client-only
54
+ bin/shakapacker-config --save --env=production --client-only
55
55
  # Creates: webpack-production-client.yaml
56
56
 
57
57
  # Compare development vs production configs
58
- bin/export-bundler-config --save --save-dir=./configs
58
+ bin/shakapacker-config --save --save-dir=./configs
59
59
  diff configs/webpack-development-client.yaml configs/webpack-production-client.yaml
60
60
 
61
61
  # View config in terminal (no files created)
62
- bin/export-bundler-config
62
+ bin/shakapacker-config
63
63
 
64
64
  # Export without inline documentation annotations
65
- bin/export-bundler-config --save --no-annotate
65
+ bin/shakapacker-config --save --no-annotate
66
66
 
67
67
  # Export in JSON format for programmatic analysis
68
- bin/export-bundler-config --save --format=json
68
+ bin/shakapacker-config --save --format=json
69
69
  ```
70
70
 
71
71
  **Config files are automatically named:** `{bundler}-{env}-{type}.{ext}`
@@ -73,9 +73,9 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
73
73
  - YAML format includes inline documentation explaining each config key
74
74
  - Separate files for client and server bundles (cleaner than combined)
75
75
 
76
- See `bin/export-bundler-config --help` for all available options.
76
+ See `bin/shakapacker-config --help` for all available options.
77
77
 
78
- 6. **Validate your webpack/rspack builds**: Use `bin/export-bundler-config --validate` to test that all your build configurations compile successfully. This is especially useful for:
78
+ 6. **Validate your webpack/rspack builds**: Use `bin/shakapacker-config --validate` to test that all your build configurations compile successfully. This is especially useful for:
79
79
  - **CI/CD pipelines**: Catch configuration errors before deployment
80
80
  - **Migration testing**: Verify builds work after upgrading webpack, rspack, or Shakapacker
81
81
  - **Multi-environment testing**: Ensure all build configurations (dev, prod, HMR) compile correctly
@@ -84,13 +84,13 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
84
84
 
85
85
  ```bash
86
86
  # Validate all builds defined in .bundler-config.yml
87
- bin/export-bundler-config --validate
87
+ bin/shakapacker-config --validate
88
88
 
89
89
  # Validate with full output logs (shows all webpack/rspack compilation output)
90
- bin/export-bundler-config --validate --verbose
90
+ bin/shakapacker-config --validate --verbose
91
91
 
92
92
  # Validate a specific build
93
- bin/export-bundler-config --validate-build=dev-hmr
93
+ bin/shakapacker-config --validate-build=dev-hmr
94
94
  ```
95
95
 
96
96
  **Verbose Mode:**
@@ -108,13 +108,13 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
108
108
 
109
109
  ```bash
110
110
  # Create a .bundler-config.yml file with example builds
111
- bin/export-bundler-config --init
111
+ bin/shakapacker-config --init
112
112
 
113
113
  # List all available builds
114
- bin/export-bundler-config --list-builds
114
+ bin/shakapacker-config --list-builds
115
115
 
116
116
  # Validate all builds
117
- bin/export-bundler-config --validate
117
+ bin/shakapacker-config --validate
118
118
  ```
119
119
 
120
120
  **Advanced options:**
@@ -177,9 +177,9 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
177
177
  💡 Debugging Tips:
178
178
  To get more details, run individual builds with --verbose:
179
179
 
180
- bin/export-bundler-config --validate-build prod --verbose
180
+ bin/shakapacker-config --validate-build prod --verbose
181
181
 
182
- Or validate all builds with full output: bin/export-bundler-config --validate --verbose
182
+ Or validate all builds with full output: bin/shakapacker-config --validate --verbose
183
183
  ================================================================================
184
184
  ```
185
185
 
@@ -189,13 +189,13 @@ If you're experiencing FOUC where content briefly appears unstyled before CSS lo
189
189
  1. **Run a specific build with verbose output** to see full webpack/rspack logs:
190
190
 
191
191
  ```bash
192
- bin/export-bundler-config --validate-build prod --verbose
192
+ bin/shakapacker-config --validate-build prod --verbose
193
193
  ```
194
194
 
195
195
  2. **Validate all builds with verbose output** to see everything:
196
196
 
197
197
  ```bash
198
- bin/export-bundler-config --validate --verbose
198
+ bin/shakapacker-config --validate --verbose
199
199
  ```
200
200
 
201
201
  3. **Test individual builds manually** using the same configuration:
@@ -25,6 +25,14 @@ module.exports = [
25
25
  ]
26
26
  },
27
27
 
28
+ // Global linter options
29
+ {
30
+ linterOptions: {
31
+ reportUnusedDisableDirectives: "error",
32
+ reportUnusedInlineConfigs: "error"
33
+ }
34
+ },
35
+
28
36
  // Base config for all JS files
29
37
  ...compat.extends("airbnb"),
30
38
  {
data/eslint.config.js CHANGED
@@ -23,10 +23,20 @@ module.exports = [
23
23
  // Temporarily ignore TypeScript files until technical debt is resolved
24
24
  // See ESLINT_TECHNICAL_DEBT.md for tracking
25
25
  // TODO: Remove this once ESLint issues are fixed (tracked in #723)
26
- "package/**/*.ts"
26
+ // Exception: configExporter is being fixed in #707
27
+ "package/**/*.ts",
28
+ "!package/configExporter/**/*.ts" // Enable linting for configExporter (issue #707)
27
29
  ]
28
30
  },
29
31
 
32
+ // Global linter options
33
+ {
34
+ linterOptions: {
35
+ reportUnusedDisableDirectives: "error",
36
+ reportUnusedInlineConfigs: "error"
37
+ }
38
+ },
39
+
30
40
  // Base config for all JS files
31
41
  ...compat.extends("airbnb"),
32
42
  {
@@ -181,21 +191,48 @@ module.exports = [
181
191
  }
182
192
  },
183
193
  {
194
+ // #707: Significant type safety improvements in configExporter module!
195
+ // - configFile.ts: ✅ Fully type-safe (0 type errors)
196
+ // - buildValidator.ts: ✅ Fully type-safe (0 type errors)
197
+ // - yamlSerializer.ts: ✅ Fully type-safe (0 type errors)
198
+ // - cli.ts: ⚠️ Partial (dynamic webpack config loading requires some `any`)
199
+ //
200
+ // Remaining overrides are for:
201
+ // 1. Code style/organization (not type safety)
202
+ // 2. Dynamic require() in cli.ts for webpack config loading
184
203
  files: ["package/configExporter/**/*.ts"],
204
+ rules: {
205
+ // Code organization (functions before use due to large file)
206
+ "@typescript-eslint/no-use-before-define": "off",
207
+ // Import style (CommonJS require for dynamic imports)
208
+ "@typescript-eslint/no-require-imports": "off",
209
+ "import/no-dynamic-require": "off",
210
+ "global-require": "off",
211
+ // Class methods that are part of public API
212
+ "class-methods-use-this": "off",
213
+ // Template expressions (valid use cases with union types)
214
+ "@typescript-eslint/restrict-template-expressions": "off",
215
+ // Style preferences
216
+ "no-continue": "off",
217
+ "import/prefer-default-export": "off",
218
+ "no-await-in-loop": "off",
219
+ "no-underscore-dangle": "off",
220
+ "no-shadow": "off",
221
+ "no-restricted-globals": "off",
222
+ "@typescript-eslint/no-unused-vars": "off",
223
+ "@typescript-eslint/require-await": "off"
224
+ }
225
+ },
226
+ {
227
+ // cli.ts: Dynamic webpack config loading requires `any` types
228
+ // This is acceptable as webpack configs can have any shape
229
+ files: ["package/configExporter/cli.ts"],
185
230
  rules: {
186
231
  "@typescript-eslint/no-explicit-any": "off",
187
232
  "@typescript-eslint/no-unsafe-assignment": "off",
188
233
  "@typescript-eslint/no-unsafe-member-access": "off",
189
234
  "@typescript-eslint/no-unsafe-call": "off",
190
- "@typescript-eslint/no-unsafe-return": "off",
191
- "@typescript-eslint/no-unsafe-argument": "off",
192
- "@typescript-eslint/no-unsafe-function-type": "off",
193
- "@typescript-eslint/no-unused-vars": "off",
194
- "@typescript-eslint/require-await": "off",
195
- "no-await-in-loop": "off",
196
- "import/prefer-default-export": "off",
197
- "global-require": "off",
198
- "no-underscore-dangle": "off"
235
+ "@typescript-eslint/no-unsafe-return": "off"
199
236
  }
200
237
  },
201
238
  {
data/knip.ts CHANGED
@@ -47,7 +47,14 @@ const config: KnipConfig = {
47
47
  "css-loader",
48
48
  "esbuild-loader",
49
49
  "swc-loader",
50
- "webpack"
50
+ "webpack",
51
+ // eslint-config-airbnb isn't detected because it's used by compat.extends("airbnb"),
52
+ // the rest are its peerDependencies
53
+ "eslint-config-airbnb",
54
+ "eslint-plugin-import",
55
+ "eslint-plugin-jsx-a11y",
56
+ "eslint-plugin-react",
57
+ "eslint-plugin-react-hooks"
51
58
  ]
52
59
  }
53
60
 
@@ -67,9 +67,8 @@ default: &default
67
67
  compiler_strategy: digest
68
68
 
69
69
  # Select whether the compiler will always use a content hash and not just in production
70
- # Don't use contentHash except for production for performance
71
- # https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
72
- useContentHash: false
70
+ # Content hashes are recommended for production cache busting
71
+ useContentHash: true
73
72
 
74
73
  # Setting the asset host here will override Rails.application.config.asset_host.
75
74
  # Here, you can set different asset_host per environment. Note that
@@ -101,6 +100,10 @@ development:
101
100
  compile: true
102
101
  compiler_strategy: mtime
103
102
 
103
+ # Disable content hashes in development for faster builds
104
+ # https://webpack.js.org/guides/caching/
105
+ useContentHash: false
106
+
104
107
  # Early hints disabled by default in development
105
108
  # To enable: Set enabled: true AND start Puma with: bundle exec puma --early-hints
106
109
  # See docs/early_hints_new_api.md for setup instructions
@@ -164,9 +167,6 @@ production:
164
167
  # Production depends on precompilation of packs prior to booting for performance.
165
168
  compile: false
166
169
 
167
- # Use content hash for naming assets. Cannot be overridden in production.
168
- useContentHash: true
169
-
170
170
  # Cache manifest.json for performance
171
171
  cache_manifest: true
172
172