From 5f37decd565ceba3af005f768a0454717c3cbb44 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 13 Dec 2022 22:03:24 +0100 Subject: [PATCH] bootstrap: include event_target into the built-in snapshot Since the module has to be loaded during bootstrap anyway. PR-URL: https://github.com/nodejs/node/pull/45849 Backport-PR-URL: https://github.com/nodejs/node/pull/46425 Reviewed-By: Geoffrey Booth Reviewed-By: Chengzhong Wu --- lib/internal/bootstrap/browser.js | 8 +++++--- test/parallel/test-bootstrap-modules.js | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/internal/bootstrap/browser.js b/lib/internal/bootstrap/browser.js index 93ae26f77a1a75..9e63e0679aca4c 100644 --- a/lib/internal/bootstrap/browser.js +++ b/lib/internal/bootstrap/browser.js @@ -42,9 +42,11 @@ defineOperation(globalThis, 'setTimeout', timers.setTimeout); exposeLazyInterfaces(globalThis, 'internal/abort_controller', [ 'AbortController', 'AbortSignal', ]); -exposeLazyInterfaces(globalThis, 'internal/event_target', [ - 'EventTarget', 'Event', -]); +const { + EventTarget, Event, +} = require('internal/event_target'); +exposeInterface(globalThis, 'Event', Event); +exposeInterface(globalThis, 'EventTarget', EventTarget); exposeLazyInterfaces(globalThis, 'internal/worker/io', [ 'MessageChannel', 'MessagePort', 'MessageEvent', ]); diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index b407760bdc9e6a..64fb780ae67749 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -46,6 +46,7 @@ const expectedModules = new Set([ 'NativeModule internal/constants', 'NativeModule internal/dns/utils', 'NativeModule internal/errors', + 'NativeModule internal/event_target', 'NativeModule internal/fixed_queue', 'NativeModule internal/fs/utils', 'NativeModule internal/idna', @@ -90,6 +91,7 @@ const expectedModules = new Set([ 'NativeModule internal/vm', 'NativeModule internal/vm/module', 'NativeModule internal/wasm_web_api', + 'NativeModule internal/webidl', 'NativeModule internal/worker/js_transferable', 'Internal Binding blob', 'NativeModule async_hooks', @@ -99,6 +101,7 @@ const expectedModules = new Set([ 'NativeModule url', 'NativeModule internal/v8/startup_snapshot', 'NativeModule vm', + 'NativeModule util', ]); if (!common.isMainThread) {