Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.6k
feat: implement thedefaultAsyncResolver#15679
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
netlifybot commentedJun 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview forjestjs ready!Builtwithout sensitive environment variables
To edit notification comments on pull requests, go to yourNetlify project configuration. |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
pkg-pr-newbot commentedJun 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
babel-jestbabel-plugin-jest-hoistbabel-preset-jestcreate-jest@jest/diff-sequencesexpect@jest/expect-utilsjestjest-changed-filesjest-circusjest-clijest-config@jest/console@jest/core@jest/create-cache-key-functionjest-diffjest-docblockjest-each@jest/environmentjest-environment-jsdom@jest/environment-jsdom-abstractjest-environment-node@jest/expect@jest/fake-timers@jest/get-type@jest/globalsjest-haste-mapjest-jasmine2jest-leak-detectorjest-matcher-utilsjest-message-utiljest-mock@jest/patternjest-phabricatorjest-regex-util@jest/reportersjest-resolvejest-resolve-dependenciesjest-runnerjest-runtime@jest/schemasjest-snapshot@jest/snapshot-utils@jest/source-map@jest/test-result@jest/test-sequencer@jest/transform@jest/typesjest-utiljest-validatejest-watcherjest-workerpretty-formatcommit: |
7e1a758 to87874b1CompareThere 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.
Nice!
Could you update the changelog as well?
JounQin commentedJun 13, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Done! @SimenB CI is also passing now. |
bfd45e0 to47d9b5bCompareThere 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 adds and wires up an asynchronous version of Jest’s default module resolver across documentation, implementation, tests, snapshots, and the changelog.
- Introduces
defaultAsyncResolverAPI in the docs and types. - Refactors
defaultResolver.tsto share logic between sync and async resolver paths. - Updates
Resolverclass, tests, e2e snapshots, and the changelog to incorporate the new async resolver.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/versioned_docs/version-30.0/Configuration.md | Documented the newdefaultAsyncResolver option |
| packages/jest-resolve/src/resolver.ts | PasseddefaultAsyncResolver into sync/async flows |
| packages/jest-resolve/src/defaultResolver.ts | Extracted common logic and exported async resolver |
| packages/jest-resolve/src/tests/resolve.test.ts | Imported and asserted presence of the new resolver |
| e2e/tests/* | Updated stack-trace line numbers in snapshots |
| CHANGELOG.md | Logged the feature under[jest-resolver] |
Comments suppressed due to low confidence (3)
packages/jest-resolve/src/defaultResolver.ts:97
- Removing the absolute resolution of
basedirmay allow relative directories to slip through, potentially breaking resolution. Consider reintroducingbasedir = path.resolve(basedir);or validating thatoptions.basediris always absolute.
// make sure that `basedir` is an absolute pathpackages/jest-resolve/src/tests/resolve.test.ts:16
- We should add direct tests for
defaultAsyncResolverto confirm it returns the same results asdefaultResolverwhen resolving valid paths and rejects on missing modules.
import defaultResolver, {defaultAsyncResolver} from '../defaultResolver';website/versioned_docs/version-30.0/Configuration.md:1499
- [nitpick] Consider adding a short code snippet showing how to call
defaultAsyncResolverwithin an async custom resolver, mirroring the example fordefaultResolverabove.
Similarly, the `defaultAsyncResolver` is the default async resolver which takes the same arguments and returns a promise that resolves with a string or rejects with an error.42c8e7d intojestjs:mainUh oh!
There was an error while loading.Please reload this page.
| }); | ||
| }; | ||
| ``` | ||
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.
There is another way to do similar with new resolver:
module.exports=(path,options)=>{// Call the defaultResolver, so we leverage its cache, error handling, etc.returnoptions.defaultResolver(path,{ ...options,// HACK!!!// this is option from unrs-resolver from https://github.com/unrs/unrs-resolver?tab=readme-ov-file#main-field// unrs-resolver used from jest-resolve now https://github.com/jestjs/jest/blob/v30.0.0/packages/jest-resolve/src/defaultResolver.ts#L84-L98// We use the fact that jest-resolve just pass extra options to resolvermainFields:["react-native","main"],});};
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.
that seems like a very reasonable way of doing it. should be added to the docs 😀
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.
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.
@JounQin I'd love to do it. Today or tomorrow!
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.
As for exposing options from unrs-resolver, it seems it is not necessary, interface ResolverOptions alreadyextends UpstreamResolveOptions.
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. |
Uh oh!
There was an error while loading.Please reload this page.
Summary
Follow up#15619 (comment)
packageFilterhas been removed with#15619, so related document has just been updated.Test plan
cc@cpojer@SimenB