esm: remove globalPreload hook (superseded by initialize)#49144
Merged
nodejs-github-bot merged 21 commits intonodejs:mainfrom Sep 10, 2023
Merged
esm: remove globalPreload hook (superseded by initialize)#49144nodejs-github-bot merged 21 commits intonodejs:mainfrom
globalPreload hook (superseded by initialize)#49144nodejs-github-bot merged 21 commits intonodejs:mainfrom
Conversation
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.
This PR removes the
globalPreloadmodule customization hook. It is no longer needed now that its functionality is provided by theregisterAPI paired with theinitializehook. You can see examples of refactoring fromglobalPreloadtoregister/initializein #49465 and in some of the updated tests in this PR.Besides removing the hook itself, the
test-esm-loader-hooks.mjstestdescribe('globalPreload'block andtest-esm-loader-side-effect.mjswere removed. These were testing parts ofglobalPreload, like that its communications ports work, that we already have separate tests for covering the superseding equivalent inregister/initialize; or they were testing things that we don’t need tests for outside of theglobalPreloadcontext, such that global variables declared in a preload script are accessible on the main thread. (The new API callsregisterfrom the main thread, and global variables can be declared there, and we don’t need a test that global variables declared on the main thread can be read on the main thread.)This PR completes the loaders roadmap Milestone 2.
Notable changes
Module customization hook
globalPreloadremoved; useregisterandinitializeinsteadThe module customization hook
globalPreloadhas been removed. Instead, useregisterto send data from the application thread to the customization hooks, and theinitializehook to establish a communications channel between the threads.