From 4e3ede8fb66c0104613f1d26f3984c82392f86c6 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 15 Apr 2017 18:51:09 +0200 Subject: [PATCH] Clarify output.strictModuleExceptionHandling --- content/configuration/output.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/content/configuration/output.md b/content/configuration/output.md index ff218e4f5f24..91c703ae3ccb 100644 --- a/content/configuration/output.md +++ b/content/configuration/output.md @@ -531,12 +531,34 @@ There is no need to change it. `boolean` -Tell webpack to remove a module from cache if it throws an exception when it is `require`d. +Tell webpack to remove a module from the module instance cache (`require.cache`) if it throws an exception when it is `require`d. It defaults to `false` for performance reasons. When set to `false`, the module is not removed from cache, which results in the exception getting thrown only on the first `require` call (making it incompatible with node.js). +For instance, consider `module.js`: + +``` js +throw new Error("error"); +``` + +With `strictModuleExceptionHandling` set to `false`, only the first `require` throws an exception: + +``` js +// with strictModuleExceptionHandling = false +require("module") // <- throws +require("module") // <- doesn't throw +``` + +Instead, with `strictModuleExceptionHandling` set to `true`, all `require`s of this module throw an exception: + +``` js +// with strictModuleExceptionHandling = true +require("module") // <- throws +require("module") // <- also throw +``` + ## `output.umdNamedDefine`