Skip to content

Commit df62f1d

Browse files
committed
lib: include url in bootstrap snapshot and remove unnecessary lazy-loads
1 parent fc269b3 commit df62f1d

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,
@@ -149,9 +150,6 @@ const {
149150
CHAR_AT,
150151
} = require('internal/constants');
151152

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

@@ -271,7 +269,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
271269
if (simplePath[2]) {
272270
this.search = simplePath[2];
273271
if (parseQueryString) {
274-
if (querystring === undefined) querystring = require('querystring');
275272
this.query = querystring.parse(this.search.slice(1));
276273
} else {
277274
this.query = this.search.slice(1);
@@ -473,7 +470,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
473470
this.query = rest.slice(questionIdx + 1, hashIdx);
474471
}
475472
if (parseQueryString) {
476-
if (querystring === undefined) querystring = require('querystring');
477473
this.query = querystring.parse(this.query);
478474
}
479475
} else if (parseQueryString) {
@@ -638,7 +634,6 @@ Url.prototype.format = function format() {
638634
}
639635

640636
if (this.query !== null && typeof this.query === 'object') {
641-
if (querystring === undefined) querystring = require('querystring');
642637
query = querystring.stringify(this.query);
643638
}
644639

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)