From c8c93d085933f49617baf624a80050064c13cbcf Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Fri, 4 Jan 2019 16:51:04 +0000 Subject: [PATCH] Hygiene: replace deprecated Webpack plugin Replace NamedModulesPlugin with `optimisations.namedModules = true`. Not to be confused with `optimization.namedModules` which is deprecated. https://github.com/webpack/webpack/releases/tag/v4.0.0 https://github.com/webpack/webpack/releases/tag/v4.16.0 Bug: T212527 Change-Id: Ie5c7b74e294b012f270de8a6ebc660bf5e75d478 --- webpack.config.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 9c260f00c..276d73463 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ /* global __dirname, process */ -const path = require( 'path' ), - webpack = require( 'webpack' ), +const + path = require( 'path' ), CleanPlugin = require( 'clean-webpack-plugin' ), PUBLIC_PATH = '/w/extensions/Popups', isProduction = process.env.NODE_ENV === 'production'; @@ -38,7 +38,14 @@ const conf = { optimization: { // Don't produce production output when a build error occurs. - noEmitOnErrors: isProduction + noEmitOnErrors: isProduction, + + // Use filenames instead of unstable numerical identifiers for file references. This + // increases the gzipped bundle size some but makes the build products easier to debug and + // appear deterministic. I.e., code changes will only alter the bundle they're packed in + // instead of shifting the identifiers in other bundles. + // https://webpack.js.org/guides/caching/#deterministic-hashes (namedModules replaces NamedModulesPlugin.) + namedModules: true }, output: { @@ -61,12 +68,7 @@ const conf = { devtool: 'source-map', plugins: [ - new CleanPlugin( distDir, { verbose: false } ), - - // To generate identifiers that are preserved over builds, webpack supplies - // the NamedModulesPlugin (generates comments with file names on bundle) - // https://webpack.js.org/guides/caching/#deterministic-hashes - new webpack.NamedModulesPlugin() + new CleanPlugin( distDir, { verbose: false } ) ], performance: {