lib: expose v8.startupSnapshot functions on globalThis#63138
Open
addaleax wants to merge 1 commit intonodejs:mainfrom
Open
lib: expose v8.startupSnapshot functions on globalThis#63138addaleax wants to merge 1 commit intonodejs:mainfrom
v8.startupSnapshot functions on globalThis#63138addaleax wants to merge 1 commit intonodejs:mainfrom
Conversation
Expose methods from `require('v8').startupSnapshot` which are
relevant for isomorphic libraries through a `Symbol`-indexed
property on the global object.
This provides a mechanism for using these functions from libraries
that do not integrate with Node.js's module system, while still
enabling integration with the startup snapshot mechanism.
It also provides a path for exposing this feature from other
runtimes that support a startup-snapshot-style feature.
We do not typically expose runtime-specific/non-standard
capabilities on the global object, so using a `Symbol` property
seems like the best way to avoid any potential naming conflicts
and its consequences.
Signed-off-by: Anna Henningsen <anna@addaleax.net>
Member
|
I am a bit wary of adding things to globalThis. process would be a better compromise. Although if process is viable, then I think |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63138 +/- ##
==========================================
+ Coverage 89.67% 89.69% +0.01%
==========================================
Files 712 712
Lines 221251 221269 +18
Branches 42391 42397 +6
==========================================
+ Hits 198405 198462 +57
+ Misses 14669 14623 -46
- Partials 8177 8184 +7
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not necessarily tied to this approach, but we've found this to be a genuine gap when trying to include libraries in startup snapshots. If we're reluctant to place these methods on the global object, I'd also consider the global
processto be a good venue to expose this.Expose methods from
require('v8').startupSnapshotwhich are relevant for isomorphic libraries through aSymbol-indexed property on the global object.This provides a mechanism for using these functions from libraries that do not integrate with Node.js's module system, while still enabling integration with the startup snapshot mechanism. It also provides a path for exposing this feature from other runtimes that support a startup-snapshot-style feature.
We do not typically expose runtime-specific/non-standard capabilities on the global object, so using a
Symbolproperty seems like the best way to avoid any potential naming conflicts and its consequences.