shakapacker 9.3.0 → 9.3.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/.claude/commands/update-changelog.md +232 -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 +24 -9
- data/CLAUDE.md +6 -10
- data/CONTRIBUTING.md +44 -0
- data/Gemfile.lock +1 -1
- data/README.md +74 -44
- data/docs/api-reference.md +519 -0
- data/docs/cdn_setup.md +3 -3
- data/docs/common-upgrades.md +6 -7
- data/docs/configuration.md +14 -8
- data/docs/css-modules-export-mode.md +40 -6
- data/docs/deployment.md +3 -3
- data/docs/early_hints_manual_api.md +1 -1
- data/docs/feature_testing.md +3 -3
- data/docs/optional-peer-dependencies.md +2 -2
- data/docs/precompile_hook.md +15 -15
- data/docs/react.md +1 -1
- data/docs/releasing.md +7 -7
- data/docs/rspack_migration_guide.md +8 -14
- data/docs/transpiler-migration.md +12 -9
- data/docs/troubleshooting.md +3 -3
- data/docs/using_swc_loader.md +13 -10
- data/docs/v6_upgrade.md +2 -2
- data/docs/v9_upgrade.md +78 -3
- data/eslint.config.fast.js +120 -8
- data/eslint.config.js +50 -31
- data/lib/install/config/shakapacker.yml +14 -1
- data/lib/shakapacker/bundler_switcher.rb +83 -18
- data/lib/shakapacker/configuration.rb +47 -4
- data/lib/shakapacker/dev_server_runner.rb +4 -0
- data/lib/shakapacker/doctor.rb +7 -7
- data/lib/shakapacker/runner.rb +1 -1
- data/lib/shakapacker/swc_migrator.rb +2 -2
- data/lib/shakapacker/version.rb +1 -1
- data/lib/tasks/shakapacker/binstubs.rake +4 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +2 -2
- data/lib/tasks/shakapacker/doctor.rake +3 -3
- data/lib/tasks/shakapacker/export_bundler_config.rake +5 -9
- data/lib/tasks/shakapacker/install.rake +4 -2
- data/lib/tasks/shakapacker/switch_bundler.rake +30 -40
- data/package/config.ts +2 -3
- data/package/configExporter/cli.ts +29 -24
- data/package/dev_server.ts +2 -2
- data/package/env.ts +1 -1
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +6 -6
- data/package/environments/base.ts +2 -2
- data/package/environments/development.ts +3 -6
- data/package/environments/production.ts +2 -2
- data/package/environments/test.ts +2 -1
- 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 +0 -1
- data/package/loaders.d.ts +1 -1
- data/package/plugins/rspack.ts +3 -1
- data/package/plugins/webpack.ts +5 -3
- data/package/rspack/index.ts +3 -3
- data/package/rules/file.ts +1 -1
- 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 -3
- data/package/utils/pathValidation.ts +10 -11
- data/package/utils/requireOrError.ts +4 -3
- data/package/webpack-types.d.ts +1 -1
- data/package/webpackDevServerConfig.ts +4 -4
- data/package.json +3 -3
- data/test/package/transpiler-defaults.test.js +42 -0
- data/yarn.lock +1 -1
- metadata +5 -2
data/README.md
CHANGED
|
@@ -85,7 +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
|
-
- [API
|
|
88
|
+
- [Ruby API Reference](#ruby-api-reference)
|
|
89
89
|
- [Webpack Configuration](#webpack-configuration)
|
|
90
90
|
- [Babel configuration](#babel-configuration)
|
|
91
91
|
- [SWC configuration](#swc-configuration)
|
|
@@ -163,7 +163,7 @@ Then run the following to install Shakapacker:
|
|
|
163
163
|
|
|
164
164
|
```bash
|
|
165
165
|
./bin/bundle install
|
|
166
|
-
|
|
166
|
+
bundle exec rake shakapacker:install
|
|
167
167
|
```
|
|
168
168
|
|
|
169
169
|
Before initiating the installation process, ensure you have committed all the changes. While installing Shakapacker, there might be some conflict between the existing file content and what Shakapacker tries to copy. You can either approve all the prompts for overriding these files or use the `FORCE=true` environment variable before the installation command to force the override without any prompt.
|
|
@@ -282,12 +282,10 @@ Depending on your setup, you'll need different subsets of the optional peer depe
|
|
|
282
282
|
**Quick tip:** You can easily switch between webpack and rspack using:
|
|
283
283
|
|
|
284
284
|
```bash
|
|
285
|
-
|
|
286
|
-
# or with rake (note the -- separator)
|
|
287
|
-
rake shakapacker:switch_bundler rspack -- --install-deps
|
|
285
|
+
bundle exec rake shakapacker:switch_bundler rspack -- --install-deps
|
|
288
286
|
|
|
289
287
|
# For faster switching, use --no-uninstall to keep both bundlers installed
|
|
290
|
-
|
|
288
|
+
bundle exec rake shakapacker:switch_bundler webpack -- --install-deps --no-uninstall
|
|
291
289
|
```
|
|
292
290
|
|
|
293
291
|
See the [Rspack Migration Guide](./docs/rspack_migration_guide.md) for details.
|
|
@@ -673,47 +671,55 @@ end
|
|
|
673
671
|
|
|
674
672
|
**Note:** Don't forget to prefix `ruby` when running these binstubs on Windows
|
|
675
673
|
|
|
676
|
-
### API
|
|
674
|
+
### Ruby API Reference
|
|
677
675
|
|
|
678
|
-
|
|
676
|
+
**📚 For comprehensive Ruby API documentation, see the [API Reference Guide](./docs/api-reference.md).**
|
|
679
677
|
|
|
680
|
-
|
|
678
|
+
This guide covers:
|
|
681
679
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
680
|
+
- **Main Shakapacker Module** - Configuration, compilation, and manifest access
|
|
681
|
+
- **Configuration API** - Accessing `config/shakapacker.yml` settings programmatically
|
|
682
|
+
- **View Helpers** - Complete reference for all Rails helpers
|
|
683
|
+
- **Manifest API** - Asset lookup and resolution methods
|
|
684
|
+
- **Dev Server API** - Development server status and management
|
|
685
|
+
- **Advanced Usage** - Multiple instances, testing, custom configurations
|
|
685
686
|
|
|
686
|
-
|
|
687
|
-
|
|
687
|
+
#### Quick Examples
|
|
688
|
+
|
|
689
|
+
```ruby
|
|
690
|
+
# Access configuration
|
|
691
|
+
Shakapacker.config.source_path
|
|
692
|
+
# => #<Pathname:/app/app/javascript>
|
|
693
|
+
|
|
694
|
+
# Get raw configuration hash
|
|
695
|
+
Shakapacker.config.data
|
|
696
|
+
# => { "source_path" => "app/javascript", ... }
|
|
697
|
+
|
|
698
|
+
# Look up compiled assets
|
|
699
|
+
Shakapacker.manifest.lookup("application.js")
|
|
700
|
+
# => "/packs/application-abc123.js"
|
|
701
|
+
|
|
702
|
+
# Check dev server status
|
|
703
|
+
Shakapacker.dev_server.running?
|
|
704
|
+
# => true
|
|
688
705
|
```
|
|
689
706
|
|
|
690
|
-
####
|
|
707
|
+
#### Generating Full API Documentation
|
|
691
708
|
|
|
692
|
-
|
|
709
|
+
For complete API documentation with all methods and parameters:
|
|
693
710
|
|
|
694
711
|
```bash
|
|
695
|
-
#
|
|
712
|
+
# Using YARD (recommended - better formatting)
|
|
696
713
|
gem install yard
|
|
697
|
-
|
|
698
|
-
# Generate documentation
|
|
699
714
|
yard doc
|
|
715
|
+
yard server # Browse at http://localhost:8808
|
|
700
716
|
|
|
701
|
-
#
|
|
717
|
+
# Using RDoc (standard Ruby documentation)
|
|
718
|
+
rdoc lib/
|
|
702
719
|
open doc/index.html
|
|
703
|
-
|
|
704
|
-
# Or start a local documentation server
|
|
705
|
-
yard server
|
|
706
720
|
```
|
|
707
721
|
|
|
708
|
-
The
|
|
709
|
-
|
|
710
|
-
- **Shakapacker** - Main module with configuration, compilation, and manifest access
|
|
711
|
-
- **Shakapacker::Configuration** - All configuration options from `shakapacker.yml`
|
|
712
|
-
- **Shakapacker::Manifest** - Asset lookup methods used by view helpers
|
|
713
|
-
- **Shakapacker::DevServer** - Development server status and configuration
|
|
714
|
-
- **Shakapacker::Instance** - Instance management and lifecycle
|
|
715
|
-
|
|
716
|
-
For the most up-to-date API reference, generate the documentation from the source code as shown above.
|
|
722
|
+
The generated documentation includes all public and private methods with detailed descriptions.
|
|
717
723
|
|
|
718
724
|
### Webpack Configuration
|
|
719
725
|
|
|
@@ -724,6 +730,21 @@ First, you don't _need_ to use Shakapacker's webpack configuration. However, the
|
|
|
724
730
|
|
|
725
731
|
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`.
|
|
726
732
|
|
|
733
|
+
#### Using a Completely Custom Webpack Configuration
|
|
734
|
+
|
|
735
|
+
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:
|
|
736
|
+
|
|
737
|
+
```yml
|
|
738
|
+
# config/shakapacker.yml
|
|
739
|
+
default: &default
|
|
740
|
+
javascript_transpiler: "none" # Skip Shakapacker's transpiler setup
|
|
741
|
+
# ... other config
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
This is useful when you're managing your own transpiler configuration entirely outside of Shakapacker's defaults.
|
|
745
|
+
|
|
746
|
+
**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.
|
|
747
|
+
|
|
727
748
|
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`:
|
|
728
749
|
|
|
729
750
|
```js
|
|
@@ -818,7 +839,7 @@ fileRule.type = "asset"
|
|
|
818
839
|
|
|
819
840
|
### Babel configuration
|
|
820
841
|
|
|
821
|
-
|
|
842
|
+
If you choose to use Babel instead of the default SWC transpiler, you will need to configure it in your `package.json`:
|
|
822
843
|
|
|
823
844
|
```json
|
|
824
845
|
"babel": {
|
|
@@ -828,19 +849,21 @@ By default, you will find the Shakapacker preset in your `package.json`. Note, y
|
|
|
828
849
|
},
|
|
829
850
|
```
|
|
830
851
|
|
|
831
|
-
|
|
852
|
+
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).
|
|
832
853
|
|
|
833
854
|
### SWC configuration
|
|
834
855
|
|
|
835
|
-
|
|
856
|
+
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).
|
|
857
|
+
|
|
858
|
+
**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"`.
|
|
836
859
|
|
|
837
|
-
Please note that
|
|
860
|
+
Please note that SWC supports [React](#react) integration out of the box - no additional configuration needed.
|
|
838
861
|
|
|
839
862
|
### esbuild loader configuration
|
|
840
863
|
|
|
841
|
-
You can
|
|
864
|
+
You can use esbuild as an alternative JavaScript transpiler. You can read more at [esbuild-loader usage docs](./docs/using_esbuild_loader.md).
|
|
842
865
|
|
|
843
|
-
Please note that
|
|
866
|
+
Please note that esbuild supports [React](#react) integration out of the box - no additional configuration needed.
|
|
844
867
|
|
|
845
868
|
### Switching between transpilers
|
|
846
869
|
|
|
@@ -1092,13 +1115,13 @@ Otherwise, Shakapacker will use the production environment as a fallback environ
|
|
|
1092
1115
|
For example, the below command will compile assets in production mode but will use staging configurations from `config/shakapacker.yml` if available or use fallback production environment configuration:
|
|
1093
1116
|
|
|
1094
1117
|
```bash
|
|
1095
|
-
RAILS_ENV=staging bundle exec
|
|
1118
|
+
RAILS_ENV=staging bundle exec rake assets:precompile
|
|
1096
1119
|
```
|
|
1097
1120
|
|
|
1098
1121
|
And, this will compile in development mode and load configuration for the cucumber environment if defined in `shakapacker.yml` or fallback to production configuration
|
|
1099
1122
|
|
|
1100
1123
|
```bash
|
|
1101
|
-
RAILS_ENV=cucumber NODE_ENV=development bundle exec
|
|
1124
|
+
RAILS_ENV=cucumber NODE_ENV=development bundle exec rake assets:precompile
|
|
1102
1125
|
```
|
|
1103
1126
|
|
|
1104
1127
|
Please note, binstubs compiles in development mode however rake tasks compiles in production mode.
|
|
@@ -1109,8 +1132,8 @@ Please note, binstubs compiles in development mode however rake tasks compiles i
|
|
|
1109
1132
|
./bin/shakapacker-dev-server
|
|
1110
1133
|
|
|
1111
1134
|
# Compiles in production mode by default unless NODE_ENV is specified, per `lib/tasks/shakapacker/compile.rake`
|
|
1112
|
-
bundle exec
|
|
1113
|
-
bundle exec
|
|
1135
|
+
bundle exec rake assets:precompile
|
|
1136
|
+
bundle exec rake shakapacker:compile
|
|
1114
1137
|
```
|
|
1115
1138
|
|
|
1116
1139
|
### Upgrading
|
|
@@ -1122,7 +1145,7 @@ You can run the following commands to upgrade Shakapacker to the latest stable v
|
|
|
1122
1145
|
bundle update shakapacker
|
|
1123
1146
|
|
|
1124
1147
|
# overwrite your changes to the default install files and revert any unwanted changes from the install
|
|
1125
|
-
|
|
1148
|
+
bundle exec rake shakapacker:install
|
|
1126
1149
|
|
|
1127
1150
|
# using npm
|
|
1128
1151
|
npm install shakapacker@latest
|
|
@@ -1269,7 +1292,7 @@ For detailed CDN setup instructions, including CloudFlare configuration, trouble
|
|
|
1269
1292
|
|
|
1270
1293
|
```bash
|
|
1271
1294
|
export SHAKAPACKER_ASSET_HOST=https://cdn.example.com
|
|
1272
|
-
RAILS_ENV=production bundle exec
|
|
1295
|
+
RAILS_ENV=production bundle exec rake assets:precompile
|
|
1273
1296
|
```
|
|
1274
1297
|
|
|
1275
1298
|
For more deployment documentation, see [Deployment](./docs/deployment.md).
|
|
@@ -1323,3 +1346,10 @@ The following companies support our Open Source projects, and ShakaCode uses the
|
|
|
1323
1346
|
<a href="https://www.honeybadger.io">
|
|
1324
1347
|
<img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
|
|
1325
1348
|
</a>
|
|
1349
|
+
<a href="https://coderabbit.ai">
|
|
1350
|
+
<picture>
|
|
1351
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://victorious-bubble-f69a016683.media.strapiapp.com/White_Typemark_7229870ac5.svg">
|
|
1352
|
+
<source media="(prefers-color-scheme: light)" srcset="https://victorious-bubble-f69a016683.media.strapiapp.com/Orange_Typemark_7958cfa790.svg">
|
|
1353
|
+
<img alt="CodeRabbit" src="https://victorious-bubble-f69a016683.media.strapiapp.com/Orange_Typemark_7958cfa790.svg" height="55px">
|
|
1354
|
+
</picture>
|
|
1355
|
+
</a>
|