shakapacker 9.3.4.beta.0 → 9.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f91e082c004aed62a936ae04be5d4a86adb4532deebe84f55662660f3735f67
4
- data.tar.gz: aa26a6595a4f37bb61f83d10e978e77f5b6cbe2df50debb7428ecb9f8a6f1072
3
+ metadata.gz: 20f8244a121f25f9c018754007b3588d99e4860677cc8ef4e2f8b55858edbd57
4
+ data.tar.gz: 4e5d80d804e55cfbce44d9139e70ea7f60d8709e92f1f07c95391e7e128a7e8e
5
5
  SHA512:
6
- metadata.gz: efeea8ba10d3a7df9d4a5d14d7f7f34169202ebd2f7f9c16e1875cdb55531be5155600ba2a06cb2fa53866785fd0a374742f2b420be68c12430a7597b553e23c
7
- data.tar.gz: 89965343135e74749d0a04cafd1c6a931b311d62432c25cfc6f3e9c1bcbee4274605a200211d39622e6934a376f00b092b556238586d1742603398b0862b7d34
6
+ metadata.gz: 02e7f011c8b6d839672e485146221a2e76f014926f4226a4394720837d56a9b646bd4d5732cbf48c0a3639b5067fcbc597c2fd44a3cc7bb2b77242a6d5ecaf41
7
+ data.tar.gz: f0510466924af335241216dc70e021ab26942012d3cdaf735fcd1bfa34d4b1ad615a4a9e7906ca5d348c519dde308a26fc46a34d0a54ebcdb9518ae3265ca209
@@ -7,6 +7,7 @@ on:
7
7
  pull_request:
8
8
  paths:
9
9
  - "**.rb"
10
+ - "**.rbs"
10
11
  - "**.gemspec"
11
12
  - "Gemfile"
12
13
  - "Rakefile"
@@ -41,6 +42,25 @@ jobs:
41
42
  - name: Ruby rubocop
42
43
  run: bundle exec rubocop
43
44
 
45
+ rbs-validate:
46
+ name: RBS Type Validation
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ with:
51
+ persist-credentials: false
52
+ - name: Remove Gemfile.lock
53
+ # Remove lock to test compatibility with latest gem versions
54
+ run: rm -f Gemfile.lock
55
+ - uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: "3.4"
58
+ rubygems: latest
59
+ bundler-cache: true
60
+
61
+ - name: Validate RBS signatures
62
+ run: bundle exec rbs validate
63
+
44
64
  test:
45
65
  name: Testing
46
66
  runs-on: ${{ matrix.os }}
data/CHANGELOG.md CHANGED
@@ -11,6 +11,12 @@
11
11
 
12
12
  Changes since the last non-beta release.
13
13
 
14
+ ## [v9.3.4-beta.0] - November 17, 2025
15
+
16
+ ### Fixed
17
+
18
+ - **Fixed `switch_bundler` task to remove packages from both dependencies and devDependencies**. [PR #838](https://github.com/shakacode/shakapacker/pull/838) by [justin808](https://github.com/justin808). The task now correctly removes old bundler packages regardless of whether they're in `dependencies` or `devDependencies` sections, fixing an issue where packages in `dependencies` were not being removed when switching bundlers.
19
+
14
20
  ## [v9.3.3] - November 15, 2025
15
21
 
16
22
  ### Fixed
@@ -42,8 +48,9 @@ Changes since the last non-beta release.
42
48
 
43
49
  ### Added
44
50
 
51
+ - **RBS type signatures for all public APIs**. [PR #822](https://github.com/shakacode/shakapacker/pull/822) by [justin808](https://github.com/justin808). Shakapacker now includes comprehensive RBS type signatures in the `sig/` directory for static type checking and improved IDE support (autocomplete, Steep/TypeProf integration). See README for usage examples.
45
52
  - **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.
46
- - **`Configuration#data` public API method** with enhanced documentation and safety. [PR #818](https://github.com/shakacode/shakapacker/pull/818) 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.
53
+ - **`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.
47
54
  - **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.
48
55
 
49
56
  ## [v9.3.0] - November 2, 2025
@@ -752,7 +759,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
752
759
 
753
760
  See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
754
761
 
755
- [Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.3.3...main
762
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.3.4-beta.0...main
763
+ [v9.3.4-beta.0]: https://github.com/shakacode/shakapacker/compare/v9.3.3...v9.3.4-beta.0
756
764
  [v9.3.3]: https://github.com/shakacode/shakapacker/compare/v9.3.2...v9.3.3
757
765
  [v9.3.2]: https://github.com/shakacode/shakapacker/compare/v9.3.1...v9.3.2
758
766
  [v9.3.1]: https://github.com/shakacode/shakapacker/compare/v9.3.0...v9.3.1
data/CONTRIBUTING.md CHANGED
@@ -27,6 +27,7 @@ We welcome pull requests that fix bugs, add new features, or improve existing on
27
27
  - Write tests for your changes and [make sure all tests pass](#making-sure-your-changes-pass-all-tests).
28
28
  - Update the documentation as needed.
29
29
  - Update CHANGELOG.md if the changes affect public behavior of the project.
30
+ - Update RBS type signatures in `sig/` directory if you modify public APIs.
30
31
 
31
32
  ---
32
33
 
@@ -49,6 +50,91 @@ npx husky add .husky/pre-commit "npx lint-staged"
49
50
 
50
51
  ---
51
52
 
53
+ ## RBS Type Signatures
54
+
55
+ Shakapacker includes RBS type signatures for all public APIs in the `sig/` directory. These signatures provide static type checking and improved IDE support.
56
+
57
+ ### When to Update RBS Files
58
+
59
+ Update RBS signatures when you:
60
+
61
+ - Add new public methods or classes
62
+ - Change method signatures (parameters, return types)
63
+ - Modify public APIs
64
+ - Add or remove public attributes
65
+
66
+ ### RBS File Structure
67
+
68
+ ```
69
+ sig/
70
+ ├── shakapacker.rbs # Main Shakapacker module
71
+ └── shakapacker/
72
+ ├── configuration.rbs # Configuration class
73
+ ├── helper.rbs # View helper module
74
+ ├── manifest.rbs # Manifest class
75
+ ├── compiler.rbs # Compiler class
76
+ └── ... # Other components
77
+ ```
78
+
79
+ ### Validating RBS Signatures
80
+
81
+ To validate your RBS signatures:
82
+
83
+ ```bash
84
+ # Install RBS if not already installed
85
+ gem install rbs
86
+
87
+ # Validate all signatures
88
+ rbs validate
89
+
90
+ # Check a specific file
91
+ rbs validate sig/shakapacker/configuration.rbs
92
+ ```
93
+
94
+ ### RBS Best Practices
95
+
96
+ 1. **Use specific types** instead of `untyped` when possible
97
+ 2. **Document optional parameters** with `?` prefix
98
+ 3. **Use union types** for methods that can return multiple types (e.g., `String | nil`)
99
+ 4. **Keep signatures in sync** with implementation changes
100
+ 5. **Test with type checkers** like [Steep](https://github.com/soutaro/steep) when possible
101
+ 6. **Use `void` vs `nil` appropriately**:
102
+ - Use `void` when the return value is expected to be discarded (e.g., `initialize`)
103
+ - Use `nil` when a method explicitly returns nil as a meaningful value
104
+ 7. **Module singleton methods**: For modules using `extend self`, use `module ModuleName : _Singleton` to indicate all methods are module-level singleton methods
105
+
106
+ ### Example RBS Signature
107
+
108
+ ```rbs
109
+ # Good: Specific types with documentation
110
+ class Shakapacker::Configuration
111
+ def initialize: (
112
+ root_path: Pathname,
113
+ config_path: Pathname,
114
+ env: ActiveSupport::StringInquirer,
115
+ ?bundler_override: String?
116
+ ) -> void
117
+
118
+ def source_path: () -> Pathname
119
+ def webpack?: () -> bool
120
+ def assets_bundler: () -> String
121
+ end
122
+
123
+ # Module with singleton methods (using extend self)
124
+ module Shakapacker : _Singleton
125
+ def self.config: () -> Configuration
126
+ def self.compile: () -> bool
127
+ end
128
+
129
+ # Avoid: Overly generic types
130
+ class Shakapacker::Configuration
131
+ def initialize: (**untyped) -> void
132
+ def source_path: () -> untyped
133
+ end
134
+ ```
135
+
136
+ ---
137
+
52
138
  ## Linting and Code Quality
53
139
 
54
140
  ### Running Linters
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (9.3.4.beta.0)
4
+ shakapacker (9.3.4)
5
5
  activesupport (>= 5.2)
6
6
  package_json
7
7
  rack-proxy (>= 0.6.1)
@@ -178,6 +178,8 @@ GEM
178
178
  zeitwerk (~> 2.6)
179
179
  rainbow (3.1.1)
180
180
  rake (13.2.1)
181
+ rbs (3.9.5)
182
+ logger
181
183
  rdoc (6.7.0)
182
184
  psych (>= 4.0.0)
183
185
  regexp_parser (2.9.2)
@@ -242,6 +244,7 @@ DEPENDENCIES
242
244
  rails (>= 6.1.6)
243
245
  rails-html-sanitizer (>= 1.4.3)
244
246
  rake (>= 11.1)
247
+ rbs (~> 3.0)
245
248
  rspec-rails (~> 6.0.2)
246
249
  rubocop
247
250
  rubocop-performance
data/README.md CHANGED
@@ -721,6 +721,61 @@ open doc/index.html
721
721
 
722
722
  The generated documentation includes all public and private methods with detailed descriptions.
723
723
 
724
+ #### Type Signatures with RBS
725
+
726
+ Shakapacker includes **RBS type signatures** for all public APIs, enabling static type checking and improved IDE support:
727
+
728
+ **Benefits:**
729
+
730
+ - **IDE Autocomplete**: Get accurate method signatures and parameter hints in your editor
731
+ - **Static Type Checking**: Catch type errors before runtime using [Steep](https://github.com/soutaro/steep) or [TypeProf](https://github.com/ruby/typeprof)
732
+ - **Self-Documenting Code**: Types provide machine-readable API documentation
733
+ - **Safer Refactoring**: Type checker catches breaking changes across your codebase
734
+
735
+ **RBS Signatures Location:**
736
+ Type signatures are in the `sig/` directory and included with the gem:
737
+
738
+ ```
739
+ sig/
740
+ ├── shakapacker.rbs # Main module
741
+ └── shakapacker/
742
+ ├── configuration.rbs # Configuration API
743
+ ├── helper.rbs # View helpers
744
+ ├── manifest.rbs # Asset lookup
745
+ ├── compiler.rbs # Compilation
746
+ ├── dev_server.rbs # Dev server
747
+ └── ... # Other components
748
+ ```
749
+
750
+ **Using with Steep (Type Checker):**
751
+
752
+ ```yaml
753
+ # Steepfile
754
+ target :app do
755
+ signature "sig"
756
+ check "app"
757
+ library "shakapacker"
758
+ end
759
+ ```
760
+
761
+ **Example Type Checking:**
762
+
763
+ ```ruby
764
+ # Your code
765
+ config = Shakapacker.config
766
+ config.source_path # Type checker knows this returns Pathname
767
+ config.webpack? # Type checker knows this returns bool
768
+
769
+ # Type error caught at development time:
770
+ config.invalid_method # ⚠️ Steep reports: Method `invalid_method` is not defined
771
+ ```
772
+
773
+ **Learn More:**
774
+
775
+ - [RBS Documentation](https://github.com/ruby/rbs)
776
+ - [Steep Type Checker](https://github.com/soutaro/steep)
777
+ - [TypeProf](https://github.com/ruby/typeprof)
778
+
724
779
  ### Webpack Configuration
725
780
 
726
781
  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:
@@ -1,4 +1,4 @@
1
1
  module Shakapacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "9.3.4.beta.0".freeze
3
+ VERSION = "9.3.4".freeze
4
4
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shakapacker",
3
- "version": "9.3.4-beta.0",
3
+ "version": "9.3.4",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "homepage": "https://github.com/shakacode/shakapacker",
6
6
  "bugs": {
data/shakapacker.gemspec CHANGED
@@ -24,12 +24,13 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "semantic_range", ">= 2.3.0"
25
25
 
26
26
  s.add_development_dependency "bundler", ">= 1.3.0"
27
+ s.add_development_dependency "rbs", "~> 3.0"
27
28
  s.add_development_dependency "rubocop"
28
29
  s.add_development_dependency "rubocop-performance"
29
30
 
30
31
  s.files = `git ls-files -z`.split("\x0").reject { |f|
31
32
  f.match(%r{^(test|spec|features|tmp|node_modules|packages|coverage|Gemfile.lock|rakelib)/})
32
- }
33
+ } + Dir.glob("sig/**/*.rbs")
33
34
 
34
35
  s.test_files = `git ls-files -- test/*`.split("\n")
35
36
  end
@@ -0,0 +1,35 @@
1
+ # Build operation commands for Shakapacker
2
+ class Shakapacker::Commands
3
+ # Creates a new commands instance
4
+ def initialize: (Instance instance) -> void
5
+
6
+ # Cleanup old assets in the compile directory
7
+ def clean: (?Integer, ?Integer) -> bool
8
+
9
+ # Removes all compiled packs
10
+ def clobber: () -> void
11
+
12
+ # Creates the default configuration files and directory structure
13
+ def bootstrap: () -> void
14
+
15
+ # Compiles all webpack/rspack packs
16
+ def compile: () -> bool
17
+
18
+ # Returns the configuration object
19
+ def config: () -> Configuration
20
+
21
+ # Returns the compiler instance
22
+ def compiler: () -> Compiler
23
+
24
+ # Returns the manifest instance
25
+ def manifest: () -> Manifest
26
+
27
+ # Returns the logger instance
28
+ def logger: () -> ActiveSupport::TaggedLogging
29
+
30
+ private
31
+
32
+ def packs: () -> Array[String]
33
+
34
+ def current_version: () -> Array[String]
35
+ end
@@ -0,0 +1,60 @@
1
+ # Compiler for compiling assets with webpack/rspack
2
+ class Shakapacker::Compiler
3
+ # Additional environment variables that the compiler is being run with
4
+ def self.env: () -> Hash[String, String]
5
+
6
+ # Sets additional environment variables
7
+ def self.env=: (Hash[String, String] env) -> Hash[String, String]
8
+
9
+ # Creates a new compiler instance
10
+ def initialize: (Instance instance) -> void
11
+
12
+ # Compiles all webpack/rspack packs
13
+ def compile: () -> bool
14
+
15
+ # Returns the configuration object
16
+ def config: () -> Configuration
17
+
18
+ # Returns the logger instance
19
+ def logger: () -> ActiveSupport::TaggedLogging
20
+
21
+ # Returns the compiler strategy
22
+ def strategy: () -> CompilerStrategy
23
+
24
+ # Returns whether assets are fresh (up-to-date)
25
+ def fresh?: () -> bool
26
+
27
+ # Returns whether assets are stale (need recompilation)
28
+ def stale?: () -> bool
29
+
30
+ # Runs the post-compile hook
31
+ def after_compile_hook: () -> void
32
+
33
+ private
34
+
35
+ attr_reader instance: Instance
36
+
37
+ def acquire_ipc_lock: [T] () { () -> T } -> T
38
+
39
+ def locked?: () -> bool
40
+
41
+ alias compiling? locked?
42
+
43
+ def wait_for_compilation_to_complete: () -> void
44
+
45
+ def open_lock_file: [T] () { (File) -> T } -> T
46
+
47
+ def create_lock_file_dir: () -> void
48
+
49
+ def lock_file_path: () -> Pathname
50
+
51
+ def optional_ruby_runner: () -> String?
52
+
53
+ def bin_shakapacker_path: () -> Pathname
54
+
55
+ def run_precompile_hook: () -> void
56
+
57
+ def run_webpack: () -> bool
58
+
59
+ def webpack_env: () -> Hash[String, String]
60
+ end
@@ -0,0 +1,41 @@
1
+ # Compiler strategy for determining staleness
2
+ module Shakapacker
3
+ # Factory class for creating compiler strategies
4
+ class CompilerStrategy
5
+ # Creates a compiler strategy from the configuration
6
+ def self.from_config: () -> (MtimeStrategy | DigestStrategy)
7
+ end
8
+
9
+ # Base strategy with common functionality
10
+ class BaseStrategy
11
+ def initialize: () -> void
12
+
13
+ # Returns whether assets are fresh (up-to-date)
14
+ def fresh?: () -> bool
15
+
16
+ # Returns whether assets are stale (need recompilation)
17
+ def stale?: () -> bool
18
+
19
+ # Runs the post-compile hook
20
+ def after_compile_hook: () -> void
21
+
22
+ private
23
+
24
+ attr_reader config: Configuration
25
+
26
+ def default_watched_paths: () -> Array[String]
27
+ end
28
+
29
+ # Mtime-based compiler strategy
30
+ class MtimeStrategy < BaseStrategy
31
+ def fresh?: () -> bool
32
+ def stale?: () -> bool
33
+ end
34
+
35
+ # Digest-based compiler strategy
36
+ class DigestStrategy < BaseStrategy
37
+ def fresh?: () -> bool
38
+ def stale?: () -> bool
39
+ def after_compile_hook: () -> void
40
+ end
41
+ end
@@ -0,0 +1,140 @@
1
+ # Configuration management for Shakapacker
2
+ #
3
+ # Loads and provides access to settings from config/shakapacker.yml
4
+ class Shakapacker::Configuration
5
+ # Flag indicating whether Shakapacker is currently being installed
6
+ def self.installing: () -> bool
7
+
8
+ # Sets the installing flag
9
+ def self.installing=: (bool value) -> bool
10
+
11
+ # The application root path
12
+ attr_reader root_path: Pathname
13
+
14
+ # The path to the shakapacker.yml configuration file
15
+ attr_reader config_path: Pathname
16
+
17
+ # The current Rails environment
18
+ attr_reader env: ActiveSupport::StringInquirer
19
+
20
+ # Override for the assets bundler (set via CLI flag)
21
+ attr_reader bundler_override: String?
22
+
23
+ # Creates a new configuration instance
24
+ def initialize: (
25
+ root_path: Pathname,
26
+ config_path: Pathname,
27
+ env: ActiveSupport::StringInquirer,
28
+ ?bundler_override: String?
29
+ ) -> void
30
+
31
+ # Returns the dev server configuration hash
32
+ def dev_server: () -> Hash[String | Symbol, untyped]
33
+
34
+ # Returns whether automatic compilation is enabled
35
+ def compile?: () -> bool
36
+
37
+ # Returns whether nested entries are enabled
38
+ def nested_entries?: () -> bool
39
+
40
+ # Returns whether consistent versioning check is enabled
41
+ def ensure_consistent_versioning?: () -> bool
42
+
43
+ # Returns whether Shakapacker should precompile assets
44
+ def shakapacker_precompile?: () -> bool
45
+
46
+ # Returns the absolute path to the source directory
47
+ def source_path: () -> Pathname
48
+
49
+ # Returns additional paths to include in compilation
50
+ def additional_paths: () -> Array[String]
51
+
52
+ # Returns the absolute path to the source entry directory
53
+ def source_entry_path: () -> Pathname
54
+
55
+ # Returns the absolute path to the manifest.json file
56
+ def manifest_path: () -> Pathname
57
+
58
+ # Alias for manifest_path
59
+ def public_manifest_path: () -> Pathname
60
+
61
+ # Returns the absolute path to the public root directory
62
+ def public_path: () -> Pathname
63
+
64
+ # Returns the absolute path to the private output directory
65
+ def private_output_path: () -> Pathname?
66
+
67
+ # Returns the absolute path to the public output directory
68
+ def public_output_path: () -> Pathname
69
+
70
+ # Returns whether manifest caching is enabled
71
+ def cache_manifest?: () -> bool
72
+
73
+ # Returns the absolute path to the compilation cache directory
74
+ def cache_path: () -> Pathname
75
+
76
+ # Returns whether webpack/rspack compilation output should be shown
77
+ def webpack_compile_output?: () -> bool
78
+
79
+ # Returns the compiler strategy for determining staleness
80
+ def compiler_strategy: () -> String
81
+
82
+ # Returns the assets bundler to use (webpack or rspack)
83
+ def assets_bundler: () -> String
84
+
85
+ # Deprecated alias for assets_bundler
86
+ def bundler: () -> String
87
+
88
+ # Returns whether rspack is the configured bundler
89
+ def rspack?: () -> bool
90
+
91
+ # Returns whether webpack is the configured bundler
92
+ def webpack?: () -> bool
93
+
94
+ # Returns the precompile hook command to run after compilation
95
+ def precompile_hook: () -> String?
96
+
97
+ # Returns the JavaScript transpiler to use (babel, swc, or esbuild)
98
+ def javascript_transpiler: () -> String
99
+
100
+ # Deprecated alias for javascript_transpiler
101
+ def webpack_loader: () -> String
102
+
103
+ # Returns the path to the bundler configuration directory
104
+ def assets_bundler_config_path: () -> String
105
+
106
+ # Returns the raw configuration data hash
107
+ def data: () -> Hash[Symbol, untyped]
108
+
109
+ # Fetches a configuration value
110
+ def fetch: (Symbol key) -> untyped
111
+
112
+ # Returns the asset host URL for serving assets
113
+ def asset_host: () -> String?
114
+
115
+ # Returns whether subresource integrity (SRI) is enabled
116
+ def integrity: () -> (bool | Hash[String | Symbol, untyped])
117
+
118
+ # Returns whether HTTP/2 Early Hints are enabled
119
+ def early_hints: () -> bool
120
+
121
+ private
122
+
123
+ def default_javascript_transpiler: () -> String
124
+
125
+ def validate_transpiler_configuration: (String transpiler) -> void
126
+
127
+ def warn_transpiler_mismatch: (String configured, String message) -> void
128
+
129
+ def validate_output_paths!: () -> void
130
+
131
+ def resolve_paths_for_comparison: () -> [String, String]
132
+
133
+ def load: () -> Hash[Symbol, untyped]
134
+
135
+ def defaults: () -> HashWithIndifferentAccess
136
+
137
+ def relative_path: (String path) -> String
138
+
139
+ def log_fallback: (String requested_env, String fallback_env) -> void
140
+ end
@@ -0,0 +1,56 @@
1
+ # Development server status and configuration
2
+ #
3
+ # Provides methods to query the status and configuration of the webpack-dev-server
4
+ # or rspack-dev-server.
5
+ class Shakapacker::DevServer
6
+ # Default environment variable prefix for dev server settings
7
+ DEFAULT_ENV_PREFIX: String
8
+
9
+ # Configure dev server connection timeout (in seconds)
10
+ def self.connect_timeout: () -> Float
11
+
12
+ # Sets the connection timeout
13
+ def self.connect_timeout=: (Float | Integer timeout) -> Float
14
+
15
+ # The Shakapacker configuration
16
+ attr_reader config: Configuration
17
+
18
+ # Creates a new dev server instance
19
+ def initialize: (Configuration config) -> void
20
+
21
+ # Returns whether the dev server is currently running
22
+ def running?: () -> bool
23
+
24
+ # Returns the dev server host
25
+ def host: () -> String
26
+
27
+ # Returns the dev server port
28
+ def port: () -> Integer
29
+
30
+ # Returns the server type (http or https)
31
+ def server: () -> String
32
+
33
+ # Alias for server
34
+ def protocol: () -> String
35
+
36
+ # Returns the host with port (e.g., "localhost:3035")
37
+ def host_with_port: () -> String
38
+
39
+ # Returns whether pretty output is enabled
40
+ def pretty?: () -> bool
41
+
42
+ # Returns whether Hot Module Replacement (HMR) is enabled
43
+ def hmr?: () -> bool
44
+
45
+ # Returns whether CSS should be inlined by the dev server
46
+ def inline_css?: () -> bool
47
+
48
+ # Returns the environment variable prefix for dev server settings
49
+ def env_prefix: () -> String
50
+
51
+ private
52
+
53
+ def connect_timeout: () -> Float
54
+
55
+ def fetch: (Symbol key) -> untyped
56
+ end
@@ -0,0 +1,25 @@
1
+ # Environment inquiry for Shakapacker
2
+ class Shakapacker::Env
3
+ # Returns the current Rails environment as an ActiveSupport::StringInquirer
4
+ def self.inquire: (Instance instance) -> ActiveSupport::StringInquirer
5
+
6
+ # Creates a new env instance
7
+ def initialize: (Instance instance) -> void
8
+
9
+ # Returns the environment inquiry
10
+ def inquire: () -> ActiveSupport::StringInquirer
11
+
12
+ # Returns the config path
13
+ def config_path: () -> Pathname
14
+
15
+ # Returns the logger
16
+ def logger: () -> ActiveSupport::TaggedLogging
17
+
18
+ private
19
+
20
+ def current: () -> ActiveSupport::StringInquirer?
21
+
22
+ def fallback_env_warning: () -> void
23
+
24
+ def available_environments: () -> (Array[String] | Hash[String, untyped])
25
+ end
@@ -0,0 +1,98 @@
1
+ # View helper methods for rendering asset tags
2
+ module Shakapacker::Helper
3
+ # Returns the current Shakapacker instance
4
+ def current_shakapacker_instance: () -> Instance
5
+
6
+ # Computes the relative path for a given Shakapacker asset
7
+ def asset_pack_path: (String name, **untyped options) -> String
8
+
9
+ # Computes the absolute path for a given Shakapacker asset
10
+ def asset_pack_url: (String name, **untyped options) -> String
11
+
12
+ # Computes the relative path for a given Shakapacker image
13
+ def image_pack_path: (String name, **untyped options) -> String
14
+
15
+ # Computes the absolute path for a given Shakapacker image
16
+ def image_pack_url: (String name, **untyped options) -> String
17
+
18
+ # Creates an image tag that references the named pack file
19
+ def image_pack_tag: (String name, **untyped options) -> ActiveSupport::SafeBuffer
20
+
21
+ # Creates a link tag for a favicon that references the named pack file
22
+ def favicon_pack_tag: (String name, **untyped options) -> ActiveSupport::SafeBuffer
23
+
24
+ # Creates script tags that reference the js chunks from entrypoints
25
+ def javascript_pack_tag: (
26
+ *String names,
27
+ ?defer: bool,
28
+ ?async: bool,
29
+ ?early_hints: (Hash[String | Symbol, String] | String | bool)?,
30
+ **untyped options
31
+ ) -> ActiveSupport::SafeBuffer
32
+
33
+ # Creates a link tag for preloading that references a given Shakapacker asset
34
+ def preload_pack_asset: (String name, **untyped options) -> ActiveSupport::SafeBuffer
35
+
36
+ # Sends HTTP 103 Early Hints for specified packs
37
+ def send_pack_early_hints: (Hash[String | Symbol, Hash[String | Symbol, String | bool]] config) -> nil
38
+
39
+ # Creates link tags that reference the css chunks from entrypoints
40
+ def stylesheet_pack_tag: (
41
+ *String names,
42
+ ?early_hints: (Hash[String | Symbol, String] | String | bool)?,
43
+ **untyped options
44
+ ) -> ActiveSupport::SafeBuffer
45
+
46
+ # Appends stylesheet pack names to the queue
47
+ def append_stylesheet_pack_tag: (*String names) -> nil
48
+
49
+ # Appends javascript pack names to the queue
50
+ def append_javascript_pack_tag: (*String names, ?defer: bool, ?async: bool) -> nil
51
+
52
+ # Prepends javascript pack names to the queue
53
+ def prepend_javascript_pack_tag: (*String names, ?defer: bool, ?async: bool) -> nil
54
+
55
+ private
56
+
57
+ def update_javascript_pack_tag_queue: (defer: bool, async: bool) { (Symbol) -> void } -> nil
58
+
59
+ def javascript_pack_tag_queue: () -> Hash[Symbol, Array[String]]
60
+
61
+ def sources_from_manifest_entrypoints: (Array[String | Symbol] names, type: Symbol) -> Array[String]
62
+
63
+ def available_sources_from_manifest_entrypoints: (Array[String | Symbol] names, type: Symbol) -> Array[String]
64
+
65
+ def resolve_path_to_image: (String name, **untyped options) -> String
66
+
67
+ def lookup_integrity: (String | Hash[String, untyped] source) -> String?
68
+
69
+ def lookup_source: (String | Hash[String, untyped] source) -> String
70
+
71
+ def render_tags: (Array[String] sources, Symbol type, Hash[Symbol, untyped] options) -> nil
72
+
73
+ def early_hints_supported?: () -> bool
74
+
75
+ def early_hints_enabled?: () -> bool
76
+
77
+ def early_hints_debug_enabled?: () -> bool
78
+
79
+ def resolve_early_hints_value: ((Hash[String | Symbol, String] | String | bool)? early_hints, Symbol asset_type) -> String
80
+
81
+ def normalize_pack_hints: (Array[String] packs, Hash[String | Symbol, String] | String | bool early_hints) -> Hash[String, String]
82
+
83
+ def normalize_hint_value: (String | bool | nil value) -> String
84
+
85
+ def early_hints_skip_reason: () -> String
86
+
87
+ def build_link_header: (String source_path, String | Hash[String, untyped] source, as: String, ?rel: String) -> String
88
+
89
+ def early_hints_store: () -> Hash[String, untyped]
90
+
91
+ def send_early_hints_internal: (Hash[String, String] config, type: Symbol) -> void
92
+
93
+ def flush_early_hints: () -> void
94
+
95
+ def send_javascript_early_hints_internal: (Hash[String, String] config) -> void
96
+
97
+ def send_stylesheet_early_hints_internal: (Hash[String, String] config) -> void
98
+ end
@@ -0,0 +1,46 @@
1
+ # Represents a single instance of Shakapacker configuration and state
2
+ #
3
+ # An instance encapsulates all the configuration, compilation, and manifest
4
+ # lookup functionality for a specific Rails application.
5
+ class Shakapacker::Instance
6
+ # The shared logger used by all Shakapacker instances
7
+ def self.logger: () -> ActiveSupport::TaggedLogging
8
+
9
+ # Sets the shared logger used by all Shakapacker instances
10
+ def self.logger=: (ActiveSupport::TaggedLogging logger) -> ActiveSupport::TaggedLogging
11
+
12
+ # The root path of the application
13
+ attr_reader root_path: Pathname
14
+
15
+ # The path to the Shakapacker configuration file
16
+ attr_reader config_path: Pathname
17
+
18
+ # Creates a new Shakapacker instance
19
+ def initialize: (?root_path: String | Pathname | nil, ?config_path: String | Pathname | nil) -> void
20
+
21
+ # Returns the current Rails environment as a StringInquirer
22
+ def env: () -> ActiveSupport::StringInquirer
23
+
24
+ # Returns the configuration object for this instance
25
+ def config: () -> Configuration
26
+
27
+ # Returns the compiler for this instance
28
+ def compiler: () -> Compiler
29
+
30
+ # Returns the development server instance
31
+ def dev_server: () -> DevServer
32
+
33
+ # Returns the manifest for looking up compiled assets
34
+ def manifest: () -> Manifest
35
+
36
+ # Returns the commands instance for build operations
37
+ def commands: () -> Commands
38
+
39
+ # Returns whether CSS should be inlined by the dev server
40
+ def inlining_css?: () -> bool
41
+
42
+ private
43
+
44
+ # Returns the compiler strategy for determining staleness
45
+ def strategy: () -> (MtimeStrategy | DigestStrategy)
46
+ end
@@ -0,0 +1,55 @@
1
+ # Manifest for looking up compiled asset paths
2
+ #
3
+ # The manifest reads the manifest.json file produced by webpack/rspack during
4
+ # compilation and provides methods to look up the compiled (digested) paths for
5
+ # source files.
6
+ class Shakapacker::Manifest
7
+ # Raised when an asset cannot be found in the manifest
8
+ class MissingEntryError < StandardError
9
+ end
10
+
11
+ # Creates a new manifest instance
12
+ def initialize: (Instance instance) -> void
13
+
14
+ # Reloads the manifest data from disk
15
+ def refresh: () -> Hash[String, untyped]
16
+
17
+ # Looks up an entry point with all its chunks (split code)
18
+ def lookup_pack_with_chunks: (String name, ?Hash[Symbol, untyped] pack_type) -> Array[String]?
19
+
20
+ # Like lookup_pack_with_chunks, but raises an error if not found
21
+ def lookup_pack_with_chunks!: (String name, ?Hash[Symbol, untyped] pack_type) -> Array[String]
22
+
23
+ # Looks up the compiled path for a given asset
24
+ def lookup: (String name, ?Hash[Symbol, untyped] pack_type) -> String?
25
+
26
+ # Like lookup, but raises an error if not found
27
+ def lookup!: (String name, ?Hash[Symbol, untyped] pack_type) -> String
28
+
29
+ # Returns the configuration object
30
+ def config: () -> Configuration
31
+
32
+ # Returns the compiler instance
33
+ def compiler: () -> Compiler
34
+
35
+ # Returns the dev server instance
36
+ def dev_server: () -> DevServer
37
+
38
+ private
39
+
40
+ def compiling?: () -> bool
41
+
42
+ def compile: () -> bool
43
+
44
+ def data: () -> Hash[String, untyped]
45
+
46
+ def load: () -> Hash[String, untyped]
47
+
48
+ def find: (String key) -> (String | Hash[String, untyped] | nil)
49
+
50
+ def handle_missing_entry: (String name, Hash[Symbol, untyped] pack_type) -> void
51
+
52
+ def manifest_type: (Symbol? type) -> String
53
+
54
+ def manifest_name: (String name, String manifest_type) -> String
55
+ end
@@ -0,0 +1,4 @@
1
+ module Shakapacker
2
+ # The current version of Shakapacker
3
+ VERSION: String
4
+ end
@@ -0,0 +1,66 @@
1
+ # Shakapacker is a Ruby gem that integrates webpack and rspack with Rails applications,
2
+ # providing a modern asset pipeline for JavaScript, CSS, and other web assets.
3
+ #
4
+ # The main Shakapacker module provides singleton-style access to configuration,
5
+ # compilation, and asset manifest functionality.
6
+ module Shakapacker : _Singleton
7
+ # Default environment when RAILS_ENV is not set
8
+ DEFAULT_ENV: String
9
+
10
+ # Environments that use their RAILS_ENV value for NODE_ENV
11
+ DEV_TEST_ENVS: Array[String]
12
+
13
+ # Returns the shared Shakapacker instance
14
+ def self.instance: () -> Instance
15
+
16
+ # Sets the shared Shakapacker instance
17
+ def self.instance=: (Instance instance) -> Instance
18
+
19
+ # Temporarily overrides NODE_ENV for the duration of the block
20
+ def self.with_node_env: [T] (String env) { () -> T } -> T
21
+
22
+ # Sets NODE_ENV based on RAILS_ENV if not already set
23
+ def self.ensure_node_env!: () -> String
24
+
25
+ # Temporarily redirects Shakapacker logging to STDOUT
26
+ def self.ensure_log_goes_to_stdout: [T] () { () -> T } -> T
27
+
28
+ # Returns the logger instance used by Shakapacker
29
+ def self.logger: () -> ActiveSupport::TaggedLogging
30
+
31
+ # Sets the logger instance used by Shakapacker
32
+ def self.logger=: (ActiveSupport::TaggedLogging logger) -> ActiveSupport::TaggedLogging
33
+
34
+ # Returns the current Rails environment as an ActiveSupport::StringInquirer
35
+ def self.env: () -> ActiveSupport::StringInquirer
36
+
37
+ # Returns whether CSS inlining is enabled
38
+ def self.inlining_css?: () -> bool
39
+
40
+ # Returns the Shakapacker configuration object
41
+ def self.config: () -> Configuration
42
+
43
+ # Returns the compiler instance for compiling assets
44
+ def self.compiler: () -> Compiler
45
+
46
+ # Returns the manifest instance for looking up compiled assets
47
+ def self.manifest: () -> Manifest
48
+
49
+ # Returns the commands instance for build operations
50
+ def self.commands: () -> Commands
51
+
52
+ # Returns the dev server instance for querying server status
53
+ def self.dev_server: () -> DevServer
54
+
55
+ # Creates the default configuration files and directory structure
56
+ def self.bootstrap: () -> void
57
+
58
+ # Removes old compiled packs, keeping the most recent versions
59
+ def self.clean: (?Integer, ?Integer) -> bool
60
+
61
+ # Removes all compiled packs
62
+ def self.clobber: () -> void
63
+
64
+ # Compiles all webpack/rspack packs
65
+ def self.compile: () -> bool
66
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shakapacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.4.beta.0
4
+ version: 9.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: 1.3.0
98
+ - !ruby/object:Gem::Dependency
99
+ name: rbs
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '3.0'
98
112
  - !ruby/object:Gem::Dependency
99
113
  name: rubocop
100
114
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +182,6 @@ files:
168
182
  - TODO_v9.md
169
183
  - __mocks__/nonexistent/package.json
170
184
  - __mocks__/sass-loader/package.json
171
- - bin/shakapacker-config
172
185
  - conductor-setup.sh
173
186
  - conductor.json
174
187
  - config/README.md
@@ -341,6 +354,17 @@ files:
341
354
  - scripts/remove-use-strict.js
342
355
  - scripts/type-check-no-emit.js
343
356
  - shakapacker.gemspec
357
+ - sig/shakapacker.rbs
358
+ - sig/shakapacker/commands.rbs
359
+ - sig/shakapacker/compiler.rbs
360
+ - sig/shakapacker/compiler_strategy.rbs
361
+ - sig/shakapacker/configuration.rbs
362
+ - sig/shakapacker/dev_server.rbs
363
+ - sig/shakapacker/env.rbs
364
+ - sig/shakapacker/helper.rbs
365
+ - sig/shakapacker/instance.rbs
366
+ - sig/shakapacker/manifest.rbs
367
+ - sig/shakapacker/version.rbs
344
368
  - test/configExporter/buildValidator.test.js
345
369
  - test/configExporter/configFile.test.js
346
370
  - test/configExporter/integration.test.js
@@ -389,7 +413,7 @@ homepage: https://github.com/shakacode/shakapacker
389
413
  licenses:
390
414
  - MIT
391
415
  metadata:
392
- source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.4.beta.0
416
+ source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.4
393
417
  rdoc_options: []
394
418
  require_paths:
395
419
  - lib
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Minimal shim - all logic is in the TypeScript module
4
- const { run } = require("shakapacker/configExporter")
5
-
6
- run(process.argv.slice(2))
7
- .then((exitCode) => process.exit(exitCode))
8
- .catch((error) => {
9
- console.error(error.message)
10
- process.exit(1)
11
- })