Webpack 5.0.0, released on October 10, 2020, stops automatically supplying browser substitutes for Node.js core modules. For teams upgrading browser applications, an imported module that previously bundled successfully can now produce a module-not-found error. Build owners need to decide which missing functions the browser application actually uses before adding replacements. [S4][S2][S3]

Those substitutes, called polyfills, let code use functionality that its environment does not supply. Webpack 4 included them for many Node.js core modules when an imported module used those application programming interfaces, or APIs. The webpack project says this convenience could add large, unnecessary polyfills to the browser bundle. Version 5 favors frontend-compatible packages instead; the announcement does not put a number on the savings for a particular application. [S4]

The initial webpack 5 release puts migration advice in the missing-module error itself. For path, the diagnostic identifies path-browserify as a replacement package. It tells developers to install the package and add a resolve.fallback entry mapping path to require.resolve("path-browserify"). Both steps belong to that repair: installing the package does not replace the configuration instruction. The advice applies when the application needs that polyfill, not to every browser build. [S2]

Setting the fallback value to false makes a different choice. The diagnostic describes this as substituting an empty module, not supplying a replacement implementation. An empty module cannot provide the omitted API’s behavior. For a migration test, check that the affected browser code does not need the module before choosing false, then exercise the feature in the browser. Silencing the missing-module error is not the same as restoring the feature. [S2]

The release announcement recommends trying frontend-compatible modules wherever possible. For application teams, that means checking the dependency’s browser support before adding substitutes locally. Package authors can make that choice available to their users through the browser field in package.json, supplying alternative implementations or dependencies for browser use. [S4]

Source documents

  1. Webpack 5 release — announcement at its October 10, 2020 repository commithttps://raw.githubusercontent.com/webpack/webpack.js.org/ef81ee1f2d496c6a49e61e34ffb7692db1ba54e7/src/content/blog/2020-10-10-webpack-5-release.md
  2. webpack v5.0.0 — ModuleNotFoundError implementationhttps://raw.githubusercontent.com/webpack/webpack/v5.0.0/lib/ModuleNotFoundError.js
  3. webpack v5.0.0 release metadatahttps://api.github.com/repos/webpack/webpack/releases/tags/v5.0.0