Skip to content
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

Fix module identity preservation with symlinks and browser field resolution #9511

Merged
merged 6 commits into from Feb 4, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/jest-resolve/src/defaultResolver.ts
Expand Up @@ -35,14 +35,20 @@ export default function defaultResolver(

const resolve = options.browser ? browserResolve : resolveSync;

return resolve(path, {
let result = resolve(path, {
basedir: options.basedir,
defaultResolver,
extensions: options.extensions,
moduleDirectory: options.moduleDirectory,
paths: options.paths,
rootDir: options.rootDir,
});
if (options.browser && result) {
// Dereference symlinks to ensure we don't create a separate
// module instance depending on how it was referenced.
result = fs.realpathSync(result);
rtsao marked this conversation as resolved.
Show resolved Hide resolved
}
return result;
}

export const clearDefaultResolverCache = () => {
Expand Down