Skip to content

Commit 8445b05

Browse files
Fix incorrect node:… module warnings in doctor (#6347)
This swaps to use `isBuiltin` from Node rather than constructing a custom set of module names with `node:` prefix. For some modules that didn't have a "bare" module (e.g. `node:test`) this fixes false positive errors. ## What's the problem this PR addresses? <!-- Describe the rationale of your PR. --> <!-- Link all issues that it closes. (Closes/Resolves #xxxx.) --> Closes #6343 ## How did you fix it? <!-- A detailed description of your implementation. --> ## Checklist <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [ ] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [ ] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [ ] I will check that all automated PR checks pass before the PR gets reviewed. --------- Co-authored-by: Maël Nison <[email protected]>
1 parent 40b5fb8 commit 8445b05

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

.yarn/versions/a4f6973d.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
releases:
2+
"@yarnpkg/doctor": patch

packages/yarnpkg-doctor/sources/cli.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@ import {PortablePath, npath, ppath, xfs}
66
import {Cli, Command, Builtins, Option} from 'clipanion';
77
import globby from 'globby';
88
import micromatch from 'micromatch';
9-
import {Module} from 'module';
9+
import {isBuiltin} from 'module';
1010
import * as ts from 'typescript';
1111

1212
import * as ast from './ast';
1313

14-
const BUILTINS = new Set([
15-
...(Module.builtinModules || []),
16-
...(Module.builtinModules || []).map(mod => `node:${mod}`),
17-
`pnpapi`,
18-
]);
19-
2014
function probablyMinified(content: string) {
2115
if (content.length > 1024 * 1024)
2216
return true;
@@ -84,7 +78,7 @@ function isValidDependency(ident: Ident, {workspace}: {workspace: Workspace}) {
8478
}
8579

8680
function checkForUndeclaredDependency(workspace: Workspace, referenceNode: ts.Node, moduleName: string, {configuration, report}: {configuration: Configuration, report: Report}) {
87-
if (BUILTINS.has(moduleName))
81+
if (isBuiltin(moduleName) || moduleName === `pnpapi`)
8882
return;
8983

9084
const idents = extractIdents(moduleName);

0 commit comments

Comments
 (0)