Skip to content

Instantly share code, notes, and snippets.

@jahredhope
Last active December 27, 2018 12:20
Show Gist options
  • Save jahredhope/684d409debfd32da7b94637fc6e6cf2f to your computer and use it in GitHub Desktop.
Save jahredhope/684d409debfd32da7b94637fc6e6cf2f to your computer and use it in GitHub Desktop.
Webpack v5 toJson namedChunkGroups
/**
* Demonstrates the different between Webpack v4 and Webpack v5 toJson behaviour
**/
const webpack = require("webpack");
const compiler = webpack({});
compiler.run((err, res) => {
if (err) {
console.log({ err });
throw err;
}
const stats = res.toJson();
/**
* Webpack 4
* stats.namedChunkGroups = { main:
* { chunks: [ 0 ],
* assets: [ 'main.js' ],
* children: [Object: null prototype] {},
* childAssets: [Object: null prototype] {},
* isOverSizeLimit: undefined } }
**/
/**
* Webpack 5
* stats.namedChunkGroups = [Object: null prototype] {}
**/
console.log("stats.namedChunkGroups", stats.namedChunkGroups);
if (!stats.namedChunkGroups.main) {
throw new Error("main not found in namedChunkGroups");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment