Skip to content

Commit

Permalink
lib: include url in bootstrap snapshot and remove unnecessary lazy-loads
Browse files Browse the repository at this point in the history
PR-URL: #38826
Refs: #35711
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
  • Loading branch information
joyeecheung authored and danielleadams committed Jun 2, 2021
1 parent eb7c932 commit 4884991
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ process.emitWarning = emitWarning;
require('fs');
require('v8');
require('vm');
require('url');

function setupPrepareStackTrace() {
const {
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ const {
validateObject,
} = require('internal/validators');

// Lazy loaded for startup performance.
let querystring;
const querystring = require('querystring');

const { platform } = process;
const isWindows = platform === 'win32';
Expand Down Expand Up @@ -1046,7 +1045,6 @@ function parseParams(qs) {
} else if (encodeCheck > 0) {
if (isHexTable[code] === 1) {
if (++encodeCheck === 3) {
querystring = require('querystring');
encoded = true;
}
} else {
Expand Down
7 changes: 1 addition & 6 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const {

const { toASCII } = require('internal/idna');
const { encodeStr, hexTable } = require('internal/querystring');
const querystring = require('querystring');

const {
ERR_INVALID_ARG_TYPE
Expand Down Expand Up @@ -148,9 +149,6 @@ const {
CHAR_AT,
} = require('internal/constants');

// Lazy loaded for startup performance.
let querystring;

function urlParse(url, parseQueryString, slashesDenoteHost) {
if (url instanceof Url) return url;

Expand Down Expand Up @@ -256,7 +254,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
if (simplePath[2]) {
this.search = simplePath[2];
if (parseQueryString) {
if (querystring === undefined) querystring = require('querystring');
this.query = querystring.parse(this.search.slice(1));
} else {
this.query = this.search.slice(1);
Expand Down Expand Up @@ -445,7 +442,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
this.query = rest.slice(questionIdx + 1, hashIdx);
}
if (parseQueryString) {
if (querystring === undefined) querystring = require('querystring');
this.query = querystring.parse(this.query);
}
} else if (parseQueryString) {
Expand Down Expand Up @@ -610,7 +606,6 @@ Url.prototype.format = function format() {
}

if (this.query !== null && typeof this.query === 'object') {
if (querystring === undefined) querystring = require('querystring');
query = querystring.stringify(this.query);
}

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-bootstrap-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const expectedModules = new Set([
'NativeModule internal/blob',
'NativeModule async_hooks',
'NativeModule path',
'NativeModule querystring',
'NativeModule stream',
'NativeModule stream/promises',
'NativeModule string_decoder',
Expand Down

0 comments on commit 4884991

Please sign in to comment.