-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this 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.', () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
👍
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
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. |
Summary
I believe we don't need a custom
isBuiltinModule
anymore.Test plan