Registry / devops / rollup-plugin-pnp-resolve

rollup-plugin-pnp-resolve

JSON →
library2.0.0jsnpmunverified

A Rollup plugin that resolves modules using Yarn's Plug'n'Play (PnP) API instead of the traditional node_modules resolution. Version 2.0.0 requires Node >=6 and supports Rollup's plugin system. It forwards options to PnP's resolveRequest, such as custom extensions. This plugin is part of a family of PnP resolvers for various tools including TypeScript (ts-pnp), Webpack (pnp-webpack-plugin), and Jest (jest-pnp-resolver). Unlike traditional resolvers, it directly uses the PnP dependency tree for faster and more reliable resolution in Yarn PnP projects, eliminating the need for node_modules.

npm install rollup-plugin-pnp-resolve
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-PNP-
R
rollup-plugin-pnp-resolve
devopsjavascriptv2.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ import pnpResolve from 'rollup-plugin-pnp-resolve'
✗ const pnpResolve = require('rollup-plugin-pnp-resolve').default
Package exports a default function; default import works in ESM. In CommonJS, require yields the function directly.
default (CommonJS)
✓ const resolve = require('rollup-plugin-pnp-resolve')
✗ const { resolve } = require('rollup-plugin-pnp-resolve')
CommonJS require returns the function directly, not an object with a named export.
Rollup Plugin
✓ plugins: [pnpResolve({ extensions: ['.js'] })]
✗ plugins: [new pnpResolve()]
pnpResolve is a factory function, not a constructor. Call it to get the plugin instance.

Basic Rollup config using PnP resolve with CommonJS support and custom extensions.

// rollup.config.js import pnpResolve from 'rollup-plugin-pnp-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'cjs', }, plugins: [ commonjs(), pnpResolve({ extensions: ['.js', '.jsx'] }) ] };
Debug
Known issues
gotchaThe plugin must be placed after rollup-plugin-commonjs in the plugins array to ensure CommonJS modules are transformed before resolution.
fix
Order plugins: commonjs() first, then pnpResolve().
affects: >=1.0.0
breakingVersion 2.0.0 dropped support for Rollup <1.0.0 and changed the API to a function that returns a plugin object.
fix
Update Rollup to >=1.0.0 and ensure plugin is invoked as a function (e.g., pnpResolve()).
affects: 2.0.0
deprecatedThe package may not be actively maintained; Yarn's PnP support is now built into Yarn's own Rollup plugin and other official tools.
fix
Consider using @yarnpkg/plugin-rollup for official Yarn PnP integration.
affects: >=1.0.0
gotchaOptions passed to pnpResolve are forwarded to PnP's resolveRequest; not all options may be supported.
fix
Consult PnP API documentation for valid options (e.g., extensions, basedir).
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-pnp-resolve'
Package not installed or Yarn PnP not enabled.
fix
Ensure the package is installed with Yarn PnP (yarn add -D rollup-plugin-pnp-resolve) and that you are using Yarn PnP (not node_modules).
TypeError: pnpResolve is not a function
Using default import in CommonJS or incorrect import syntax.
fix
In CommonJS: const pnpResolve = require('rollup-plugin-pnp-resolve'). In ESM: import pnpResolve from 'rollup-plugin-pnp-resolve'.
Error: Plugin returned something but it is not a valid plugin.
Calling pnpResolve without invoking it as a function (i.e., passing the function instead of calling it).
fix
Use pnpResolve() in plugins array, not pnpResolve.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
rollup-plugin-commonjsoptionalRequired when bundling CommonJS modules alongside PnP-resolved ES modules
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-pnp-resolve — npm install rollup-plugin-pnp-resolve · libregistry