Skip to content

fix: resolve builtin modules correctly #15683

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
Merged

Conversation

JounQin
Copy link
Collaborator

@JounQin JounQin commented Jun 18, 2025

Summary

close #15676

Test plan

Copy link

netlify bot commented Jun 18, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 35b947a
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6852ab053aa17a00083ba001
😎 Deploy Preview https://deploy-preview-15683--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, cpojer and SimenB June 18, 2025 07:16
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 fixes the resolution of built-in modules in jest-resolver by adding an early exit for built-in module paths and refining the resolver state management.

  • Added an import and early return for built-in modules using isBuiltin.
  • Adjusted the placement of the setResolver calls to update resolver state within the final resolver callback.
  • Updated CHANGELOG.md to reflect the fix.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/jest-resolve/src/defaultResolver.ts Introduces isBuiltin check and refines resolver state updates.
CHANGELOG.md Updates documentation with the fix details.

Copy link

pkg-pr-new bot commented Jun 18, 2025

Open in StackBlitz

babel-jest

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

babel-plugin-jest-hoist

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

babel-preset-jest

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

create-jest

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

@jest/diff-sequences

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

expect

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

@jest/expect-utils

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

jest

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

jest-changed-files

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

jest-circus

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

jest-cli

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

jest-config

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

@jest/console

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

@jest/core

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

@jest/create-cache-key-function

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

jest-diff

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

jest-docblock

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

jest-each

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

@jest/environment

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

jest-environment-jsdom

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

@jest/environment-jsdom-abstract

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

jest-environment-node

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

@jest/expect

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

@jest/fake-timers

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

@jest/get-type

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

@jest/globals

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

jest-haste-map

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

jest-jasmine2

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

jest-leak-detector

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

jest-matcher-utils

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

jest-message-util

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

jest-mock

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

@jest/pattern

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

jest-phabricator

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

jest-regex-util

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

@jest/reporters

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

jest-resolve

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

jest-resolve-dependencies

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

jest-runner

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

jest-runtime

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

@jest/schemas

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

jest-snapshot

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

@jest/snapshot-utils

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

@jest/source-map

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

@jest/test-result

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

@jest/test-sequencer

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

@jest/transform

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

@jest/types

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

jest-util

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

jest-validate

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

jest-watcher

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

jest-worker

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

pretty-format

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

commit: 35b947a

@JounQin JounQin force-pushed the fix/builtin_modules branch from c50b48f to 705726e Compare June 18, 2025 07:40
@SimenB
Copy link
Member

SimenB commented Jun 18, 2025

can you add a test?

@JounQin
Copy link
Collaborator Author

JounQin commented Jun 18, 2025

can you add a test?

@SimenB Done!

@cpojer cpojer enabled auto-merge (squash) June 18, 2025 12:10
@cpojer cpojer disabled auto-merge June 18, 2025 12:10
@cpojer cpojer merged commit edc3272 into jestjs:main Jun 18, 2025
76 checks passed
@JounQin JounQin deleted the fix/builtin_modules branch June 18, 2025 12:22
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.

[Bug]: "Cannot find module" with automocked Node.js builtin module and custom resolver in v30
3 participants