mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
bootstrap: lazy load non-essential modules
It turns out that even with startup snapshots, there is a non-trivial overhead for loading internal modules. This patch makes the loading of the non-essential modules lazy again. Caveat: we have to make some of the globals lazily-loaded too, so the WPT runner is updated to test what the state of the global scope is after the globals are accessed (and replaced with the loaded value). PR-URL: https://github.com/nodejs/node/pull/45659 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
This commit is contained in:
parent
7d80ca3683
commit
265ea1e74e
26 changed files with 320 additions and 366 deletions
|
@ -78,7 +78,8 @@ const {
|
|||
isInsideNodeModules,
|
||||
lazyDOMException,
|
||||
normalizeEncoding,
|
||||
kIsEncodingSymbol
|
||||
kIsEncodingSymbol,
|
||||
defineLazyProperties,
|
||||
} = require('internal/util');
|
||||
const {
|
||||
isAnyArrayBuffer,
|
||||
|
@ -121,15 +122,6 @@ const {
|
|||
createUnsafeBuffer
|
||||
} = require('internal/buffer');
|
||||
|
||||
const {
|
||||
Blob,
|
||||
resolveObjectURL,
|
||||
} = require('internal/blob');
|
||||
|
||||
const {
|
||||
File,
|
||||
} = require('internal/file');
|
||||
|
||||
FastBuffer.prototype.constructor = Buffer;
|
||||
Buffer.prototype = FastBuffer.prototype;
|
||||
addBufferPrototypeMethods(Buffer.prototype);
|
||||
|
@ -1323,9 +1315,6 @@ function atob(input) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
Blob,
|
||||
File,
|
||||
resolveObjectURL,
|
||||
Buffer,
|
||||
SlowBuffer,
|
||||
transcode,
|
||||
|
@ -1352,3 +1341,14 @@ ObjectDefineProperties(module.exports, {
|
|||
set(val) { INSPECT_MAX_BYTES = val; }
|
||||
}
|
||||
});
|
||||
|
||||
defineLazyProperties(
|
||||
module.exports,
|
||||
'internal/blob',
|
||||
['Blob', 'resolveObjectURL']
|
||||
);
|
||||
defineLazyProperties(
|
||||
module.exports,
|
||||
'internal/file',
|
||||
['File']
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue