From 0b149f60bd0c000c0dec136f2d3d3c7c7de44357 Mon Sep 17 00:00:00 2001 From: bmacnaughton Date: Thu, 19 Oct 2023 09:55:59 -0700 Subject: [PATCH] doc: fix `globalPreload` example Fixes: https://github.com/nodejs/node/issues/50279 --- doc/api/esm.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 8f147b9c2445b2..caf21f6607faff 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -976,14 +976,14 @@ close normally. * and sends the message back to the application context */ export function globalPreload({ port }) { - port.onmessage = (evt) => { - port.postMessage(evt.data); - }; + port.on('message', (msg) => { + port.postMessage(msg); + }); return `\ port.postMessage('console.log("I went to the Loader and back");'); - port.onmessage = (evt) => { - eval(evt.data); - }; + port.on('message', (data) => { + eval(data); + }); `; } ```