Skip to content

Commit 0cd8f41

Browse files
authored
perf: use node: prefix to bypass require.cache call for builtins (#4302)
1 parent 12281b6 commit 0cd8f41

File tree

40 files changed

+72
-72
lines changed

40 files changed

+72
-72
lines changed

@alias/commitlint/cli.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {test, expect} from 'vitest';
2-
import {createRequire} from 'module';
3-
import path from 'path';
4-
import {fileURLToPath} from 'url';
2+
import {createRequire} from 'node:module';
3+
import path from 'node:path';
4+
import {fileURLToPath} from 'node:url';
55

66
import {x} from 'tinyexec';
77
import {fix} from '@commitlint/test';

@commitlint/cli/index.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const path = require('path');
1+
const path = require('node:path');
22

33
module.exports = path.join(__dirname, 'cli.js');

@commitlint/cli/src/cli.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {describe, test, expect} from 'vitest';
2-
import {createRequire} from 'module';
3-
import path from 'path';
4-
import {fileURLToPath} from 'url';
2+
import {createRequire} from 'node:module';
3+
import path from 'node:path';
4+
import {fileURLToPath} from 'node:url';
55
import {fix, git} from '@commitlint/test';
66
import fs from 'fs-extra';
77
import merge from 'lodash.merge';

@commitlint/cli/src/cli.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {createRequire} from 'module';
2-
import path from 'path';
3-
import {fileURLToPath, pathToFileURL} from 'url';
4-
import util from 'util';
1+
import {createRequire} from 'node:module';
2+
import path from 'node:path';
3+
import {fileURLToPath, pathToFileURL} from 'node:url';
4+
import util from 'node:util';
55

66
import lint from '@commitlint/lint';
77
import load, {resolveFromSilent, resolveGlobalSilent} from '@commitlint/load';

@commitlint/config-conventional/src/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {pathToFileURL} from 'url';
2+
import path from 'node:path';
3+
import {pathToFileURL} from 'node:url';
44

55
import lint from '@commitlint/lint';
66

@commitlint/config-lerna-scopes/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {createRequire} from 'module';
2-
import Path from 'path';
1+
import {createRequire} from 'node:module';
2+
import Path from 'node:path';
33

44
import {globSync} from 'glob';
55
import importFrom from 'import-from';

@commitlint/config-lerna-scopes/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

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

@commitlint/config-nx-scopes/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

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

@commitlint/config-patternplate/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import configAngular from '@commitlint/config-angular';
44
import {glob} from 'glob';

@commitlint/config-pnpm-scopes/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import fg from 'fast-glob';
44
import readYamlFile from 'read-yaml-file';

@commitlint/config-pnpm-scopes/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

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

@commitlint/config-rush-scopes/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Path from 'path';
1+
import Path from 'node:path';
22
import fs from 'fs/promises';
33

44
import jsonc from 'jsonc';

@commitlint/config-rush-scopes/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

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

@commitlint/config-validator/src/validate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createRequire} from 'module';
1+
import {createRequire} from 'node:module';
22

33
import {UserConfig} from '@commitlint/types';
44
import _Ajv from 'ajv';

@commitlint/config-workspace-scopes/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {createRequire} from 'module';
2-
import Path from 'path';
1+
import {createRequire} from 'node:module';
2+
import Path from 'node:path';
33

44
import {globSync} from 'glob';
55

@commitlint/config-workspace-scopes/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

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

@commitlint/ensure/src/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import path from 'path';
3-
import {fileURLToPath} from 'url';
2+
import path from 'node:path';
3+
import {fileURLToPath} from 'node:url';
44

55
import {globSync} from 'glob';
66
import camelCase from 'lodash.camelcase';

@commitlint/lint/src/lint.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import util from 'util';
1+
import util from 'node:util';
22
import isIgnored from '@commitlint/is-ignored';
33
import parse from '@commitlint/parse';
44
import defaultRules from '@commitlint/rules';

@commitlint/load/src/load.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {describe, test, expect, vi} from 'vitest';
2-
import {readFileSync, writeFileSync} from 'fs';
3-
import path from 'path';
4-
import {fileURLToPath} from 'url';
2+
import {readFileSync, writeFileSync} from 'node:fs';
3+
import path from 'node:path';
4+
import {fileURLToPath} from 'node:url';
55

66
import {RuleConfigSeverity} from '@commitlint/types';
77
import {fix, git, npm} from '@commitlint/test';

@commitlint/load/src/load.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import {validateConfig} from '@commitlint/config-validator';
44
import executeRule from '@commitlint/execute-rule';

@commitlint/load/src/utils/load-config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {existsSync, readFileSync} from 'fs';
2-
import path from 'path';
1+
import {existsSync, readFileSync} from 'node:fs';
2+
import path from 'node:path';
33

44
import {
55
cosmiconfig,

@commitlint/load/src/utils/load-plugin.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {createRequire} from 'module';
2-
import path from 'path';
3-
import {fileURLToPath, pathToFileURL} from 'url';
1+
import {createRequire} from 'node:module';
2+
import path from 'node:path';
3+
import {fileURLToPath, pathToFileURL} from 'node:url';
44

55
import {Plugin, PluginRecords} from '@commitlint/types';
66
import chalk from 'chalk';

@commitlint/load/src/utils/plugin-naming.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
// largely adapted from eslint's plugin system
44
const NAMESPACE_REGEX = /^@.*\//u;

@commitlint/prompt-cli/cli.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {test, expect} from 'vitest';
2-
import {createRequire} from 'module';
2+
import {createRequire} from 'node:module';
33
import {git} from '@commitlint/test';
44
import {x} from 'tinyexec';
55

@commitlint/prompt/src/inquirer/InputCustomPrompt.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import chalk from 'chalk';
44
import inquirer, {type Answers, type InputCustomOptions} from 'inquirer';
55
import InputPrompt from 'inquirer/lib/prompts/input.js';
66
import observe from 'inquirer/lib/utils/events.js';
7-
import type {Interface as ReadlineInterface, Key} from 'readline';
7+
import type {Interface as ReadlineInterface, Key} from 'node:readline';
88
import type {Subscription} from 'rxjs';
99

1010
import SuccessfulPromptStateData = inquirer.prompts.SuccessfulPromptStateData;

@commitlint/read/src/get-edit-file-path.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import path from 'path';
2-
import {Stats} from 'fs';
1+
import path from 'node:path';
2+
import {Stats} from 'node:fs';
33
import fs from 'fs/promises';
44

55
// Get path to recently edited commit message file

@commitlint/read/src/read.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
22
import fs from 'fs/promises';
3-
import path from 'path';
3+
import path from 'node:path';
44
import {git} from '@commitlint/test';
55
import {x} from 'tinyexec';
66

@commitlint/read/src/stream-to-promise.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Readable} from 'stream';
1+
import {Readable} from 'node:stream';
22

33
export function streamToPromise(stream: Readable): Promise<string[]> {
44
const data: string[] = [];

@commitlint/resolve-extends/src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {test, expect, vi} from 'vitest';
2-
import {createRequire} from 'module';
2+
import {createRequire} from 'node:module';
33
import {RuleConfigSeverity, UserConfig} from '@commitlint/types';
44

55
import resolveExtends, {ResolveExtendsContext} from './index.js';

@commitlint/resolve-extends/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import fs from 'fs';
2-
import path from 'path';
3-
import {pathToFileURL, fileURLToPath} from 'url';
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import {pathToFileURL, fileURLToPath} from 'node:url';
44

55
import globalDirectory from 'global-directory';
66
import {moduleResolve} from 'import-meta-resolve';

@commitlint/rules/src/index.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {test, expect} from 'vitest';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import {fileURLToPath} from 'url';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
4+
import {fileURLToPath} from 'node:url';
55

66
import {globSync} from 'glob';
77

@commitlint/rules/src/trailer-exists.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {spawnSync} from 'child_process';
1+
import {spawnSync} from 'node:child_process';
22
import message from '@commitlint/message';
33
import toLines from '@commitlint/to-lines';
44
import {SyncRule} from '@commitlint/types';

@commitlint/top-level/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22
import {findUp} from 'find-up';
33

44
export default toplevel;

@commitlint/travis-cli/src/cli.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {SpawnOptions} from 'node:child_process';
22

33
import {test, expect} from 'vitest';
4-
import {createRequire} from 'module';
5-
import path from 'path';
6-
import {fileURLToPath} from 'url';
4+
import {createRequire} from 'node:module';
5+
import path from 'node:path';
6+
import {fileURLToPath} from 'node:url';
77

88
import {git} from '@commitlint/test';
99
import {x} from 'tinyexec';

@commitlint/travis-cli/src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {SpawnOptions} from 'node:child_process';
22

3-
import {createRequire} from 'module';
3+
import {createRequire} from 'node:module';
44

55
import {x} from 'tinyexec';
66

@packages/test/src/fix.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import fs from 'fs-extra';
44
import {packageDirectory as pkgDir} from 'pkg-dir';

@packages/test/src/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {test, expect} from 'vitest';
2-
import os from 'os';
3-
import path from 'path';
2+
import os from 'node:os';
3+
import path from 'node:path';
44
import fs from 'fs-extra';
55

66
import * as u from './index.js';

@packages/test/src/npm.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import path from 'node:path';
22

33
import fs from 'fs-extra';
44
import resolvePkg from 'resolve-pkg';

@packages/utils/dep-check.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import path from 'path';
2+
import path from 'node:path';
33
import {x} from 'tinyexec';
44

55
const cwd = process.cwd();

@packages/utils/pkg-check.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/usr/bin/env node
2-
import path from 'path';
3-
import fs from 'fs';
2+
import path from 'node:path';
3+
import fs from 'node:fs';
44

55
import readPkg from 'read-pkg';
66
import requireFromString from 'require-from-string';
77
import tar from 'tar-fs';
88
import {x} from 'tinyexec';
99
import tmp from 'tmp';
1010
import yargs from 'yargs';
11-
import zlib from 'zlib';
11+
import zlib from 'node:zlib';
1212

1313
tmp.setGracefulCleanup();
1414

1515
const PRELUDE = `
16-
var Module = require('module');
16+
var Module = require('node:module');
1717
var originalLoader = Module._load
1818
1919
Module._load = function(path, parent) {

0 commit comments

Comments
 (0)