Skip to content

Commit af7bb75

Browse files
committed
declare when not building snapshot
1 parent c89ce29 commit af7bb75

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/internal/bootstrap/web/exposed-wildcard.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
} = primordials;
1212

1313
const {
14+
doWhenNotBUildingSnapshot,
1415
exposeInterface,
1516
exposeLazyInterfaces,
1617
exposeNamespace,
@@ -27,7 +28,7 @@ const { URL, URLSearchParams } = require('internal/url');
2728
exposeInterface(globalThis, 'URL', URL);
2829
// https://url.spec.whatwg.org/#urlsearchparams
2930
exposeInterface(globalThis, 'URLSearchParams', URLSearchParams);
30-
exposeLazyDOMExceptionProperty(globalThis);
31+
doWhenNotBUildingSnapshot(() => exposeLazyDOMExceptionProperty(globalThis));
3132

3233
// https://dom.spec.whatwg.org/#interface-abortcontroller
3334
// Lazy ones.

lib/internal/util.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const {
5555
const { signals } = internalBinding('constants').os;
5656
const {
5757
guessHandleType: _guessHandleType,
58-
defineLazyProperties,
58+
defineLazyProperties: _defineLazyProperties,
5959
privateSymbols: {
6060
arrow_message_private_symbol,
6161
decorated_private_symbol,
@@ -66,6 +66,10 @@ const { isNativeError, isPromise } = internalBinding('types');
6666
const { getOptionValue } = require('internal/options');
6767
const assert = require('internal/assert');
6868
const { encodings } = internalBinding('string_decoder');
69+
const {
70+
isBuildingSnapshot,
71+
addDeserializeCallback,
72+
} = require('internal/v8/startup_snapshot').namespace;
6973

7074
const noCrypto = !process.versions.openssl;
7175
const noTypeScript = !process.versions.amaro;
@@ -611,6 +615,18 @@ function exposeGetterAndSetter(target, name, getter, setter = undefined) {
611615
});
612616
}
613617

618+
function doWhenNotBUildingSnapshot(fn) {
619+
if (isBuildingSnapshot()) {
620+
addDeserializeCallback(fn);
621+
} else {
622+
fn();
623+
}
624+
}
625+
626+
function defineLazyProperties(...args) {
627+
doWhenNotBUildingSnapshot(() => ReflectApply(_defineLazyProperties, this, args));
628+
}
629+
614630
function defineReplaceableLazyAttribute(target, id, keys, writable = true, check) {
615631
let mod;
616632
for (let i = 0; i < keys.length; i++) {
@@ -852,6 +868,7 @@ module.exports = {
852868
defineReplaceableLazyAttribute,
853869
deprecate,
854870
deprecateInstantiation,
871+
doWhenNotBUildingSnapshot,
855872
emitExperimentalWarning,
856873
encodingsMap,
857874
exposeInterface,

0 commit comments

Comments
 (0)