Skip to content

Commit 4884991

Browse files
joyeecheungdanielleadams
authored andcommittedJun 2, 2021
lib: include url in bootstrap snapshot and remove unnecessary lazy-loads
PR-URL: #38826 Refs: #35711 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Khaidi Chu <[email protected]>
1 parent eb7c932 commit 4884991

File tree

4 files changed

+4
-9
lines changed

4 files changed

+4
-9
lines changed
 

‎lib/internal/bootstrap/node.js

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ process.emitWarning = emitWarning;
362362
require('fs');
363363
require('v8');
364364
require('vm');
365+
require('url');
365366

366367
function setupPrepareStackTrace() {
367368
const {

‎lib/internal/url.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ const {
7070
validateObject,
7171
} = require('internal/validators');
7272

73-
// Lazy loaded for startup performance.
74-
let querystring;
73+
const querystring = require('querystring');
7574

7675
const { platform } = process;
7776
const isWindows = platform === 'win32';
@@ -1046,7 +1045,6 @@ function parseParams(qs) {
10461045
} else if (encodeCheck > 0) {
10471046
if (isHexTable[code] === 1) {
10481047
if (++encodeCheck === 3) {
1049-
querystring = require('querystring');
10501048
encoded = true;
10511049
}
10521050
} else {

‎lib/url.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const {
3232

3333
const { toASCII } = require('internal/idna');
3434
const { encodeStr, hexTable } = require('internal/querystring');
35+
const querystring = require('querystring');
3536

3637
const {
3738
ERR_INVALID_ARG_TYPE
@@ -148,9 +149,6 @@ const {
148149
CHAR_AT,
149150
} = require('internal/constants');
150151

151-
// Lazy loaded for startup performance.
152-
let querystring;
153-
154152
function urlParse(url, parseQueryString, slashesDenoteHost) {
155153
if (url instanceof Url) return url;
156154

@@ -256,7 +254,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
256254
if (simplePath[2]) {
257255
this.search = simplePath[2];
258256
if (parseQueryString) {
259-
if (querystring === undefined) querystring = require('querystring');
260257
this.query = querystring.parse(this.search.slice(1));
261258
} else {
262259
this.query = this.search.slice(1);
@@ -445,7 +442,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
445442
this.query = rest.slice(questionIdx + 1, hashIdx);
446443
}
447444
if (parseQueryString) {
448-
if (querystring === undefined) querystring = require('querystring');
449445
this.query = querystring.parse(this.query);
450446
}
451447
} else if (parseQueryString) {
@@ -610,7 +606,6 @@ Url.prototype.format = function format() {
610606
}
611607

612608
if (this.query !== null && typeof this.query === 'object') {
613-
if (querystring === undefined) querystring = require('querystring');
614609
query = querystring.stringify(this.query);
615610
}
616611

‎test/parallel/test-bootstrap-modules.js

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const expectedModules = new Set([
116116
'NativeModule internal/blob',
117117
'NativeModule async_hooks',
118118
'NativeModule path',
119+
'NativeModule querystring',
119120
'NativeModule stream',
120121
'NativeModule stream/promises',
121122
'NativeModule string_decoder',

0 commit comments

Comments
 (0)
Please sign in to comment.