webpack / webpack/enhanced-resolve
Bug: resolves using node_modules when using PnP
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 983
- Forks
- 206
- Avg merge
- 23h 27m
- Merged PRs (30d)
- 15
Description
Describe the bug
When running under Yarn PnP enhanced-resolve will still use the node_modules resolution
To Reproduce
Setup:
mkdir repro && cd repro
yarn init -y
yarn set version berry
yarn add enhanced-resolve@5.4.1 lodash@4.17.20
Code:
import { ResolverFactory, CachedInputFileSystem } from 'enhanced-resolve';
import path from 'path';
import fs from 'fs';
const cachedFS = new CachedInputFileSystem(fs);
const commonResolver = ResolverFactory.createResolver({
fileSystem: cachedFS,
useSyncFileSystemCalls: true,
});
fs.mkdirSync(path.join(__dirname, 'node_modules/lodash'), { recursive: true });
fs.writeFileSync(path.join(__dirname, 'node_modules/lodash/foo.js'), '');
commonResolver.resolveSync({}, __filename, 'lodash/foo');
throw new Error(`Resolve should have failed since lodash/foo doesn't exist`);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided Yarn Berry setup and inspect the ResolverFactory.createResolver and resolveSync entry points. Trace why the resolver accepts the created node_modules/lodash/foo.js under Yarn PnP. Done means the same resolveSync call fails when lodash/foo is unavailable through PnP, despite that node_modules path existing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100