Skip to content

Bug: resolves using node_modules when using PnP #273

@merceyz

Description

@merceyz

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`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions