shakapacker 9.3.0.beta.7 → 9.3.1
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/.claude/commands/update-changelog.md +224 -0
- data/.github/actionlint-matcher.json +17 -0
- data/.github/workflows/dummy.yml +9 -0
- data/.github/workflows/generator.yml +13 -0
- data/.github/workflows/node.yml +83 -0
- data/.github/workflows/ruby.yml +11 -0
- data/.github/workflows/test-bundlers.yml +10 -0
- data/CHANGELOG.md +55 -111
- data/CLAUDE.md +6 -10
- data/CONTRIBUTING.md +57 -0
- data/Gemfile.lock +1 -1
- data/README.md +84 -8
- data/docs/api-reference.md +519 -0
- data/docs/configuration.md +38 -4
- data/docs/css-modules-export-mode.md +40 -6
- data/docs/rspack_migration_guide.md +238 -2
- data/docs/transpiler-migration.md +12 -9
- data/docs/troubleshooting.md +21 -21
- data/docs/using_swc_loader.md +13 -10
- data/docs/v9_upgrade.md +11 -2
- data/eslint.config.fast.js +128 -8
- data/eslint.config.js +89 -33
- data/knip.ts +8 -1
- data/lib/install/config/shakapacker.yml +20 -7
- data/lib/shakapacker/configuration.rb +274 -8
- data/lib/shakapacker/dev_server.rb +88 -1
- data/lib/shakapacker/dev_server_runner.rb +4 -0
- data/lib/shakapacker/doctor.rb +5 -5
- data/lib/shakapacker/instance.rb +85 -1
- data/lib/shakapacker/manifest.rb +85 -11
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker.rb +143 -3
- data/lib/tasks/shakapacker/doctor.rake +1 -1
- data/lib/tasks/shakapacker/export_bundler_config.rake +4 -4
- data/package/config.ts +2 -4
- data/package/configExporter/buildValidator.ts +53 -29
- data/package/configExporter/cli.ts +106 -76
- data/package/configExporter/configFile.ts +33 -26
- data/package/configExporter/types.ts +64 -0
- data/package/configExporter/yamlSerializer.ts +118 -43
- data/package/dev_server.ts +3 -2
- data/package/env.ts +2 -2
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +6 -6
- data/package/environments/base.ts +6 -6
- data/package/environments/development.ts +7 -9
- data/package/environments/production.ts +7 -8
- data/package/environments/test.ts +4 -2
- data/package/esbuild/index.ts +0 -2
- data/package/index.d.ts +1 -0
- data/package/index.d.ts.template +1 -0
- data/package/index.ts +28 -5
- data/package/loaders.d.ts +2 -2
- data/package/optimization/webpack.ts +29 -31
- data/package/plugins/rspack.ts +3 -1
- data/package/plugins/webpack.ts +5 -3
- data/package/rspack/index.ts +5 -4
- data/package/rules/file.ts +2 -1
- data/package/rules/jscommon.ts +1 -0
- data/package/rules/raw.ts +3 -1
- data/package/rules/rspack.ts +0 -2
- data/package/rules/sass.ts +0 -2
- data/package/rules/webpack.ts +0 -1
- data/package/swc/index.ts +0 -2
- data/package/types.ts +8 -11
- data/package/utils/debug.ts +0 -4
- data/package/utils/getStyleRule.ts +17 -9
- data/package/utils/helpers.ts +8 -4
- data/package/utils/pathValidation.ts +78 -18
- data/package/utils/requireOrError.ts +14 -5
- data/package/utils/typeGuards.ts +43 -46
- data/package/webpack-types.d.ts +2 -2
- data/package/webpackDevServerConfig.ts +5 -4
- data/package.json +2 -3
- data/test/package/configExporter/cli.test.js +440 -0
- data/test/package/configExporter/types.test.js +163 -0
- data/test/package/configExporter.test.js +264 -0
- data/test/package/transpiler-defaults.test.js +42 -0
- data/test/package/yamlSerializer.test.js +204 -0
- data/test/typescript/pathValidation.test.js +44 -0
- data/test/typescript/requireOrError.test.js +49 -0
- data/yarn.lock +0 -32
- metadata +14 -5
- data/.eslintrc.fast.js +0 -40
- data/.eslintrc.js +0 -84
data/CHANGELOG.md
CHANGED
|
@@ -9,134 +9,78 @@
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Extended manifest merging for multiple client configurations to all environments. [PR #800](https://github.com/shakacode/shakapacker/pull/800) by [Judahmeek](https://github.com/Judahmeek).
|
|
15
|
+
|
|
12
16
|
Changes since the last non-beta release.
|
|
13
17
|
|
|
14
18
|
### Added
|
|
15
19
|
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **Enhanced error
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
- Improved
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- New `early_hints` configuration in `shakapacker.yml` with per-environment settings (`enabled: false` by default)
|
|
44
|
-
- Requires Rails 5.2+ and HTTP/2-capable server (e.g., Puma 5+)
|
|
45
|
-
- Browser support: All modern browsers (Chrome/Edge/Firefox 103+, Safari 16.4+)
|
|
46
|
-
- Gracefully degrades if not supported
|
|
47
|
-
- **Performance note**: May improve or hurt page load performance depending on content - careful testing advised
|
|
48
|
-
- See [Early Hints Guide](docs/early_hints.md) for detailed usage and advanced patterns
|
|
49
|
-
|
|
50
|
-
## [v9.3.0-beta.5] - October 18, 2025
|
|
20
|
+
- **Support for `css_modules_export_mode` configuration option**. [PR #817](https://github.com/shakacode/shakapacker/pull/817) by [justin808](https://github.com/justin808). Adds `css_modules_export_mode` setting in `shakapacker.yml` to control CSS Modules export style. Set to `"named"` (default, v9+ behavior with true named exports) or `"default"` (v8 behavior with default export object). Allows teams to opt into v8-style exports for easier migration from v8 or when using TypeScript with strict type checking.
|
|
21
|
+
- **`Configuration#data` public API method** with enhanced documentation and safety. [PR #820](https://github.com/shakacode/shakapacker/pull/820) by [justin808](https://github.com/justin808). The `Configuration#data` method is now part of the public Ruby API, providing stable access to raw configuration data. Returns a frozen hash with symbolized keys to prevent accidental mutations. Includes comprehensive test coverage and detailed RDoc documentation.
|
|
22
|
+
- **Support for `javascript_transpiler: 'none'`** for completely custom webpack configurations. [PR #799](https://github.com/shakacode/shakapacker/pull/799) by [justin808](https://github.com/justin808). Allows users with custom webpack configs to skip Shakapacker's transpiler setup and validation by setting `javascript_transpiler: 'none'` in `shakapacker.yml`. Useful when managing transpilation entirely outside of Shakapacker's defaults.
|
|
23
|
+
|
|
24
|
+
## [v9.3.0] - November 2, 2025
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Enhanced error handling for better security and debugging**. [PR #786](https://github.com/shakacode/shakapacker/pull/786) by [justin808](https://github.com/justin808).
|
|
29
|
+
- Path validation now properly reports permission errors instead of silently handling them
|
|
30
|
+
- Module loading errors now include original error context for easier troubleshooting
|
|
31
|
+
- Improved security by only catching ENOENT errors in path resolution, rethrowing permission and access errors
|
|
32
|
+
- Better type safety with custom ErrorWithCause interface and optional chaining for error.code checks
|
|
33
|
+
- **Improved type safety and error handling in configExporter module**. [PR #778](https://github.com/shakacode/shakapacker/pull/778) by [justin808](https://github.com/justin808). Resolves [#707](https://github.com/shakacode/shakapacker/issues/707).
|
|
34
|
+
- Enhanced type safety across configFile, buildValidator, and yamlSerializer modules
|
|
35
|
+
- Improved error message preservation for webpack/rspack build failures
|
|
36
|
+
- Fixed edge cases in YAML serialization (empty arrays, malformed objects)
|
|
37
|
+
- More robust constructor name detection for object serialization
|
|
38
|
+
- Better handling of Symbol, BigInt, and edge case types
|
|
39
|
+
- **Default template no longer triggers production warning**. [PR #774](https://github.com/shakacode/shakapacker/pull/774) by [justin808](https://github.com/justin808). Fixes [#703](https://github.com/shakacode/shakapacker/issues/703).
|
|
40
|
+
- Changed default `useContentHash` to `true` in `shakapacker.yml` template
|
|
41
|
+
- Eliminates confusing warning about `useContentHash: false` not being allowed in production
|
|
42
|
+
- Development environment now explicitly sets `useContentHash: false` for faster builds
|
|
43
|
+
- Production no longer needs explicit override since it inherits the correct default
|
|
44
|
+
- Fixed Rails constant error when using custom environments like staging. [PR #681](https://github.com/shakacode/shakapacker/pull/681) by [justin808](https://github.com/justin808). `RAILS_ENV=staging` no longer causes "uninitialized constant Shakapacker::Instance::Rails" error. Shakapacker now works in non-Rails contexts.
|
|
45
|
+
- 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). Previously `package/index.d.ts` was exporting all types as `any`, breaking IDE autocomplete. Now properly exports typed interfaces.
|
|
46
|
+
- Fixed integrity config handling and sass-loader version check. [PR #688](https://github.com/shakacode/shakapacker/pull/688) by [justin808](https://github.com/justin808). Properly handles subresource integrity configuration and correctly detects sass-loader version for conditional logic.
|
|
51
47
|
|
|
52
48
|
### Added
|
|
53
49
|
|
|
54
|
-
- **
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- **
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- **Custom help messages for `bin/shakapacker` commands**. [PR #702](https://github.com/shakacode/shakapacker/pull/702) by [justin808](https://github.com/justin808).
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
- **
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
- **
|
|
70
|
-
|
|
71
|
-
- Helps identify performance bottlenecks
|
|
72
|
-
- **Named build configurations with `--build` flag**. [PR #728](https://github.com/shakacode/shakapacker/pull/728) by [justin808](https://github.com/justin808).
|
|
73
|
-
- Allows specifying custom build configurations: `bin/shakapacker --build=production` or `bin/shakapacker --build=test`
|
|
74
|
-
- Useful for creating specialized build configurations for different deployment environments
|
|
75
|
-
- **Build validation in `bin/export-bundler-config`**. [PR #717](https://github.com/shakacode/shakapacker/pull/717) by [justin808](https://github.com/justin808).
|
|
76
|
-
- Validates webpack/rspack configuration before export to catch errors early
|
|
77
|
-
- Provides clear error messages for configuration issues
|
|
78
|
-
- **Backward compatibility for rspack config in `config/webpack/`**. [PR #734](https://github.com/shakacode/shakapacker/pull/734) by [justin808](https://github.com/justin808).
|
|
79
|
-
- Rspack configurations can now be placed in `config/webpack/` directory for easier migration
|
|
80
|
-
- Maintains compatibility with existing project structures
|
|
81
|
-
- Added Knip for detecting dead code to CI. [PR #675](https://github.com/shakacode/shakapacker/pull/675) by [justin808](https://github.com/justin808).
|
|
50
|
+
- **HTTP 103 Early Hints support** for faster asset loading. [PR #722](https://github.com/shakacode/shakapacker/pull/722) by [justin808](https://github.com/justin808). Automatically sends early hints when `early_hints: enabled: true` in `shakapacker.yml`. Works with `append_javascript_pack_tag`/`append_stylesheet_pack_tag`, supports per-controller/action configuration, and includes helpers like `configure_pack_early_hints` and `skip_send_pack_early_hints`. Requires Rails 5.2+ and HTTP/2-capable server. See [Early Hints Guide](docs/early_hints.md).
|
|
51
|
+
- **`--help=verbose` flag** to display all available webpack/rspack bundler options. [PR #763](https://github.com/shakacode/shakapacker/pull/763) by [justin808](https://github.com/justin808). Run `bin/shakapacker --help=verbose` to see complete bundler documentation.
|
|
52
|
+
- **Support for arbitrary output names in build configurations**. [PR #752](https://github.com/shakacode/shakapacker/pull/752) by [justin808](https://github.com/justin808). The `outputs` array now accepts any custom names (e.g., `client-modern`, `client-legacy`, `server-bundle`) instead of being limited to only `client`, `server`, and `all`.
|
|
53
|
+
- **Enhanced error reporting in config exporter**. [PR #752](https://github.com/shakacode/shakapacker/pull/752) by [justin808](https://github.com/justin808). Shows detailed environment variable state when config functions fail and provides actionable suggestions based on error patterns.
|
|
54
|
+
- **Config count validation for build outputs**. [PR #752](https://github.com/shakacode/shakapacker/pull/752) by [justin808](https://github.com/justin808). Validates webpack/rspack config array length matches `outputs` array with clear error messages and suggested fixes.
|
|
55
|
+
- **`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). Configure in `shakapacker.yml` with `precompile_hook: "command to run"`.
|
|
56
|
+
- **`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). Allows specifying a custom path for webpack/rspack configuration files.
|
|
57
|
+
- **YAML output format support for `bin/shakapacker-config`** (formerly `bin/export-bundler-config`). [PR #704](https://github.com/shakacode/shakapacker/pull/704) by [justin808](https://github.com/justin808). New `--format yaml` option exports bundler configuration as YAML.
|
|
58
|
+
- **Plugin names displayed in YAML config export**. [PR #750](https://github.com/shakacode/shakapacker/pull/750) by [justin808](https://github.com/justin808). Shows plugin constructor names in exported configuration to help identify which plugins are active.
|
|
59
|
+
- **Custom help messages for `bin/shakapacker` commands**. [PR #702](https://github.com/shakacode/shakapacker/pull/702) by [justin808](https://github.com/justin808). Improved help output for better command discoverability with clear usage examples.
|
|
60
|
+
- **HMR client config export in doctor mode**. [PR #701](https://github.com/shakacode/shakapacker/pull/701) by [justin808](https://github.com/justin808). `bin/shakapacker-config --doctor` now includes HMR client configuration to help debug Hot Module Replacement issues.
|
|
61
|
+
- **Build timing logs** for webpack and rspack. [PR #706](https://github.com/shakacode/shakapacker/pull/706) by [justin808](https://github.com/justin808). Shows duration of build operations to help identify performance bottlenecks.
|
|
62
|
+
- **Named build configurations with `--build` flag**. [PR #728](https://github.com/shakacode/shakapacker/pull/728) by [justin808](https://github.com/justin808). Allows specifying custom build configurations like `bin/shakapacker --build=production` or `bin/shakapacker --build=test`.
|
|
63
|
+
- **Build validation in `bin/shakapacker-config`**. [PR #717](https://github.com/shakacode/shakapacker/pull/717) by [justin808](https://github.com/justin808). Validates webpack/rspack configuration before export to catch errors early.
|
|
64
|
+
- **Backward compatibility for rspack config in `config/webpack/`**. [PR #734](https://github.com/shakacode/shakapacker/pull/734) by [justin808](https://github.com/justin808). Rspack configurations can now be placed in `config/webpack/` directory for easier migration.
|
|
65
|
+
- **Merge option for WebpackAssetsManifestPlugin**. [PR #760](https://github.com/shakacode/shakapacker/pull/760) by [justin808](https://github.com/justin808). Adds `merge` option to control manifest merging behavior, useful for multi-compiler setups.
|
|
66
|
+
- Support for esbuild-loader v5. [PR #758](https://github.com/shakacode/shakapacker/pull/758) by [justin808](https://github.com/justin808).
|
|
82
67
|
|
|
83
68
|
### Changed
|
|
84
69
|
|
|
85
|
-
- **
|
|
86
|
-
- Updated all ESLint plugins to latest versions
|
|
87
|
-
- Uses new flat config format for better maintainability
|
|
88
|
-
- **Replaced custom argument parser with yargs**. [PR #692](https://github.com/shakacode/shakapacker/pull/692) by [justin808](https://github.com/justin808).
|
|
89
|
-
- More robust command-line argument parsing
|
|
90
|
-
- Better error messages and help output
|
|
91
|
-
- Replaced `require` with `import` in package/index.ts. [PR #674](https://github.com/shakacode/shakapacker/pull/674) by [justin808](https://github.com/justin808).
|
|
70
|
+
- **Generated `swc.config.js` now uses single quotes and trailing commas**. [PR #755](https://github.com/shakacode/shakapacker/pull/755) by [justin808](https://github.com/justin808). Consistent code style in generated configuration files.
|
|
92
71
|
- Updated @rspack dependencies to 1.5.8. [PR #700](https://github.com/shakacode/shakapacker/pull/700) by [justin808](https://github.com/justin808).
|
|
93
72
|
|
|
94
73
|
### Improved
|
|
95
74
|
|
|
96
|
-
- **
|
|
97
|
-
|
|
98
|
-
- Common pitfalls and solutions documented
|
|
99
|
-
- **Consolidated duplicate configuration documentation**. [PR #714](https://github.com/shakacode/shakapacker/pull/714) by [justin808](https://github.com/justin808).
|
|
100
|
-
- Removed redundant documentation
|
|
101
|
-
- Single source of truth for configuration options
|
|
102
|
-
- **Improved error messages** to suggest `assets_bundler_config_path`. [PR #712](https://github.com/shakacode/shakapacker/pull/712) by [justin808](https://github.com/justin808).
|
|
103
|
-
- More helpful error messages when bundler config is not found
|
|
104
|
-
- Suggests using `assets_bundler_config_path` for custom locations
|
|
105
|
-
- **Improved doctor command output** clarity and accuracy. [PR #682](https://github.com/shakacode/shakapacker/pull/682) by [justin808](https://github.com/justin808).
|
|
106
|
-
- Better formatting and organization of diagnostic information
|
|
107
|
-
- More actionable recommendations
|
|
108
|
-
- **Documented `content_for` pattern to prevent FOUC** with `stylesheet_pack_tag`. [PR #737](https://github.com/shakacode/shakapacker/pull/737) by [justin808](https://github.com/justin808).
|
|
109
|
-
- Added documentation on using `content_for` to prevent Flash of Unstyled Content
|
|
110
|
-
- Best practice patterns for managing stylesheet loading order
|
|
111
|
-
- **Improved upgrade documentation** to clarify dual Gemfile and package.json updates. [PR #731](https://github.com/shakacode/shakapacker/pull/731) by [justin808](https://github.com/justin808).
|
|
112
|
-
- Clearer instructions for upgrading both Ruby gem and NPM package
|
|
113
|
-
- Helps prevent version mismatch issues
|
|
114
|
-
- Formatted all markdown files with prettier. [PR #673](https://github.com/shakacode/shakapacker/pull/673) by [justin808](https://github.com/justin808).
|
|
115
|
-
|
|
116
|
-
### Fixed
|
|
117
|
-
|
|
118
|
-
- Fixed rspack native bindings installation issue when switching bundlers. [PR #672](https://github.com/shakacode/shakapacker/pull/672) by [justin808](https://github.com/justin808).
|
|
119
|
-
- Running `rake shakapacker:switch_bundler rspack -- --install-deps` now properly installs platform-specific native bindings
|
|
120
|
-
- Fixes "Cannot find native binding" error when switching to rspack
|
|
121
|
-
- Fixed Rails constant error when using custom environments like staging. [PR #681](https://github.com/shakacode/shakapacker/pull/681) by [justin808](https://github.com/justin808).
|
|
122
|
-
- `RAILS_ENV=staging` no longer causes "uninitialized constant Shakapacker::Instance::Rails" error
|
|
123
|
-
- Shakapacker now works in non-Rails contexts (like standalone runner)
|
|
124
|
-
- 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).
|
|
125
|
-
- Previously `package/index.d.ts` was exporting all types as `any`, breaking IDE autocomplete
|
|
126
|
-
- Now properly exports typed interfaces for `WebpackConfig`, `RspackConfig`, etc.
|
|
127
|
-
- Fixed integrity config handling and sass-loader version check. [PR #688](https://github.com/shakacode/shakapacker/pull/688) by [justin808](https://github.com/justin808).
|
|
128
|
-
- Properly handles subresource integrity configuration
|
|
129
|
-
- Correctly detects sass-loader version for conditional logic
|
|
130
|
-
- Prevented index.d.ts confusion in build process. [PR #698](https://github.com/shakacode/shakapacker/pull/698) by [justin808](https://github.com/justin808).
|
|
131
|
-
- TypeScript declaration files no longer interfere with build output
|
|
132
|
-
- Fixed yarn.lock formatting changes in Conductor setup. [PR #683](https://github.com/shakacode/shakapacker/pull/683) by [justin808](https://github.com/justin808).
|
|
75
|
+
- **Improved error messages** to suggest `assets_bundler_config_path`. [PR #712](https://github.com/shakacode/shakapacker/pull/712) by [justin808](https://github.com/justin808). More helpful error messages when bundler config is not found, suggesting use of `assets_bundler_config_path` for custom locations.
|
|
76
|
+
- **Improved doctor command output** clarity and accuracy. [PR #682](https://github.com/shakacode/shakapacker/pull/682) by [justin808](https://github.com/justin808). Better formatting and organization of diagnostic information with more actionable recommendations.
|
|
133
77
|
|
|
134
78
|
## [v9.2.0] - October 9, 2025
|
|
135
79
|
|
|
136
80
|
### Added
|
|
137
81
|
|
|
138
82
|
- **New config export utility for debugging webpack/rspack configurations** [PR #647](https://github.com/shakacode/shakapacker/pull/647) by [justin808](https://github.com/justin808).
|
|
139
|
-
- Adds `bin/export-bundler-config
|
|
83
|
+
- Adds `bin/shakapacker-config` utility (originally named `bin/export-bundler-config`, renamed in PR #728) with three modes:
|
|
140
84
|
- **Doctor mode** (`--doctor`): Exports all configs (dev + prod, client + server) to `shakapacker-config-exports/` directory - best for troubleshooting
|
|
141
85
|
- **Save mode** (`--save`): Export current environment configs to files
|
|
142
86
|
- **Stdout mode** (default): View configs in terminal
|
|
@@ -148,7 +92,7 @@ Changes since the last non-beta release.
|
|
|
148
92
|
- Validates bundler value and output paths
|
|
149
93
|
- Sanitizes filenames to prevent path traversal
|
|
150
94
|
- Helpful `.gitignore` suggestions
|
|
151
|
-
- **Usage:** `bin/
|
|
95
|
+
- **Usage:** `bin/shakapacker-config --doctor` or `bundle exec rake shakapacker:export_bundler_config`
|
|
152
96
|
- Works seamlessly with `rake shakapacker:switch_bundler` for comparing webpack vs rspack configs
|
|
153
97
|
- Lays groundwork for future config diff feature (tracked in [#667](https://github.com/shakacode/shakapacker/issues/667))
|
|
154
98
|
|
|
@@ -783,8 +727,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
783
727
|
|
|
784
728
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
|
785
729
|
|
|
786
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.3.0
|
|
787
|
-
[v9.3.0
|
|
730
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.3.0...main
|
|
731
|
+
[v9.3.0]: https://github.com/shakacode/shakapacker/compare/v9.2.0...v9.3.0
|
|
788
732
|
[v9.2.0]: https://github.com/shakacode/shakapacker/compare/v9.1.0...v9.2.0
|
|
789
733
|
[v9.1.0]: https://github.com/shakacode/shakapacker/compare/v9.0.0...v9.1.0
|
|
790
734
|
[v9.0.0]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0
|
data/CLAUDE.md
CHANGED
|
@@ -29,16 +29,12 @@
|
|
|
29
29
|
|
|
30
30
|
## Changelog
|
|
31
31
|
|
|
32
|
-
- **Update CHANGELOG.md for user-visible changes only**
|
|
33
|
-
-
|
|
34
|
-
- **
|
|
35
|
-
-
|
|
36
|
-
- **
|
|
37
|
-
|
|
38
|
-
- Always link to the author: `by [username](https://github.com/username)`
|
|
39
|
-
- Keep formatting consistent with existing entries
|
|
40
|
-
- When releasing a version, update the version diff links at the bottom of CHANGELOG.md
|
|
41
|
-
- **For breaking changes**: Use bold formatting and link to migration documentation (e.g., `**Breaking**: Description. See [Migration Guide](docs/vX_upgrade.md)`)
|
|
32
|
+
- **Update CHANGELOG.md for user-visible changes only** (features, bug fixes, breaking changes, deprecations, performance improvements)
|
|
33
|
+
- **Do NOT add entries for**: linting, formatting, refactoring, tests, or documentation fixes
|
|
34
|
+
- **Format**: `[PR #123](https://github.com/shakacode/shakapacker/pull/123) by [username](https://github.com/username)` (Shakapacker uses `#` in PR links)
|
|
35
|
+
- **Use `/update-changelog` command** for guided changelog updates with automatic formatting
|
|
36
|
+
- **Version management**: Run `bundle exec rake update_changelog` after releases to update version headers
|
|
37
|
+
- **Examples**: Run `grep -A 3 "^### " CHANGELOG.md | head -30` to see real formatting examples
|
|
42
38
|
|
|
43
39
|
## Shakapacker-Specific
|
|
44
40
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -103,11 +103,36 @@ Shakapacker uses optional peer dependencies (via `peerDependenciesMeta`) for max
|
|
|
103
103
|
- **No installation warnings** - Package managers won't warn about missing optional dependencies
|
|
104
104
|
- **Version constraints still apply** - When a package is installed, version compatibility is enforced
|
|
105
105
|
|
|
106
|
+
### TypeScript Declaration Files and Optional Dependencies
|
|
107
|
+
|
|
108
|
+
When importing types from optional peer dependencies, we use `@ts-expect-error` directives:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// @ts-expect-error: webpack is an optional peer dependency (using type-only import)
|
|
112
|
+
import type { Configuration } from "webpack"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Important behavior:**
|
|
116
|
+
|
|
117
|
+
- **In development** (webpack installed): TypeScript doesn't error, but `@ts-expect-error` expects one → TypeScript compilation will fail
|
|
118
|
+
- **In production** (webpack not installed): TypeScript errors on import, `@ts-expect-error` suppresses it → TypeScript compilation succeeds
|
|
119
|
+
|
|
120
|
+
This is counterintuitive but correct. Our CI validates both scenarios to ensure the behavior works as expected.
|
|
121
|
+
|
|
122
|
+
**Example scenario:**
|
|
123
|
+
|
|
124
|
+
If webpack were changed from optional to required in `package.json`:
|
|
125
|
+
|
|
126
|
+
- Development builds would fail with: `error TS2578: Unused '@ts-expect-error' directive`
|
|
127
|
+
- This surfaces the dependency change immediately, preventing accidental breakage
|
|
128
|
+
- The build failure prompts developers to remove the `@ts-expect-error` directive
|
|
129
|
+
|
|
106
130
|
### When modifying dependencies:
|
|
107
131
|
|
|
108
132
|
1. Add new peer dependencies to both `peerDependencies` and `peerDependenciesMeta` (marking as optional)
|
|
109
133
|
2. Keep version ranges synchronized between `devDependencies` and `peerDependencies`
|
|
110
134
|
3. Test with multiple package managers: `npm`, `yarn`, and `pnpm`
|
|
135
|
+
4. If adding type-only imports from optional dependencies, use the `@ts-expect-error` pattern shown above
|
|
111
136
|
|
|
112
137
|
### Testing peer dependency changes:
|
|
113
138
|
|
|
@@ -223,6 +248,8 @@ The project uses Yarn in CI workflows for the following reasons:
|
|
|
223
248
|
- `.github/workflows/ruby.yml` - Ruby test suite across Ruby/Rails versions
|
|
224
249
|
- `.github/workflows/node.yml` - Node.js test suite across Node versions
|
|
225
250
|
- `.github/workflows/generator.yml` - Generator installation tests
|
|
251
|
+
- `.github/workflows/dummy.yml` - Dummy app integration tests
|
|
252
|
+
- `.github/workflows/eslint-validation.yml` - ESLint configuration validation
|
|
226
253
|
|
|
227
254
|
All workflows use:
|
|
228
255
|
|
|
@@ -239,6 +266,36 @@ And install dependencies with:
|
|
|
239
266
|
yarn install
|
|
240
267
|
```
|
|
241
268
|
|
|
269
|
+
### CI Optimization: Path Filtering
|
|
270
|
+
|
|
271
|
+
To reduce CI costs and execution time, workflows use **path filtering** to run only when relevant files change:
|
|
272
|
+
|
|
273
|
+
- **Ruby workflow** - Only runs when Ruby files, gemspecs, Gemfile, or RuboCop config changes
|
|
274
|
+
- **Node workflow** - Only runs when JS/TS files, package.json, or Node config changes
|
|
275
|
+
- **Generator specs** - Only runs when generator-related files change
|
|
276
|
+
- **Dummy specs** - Only runs when dummy app or lib files change
|
|
277
|
+
- **Test bundlers** - Only runs when code affecting bundler integration changes
|
|
278
|
+
|
|
279
|
+
This means documentation-only PRs (e.g., only changing `README.md`) will skip all test workflows entirely.
|
|
280
|
+
|
|
281
|
+
**Important:** The full test suite always runs on pushes to the `main` branch to ensure the main branch is always thoroughly tested.
|
|
282
|
+
|
|
283
|
+
### Manual Workflow Execution
|
|
284
|
+
|
|
285
|
+
All workflows can be triggered manually via the GitHub Actions UI using the "Run workflow" button. This is useful for:
|
|
286
|
+
|
|
287
|
+
- Re-running tests after a temporary CI failure
|
|
288
|
+
- Testing workflows on specific branches without creating a PR
|
|
289
|
+
- Running full test suites on PRs that would normally skip certain workflows
|
|
290
|
+
|
|
291
|
+
### Conditional Linting
|
|
292
|
+
|
|
293
|
+
The Node workflow includes conditional execution of actionlint (GitHub Actions linter):
|
|
294
|
+
|
|
295
|
+
- Only downloads and runs when `.github/workflows/*` files change
|
|
296
|
+
- Saves time by skipping on most PRs
|
|
297
|
+
- Includes caching for faster execution when needed
|
|
298
|
+
|
|
242
299
|
### Testing with Other Package Managers
|
|
243
300
|
|
|
244
301
|
While CI uses Yarn, the gem supports all major package managers (npm, yarn, pnpm, bun). Generator specs test against all package managers to ensure compatibility.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -85,6 +85,7 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=
|
|
|
85
85
|
- [Automatic Webpack Code Building](#automatic-webpack-code-building)
|
|
86
86
|
- [Compiler strategies](#compiler-strategies)
|
|
87
87
|
- [Common Development Commands](#common-development-commands)
|
|
88
|
+
- [Ruby API Reference](#ruby-api-reference)
|
|
88
89
|
- [Webpack Configuration](#webpack-configuration)
|
|
89
90
|
- [Babel configuration](#babel-configuration)
|
|
90
91
|
- [SWC configuration](#swc-configuration)
|
|
@@ -316,7 +317,15 @@ At its core, Shakapacker's essential function is to:
|
|
|
316
317
|
|
|
317
318
|
### Configuration and Code
|
|
318
319
|
|
|
319
|
-
**📖 For a comprehensive guide to all configuration options, see [Configuration Guide](./docs/configuration.md)**
|
|
320
|
+
**📖 For a comprehensive guide to all configuration options, see the [Configuration Guide](./docs/configuration.md)**
|
|
321
|
+
|
|
322
|
+
This includes documentation for:
|
|
323
|
+
|
|
324
|
+
- All `config/shakapacker.yml` options (including `assets_bundler_config_path`)
|
|
325
|
+
- Environment-specific configuration
|
|
326
|
+
- Development server settings
|
|
327
|
+
- Build configurations (`config/shakapacker-builds.yml`)
|
|
328
|
+
- Best practices and common patterns
|
|
320
329
|
|
|
321
330
|
You will need your file system to correspond to the setup of your `config/shakapacker.yml` file.
|
|
322
331
|
|
|
@@ -664,6 +673,56 @@ end
|
|
|
664
673
|
|
|
665
674
|
**Note:** Don't forget to prefix `ruby` when running these binstubs on Windows
|
|
666
675
|
|
|
676
|
+
### Ruby API Reference
|
|
677
|
+
|
|
678
|
+
**📚 For comprehensive Ruby API documentation, see the [API Reference Guide](./docs/api-reference.md).**
|
|
679
|
+
|
|
680
|
+
This guide covers:
|
|
681
|
+
|
|
682
|
+
- **Main Shakapacker Module** - Configuration, compilation, and manifest access
|
|
683
|
+
- **Configuration API** - Accessing `config/shakapacker.yml` settings programmatically
|
|
684
|
+
- **View Helpers** - Complete reference for all Rails helpers
|
|
685
|
+
- **Manifest API** - Asset lookup and resolution methods
|
|
686
|
+
- **Dev Server API** - Development server status and management
|
|
687
|
+
- **Advanced Usage** - Multiple instances, testing, custom configurations
|
|
688
|
+
|
|
689
|
+
#### Quick Examples
|
|
690
|
+
|
|
691
|
+
```ruby
|
|
692
|
+
# Access configuration
|
|
693
|
+
Shakapacker.config.source_path
|
|
694
|
+
# => #<Pathname:/app/app/javascript>
|
|
695
|
+
|
|
696
|
+
# Get raw configuration hash
|
|
697
|
+
Shakapacker.config.data
|
|
698
|
+
# => { "source_path" => "app/javascript", ... }
|
|
699
|
+
|
|
700
|
+
# Look up compiled assets
|
|
701
|
+
Shakapacker.manifest.lookup("application.js")
|
|
702
|
+
# => "/packs/application-abc123.js"
|
|
703
|
+
|
|
704
|
+
# Check dev server status
|
|
705
|
+
Shakapacker.dev_server.running?
|
|
706
|
+
# => true
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
#### Generating Full API Documentation
|
|
710
|
+
|
|
711
|
+
For complete API documentation with all methods and parameters:
|
|
712
|
+
|
|
713
|
+
```bash
|
|
714
|
+
# Using YARD (recommended - better formatting)
|
|
715
|
+
gem install yard
|
|
716
|
+
yard doc
|
|
717
|
+
yard server # Browse at http://localhost:8808
|
|
718
|
+
|
|
719
|
+
# Using RDoc (standard Ruby documentation)
|
|
720
|
+
rdoc lib/
|
|
721
|
+
open doc/index.html
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
The generated documentation includes all public and private methods with detailed descriptions.
|
|
725
|
+
|
|
667
726
|
### Webpack Configuration
|
|
668
727
|
|
|
669
728
|
First, you don't _need_ to use Shakapacker's webpack configuration. However, the `shakapacker` NPM package provides convenient access to configuration code that reads the `config/shakapacker.yml` file which the view helpers also use. If you have your customized webpack configuration, at the minimum, you must ensure:
|
|
@@ -673,6 +732,21 @@ First, you don't _need_ to use Shakapacker's webpack configuration. However, the
|
|
|
673
732
|
|
|
674
733
|
The webpack configuration used by Shakapacker lives in `config/webpack/webpack.config.js`; this makes it easy to customize the configuration beyond what's available in `config/shakapacker.yml` by giving you complete control of the final configuration. By default, this file exports the result of `generateWebpackConfig` which handles generating a webpack configuration based on `config/shakapacker.yml`.
|
|
675
734
|
|
|
735
|
+
#### Using a Completely Custom Webpack Configuration
|
|
736
|
+
|
|
737
|
+
If you're providing a completely custom webpack configuration without using `generateWebpackConfig()`, you should set `javascript_transpiler: 'none'` in your `config/shakapacker.yml` to skip Shakapacker's transpiler validation and dependency checks:
|
|
738
|
+
|
|
739
|
+
```yml
|
|
740
|
+
# config/shakapacker.yml
|
|
741
|
+
default: &default
|
|
742
|
+
javascript_transpiler: "none" # Skip Shakapacker's transpiler setup
|
|
743
|
+
# ... other config
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
This is useful when you're managing your own transpiler configuration entirely outside of Shakapacker's defaults.
|
|
747
|
+
|
|
748
|
+
**Note:** Only use `javascript_transpiler: 'none'` if you're providing a completely custom webpack configuration without using `generateWebpackConfig()`. If you're using Shakapacker's webpack generation (which is the common case), use one of the supported transpilers (`'babel'`, `'swc'`, or `'esbuild'`) instead.
|
|
749
|
+
|
|
676
750
|
The easiest way to modify this config is to pass your desired customizations to `generateWebpackConfig` which will use [webpack-merge](https://github.com/survivejs/webpack-merge) to merge them with the configuration generated from `config/shakapacker.yml`:
|
|
677
751
|
|
|
678
752
|
```js
|
|
@@ -767,7 +841,7 @@ fileRule.type = "asset"
|
|
|
767
841
|
|
|
768
842
|
### Babel configuration
|
|
769
843
|
|
|
770
|
-
|
|
844
|
+
If you choose to use Babel instead of the default SWC transpiler, you will need to configure it in your `package.json`:
|
|
771
845
|
|
|
772
846
|
```json
|
|
773
847
|
"babel": {
|
|
@@ -777,19 +851,21 @@ By default, you will find the Shakapacker preset in your `package.json`. Note, y
|
|
|
777
851
|
},
|
|
778
852
|
```
|
|
779
853
|
|
|
780
|
-
|
|
854
|
+
You can also change your Babel configuration by removing these lines in your `package.json` and adding [a Babel configuration file](https://babeljs.io/docs/en/config-files) to your project. For an example of customization based on the original, see [Customizing Babel Config](./docs/customizing_babel_config.md).
|
|
781
855
|
|
|
782
856
|
### SWC configuration
|
|
783
857
|
|
|
784
|
-
|
|
858
|
+
SWC is the recommended JavaScript transpiler in Shakapacker v9+ (20x faster than Babel). New installations use SWC by default via the installation template. You can read more at [SWC usage docs](./docs/using_swc_loader.md).
|
|
859
|
+
|
|
860
|
+
**Note on defaults**: The installation template explicitly sets `javascript_transpiler: "swc"` for new projects. However, for backward compatibility, webpack's runtime default (when no explicit config exists) remains `"babel"`. Rspack always defaults to `"swc"`.
|
|
785
861
|
|
|
786
|
-
Please note that
|
|
862
|
+
Please note that SWC supports [React](#react) integration out of the box - no additional configuration needed.
|
|
787
863
|
|
|
788
864
|
### esbuild loader configuration
|
|
789
865
|
|
|
790
|
-
You can
|
|
866
|
+
You can use esbuild as an alternative JavaScript transpiler. You can read more at [esbuild-loader usage docs](./docs/using_esbuild_loader.md).
|
|
791
867
|
|
|
792
|
-
Please note that
|
|
868
|
+
Please note that esbuild supports [React](#react) integration out of the box - no additional configuration needed.
|
|
793
869
|
|
|
794
870
|
### Switching between transpilers
|
|
795
871
|
|
|
@@ -801,7 +877,7 @@ Shakapacker provides a powerful utility to export and analyze your webpack/rspac
|
|
|
801
877
|
|
|
802
878
|
```bash
|
|
803
879
|
# Export all configs for troubleshooting (recommended)
|
|
804
|
-
bin/
|
|
880
|
+
bin/shakapacker-config --doctor
|
|
805
881
|
|
|
806
882
|
# Or via rake task
|
|
807
883
|
bundle exec rake shakapacker:export_bundler_config -- --doctor
|