bootsnap 1.13.0 → 1.14.0
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/CHANGELOG.md +8 -0
- data/README.md +5 -1
- data/lib/bootsnap/load_path_cache/change_observer.rb +1 -1
- data/lib/bootsnap/load_path_cache/loaded_features_index.rb +2 -2
- data/lib/bootsnap/load_path_cache/path_scanner.rb +6 -0
- data/lib/bootsnap/load_path_cache.rb +2 -2
- data/lib/bootsnap/version.rb +1 -1
- data/lib/bootsnap.rb +9 -27
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f2b4691e78336f28b1f78e9751235bc558b0f6ad86dee541acd478fc23ef510
|
4
|
+
data.tar.gz: 51eb44a77465f49db0d15425536e17d94f8d3fe77433ab48260b4c81613d9c72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e98271863cf3dec676eea43ecaecf4d97a543ba5c0d840160d9862b4f212906910e3654263db49457320b5783150c719a8ef479266be96df5243a04addc43b
|
7
|
+
data.tar.gz: 46aa01dff95699d6148ed539c8a56e1d749801ee89e953a37f32b4a3974f1da99fe594c4fb1b04c99a42f030cb4b12bd6dd892fac5b00af4de1f7a560cb420ba
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 1.14.0
|
4
|
+
|
5
|
+
* Require Ruby 2.6.
|
6
|
+
* Add a way to skip directories during load path scanning.
|
7
|
+
If you have large non-ruby directories in the middle of your load path, it can severly slow down scanning.
|
8
|
+
Typically this is a problem with `node_modules`. See #277.
|
9
|
+
* Fix `Bootsnap.unload_cache!`, it simply wouldn't work at all becaue of a merge mistake. See #421.
|
10
|
+
|
3
11
|
# 1.13.0
|
4
12
|
|
5
13
|
* Stop decorating `Kernel.load`. This used to be very useful in development because the Rails "classic" autoloader
|
data/README.md
CHANGED
@@ -52,10 +52,11 @@ require 'bootsnap'
|
|
52
52
|
env = ENV['RAILS_ENV'] || "development"
|
53
53
|
Bootsnap.setup(
|
54
54
|
cache_dir: 'tmp/cache', # Path to your cache
|
55
|
+
ignored_directories ['node_modules'], # Directory names to skip.
|
55
56
|
development_mode: env == 'development', # Current working environment, e.g. RACK_ENV, RAILS_ENV, etc
|
56
57
|
load_path_cache: true, # Optimize the LOAD_PATH with a cache
|
57
58
|
compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
|
58
|
-
compile_cache_yaml: true
|
59
|
+
compile_cache_yaml: true, # Compile YAML into a cache
|
59
60
|
)
|
60
61
|
```
|
61
62
|
|
@@ -77,6 +78,9 @@ well together, and are both included in a newly-generated Rails applications by
|
|
77
78
|
- `DISABLE_BOOTSNAP_LOAD_PATH_CACHE` allows to disable load path caching.
|
78
79
|
- `DISABLE_BOOTSNAP_COMPILE_CACHE` allows to disable ISeq and YAML caches.
|
79
80
|
- `BOOTSNAP_LOG` configure bootsnap to log all caches misses to STDERR.
|
81
|
+
- `BOOTSNAP_IGNORE_DIRECTORIES` a comma separated list of directories that shouldn't be scanned.
|
82
|
+
Useful when you have large directories of non-ruby files inside `$LOAD_PATH`.
|
83
|
+
It default to ignore any directory named `node_modules`.
|
80
84
|
|
81
85
|
### Environments
|
82
86
|
|
@@ -66,7 +66,7 @@ module Bootsnap
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.unregister(arr)
|
69
|
-
return unless arr.instance_variable_get(:@lpc_observer)
|
69
|
+
return unless arr.instance_variable_defined?(:@lpc_observer) && arr.instance_variable_get(:@lpc_observer)
|
70
70
|
|
71
71
|
ArrayMixin.instance_methods.each do |method_name|
|
72
72
|
arr.singleton_class.send(:remove_method, method_name)
|
@@ -40,7 +40,7 @@ module Bootsnap
|
|
40
40
|
|
41
41
|
# /a/b/lib/my/foo.rb
|
42
42
|
# ^^^^^^^^^
|
43
|
-
short = feat[(lpe.length + 1)
|
43
|
+
short = feat[(lpe.length + 1)..]
|
44
44
|
stripped = strip_extension_if_elidable(short)
|
45
45
|
@lfi[short] = hash
|
46
46
|
@lfi[stripped] = hash
|
@@ -76,7 +76,7 @@ module Bootsnap
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def identify(short, cursor)
|
79
|
-
$LOADED_FEATURES[cursor
|
79
|
+
$LOADED_FEATURES[cursor..].detect do |feat|
|
80
80
|
offset = 0
|
81
81
|
while (offset = feat.index(short, offset))
|
82
82
|
if feat.index(".", offset + 1) && !feat.index("/", offset + 2)
|
@@ -15,7 +15,11 @@ module Bootsnap
|
|
15
15
|
""
|
16
16
|
end
|
17
17
|
|
18
|
+
@ignored_directories = %w(node_modules)
|
19
|
+
|
18
20
|
class << self
|
21
|
+
attr_accessor :ignored_directories
|
22
|
+
|
19
23
|
def call(path)
|
20
24
|
path = File.expand_path(path.to_s).freeze
|
21
25
|
return [[], []] unless File.directory?(path)
|
@@ -50,6 +54,8 @@ module Bootsnap
|
|
50
54
|
|
51
55
|
absolute_path = "#{absolute_dir_path}/#{name}"
|
52
56
|
if File.directory?(absolute_path)
|
57
|
+
next if ignored_directories.include?(name)
|
58
|
+
|
53
59
|
if yield relative_path, absolute_path, true
|
54
60
|
walk(absolute_path, relative_path, &block)
|
55
61
|
end
|
@@ -28,7 +28,7 @@ module Bootsnap
|
|
28
28
|
alias_method :enabled?, :enabled
|
29
29
|
remove_method(:enabled)
|
30
30
|
|
31
|
-
def setup(cache_path:, development_mode:)
|
31
|
+
def setup(cache_path:, development_mode:, ignore_directories:)
|
32
32
|
unless supported?
|
33
33
|
warn("[bootsnap/setup] Load path caching is not supported on this implementation of Ruby") if $VERBOSE
|
34
34
|
return
|
@@ -39,6 +39,7 @@ module Bootsnap
|
|
39
39
|
@loaded_features_index = LoadedFeaturesIndex.new
|
40
40
|
|
41
41
|
@load_path_cache = Cache.new(store, $LOAD_PATH, development_mode: development_mode)
|
42
|
+
PathScanner.ignored_directories = ignore_directories if ignore_directories
|
42
43
|
@enabled = true
|
43
44
|
require_relative("load_path_cache/core_ext/kernel_require")
|
44
45
|
require_relative("load_path_cache/core_ext/loaded_features")
|
@@ -50,7 +51,6 @@ module Bootsnap
|
|
50
51
|
@realpath_cache = nil
|
51
52
|
@load_path_cache = nil
|
52
53
|
ChangeObserver.unregister($LOAD_PATH)
|
53
|
-
::Kernel.alias_method(:require_relative, :require_relative_without_bootsnap)
|
54
54
|
end
|
55
55
|
|
56
56
|
def supported?
|
data/lib/bootsnap/version.rb
CHANGED
data/lib/bootsnap.rb
CHANGED
@@ -39,32 +39,16 @@ module Bootsnap
|
|
39
39
|
cache_dir:,
|
40
40
|
development_mode: true,
|
41
41
|
load_path_cache: true,
|
42
|
-
|
43
|
-
disable_trace: nil,
|
42
|
+
ignore_directories: nil,
|
44
43
|
compile_cache_iseq: true,
|
45
44
|
compile_cache_yaml: true,
|
46
45
|
compile_cache_json: true
|
47
46
|
)
|
48
|
-
unless autoload_paths_cache.nil?
|
49
|
-
warn "[DEPRECATED] Bootsnap's `autoload_paths_cache:` option is deprecated and will be removed. " \
|
50
|
-
"If you use Zeitwerk this option is useless, and if you are still using the classic autoloader " \
|
51
|
-
"upgrading is recommended."
|
52
|
-
end
|
53
|
-
|
54
|
-
unless disable_trace.nil?
|
55
|
-
warn "[DEPRECATED] Bootsnap's `disable_trace:` option is deprecated and will be removed. " \
|
56
|
-
"If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended."
|
57
|
-
end
|
58
|
-
|
59
|
-
if compile_cache_iseq && !iseq_cache_supported?
|
60
|
-
warn "Ruby 2.5 has a bug that break code tracing when code is loaded from cache. It is recommened " \
|
61
|
-
"to turn `compile_cache_iseq` off on Ruby 2.5"
|
62
|
-
end
|
63
|
-
|
64
47
|
if load_path_cache
|
65
48
|
Bootsnap::LoadPathCache.setup(
|
66
49
|
cache_path: "#{cache_dir}/bootsnap/load-path-cache",
|
67
50
|
development_mode: development_mode,
|
51
|
+
ignore_directories: ignore_directories,
|
68
52
|
)
|
69
53
|
end
|
70
54
|
|
@@ -76,17 +60,10 @@ module Bootsnap
|
|
76
60
|
)
|
77
61
|
end
|
78
62
|
|
79
|
-
def
|
63
|
+
def unload_cache!
|
80
64
|
LoadPathCache.unload!
|
81
65
|
end
|
82
66
|
|
83
|
-
def iseq_cache_supported?
|
84
|
-
return @iseq_cache_supported if defined? @iseq_cache_supported
|
85
|
-
|
86
|
-
ruby_version = Gem::Version.new(RUBY_VERSION)
|
87
|
-
@iseq_cache_supported = ruby_version < Gem::Version.new("2.5.0") || ruby_version >= Gem::Version.new("2.6.0")
|
88
|
-
end
|
89
|
-
|
90
67
|
def default_setup
|
91
68
|
env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["ENV"]
|
92
69
|
development_mode = ["", nil, "development"].include?(env)
|
@@ -113,13 +90,18 @@ module Bootsnap
|
|
113
90
|
cache_dir = File.join(app_root, "tmp", "cache")
|
114
91
|
end
|
115
92
|
|
93
|
+
ignore_directories = if ENV.key?("BOOTSNAP_IGNORE_DIRECTORIES")
|
94
|
+
ENV["BOOTSNAP_IGNORE_DIRECTORIES"].split(",")
|
95
|
+
end
|
96
|
+
|
116
97
|
setup(
|
117
98
|
cache_dir: cache_dir,
|
118
99
|
development_mode: development_mode,
|
119
100
|
load_path_cache: !ENV["DISABLE_BOOTSNAP_LOAD_PATH_CACHE"],
|
120
|
-
compile_cache_iseq: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"]
|
101
|
+
compile_cache_iseq: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
|
121
102
|
compile_cache_yaml: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
|
122
103
|
compile_cache_json: !ENV["DISABLE_BOOTSNAP_COMPILE_CACHE"],
|
104
|
+
ignore_directories: ignore_directories,
|
123
105
|
)
|
124
106
|
|
125
107
|
if ENV["BOOTSNAP_LOG"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootsnap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Burke Libbey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements:
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 2.
|
79
|
+
version: 2.6.0
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - ">="
|