Skip to content

chore: bump unrs-resolver to 1.11.0, remove jest-pnp-resolver and unnecessary checks #15721

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ compressionLevel: mixed

enableGlobalCache: true

enableTelemetry: false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It slows every yarn related command.


logFilters:
- code: YN0032
level: discard
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## main

### Features

- `[resolve]` Bump `unrs-resolver` to 1.11.0, remove `jest-pnp-resolver` and unnecessary checks ([#15721](https://github.com/jestjs/jest/pull/15721))

### Fixes

- `[expect]` Fix `bigint` error ([#15702](https://github.com/jestjs/jest/pull/15702))
Expand Down
4 changes: 2 additions & 2 deletions e2e/__tests__/__snapshots__/moduleNameMapper.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`moduleNameMapper wrong array configuration 1`] = `
12 | module.exports = () => 'test';
13 |

at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1117:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1095:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
Expand Down Expand Up @@ -71,7 +71,7 @@ exports[`moduleNameMapper wrong configuration 1`] = `
12 | module.exports = () => 'test';
13 |

at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1117:17)
at createNoMappedModuleFoundError (../../packages/jest-resolve/build/index.js:1095:17)
at Object.require (index.js:10:1)
at Object.require (__tests__/index.js:10:20)"
`;
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/requireMissingExt.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`shows a proper error from deep requires 1`] = `
12 | test('dummy', () => {
13 | expect(1).toBe(1);

at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:863:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:841:11)
at Object.<anonymous> (node_modules/discord.js/src/index.js:21:12)
at Object.require (__tests__/test.js:10:1)"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`show error message with matching files 1`] = `
| ^
9 |

at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:863:11)
at Resolver._throwModNotFoundError (../../packages/jest-resolve/build/index.js:841:11)
at Object.require (index.js:8:18)
at Object.require (__tests__/test.js:8:11)"
`;
2 changes: 1 addition & 1 deletion e2e/pnp/__tests__/undeclared-dependency.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
it('should surface pnp errors', () => {
expect(() => {
require('undeclared');
}).toThrow(expect.objectContaining({code: 'MODULE_NOT_FOUND'}));
}).toThrow("Cannot find module 'unesitent_module__'");
Copy link
Member

Choose a reason for hiding this comment

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

Why no longer error code? And where does unesitent_module__ (typo and all) come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

const nope = require('unesitent_module__');

The error message comes from unrs-resolver if this PR merged, and it comes from jest-pnp-resolver before.

});
3 changes: 1 addition & 2 deletions packages/jest-resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
"chalk": "^4.1.2",
"graceful-fs": "^4.2.11",
"jest-haste-map": "workspace:*",
"jest-pnp-resolver": "^1.2.3",
"jest-util": "workspace:*",
"jest-validate": "workspace:*",
"slash": "^3.0.0",
"unrs-resolver": "^1.7.11"
"unrs-resolver": "^1.11.0"
},
"devDependencies": {
"@types/graceful-fs": "^4.1.9",
Expand Down
19 changes: 1 addition & 18 deletions packages/jest-resolve/src/defaultResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
*/

import {isBuiltin} from 'module';
import {fileURLToPath} from 'url';
import pnpResolver from 'jest-pnp-resolver';
import {
type ResolveResult,
ResolverFactory,
Expand Down Expand Up @@ -40,12 +38,6 @@ export interface ResolverOptions extends UpstreamResolveOptions {
paths?: Array<string>;
/** Current root directory. */
rootDir?: string;

/**
* @internal Whether to allow the `jest-pnp-resolver` to be used.
* @see https://github.com/arcanis/jest-pnp-resolver/blob/ae8e3992349f3b43d1476572e9315e14358e8944/index.js#L49
*/
allowPnp?: boolean;
}

export type SyncResolver = (path: string, options: ResolverOptions) => string;
Expand Down Expand Up @@ -74,20 +66,11 @@ function baseResolver(
options: ResolverOptions,
async?: true,
): string | Promise<string> {
// https://github.com/oxc-project/oxc-resolver/issues/565
// https://github.com/jestjs/jest/issues/15676
// `builtins` in `unrs-resolver` is static which could be wrong at runtime.
if (isBuiltin(path)) {
return path;
}

if (process.versions.pnp && options.allowPnp !== false) {
return pnpResolver(path, options);
}

if (path.startsWith('file://')) {
path = fileURLToPath(path);
}

/* eslint-disable prefer-const */
let {
basedir,
Expand Down
Loading
Loading