-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Open
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.
Description
Affected URL(s)
https://nodejs.org/docs/latest-v16.x/api/esm.html#globalpreload
https://nodejs.org/docs/latest-v18.x/api/esm.html#globalpreload
Description of the problem
The example code from the docs doesn't work.
port.onmessage
doesn't work. the code needs to be port.on('message', ...)
. Additionally, there is just data
, not evt.data
.
I know that globalPreload is gone in 20, so feel free to close this. I am working with making loaders work across multiple versions of node and this was a problem that I ran into.
/**
* This example has the application context send a message to the loader
* and sends the message back to the application context
*/
export function globalPreload({ port }) {
port.onmessage = (evt) => {
port.postMessage(evt.data);
};
return `\
port.postMessage('console.log("I went to the Loader and back");');
port.onmessage = (evt) => {
eval(evt.data);
};
`;
}
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.