Skip to content

Instantly share code, notes, and snippets.

@Edouard-chin
Created March 19, 2019 15:48
Show Gist options
  • Save Edouard-chin/f3092baab8544d97c91a9c3e3da70c8d to your computer and use it in GitHub Desktop.
Save Edouard-chin/f3092baab8544d97c91a9c3e3da70c8d to your computer and use it in GitHub Desktop.
Bootsnap autoload
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'bootsnap', '~> 1.4.1'
gem 'activesupport'
end
require 'bootsnap'
require 'tempfile'
Bootsnap.setup(
cache_dir: Dir.mktmpdir,
development_mode: true,
load_path_cache: true,
autoload_paths_cache: true,
disable_trace: true,
compile_cache_iseq: false,
compile_cache_yaml: true
)
File.write(__dir__ + '/b.rb', "class B\nend\n")
autoload :B, './b'
B
Object.send(:remove_const, :B)
$LOADED_FEATURES.pop
autoload :B, './b'
B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment