Skip to content

perf: use node: prefix to bypass require.cache call for builtins #4302

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

Merged
merged 1 commit into from
Feb 28, 2025
Merged
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
6 changes: 3 additions & 3 deletions @alias/commitlint/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {test, expect} from 'vitest';
import {createRequire} from 'module';
import path from 'path';
import {fileURLToPath} from 'url';
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {x} from 'tinyexec';
import {fix} from '@commitlint/test';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/cli/index.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const path = require('path');
const path = require('node:path');

module.exports = path.join(__dirname, 'cli.js');
6 changes: 3 additions & 3 deletions @commitlint/cli/src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, test, expect} from 'vitest';
import {createRequire} from 'module';
import path from 'path';
import {fileURLToPath} from 'url';
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {fix, git} from '@commitlint/test';
import fs from 'fs-extra';
import merge from 'lodash.merge';
Expand Down
8 changes: 4 additions & 4 deletions @commitlint/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {createRequire} from 'module';
import path from 'path';
import {fileURLToPath, pathToFileURL} from 'url';
import util from 'util';
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath, pathToFileURL} from 'node:url';
import util from 'node:util';

import lint from '@commitlint/lint';
import load, {resolveFromSilent, resolveGlobalSilent} from '@commitlint/load';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-conventional/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {pathToFileURL} from 'url';
import path from 'node:path';
import {pathToFileURL} from 'node:url';

import lint from '@commitlint/lint';

Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-lerna-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createRequire} from 'module';
import Path from 'path';
import {createRequire} from 'node:module';
import Path from 'node:path';

import {globSync} from 'glob';
import importFrom from 'import-from';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-lerna-scopes/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {npm} from '@commitlint/test';

Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-nx-scopes/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {npm} from '@commitlint/test';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-patternplate/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

import configAngular from '@commitlint/config-angular';
import {glob} from 'glob';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-pnpm-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

import fg from 'fast-glob';
import readYamlFile from 'read-yaml-file';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-pnpm-scopes/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {npm} from '@commitlint/test';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-rush-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Path from 'path';
import Path from 'node:path';
import fs from 'fs/promises';

import jsonc from 'jsonc';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-rush-scopes/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {npm} from '@commitlint/test';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/config-validator/src/validate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createRequire} from 'module';
import {createRequire} from 'node:module';

import {UserConfig} from '@commitlint/types';
import _Ajv from 'ajv';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-workspace-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {createRequire} from 'module';
import Path from 'path';
import {createRequire} from 'node:module';
import Path from 'node:path';

import {globSync} from 'glob';

Expand Down
4 changes: 2 additions & 2 deletions @commitlint/config-workspace-scopes/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {npm} from '@commitlint/test';

Expand Down
4 changes: 2 additions & 2 deletions @commitlint/ensure/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import path from 'path';
import {fileURLToPath} from 'url';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {globSync} from 'glob';
import camelCase from 'lodash.camelcase';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/lint/src/lint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util from 'util';
import util from 'node:util';
import isIgnored from '@commitlint/is-ignored';
import parse from '@commitlint/parse';
import defaultRules from '@commitlint/rules';
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/load/src/load.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, test, expect, vi} from 'vitest';
import {readFileSync, writeFileSync} from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
import {readFileSync, writeFileSync} from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {RuleConfigSeverity} from '@commitlint/types';
import {fix, git, npm} from '@commitlint/test';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/load/src/load.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

import {validateConfig} from '@commitlint/config-validator';
import executeRule from '@commitlint/execute-rule';
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/load/src/utils/load-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {existsSync, readFileSync} from 'fs';
import path from 'path';
import {existsSync, readFileSync} from 'node:fs';
import path from 'node:path';

import {
cosmiconfig,
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/load/src/utils/load-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createRequire} from 'module';
import path from 'path';
import {fileURLToPath, pathToFileURL} from 'url';
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath, pathToFileURL} from 'node:url';

import {Plugin, PluginRecords} from '@commitlint/types';
import chalk from 'chalk';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/load/src/utils/plugin-naming.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

// largely adapted from eslint's plugin system
const NAMESPACE_REGEX = /^@.*\//u;
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/prompt-cli/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {test, expect} from 'vitest';
import {createRequire} from 'module';
import {createRequire} from 'node:module';
import {git} from '@commitlint/test';
import {x} from 'tinyexec';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/prompt/src/inquirer/InputCustomPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chalk from 'chalk';
import inquirer, {type Answers, type InputCustomOptions} from 'inquirer';
import InputPrompt from 'inquirer/lib/prompts/input.js';
import observe from 'inquirer/lib/utils/events.js';
import type {Interface as ReadlineInterface, Key} from 'readline';
import type {Interface as ReadlineInterface, Key} from 'node:readline';
import type {Subscription} from 'rxjs';

import SuccessfulPromptStateData = inquirer.prompts.SuccessfulPromptStateData;
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/read/src/get-edit-file-path.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import {Stats} from 'fs';
import path from 'node:path';
import {Stats} from 'node:fs';
import fs from 'fs/promises';

// Get path to recently edited commit message file
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/read/src/read.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import fs from 'fs/promises';
import path from 'path';
import path from 'node:path';
import {git} from '@commitlint/test';
import {x} from 'tinyexec';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/read/src/stream-to-promise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Readable} from 'stream';
import {Readable} from 'node:stream';

export function streamToPromise(stream: Readable): Promise<string[]> {
const data: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/resolve-extends/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {test, expect, vi} from 'vitest';
import {createRequire} from 'module';
import {createRequire} from 'node:module';
import {RuleConfigSeverity, UserConfig} from '@commitlint/types';

import resolveExtends, {ResolveExtendsContext} from './index.js';
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/resolve-extends/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import {pathToFileURL, fileURLToPath} from 'url';
import fs from 'node:fs';
import path from 'node:path';
import {pathToFileURL, fileURLToPath} from 'node:url';

import globalDirectory from 'global-directory';
import {moduleResolve} from 'import-meta-resolve';
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/rules/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {test, expect} from 'vitest';
import fs from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {globSync} from 'glob';

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/rules/src/trailer-exists.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {spawnSync} from 'child_process';
import {spawnSync} from 'node:child_process';
import message from '@commitlint/message';
import toLines from '@commitlint/to-lines';
import {SyncRule} from '@commitlint/types';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/top-level/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';
import {findUp} from 'find-up';

export default toplevel;
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/travis-cli/src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {SpawnOptions} from 'node:child_process';

import {test, expect} from 'vitest';
import {createRequire} from 'module';
import path from 'path';
import {fileURLToPath} from 'url';
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import {git} from '@commitlint/test';
import {x} from 'tinyexec';
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/travis-cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {SpawnOptions} from 'node:child_process';

import {createRequire} from 'module';
import {createRequire} from 'node:module';

import {x} from 'tinyexec';

Expand Down
2 changes: 1 addition & 1 deletion @packages/test/src/fix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

import fs from 'fs-extra';
import {packageDirectory as pkgDir} from 'pkg-dir';
Expand Down
4 changes: 2 additions & 2 deletions @packages/test/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from 'vitest';
import os from 'os';
import path from 'path';
import os from 'node:os';
import path from 'node:path';
import fs from 'fs-extra';

import * as u from './index.js';
Expand Down
2 changes: 1 addition & 1 deletion @packages/test/src/npm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';

import fs from 'fs-extra';
import resolvePkg from 'resolve-pkg';
Expand Down
2 changes: 1 addition & 1 deletion @packages/utils/dep-check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import path from 'path';
import path from 'node:path';
import {x} from 'tinyexec';

const cwd = process.cwd();
Expand Down
8 changes: 4 additions & 4 deletions @packages/utils/pkg-check.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env node
import path from 'path';
import fs from 'fs';
import path from 'node:path';
import fs from 'node:fs';

import readPkg from 'read-pkg';
import requireFromString from 'require-from-string';
import tar from 'tar-fs';
import {x} from 'tinyexec';
import tmp from 'tmp';
import yargs from 'yargs';
import zlib from 'zlib';
import zlib from 'node:zlib';

tmp.setGracefulCleanup();

const PRELUDE = `
var Module = require('module');
var Module = require('node:module');
var originalLoader = Module._load

Module._load = function(path, parent) {
Expand Down