Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: include url in bootstrap snapshot and remove unnecessary lazy-loads #38826

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -149,9 +150,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 @@ -271,7 +269,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 @@ -473,7 +470,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 @@ -638,7 +634,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