You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

webpack-pnp-externals

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-pnp-externals

Exclude Yarn PnP modules from the webpack bundle

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
1.4K
-13.37%
Maintainers
1
Weekly downloads
 
Created
Source

Webpack PnP Externals

Allows you to exclude modules installed using Yarn's PnP from the bundle. Mostly useful for the backend. Intended to be used alongside webpack-node-externals. Works with both Webpack 4 and 5.

Installation

npm install -D webpack-pnp-externals

Usage

Webpack Documentation: Externals.

const {WebpackPnpExternals} = require('webpack-pnp-externals');

module.exports = {
    //...
    externals: [
        WebpackPnpExternals()
    ]
    //...
};

This will exclude all PnP modules from the bundle and instead load them with require.

Options

  • include Only externalizes the matching requests. Can be one of the following types:
    • string A string to match the request against exactly.
    • RegExp A regex pattern to match the request against.
    • function: (request: string, resolution: string) -> boolean A custom function to check whether to externalize the request.
      • request The content of the import statement.
      • resolution The file which the request resolved to.
    • Array An array of the preceding to be or-ed together.
  • exclude Same as include, but excludes requests that match.
  • importType (default 'commonjs') The external type to use when loading the externalized modules. Can be one of the following types:
    • string A type to use for all modules.
    • function: (request: string, resolution: string) -> string A custom function to get the external type for a given request and resolution.

License

MIT

FAQs

Package last updated on 12 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts