{"id":20266,"library":"pnp-webpack-plugin","title":"pnp-webpack-plugin","description":"Webpack plugin for Yarn Plug'n'Play (PnP) resolution, version 1.7.0. It integrates PnP into Webpack's resolver and resolveLoader, allowing dependencies to be resolved from zip archives without node_modules. Updated occasionally; key differentiator: enables PnP in Webpack builds where packages are hoisted into compressed archives, avoiding disk I/O for package resolution. Alternatives include manual resolve.alias configuration or disabling PnP.","status":"active","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/arcanis/pnp-webpack-plugin","tags":["javascript","webpack","yarn","plugnplay","pnp"],"install":[{"cmd":"npm install pnp-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add pnp-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add pnp-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for resolver plugin integration","package":"webpack","optional":false}],"imports":[{"note":"The package is CommonJS only; ESM import via Babel or TypeScript may fail without interop.","wrong":"import PnpWebpackPlugin from 'pnp-webpack-plugin';","symbol":"default plugin","correct":"const PnpWebpackPlugin = require('pnp-webpack-plugin');"},{"note":"moduleLoader requires the `module` object (typically from Node.js) to resolve loaders relative to the config file.","wrong":"PnpWebpackPlugin.moduleLoader()","symbol":"moduleLoader","correct":"PnpWebpackPlugin.moduleLoader(module)"},{"note":"The plugin is not a constructor; it is already an instance of WebpackPluginInstance.","wrong":"new PnpWebpackPlugin()","symbol":"PnpWebpackPlugin as WebpackPluginInstance","correct":"PnpWebpackPlugin"}],"quickstart":{"code":"const PnpWebpackPlugin = require('pnp-webpack-plugin');\n\nmodule.exports = {\n  resolve: {\n    plugins: [PnpWebpackPlugin],\n  },\n  resolveLoader: {\n    plugins: [PnpWebpackPlugin.moduleLoader(module)],\n  },\n};","lang":"javascript","description":"Shows minimal Webpack config adding PnP resolver for both modules and loaders."},"warnings":[{"fix":"Replace loader name string with require.resolve('loader-name').","message":"When using PnP, loaders must be resolved via require.resolve() in webpack config rules to avoid resolution failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using @yarnpkg/pnpify or webpack's built-in PnP support.","message":"The package is not actively maintained; Webpack 5 may require alternative integration.","severity":"deprecated","affected_versions":">=1.7.0"},{"fix":"Always add resolveLoader.plugins with PnpWebpackPlugin.moduleLoader(module).","message":"Does not resolve loaders inside node_modules automatically; moduleLoader must be used.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use require.resolve('some-loader') in the loader option.","cause":"Loader referenced by string name, not require.resolve; PnP cannot resolve it.","error":"Error: Cannot find module 'some-loader'"},{"fix":"Add PnpWebpackPlugin to resolve.plugins in webpack config.","cause":"PnP resolver not configured in resolve.plugins.","error":"Module not found: Error: Can't resolve 'some-package'"},{"fix":"Remove 'new' keyword: resolve: { plugins: [PnpWebpackPlugin] }","cause":"Using new PnpWebpackPlugin() instead of direct reference.","error":"TypeError: PnpWebpackPlugin is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}