Webpack plugin (v1.1.0) to exclude Yarn Plug'n'Play (PnP) modules from the bundle, intended for backend bundles using Yarn PnP. Works with Webpack 4 and 5. It complements webpack-node-externals by resolving PnP packages to their virtual locators, preventing bundling of dependencies that should be loaded at runtime. It supports include/exclude filters and custom import types. Lightweight, no runtime dependencies. Minimal maintenance frequency as of 2023.
npm install webpack-pnp-externalsVerified import paths — ran on the pinned version, not inferred.
Shows how to use WebpackPnpExternals in webpack config to externalize Yarn PnP packages with include/exclude filters and custom import type.
Use WebpackPnpExternals() with parentheses, not WebpackPnpExternals.
For Yarn Berry, consider using webpack-plugin-yarn-pnp-externals or manually configuring externals with locator logic.
Use RegExp for substring matching, e.g., include: /^lodash/.
Upgrade to Webpack 5 for full compatibility.
Install: npm install -D webpack-pnp-externals
Use require syntax: const { WebpackPnpExternals } = require('webpack-pnp-externals');Check that options.include/exclude are valid types; ensure WebpackPnpExternals() is called with parentheses.