Allow private class members to be mangled
Openlayers classes use an underscore suffix convention to mark class members as private. These are undocumented implementation details and presumably unsafe for code outside the class to rely on. Allowing javascript minimisation to change these names gives 5% bundle size reduction to the library.
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: './build/index.js',
|
entry: './build/index.js',
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
@@ -30,6 +32,16 @@ module.exports = {
|
|||||||
ol: path.resolve('./build/ol'),
|
ol: path.resolve('./build/ol'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
optimization: {
|
||||||
|
minimizer: [
|
||||||
|
new TerserPlugin({
|
||||||
|
terserOptions: {
|
||||||
|
// Mangle private members convention with underscore suffix
|
||||||
|
mangle: {properties: {regex: /_$/}},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
},
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve('./build/legacy'),
|
path: path.resolve('./build/legacy'),
|
||||||
filename: 'ol.js',
|
filename: 'ol.js',
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ module.exports = {
|
|||||||
// Do not minify examples that inject code into workers
|
// Do not minify examples that inject code into workers
|
||||||
exclude: [/(color-manipulation|region-growing|raster)\.js/],
|
exclude: [/(color-manipulation|region-growing|raster)\.js/],
|
||||||
extractComments: false,
|
extractComments: false,
|
||||||
|
terserOptions: {
|
||||||
|
// Mangle private members convention with underscore suffix
|
||||||
|
mangle: {properties: {regex: /_$/}},
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
runtimeChunk: {
|
runtimeChunk: {
|
||||||
|
|||||||
Reference in New Issue
Block a user