The Plugin

SharedLibraryWebpackPlugin

SharedLibraryWebpackPlugin is a class that implements webpack plugin functionality,

Options

libs

Description
Example
string | SharedLibrarySearchConfig | Array<string | SharedLibrarySearchConfig>
An option that configures the search for shared libraries and the formation of a chunk name. It can be a string or SharedLibrarySearchConfig or an array of them.
new SharedLibraryWebpackPlugin({
libs: 'lodash'
});
new SharedLibraryWebpackPlugin({
libs: '@angular/**'
});
new SharedLibraryWebpackPlugin({
libs: ['@angular/**', 'zone.js/dist/zone']
});
new SharedLibraryWebpackPlugin({
libs: {name: '@angular/core', chunkName: 'ng', separator: '@'}
});

namespace

Description
Example
string
The namespace for saving exported libraries
{
namespace: "__shared_libraries__"
}

disableDefaultJsonpFunctionChange

Description
Example
boolean
By default: false
If true jsonpFunction will be replaced with a random name
{
disableDefaultJsonpFunctionChange: false
}

SharedLibrarySearchConfig

SharedLibrarySearchConfig configures the search for sharing library and the formation of a chunk name.

pattern

Description
Example
string
An option to search for libraries in a bundle.
{
pattern: "@angular/**"
}

name

Description
Example
string
A name to search for a library in a bundle.
{
name: "@angular/core"
}

chunkName

Description
Example
string
A name of a shared chunk
If a pattern exists chunkName is ignored
{
chunkName: "ng"
}

suffix

Description
Example
string
A chunk name suffix
By default library version {major}.{minor}-{prerelease}
{
suffix: 'suffix'
}

separator

Description
Example
string
Separator for a chunk name and suffix
{
separator: "@"
}

deps

Description
Example
string[]
Libraries that the current one depends on.
new SharedLibraryWebpackPlugin({
libs: [
'@angular/**',
{name: '@tinkoff/angular-ui', deps: ['@angular/core']}
]
})

usedExports

Description
Example
string[]
The import names to be used by another application
{name: '@angular/core', usedExports: ['DomSanitizer']}