8000 refactor: replace custom `isBuiltinModule` with node's `isBuiltin` by JounQin · Pull Request #15685 · jestjs/jest · GitHub
[go: up one dir, main page]

Skip to content

refactor: replace custom isBuiltinModule with node's isBuiltin #15685

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 2 commits into from
Jun 18, 2025

Conversation

JounQin
Copy link
Collaborator
@JounQin JounQin commented Jun 18, 2025

Summary

I believe we don't need a custom isBuiltinModule anymore.

Test plan

Copy link
netlify bot commented Jun 18, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit aad1204
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6852b44eba1ba500089a8ad4
😎 Deploy Preview https://deploy-preview-15685--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@JounQin JounQin requested review from Copilot, SimenB and cpojer June 18, 2025 12:39
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors module resolution by replacing the custom isBuiltinModule check with Node’s built-in isBuiltin API, simplifying the core module check logic.

  • Replaces the custom isBuiltinModule with Node's isBuiltin.
  • Updates the isCoreModule method to rely solely on isBuiltin.
  • Updates tests and snapshots accordingly to reflect the reduced checks.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/jest-resolve/src/resolver.ts Refactored isCoreModule to use Node’s isBuiltin and removed extra check for 'node:' prefix.
packages/jest-resolve/src/isBuiltinModule.ts Removed file as Node's built-in functionality now replaces it.
packages/jest-resolve/src/tests/resolve.test.ts Updated tests to align with the new core module determination logic.
packages/jest-resolve/src/tests/isBuiltinModule.test.ts Removed tests for isBuiltinModule since the custom check was removed.
e2e/tests/__snapshots/* Adjusted snapshot error messages to reflect updated line numbers.
Comments suppressed due to low confidence (2)

packages/jest-resolve/src/resolver.ts:457

  • The updated isCoreModule method now relies solely on isBuiltin; please confirm that this behavior correctly identifies all core modules, including handling the 'node:' prefix as expected by Node's API.
  isCoreModule(moduleName: string): boolean {

e2e/tests/snapshots/resolveNoFileExtensions.test.ts.snap:40

  • Ensure that the updated snapshot error references accurately reflect the intended location changes in the code, maintaining consistency across error reporting.
      at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:863:11)

@@ -75,11 +75,11 @@ describe('isCoreModule', () => {
expect(isCore).toBe(true);
});

it('returns true if using `node:` URLs and `moduleName` is not a core module.', () => {
it('returns false if using `node:` URLs and `moduleName` is not a core module.', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is intended, and should we really support this usage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this should be false 👍

Copy link
pkg-pr-new bot commented Jun 18, 2025

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15685

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15685

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15685

create-jest

npm i https://pkg.pr.new/create-jest@15685

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15685

expect

npm i https://pkg.pr.new/expect@15685

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15685

jest

npm i https://pkg.pr.new/jest@15685

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15685

jest-circus

npm i https://pkg.pr.new/jest-circus@15685

jest-cli

npm i https://pkg.pr.new/jest-cli@15685

jest-config

npm i https://pkg.pr.new/jest-config@15685

@jest/console

npm i https://pkg.pr.new/@jest/console@15685

@jest/core

npm i https://pkg.pr.new/@jest/core@15685

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15685

jest-diff

npm i https://pkg.pr.new/jest-diff@15685

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15685

jest-each

npm i https://pkg.pr.new/jest-each@15685

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15685

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15685

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15685

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15685

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15685

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15685

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15685

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15685

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15685

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15685

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15685

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15685

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15685

jest-mock

npm i https://pkg.pr.new/jest-mock@15685

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15685

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15685

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15685

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15685

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15685

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15685

jest-runner

npm i https://pkg.pr.new/jest-runner@15685

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15685

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15685

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15685

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15685

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15685

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15685

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15685

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15685

@jest/types

npm i https://pkg.pr.new/@jest/types@15685

jest-util

npm i https://pkg.pr.new/jest-util@15685

jest-validate

npm i https://pkg.pr.new/jest-validate@15685

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15685

jest-worker

npm i https://pkg.pr.new/jest-worker@15685

pretty-format

npm i https://pkg.pr.new/pretty-format@15685

commit: aad1204

@SimenB SimenB merged commit 054fa33 into jestjs:main Jun 18, 2025
76 checks passed
@JounQin JounQin deleted the refactor/isBuiltin branch June 18, 2025 13:21
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0