Skip to content

Add external Bootsnap cache inputs - #6

Merged
palkan merged 2 commits into
ruby-next:masterfrom
rafaelfranca:rm-custom_hash
Aug 26, 2026
Merged

Add external Bootsnap cache inputs#6
palkan merged 2 commits into
ruby-next:masterfrom
rafaelfranca:rm-custom_hash

Conversation

@rafaelfranca

@rafaelfranca rafaelfranca commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Require Hooks source transforms can depend on external libraries or configuration. The existing version_hash= API sets one complete, static key and replaces the automatic hook key. For example:

RequireHooks::Bootsnap.version_hash = Parser::VERSION RequireHooks.source_transform do |_path, source|
  source.gsub("...", options_digest)
end

If options_digest changes while Parser::VERSION stays the same, Bootsnap reuses the old transformed entry because version_hash= does not include the transform option. A second version_hash= assignment would instead discard the first dependency.

Applications can register both inputs with:

RequireHooks::Bootsnap.add_version_hash do
  "parser-#{Parser::VERSION}-#{options_digest}"
end

Require Hooks evaluates each callable when it computes the key, hashes each contribution, and combines all contributions with the hook configuration. It then isolates transformed entries with Bootsnap compiler namespaces on modern Bootsnap and versioned cache directories on older versions.

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation

Require Hooks source transforms can depend on external libraries or
configuration. The existing version_hash= API sets one complete, static key
and replaces the automatic hook key. For example:

RequireHooks::Bootsnap.version_hash = Parser::VERSION
RequireHooks.source_transform do |_path, source|
  source.gsub("...", options_digest)
end

If options_digest changes while Parser::VERSION stays the same, Bootsnap
reuses the old transformed entry because version_hash= does not include the
transform option. A second version_hash= assignment would instead discard the
first dependency.

Applications can register both inputs with:

RequireHooks::Bootsnap.add_version_hash do
  "parser-#{Parser::VERSION}-#{options_digest}"
end

Require Hooks evaluates each callable when it computes the key, hashes each
contribution, and combines all contributions with the hook configuration. It
then isolates transformed entries with Bootsnap compiler namespaces on modern
Bootsnap and versioned cache directories on older versions.
Comment thread lib/require-hooks/mode/bootsnap.rb Outdated
@palkan
palkan merged commit 493070b into ruby-next:master Aug 26, 2026
25 checks passed
@palkan

palkan commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

@rafaelfranca Please, let me know if you want me to publish a new release or there is more Bootsnap-related expected

@rafaelfranca

Copy link
Copy Markdown
Contributor Author

This is the last one. Feel free to make a release. 0.5.0 is already good enough for us, but this will make sure our caches aren't reused when our transformation library changes

@rafaelfranca
rafaelfranca deleted the rm-custom_hash branch August 26, 2026 18:44
@palkan

palkan commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Great! v0.5.1 is on its way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants