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.
- checksums.yaml +4 -4
- data/.github/workflows/eslint-validation.yml +46 -0
- data/CHANGELOG.md +56 -2
- data/ESLINT_TECHNICAL_DEBT.md +160 -0
- data/Gemfile.lock +1 -1
- data/docs/common-upgrades.md +80 -0
- data/docs/troubleshooting.md +141 -1
- data/docs/v9_upgrade.md +90 -8
- data/eslint.config.js +123 -7
- data/jest.config.js +8 -1
- data/lib/shakapacker/runner.rb +24 -1
- data/lib/shakapacker/version.rb +1 -1
- data/package/configExporter/buildValidator.ts +883 -0
- data/package/configExporter/cli.ts +194 -27
- data/package/configExporter/fileWriter.ts +12 -12
- data/package/configExporter/index.ts +3 -1
- data/package/configExporter/types.ts +18 -0
- data/package-lock.json +2 -2
- data/package.json +17 -16
- data/test/configExporter/buildValidator.test.js +1295 -0
- data/test/package/configExporter.test.js +4 -8
- data/test/package/environments/base.test.js +6 -3
- data/test/package/rules/babel.test.js +61 -51
- data/test/package/rules/esbuild.test.js +12 -3
- data/test/package/rules/file.test.js +3 -1
- data/test/package/rules/sass.test.js +9 -2
- data/test/package/rules/sass1.test.js +3 -2
- data/test/package/rules/sass16.test.js +3 -2
- data/test/package/rules/swc.test.js +48 -38
- data/yarn.lock +62 -3
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d196f7ff4fd6270c0a4739f62ed17ee202eef663222018dc0b031b7dfb8ec015
|
|
4
|
+
data.tar.gz: cb645bae3cb677c7b7f7e35164d99b779dfb92d7d6a975204ac0fcae71b56f40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee177b62cc41abd5fbd460d34f8f8dfe387385152cc683aed5034fe3fd67050043dd3cd2fe32f09f06735ff28a4e71ec6f1f4f945e6ea582dbba06e0883dbb1d
|
|
7
|
+
data.tar.gz: dcb85543ec034ede52cf91ed5e36ab5a987e8fb485d54c857fd1762f133252a827d760ac92dd36b9973897e30c3ab1d89f64bacd5761ffe6815b75c990c2c2f9
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
name: ESLint Validation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- "eslint.config.js"
|
|
7
|
+
- "package.json"
|
|
8
|
+
- "package/**/*.js"
|
|
9
|
+
- "test/**/*.js"
|
|
10
|
+
- ".github/workflows/eslint-validation.yml"
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
validate:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Setup Node
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: "20"
|
|
22
|
+
cache: "yarn"
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: yarn install --frozen-lockfile
|
|
26
|
+
|
|
27
|
+
- name: Validate ESLint config
|
|
28
|
+
run: |
|
|
29
|
+
echo "Validating ESLint configuration..."
|
|
30
|
+
node -e "const config = require('./eslint.config.js'); console.log('✓ Config is valid with', config.length, 'rule sets')"
|
|
31
|
+
|
|
32
|
+
- name: Run ESLint
|
|
33
|
+
run: |
|
|
34
|
+
echo "Running ESLint on allowed files..."
|
|
35
|
+
yarn eslint . --max-warnings 5
|
|
36
|
+
|
|
37
|
+
- name: Check warning count
|
|
38
|
+
run: |
|
|
39
|
+
echo "Checking warning count..."
|
|
40
|
+
WARNING_COUNT=$(yarn eslint . 2>&1 | grep -E "^✖.*warning" | grep -oE "[0-9]+ warning" | cut -d' ' -f1)
|
|
41
|
+
echo "Current warning count: $WARNING_COUNT"
|
|
42
|
+
if [ "$WARNING_COUNT" -gt "5" ]; then
|
|
43
|
+
echo "❌ Too many warnings: $WARNING_COUNT (max allowed: 5)"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
echo "✓ Warning count is acceptable"
|
data/CHANGELOG.md
CHANGED
|
@@ -11,9 +11,56 @@
|
|
|
11
11
|
|
|
12
12
|
Changes since the last non-beta release.
|
|
13
13
|
|
|
14
|
+
## [v9.3.0-beta.0] - October 13, 2025
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **New `precompile_hook` configuration option** to run custom commands during asset precompilation. [PR #678](https://github.com/shakacode/shakapacker/pull/678) by [justin808](https://github.com/justin808).
|
|
19
|
+
- Allows executing custom scripts or tasks during the precompile process
|
|
20
|
+
- Configure in `shakapacker.yml` with `precompile_hook: "command to run"`
|
|
21
|
+
- **New `assets_bundler_config_path` configuration option** for custom bundler config locations. [PR #710](https://github.com/shakacode/shakapacker/pull/710) by [justin808](https://github.com/justin808).
|
|
22
|
+
- Allows specifying a custom path for webpack/rspack configuration files
|
|
23
|
+
- Useful for complex project structures or shared configurations
|
|
24
|
+
- **YAML output format support for `bin/export-bundler-config`**. [PR #704](https://github.com/shakacode/shakapacker/pull/704) by [justin808](https://github.com/justin808).
|
|
25
|
+
- New `--format yaml` option exports bundler configuration as YAML
|
|
26
|
+
- Easier to read than JSON for debugging and documentation
|
|
27
|
+
- **Custom help messages for `bin/shakapacker` commands**. [PR #702](https://github.com/shakacode/shakapacker/pull/702) by [justin808](https://github.com/justin808).
|
|
28
|
+
- Improved help output for better command discoverability
|
|
29
|
+
- Clear usage examples and option descriptions
|
|
30
|
+
- **HMR client config export in doctor mode**. [PR #701](https://github.com/shakacode/shakapacker/pull/701) by [justin808](https://github.com/justin808).
|
|
31
|
+
- `bin/export-bundler-config --doctor` now includes HMR client configuration
|
|
32
|
+
- Helps debug Hot Module Replacement issues
|
|
33
|
+
- **Build timing logs** for webpack and rspack. [PR #706](https://github.com/shakacode/shakapacker/pull/706) by [justin808](https://github.com/justin808).
|
|
34
|
+
- Shows duration of build operations
|
|
35
|
+
- Helps identify performance bottlenecks
|
|
36
|
+
- Added Knip for detecting dead code to CI. [PR #675](https://github.com/shakacode/shakapacker/pull/675) by [justin808](https://github.com/justin808).
|
|
37
|
+
|
|
14
38
|
### Changed
|
|
15
39
|
|
|
16
|
-
-
|
|
40
|
+
- **Migrated to ESLint v9 with flat config format**. [PR #677](https://github.com/shakacode/shakapacker/pull/677) by [justin808](https://github.com/justin808).
|
|
41
|
+
- Updated all ESLint plugins to latest versions
|
|
42
|
+
- Uses new flat config format for better maintainability
|
|
43
|
+
- **Replaced custom argument parser with yargs**. [PR #692](https://github.com/shakacode/shakapacker/pull/692) by [justin808](https://github.com/justin808).
|
|
44
|
+
- More robust command-line argument parsing
|
|
45
|
+
- Better error messages and help output
|
|
46
|
+
- Replaced `require` with `import` in package/index.ts. [PR #674](https://github.com/shakacode/shakapacker/pull/674) by [justin808](https://github.com/justin808).
|
|
47
|
+
- Updated @rspack dependencies to 1.5.8. [PR #700](https://github.com/shakacode/shakapacker/pull/700) by [justin808](https://github.com/justin808).
|
|
48
|
+
|
|
49
|
+
### Improved
|
|
50
|
+
|
|
51
|
+
- **Enhanced rspack migration documentation** with real-world lessons. [PR #713](https://github.com/shakacode/shakapacker/pull/713) by [justin808](https://github.com/justin808).
|
|
52
|
+
- Added practical migration guidance based on actual project experiences
|
|
53
|
+
- Common pitfalls and solutions documented
|
|
54
|
+
- **Consolidated duplicate configuration documentation**. [PR #714](https://github.com/shakacode/shakapacker/pull/714) by [justin808](https://github.com/justin808).
|
|
55
|
+
- Removed redundant documentation
|
|
56
|
+
- Single source of truth for configuration options
|
|
57
|
+
- **Improved error messages** to suggest `assets_bundler_config_path`. [PR #712](https://github.com/shakacode/shakapacker/pull/712) by [justin808](https://github.com/justin808).
|
|
58
|
+
- More helpful error messages when bundler config is not found
|
|
59
|
+
- Suggests using `assets_bundler_config_path` for custom locations
|
|
60
|
+
- **Improved doctor command output** clarity and accuracy. [PR #682](https://github.com/shakacode/shakapacker/pull/682) by [justin808](https://github.com/justin808).
|
|
61
|
+
- Better formatting and organization of diagnostic information
|
|
62
|
+
- More actionable recommendations
|
|
63
|
+
- Formatted all markdown files with prettier. [PR #673](https://github.com/shakacode/shakapacker/pull/673) by [justin808](https://github.com/justin808).
|
|
17
64
|
|
|
18
65
|
### Fixed
|
|
19
66
|
|
|
@@ -26,6 +73,12 @@ Changes since the last non-beta release.
|
|
|
26
73
|
- Fixed TypeScript type definitions to export proper types instead of `any`. [PR #684](https://github.com/shakacode/shakapacker/pull/684) by [justin808](https://github.com/justin808).
|
|
27
74
|
- Previously `package/index.d.ts` was exporting all types as `any`, breaking IDE autocomplete
|
|
28
75
|
- Now properly exports typed interfaces for `WebpackConfig`, `RspackConfig`, etc.
|
|
76
|
+
- Fixed integrity config handling and sass-loader version check. [PR #688](https://github.com/shakacode/shakapacker/pull/688) by [justin808](https://github.com/justin808).
|
|
77
|
+
- Properly handles subresource integrity configuration
|
|
78
|
+
- Correctly detects sass-loader version for conditional logic
|
|
79
|
+
- Prevented index.d.ts confusion in build process. [PR #698](https://github.com/shakacode/shakapacker/pull/698) by [justin808](https://github.com/justin808).
|
|
80
|
+
- TypeScript declaration files no longer interfere with build output
|
|
81
|
+
- Fixed yarn.lock formatting changes in Conductor setup. [PR #683](https://github.com/shakacode/shakapacker/pull/683) by [justin808](https://github.com/justin808).
|
|
29
82
|
|
|
30
83
|
## [v9.2.0] - October 9, 2025
|
|
31
84
|
|
|
@@ -679,7 +732,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
679
732
|
|
|
680
733
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
|
681
734
|
|
|
682
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0...main
|
|
735
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.3.0-beta.0...main
|
|
736
|
+
[v9.3.0-beta.0]: https://github.com/shakacode/shakapacker/compare/v9.2.0...v9.3.0-beta.0
|
|
683
737
|
[v9.2.0]: https://github.com/shakacode/shakapacker/compare/v9.1.0...v9.2.0
|
|
684
738
|
[v9.1.0]: https://github.com/shakacode/shakapacker/compare/v9.0.0...v9.1.0
|
|
685
739
|
[v9.0.0]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# ESLint Technical Debt Documentation
|
|
2
|
+
|
|
3
|
+
This document tracks the ESLint errors currently suppressed in the codebase and outlines the plan to address them.
|
|
4
|
+
|
|
5
|
+
## Current Approach
|
|
6
|
+
|
|
7
|
+
**As of 2025-10-14**: All TypeScript files in `package/` directory are temporarily excluded from linting via the ignore pattern `package/**/*.ts` in `eslint.config.js`. This allows the project to adopt ESLint configuration without requiring immediate fixes to all existing issues.
|
|
8
|
+
|
|
9
|
+
**Latest Update**: Fixed all `class-methods-use-this` violations by converting FileWriter methods to static methods (4 violations resolved).
|
|
10
|
+
|
|
11
|
+
## Current Linting Status
|
|
12
|
+
|
|
13
|
+
**Files currently linted** (`test/**/*.js`, `scripts/*.js`):
|
|
14
|
+
|
|
15
|
+
- ✅ **0 errors** (CI passing)
|
|
16
|
+
- ⚠️ **3 warnings** (acceptable, won't block CI)
|
|
17
|
+
- 1x unused eslint-disable directive in `scripts/remove-use-strict.js`
|
|
18
|
+
- 2x jest/no-disabled-tests in test files (expected for conditional test skipping)
|
|
19
|
+
|
|
20
|
+
**TypeScript files** (currently ignored via `package/**/*.ts`):
|
|
21
|
+
|
|
22
|
+
- **Estimated suppressed errors: ~172** (from sample analysis)
|
|
23
|
+
- TypeScript type-safety issues: ~114 (66%)
|
|
24
|
+
- Style/convention issues: ~58 (34%)
|
|
25
|
+
|
|
26
|
+
**Target**: Reduce suppressed errors by 50% within Q1 2025
|
|
27
|
+
**Last Updated**: 2025-10-14
|
|
28
|
+
|
|
29
|
+
## Priority Matrix
|
|
30
|
+
|
|
31
|
+
| Category | Impact | Effort | Priority | Count |
|
|
32
|
+
| ------------------------------------ | ------ | ------ | -------- | ----- |
|
|
33
|
+
| `@typescript-eslint/no-explicit-any` | High | High | P1 | 22 |
|
|
34
|
+
| `@typescript-eslint/no-unsafe-*` | High | High | P1 | 85 |
|
|
35
|
+
| `config.ts` type safety | High | Medium | P1 | 7 |
|
|
36
|
+
| `no-param-reassign` | Medium | Low | P2 | 7 |
|
|
37
|
+
| `class-methods-use-this` | Low | Low | P3 | 0 |
|
|
38
|
+
| `no-nested-ternary` | Low | Low | P3 | 3 |
|
|
39
|
+
| `import/prefer-default-export` | Low | Medium | P3 | 9 |
|
|
40
|
+
| `global-require` | Medium | High | P2 | 3 |
|
|
41
|
+
| Other style issues | Low | Low | P3 | 31 |
|
|
42
|
+
|
|
43
|
+
## Categories of Suppressed Errors
|
|
44
|
+
|
|
45
|
+
### 1. TypeScript Type Safety (Requires Major Refactoring)
|
|
46
|
+
|
|
47
|
+
#### `@typescript-eslint/no-explicit-any` (22 instances)
|
|
48
|
+
|
|
49
|
+
**Files affected:** `configExporter/`, `config.ts`, `utils/`
|
|
50
|
+
**Why suppressed:** These require careful type definitions and potentially breaking API changes
|
|
51
|
+
**Fix strategy:** Create proper type definitions for configuration objects and YAML parsing
|
|
52
|
+
|
|
53
|
+
#### `@typescript-eslint/no-unsafe-*` (85 instances)
|
|
54
|
+
|
|
55
|
+
- `no-unsafe-assignment`: 47 instances
|
|
56
|
+
- `no-unsafe-member-access`: 20 instances
|
|
57
|
+
- `no-unsafe-call`: 8 instances
|
|
58
|
+
- `no-unsafe-return`: 8 instances
|
|
59
|
+
- `no-unsafe-argument`: 7 instances
|
|
60
|
+
**Why suppressed:** These stem from `any` types and dynamic property access
|
|
61
|
+
**Fix strategy:** Requires comprehensive type refactoring alongside `no-explicit-any` fixes
|
|
62
|
+
|
|
63
|
+
### 2. Module System (Potential Breaking Changes)
|
|
64
|
+
|
|
65
|
+
#### `global-require` (3 instances)
|
|
66
|
+
|
|
67
|
+
**Files affected:** `configExporter/cli.ts`
|
|
68
|
+
**Why suppressed:** Dynamic require calls are needed for conditional module loading
|
|
69
|
+
**Fix strategy:** Would require converting to ES modules with dynamic imports
|
|
70
|
+
|
|
71
|
+
#### `import/prefer-default-export` (9 instances)
|
|
72
|
+
|
|
73
|
+
**Files affected:** Multiple single-export modules
|
|
74
|
+
**Why suppressed:** Adding default exports alongside named exports could break consumers
|
|
75
|
+
**Fix strategy:** Can be fixed non-breaking by adding default exports that match named exports
|
|
76
|
+
|
|
77
|
+
### 3. Code Style (Can Be Fixed)
|
|
78
|
+
|
|
79
|
+
#### `class-methods-use-this` (0 instances)
|
|
80
|
+
|
|
81
|
+
✅ **FIXED** - All FileWriter methods that didn't use instance state have been converted to static methods
|
|
82
|
+
|
|
83
|
+
#### `no-nested-ternary` (3 instances)
|
|
84
|
+
|
|
85
|
+
**Fix strategy:** Refactor to if-else statements
|
|
86
|
+
|
|
87
|
+
#### `no-param-reassign` (7 instances)
|
|
88
|
+
|
|
89
|
+
**Files affected:** `configExporter/cli.ts`
|
|
90
|
+
**Why suppressed:** Common pattern for option objects
|
|
91
|
+
**Fix strategy:** Create new objects instead of mutating parameters
|
|
92
|
+
|
|
93
|
+
#### `no-underscore-dangle` (2 instances)
|
|
94
|
+
|
|
95
|
+
**Fix strategy:** Rename variables or add exceptions for Node internals
|
|
96
|
+
|
|
97
|
+
### 4. Control Flow
|
|
98
|
+
|
|
99
|
+
#### `no-await-in-loop` (1 instance)
|
|
100
|
+
|
|
101
|
+
**Fix strategy:** Use `Promise.all()` for parallel execution
|
|
102
|
+
|
|
103
|
+
#### `no-continue` (1 instance)
|
|
104
|
+
|
|
105
|
+
**Fix strategy:** Refactor loop logic
|
|
106
|
+
|
|
107
|
+
## Recommended Approach
|
|
108
|
+
|
|
109
|
+
### Phase 1: Non-Breaking Fixes
|
|
110
|
+
|
|
111
|
+
✅ Completed:
|
|
112
|
+
|
|
113
|
+
- Fixed `no-use-before-define` by reordering functions
|
|
114
|
+
- Fixed redundant type constituents with `string & {}` pattern
|
|
115
|
+
- Added proper type annotations for `requireOrError` calls
|
|
116
|
+
- Configured appropriate global rule disables (`no-console`, `no-restricted-syntax`)
|
|
117
|
+
- ✅ **Fixed `class-methods-use-this`** - Converted FileWriter methods to static methods
|
|
118
|
+
|
|
119
|
+
🔧 Could still fix (low risk):
|
|
120
|
+
|
|
121
|
+
- `no-nested-ternary` - Refactor conditionals
|
|
122
|
+
- `no-useless-escape` - Remove unnecessary escapes
|
|
123
|
+
- Unused variables - Remove or prefix with underscore
|
|
124
|
+
|
|
125
|
+
### Phase 2: Follow-up PRs (Non-Breaking)
|
|
126
|
+
|
|
127
|
+
- Systematic type safety improvements file by file
|
|
128
|
+
- Add explicit type definitions for configuration objects
|
|
129
|
+
- Replace `any` with `unknown` where possible
|
|
130
|
+
|
|
131
|
+
### Phase 3: Future Major Version (Breaking Changes)
|
|
132
|
+
|
|
133
|
+
- Convert `export =` to `export default`
|
|
134
|
+
- Convert `require()` to ES6 imports
|
|
135
|
+
- Full TypeScript strict mode compliance
|
|
136
|
+
- Provide codemod for automatic migration
|
|
137
|
+
|
|
138
|
+
## Configuration Strategy
|
|
139
|
+
|
|
140
|
+
The current approach uses file-specific overrides to suppress errors in affected files while maintaining strict checking elsewhere. This allows:
|
|
141
|
+
|
|
142
|
+
1. New code to follow strict standards
|
|
143
|
+
2. Gradual refactoring of existing code
|
|
144
|
+
3. Clear visibility of technical debt
|
|
145
|
+
|
|
146
|
+
## Issue Tracking
|
|
147
|
+
|
|
148
|
+
GitHub issues should be created for each category:
|
|
149
|
+
|
|
150
|
+
1. [ ] Issue: Type safety refactoring for configExporter module
|
|
151
|
+
2. [ ] Issue: Type safety for dynamic config loading
|
|
152
|
+
3. [ ] Issue: Convert class methods to static where appropriate
|
|
153
|
+
4. [ ] Issue: Module system modernization (ES6 modules)
|
|
154
|
+
5. [ ] Issue: Create codemod for breaking changes migration
|
|
155
|
+
|
|
156
|
+
## Notes
|
|
157
|
+
|
|
158
|
+
- All suppressed errors are documented in `eslint.config.js` with TODO comments
|
|
159
|
+
- The suppressions are scoped to specific files to prevent spreading technical debt
|
|
160
|
+
- New code should not add to these suppressions
|
data/Gemfile.lock
CHANGED
data/docs/common-upgrades.md
CHANGED
|
@@ -6,6 +6,7 @@ This document provides step-by-step instructions for the most common upgrade sce
|
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
|
+
- [Upgrading Shakapacker](#upgrading-shakapacker)
|
|
9
10
|
- [Migrating Package Managers](#migrating-package-managers)
|
|
10
11
|
- [Yarn to npm](#yarn-to-npm)
|
|
11
12
|
- [npm to Yarn](#npm-to-yarn)
|
|
@@ -15,6 +16,85 @@ This document provides step-by-step instructions for the most common upgrade sce
|
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
19
|
+
## Upgrading Shakapacker
|
|
20
|
+
|
|
21
|
+
> **⚠️ Important:** Shakapacker is both a Ruby gem AND an npm package. **You must update BOTH** when upgrading.
|
|
22
|
+
|
|
23
|
+
Shakapacker consists of two components that must be updated together:
|
|
24
|
+
|
|
25
|
+
1. **Ruby gem** - provides Rails integration and view helpers
|
|
26
|
+
2. **npm package** - provides webpack/rspack configuration and build tools
|
|
27
|
+
|
|
28
|
+
### Upgrade Steps
|
|
29
|
+
|
|
30
|
+
#### 1. Update `Gemfile`
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
gem "shakapacker", "9.3.0" # or the version you want to upgrade to
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Pre-release versions:** Ruby gems use dot notation (e.g., `"9.3.0.beta.1"`)
|
|
37
|
+
|
|
38
|
+
#### 2. Update `package.json`
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"shakapacker": "9.3.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Pre-release versions:** npm uses hyphen notation (e.g., `"9.3.0-beta.1"`)
|
|
49
|
+
|
|
50
|
+
#### 3. Run bundler and package manager
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
bundle update shakapacker
|
|
54
|
+
yarn install # or npm install, pnpm install, bun install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### 4. Test your build
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bin/shakapacker
|
|
61
|
+
bin/shakapacker-dev-server
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Why Both Must Be Updated
|
|
65
|
+
|
|
66
|
+
- **Mismatched versions can cause build failures** - The Ruby gem expects specific configuration formats from the npm package
|
|
67
|
+
- **Feature compatibility** - New features in the gem require corresponding npm package updates
|
|
68
|
+
- **Bug fixes** - Fixes often span both Ruby and JavaScript code
|
|
69
|
+
|
|
70
|
+
### Version Format Differences
|
|
71
|
+
|
|
72
|
+
Note that pre-release versions use different formats:
|
|
73
|
+
|
|
74
|
+
| Component | Stable Version | Pre-release Version |
|
|
75
|
+
| ------------ | -------------- | ------------------- |
|
|
76
|
+
| Gemfile | `"9.3.0"` | `"9.3.0.beta.1"` |
|
|
77
|
+
| package.json | `"9.3.0"` | `"9.3.0-beta.1"` |
|
|
78
|
+
|
|
79
|
+
### Finding the Latest Version
|
|
80
|
+
|
|
81
|
+
- **Ruby gem:** Check [RubyGems.org](https://rubygems.org/gems/shakapacker)
|
|
82
|
+
- **npm package:** Check [npmjs.com](https://www.npmjs.com/package/shakapacker)
|
|
83
|
+
- **Releases:** See [GitHub Releases](https://github.com/shakacode/shakapacker/releases)
|
|
84
|
+
|
|
85
|
+
### Major Version Upgrades
|
|
86
|
+
|
|
87
|
+
For major version upgrades, always consult the version-specific upgrade guides for breaking changes and new features:
|
|
88
|
+
|
|
89
|
+
- [V9 Upgrade Guide](./v9_upgrade.md) - Upgrading from v8 to v9 (includes CSS Modules changes, SWC defaults, and more)
|
|
90
|
+
- [V8 Upgrade Guide](./v8_upgrade.md) - Upgrading from v7 to v8
|
|
91
|
+
- [V7 Upgrade Guide](./v7_upgrade.md) - Upgrading from v6 to v7
|
|
92
|
+
- [V6 Upgrade Guide](./v6_upgrade.md) - Upgrading from v5 to v6
|
|
93
|
+
|
|
94
|
+
> **💡 Note:** Major version upgrades may include breaking changes. The steps above cover the basic gem/package updates that apply to all versions, but you should always review the version-specific guide for additional migration steps.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
18
98
|
## Migrating Package Managers
|
|
19
99
|
|
|
20
100
|
### Yarn to npm
|
data/docs/troubleshooting.md
CHANGED
|
@@ -71,7 +71,147 @@
|
|
|
71
71
|
|
|
72
72
|
See `bin/export-bundler-config --help` for all available options.
|
|
73
73
|
|
|
74
|
-
6.
|
|
74
|
+
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:
|
|
75
|
+
- **CI/CD pipelines**: Catch configuration errors before deployment
|
|
76
|
+
- **Migration testing**: Verify builds work after upgrading webpack, rspack, or Shakapacker
|
|
77
|
+
- **Multi-environment testing**: Ensure all build configurations (dev, prod, HMR) compile correctly
|
|
78
|
+
|
|
79
|
+
**Quick validation:**
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Validate all builds defined in .bundler-config.yml
|
|
83
|
+
bin/export-bundler-config --validate
|
|
84
|
+
|
|
85
|
+
# Validate with full output logs (shows all webpack/rspack compilation output)
|
|
86
|
+
bin/export-bundler-config --validate --verbose
|
|
87
|
+
|
|
88
|
+
# Validate a specific build
|
|
89
|
+
bin/export-bundler-config --validate-build=dev-hmr
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Verbose Mode:**
|
|
93
|
+
|
|
94
|
+
When using `--verbose`, you'll see:
|
|
95
|
+
- A clear header indicating verbose mode is enabled
|
|
96
|
+
- Full real-time compilation output from webpack/rspack
|
|
97
|
+
- All warnings and progress messages
|
|
98
|
+
- Detailed error traces
|
|
99
|
+
- Separators between builds for clarity
|
|
100
|
+
|
|
101
|
+
This is useful for debugging compilation issues or understanding build performance.
|
|
102
|
+
|
|
103
|
+
**Setting up build configurations:**
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Create a .bundler-config.yml file with example builds
|
|
107
|
+
bin/export-bundler-config --init
|
|
108
|
+
|
|
109
|
+
# List all available builds
|
|
110
|
+
bin/export-bundler-config --list-builds
|
|
111
|
+
|
|
112
|
+
# Validate all builds
|
|
113
|
+
bin/export-bundler-config --validate
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Advanced options:**
|
|
117
|
+
|
|
118
|
+
The validator uses a default timeout of 2 minutes per build. For large projects or slow CI environments, you can customize this behavior by modifying the `ValidatorOptions` in your code, or by adjusting your build configuration to be more efficient.
|
|
119
|
+
|
|
120
|
+
If validation times out, try:
|
|
121
|
+
- Using `--verbose` to see where the build is hanging
|
|
122
|
+
- Optimizing your webpack/rspack configuration for faster builds
|
|
123
|
+
- Running validation on a single build with `--validate-build=build-name`
|
|
124
|
+
|
|
125
|
+
**How it works:**
|
|
126
|
+
|
|
127
|
+
The validator will:
|
|
128
|
+
- For HMR builds (with `WEBPACK_SERVE=true`): Start webpack-dev-server, wait for successful compilation, then shut down
|
|
129
|
+
- For static builds: Run webpack/rspack and check for compilation errors
|
|
130
|
+
- Report all errors and warnings with clear output
|
|
131
|
+
- Exit with code 1 if any build fails (perfect for CI)
|
|
132
|
+
|
|
133
|
+
**Example output:**
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
🔍 Validating Builds
|
|
137
|
+
================================================================================
|
|
138
|
+
|
|
139
|
+
📦 Validating build: dev-hmr
|
|
140
|
+
✅ Build passed
|
|
141
|
+
|
|
142
|
+
📦 Validating build: dev
|
|
143
|
+
✅ Build passed
|
|
144
|
+
|
|
145
|
+
📦 Validating build: prod
|
|
146
|
+
❌ Build failed with 2 error(s)
|
|
147
|
+
|
|
148
|
+
================================================================================
|
|
149
|
+
🔍 Build Validation Results
|
|
150
|
+
================================================================================
|
|
151
|
+
|
|
152
|
+
✅ Build: dev-hmr (2.34s)
|
|
153
|
+
📦 Outputs: client
|
|
154
|
+
⚙️ Config: config/webpack/webpack.config.js
|
|
155
|
+
|
|
156
|
+
✅ Build: dev (3.12s)
|
|
157
|
+
📦 Outputs: client, server
|
|
158
|
+
⚙️ Config: config/webpack/webpack.config.js
|
|
159
|
+
📁 Output: /app/public/packs
|
|
160
|
+
|
|
161
|
+
❌ Build: prod (4.56s)
|
|
162
|
+
📦 Outputs: client, server
|
|
163
|
+
⚙️ Config: config/webpack/webpack.config.js
|
|
164
|
+
📁 Output: /app/public/packs
|
|
165
|
+
❌ 2 error(s)
|
|
166
|
+
Module not found: Error: Can't resolve './missing'
|
|
167
|
+
SyntaxError: Unexpected token
|
|
168
|
+
|
|
169
|
+
================================================================================
|
|
170
|
+
Summary: 2/3 builds passed, 1 failed (Total: 10.02s)
|
|
171
|
+
================================================================================
|
|
172
|
+
|
|
173
|
+
💡 Debugging Tips:
|
|
174
|
+
To get more details, run individual builds with --verbose:
|
|
175
|
+
|
|
176
|
+
bin/export-bundler-config --validate-build prod --verbose
|
|
177
|
+
|
|
178
|
+
Or validate all builds with full output: bin/export-bundler-config --validate --verbose
|
|
179
|
+
================================================================================
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Debugging Failed Builds:**
|
|
183
|
+
|
|
184
|
+
When builds fail, the validator automatically provides debugging commands. You can:
|
|
185
|
+
1. **Run a specific build with verbose output** to see full webpack/rspack logs:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
bin/export-bundler-config --validate-build prod --verbose
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
2. **Validate all builds with verbose output** to see everything:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
bin/export-bundler-config --validate --verbose
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
3. **Test individual builds manually** using the same configuration:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# For static builds
|
|
201
|
+
NODE_ENV=production RAILS_ENV=production bundle exec webpack --config config/webpack/webpack.config.js
|
|
202
|
+
|
|
203
|
+
# For HMR/dev-server builds
|
|
204
|
+
NODE_ENV=development WEBPACK_SERVE=true bundle exec webpack serve --config config/webpack/webpack.config.js
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The verbose mode shows:
|
|
208
|
+
- Full real-time compilation output
|
|
209
|
+
- All webpack/rspack warnings and progress messages
|
|
210
|
+
- Detailed stack traces for errors
|
|
211
|
+
- Timing information for each build phase
|
|
212
|
+
- Clear separators between different builds
|
|
213
|
+
|
|
214
|
+
7. Generate webpack stats for build analysis (useful for bundle size optimization):
|
|
75
215
|
|
|
76
216
|
```bash
|
|
77
217
|
NODE_ENV=development bin/shakapacker --profile --json > /tmp/webpack-stats.json
|