Registry / devops / webpack-pnp-externals

webpack-pnp-externals

JSON →
library1.1.0jsnpmunverified

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-externals
INSTALL
IMPORT
SIG · WEBPACK-PNP-EXTERN
W
webpack-pnp-externals
devopsjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

WebpackPnpExternals
const { WebpackPnpExternals } = require('webpack-pnp-externals')
import WebpackPnpExternals from 'webpack-pnp-externals'
Package is CJS-only; ES modules import syntax will fail. Use require or dynamic import().
default
const WebpackPnpExternals = require('webpack-pnp-externals')
const { default: WebpackPnpExternals } = require('webpack-pnp-externals')
The package exports a named export 'WebpackPnpExternals' which is a function. Default import is not provided.
WebpackPnpExternals
import { WebpackPnpExternals } from 'webpack-pnp-externals'
TypeScript users: this package has no type definitions. Declare module or use @types/webpack-pnp-externals if available.

Shows how to use WebpackPnpExternals in webpack config to externalize Yarn PnP packages with include/exclude filters and custom import type.

const { WebpackPnpExternals } = require('webpack-pnp-externals'); module.exports = { target: 'node', externals: [ WebpackPnpExternals({ include: /^lodash/, exclude: ['lodash.omit'], importType: 'commonjs2' }) ] };
Debug
Known issues
gotchaWebpackPnpExternals() must be called (returning a function) in the externals array; passing the reference without invoking will fail.
fix
Use WebpackPnpExternals() with parentheses, not WebpackPnpExternals.
affects: >=1.0.0
gotchaOnly works with Yarn Classic (v1) PnP; Yarn Berry (v2+) has different PnP resolution that is not supported.
fix
For Yarn Berry, consider using webpack-plugin-yarn-pnp-externals or manually configuring externals with locator logic.
affects: >=1.0.0
gotchaThe 'include' and 'exclude' options can be a string, RegExp, function, or array. Using a string matches the request exactly, not a substring.
fix
Use RegExp for substring matching, e.g., include: /^lodash/.
affects: >=1.0.0
deprecatedWebpack 4 is no longer supported by the package explicitly; but it still works. No deprecation warnings.
fix
Upgrade to Webpack 5 for full compatibility.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'webpack-pnp-externals'
Package not installed or not in node_modules.
fix
Install: npm install -D webpack-pnp-externals
TypeError: WebpackPnpExternals is not a function
Using import statement in CJS context, or misspelling the import.
fix
Use require syntax: const { WebpackPnpExternals } = require('webpack-pnp-externals');
Error: Externals function must return a string, array, or object.
WebpackPnpExternals() returned a non-standard value, likely due to invalid options.
fix
Check that options.include/exclude are valid types; ensure WebpackPnpExternals() is called with parentheses.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency for externals configuration
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
webpack-pnp-externals — npm install webpack-pnp-externals · libregistry