1.1.0 • Published 5 years ago
webpack-pnp-externals v1.1.0
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-externalsUsage
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
includeOnly externalizes the matching requests. Can be one of the following types:stringA string to match the request against exactly.RegExpA regex pattern to match the request against.function: (request: string, resolution: string) -> booleanA custom function to check whether to externalize the request.requestThe content of the import statement.resolutionThe file which the request resolved to.
ArrayAn array of the preceding to be or-ed together.
excludeSame asinclude, 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:stringA type to use for all modules.function: (request: string, resolution: string) -> stringA custom function to get the external type for a given request and resolution.