Skip to content

src: preload function for Environment#51539

Merged
nodejs-github-bot merged 2 commits intonodejs:mainfrom
zcbenz:feat-preload-env
Mar 4, 2024
Merged

src: preload function for Environment#51539
nodejs-github-bot merged 2 commits intonodejs:mainfrom
zcbenz:feat-preload-env

Conversation

@zcbenz
Copy link
Contributor

@zcbenz zcbenz commented Jan 22, 2024

This PR provides an API in node::Environment to allow embedders to set a preload function for environment, which will run after the environment is loaded and before the main script runs.

This is similiar to the --require CLI option, but runs a C++ function, and can only be set by embedders.

The preload function can be used by embedders to inject scripts before running the main script, for example:

  1. In Electron it is used to initialize the ASAR virtual filesystem, inject custom process properties, etc.
  2. In VS Code it can be used to reset the module search paths for extensions.

/cc @nodejs/embedders @bpasero

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants