Last active
December 27, 2018 12:20
-
-
Save jahredhope/684d409debfd32da7b94637fc6e6cf2f to your computer and use it in GitHub Desktop.
Webpack v5 toJson namedChunkGroups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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