{"id":22160,"library":"rollup-plugin-pnp-resolve","title":"rollup-plugin-pnp-resolve","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/arcanis/rollup-plugin-pnp-resolve","tags":["javascript","rollup","yarn","plugnplay","pnp"],"install":[{"cmd":"npm install rollup-plugin-pnp-resolve","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-pnp-resolve","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-pnp-resolve","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required when bundling CommonJS modules alongside PnP-resolved ES modules","package":"rollup-plugin-commonjs","optional":true}],"imports":[{"note":"Package exports a default function; default import works in ESM. In CommonJS, require yields the function directly.","wrong":"const pnpResolve = require('rollup-plugin-pnp-resolve').default","symbol":"default","correct":"import pnpResolve from 'rollup-plugin-pnp-resolve'"},{"note":"CommonJS require returns the function directly, not an object with a named export.","wrong":"const { resolve } = require('rollup-plugin-pnp-resolve')","symbol":"default (CommonJS)","correct":"const resolve = require('rollup-plugin-pnp-resolve')"},{"note":"pnpResolve is a factory function, not a constructor. Call it to get the plugin instance.","wrong":"plugins: [new pnpResolve()]","symbol":"Rollup Plugin","correct":"plugins: [pnpResolve({ extensions: ['.js'] })]"}],"quickstart":{"code":"// rollup.config.js\nimport pnpResolve from 'rollup-plugin-pnp-resolve';\nimport commonjs from 'rollup-plugin-commonjs';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs',\n  },\n  plugins: [\n    commonjs(),\n    pnpResolve({ extensions: ['.js', '.jsx'] })\n  ]\n};","lang":"javascript","description":"Basic Rollup config using PnP resolve with CommonJS support and custom extensions."},"warnings":[{"fix":"Order plugins: commonjs() first, then pnpResolve().","message":"The plugin must be placed after rollup-plugin-commonjs in the plugins array to ensure CommonJS modules are transformed before resolution.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update Rollup to >=1.0.0 and ensure plugin is invoked as a function (e.g., pnpResolve()).","message":"Version 2.0.0 dropped support for Rollup <1.0.0 and changed the API to a function that returns a plugin object.","severity":"breaking","affected_versions":"2.0.0"},{"fix":"Consider using @yarnpkg/plugin-rollup for official Yarn PnP integration.","message":"The package may not be actively maintained; Yarn's PnP support is now built into Yarn's own Rollup plugin and other official tools.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Consult PnP API documentation for valid options (e.g., extensions, basedir).","message":"Options passed to pnpResolve are forwarded to PnP's resolveRequest; not all options may be supported.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"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).","cause":"Package not installed or Yarn PnP not enabled.","error":"Error: Cannot find module 'rollup-plugin-pnp-resolve'"},{"fix":"In CommonJS: const pnpResolve = require('rollup-plugin-pnp-resolve'). In ESM: import pnpResolve from 'rollup-plugin-pnp-resolve'.","cause":"Using default import in CommonJS or incorrect import syntax.","error":"TypeError: pnpResolve is not a function"},{"fix":"Use pnpResolve() in plugins array, not pnpResolve.","cause":"Calling pnpResolve without invoking it as a function (i.e., passing the function instead of calling it).","error":"Error: Plugin returned something but it is not a valid plugin."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}