Skip to content

Support babel option includeNodeModules with pnpm #785

@leonexcc

Description

@leonexcc

The option includeNodeModules of bable doesn't work with pnpm, since filePath will contain the real path after resolving the link (for example .../node_modules/.pnpm/plyr@3.6.2/node_modules/plyr/...)

After replacing

const whitelistedModules = options[optionKey].map(
     module => path.join('node_modules', module) + path.sep
);

with

const whitelistedModules = options[optionKey].map(
    module => path.dirname(require.resolve(module + '/package.json'))
);

it works as expected.

Also the mapping is currently executed for each file again. This could probably done once outside of the callback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions