webpack 4: Changes Part 1 (week 24–25)

2017/09/11–2017/09/24

Tobias Koppers
Sep 25, 2017 · 3 min read

Sets

Many classes now use Sets (or SortableSets) on the API level now. This change may break plugins which try to modify these arrays.

Reason

Performance. “Deleting” and “Adding once” is now O(1) instead of O(n).

StackedSetMap

The Parser also uses Arrays/Objects to track renaming and variable definitions. The additional challenge here was the inheriting in AST scopes. Previously we just added definitions to the Array. When entering a scope we stored the array length, so we could reset length back to this value when leaving the scope. This was pretty efficient because arrays don’t have to be copied. For Objects we created a prototype chain

Chunk loading with Array push

In webpack 3 and lower chunks are loaded in this way:

(window.webpackJsonp = window.webpackJsonp || []).push([...])
  • This allow to put the webpack runtime into any chunk. In many cases no need for a manifest chunk anymore, you can put the runtime into the app chunk and keep the vendor chunk cached.

Sideeffect-free modules

I already talked about this in a previous blog post (“Pure Modules”). The flag was renamed to "side-effects": false. Take a look at the example here.

Deprecated stuff

The following API-things were removed:

  • Compilation.notCacheable
  • HMR orignalErrororiginalError
  • loaderContext resolveSync ( → resolve)
  • SourceMapDevToolPlugin with only a string argument
  • loaderContext options ( → LoaderOptionsPlugin for incompatible loaders, but eventually loaders should be fixed)


  • Trivago (Hotel metasearch) donated a total of $20,000
  • ag-Grid (DataGrid) donated a total of $17,500
  • Capital One (Bank) donated a total of $12,000
  • Slack (Web-IM) donated a total of $8,000
  • Full list

webpack

The official Medium publication for the webpack open source project!

Tobias Koppers

Written by

webpack

webpack

The official Medium publication for the webpack open source project!