File tree Expand file tree Collapse file tree
test/configCases/runtime/hashing-error-non-error Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,9 +148,10 @@ class RuntimeModule extends Module {
148148 this . generate ( )
149149 : this . getGeneratedCode ( ) ;
150150 } catch ( err ) {
151+ const { toError } = require ( "../errors/ErrorHelpers" ) ;
151152 const RuntimeModuleGenerationError = require ( "../errors/RuntimeModuleGenerationError" ) ;
152153
153- throw new RuntimeModuleGenerationError ( this , /** @type { Error } */ ( err ) ) ;
154+ throw new RuntimeModuleGenerationError ( this , toError ( err ) ) ;
154155 }
155156 if ( code !== null && code !== undefined ) {
156157 hash . update ( code ) ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ module . exports = [
4+ [
5+ / G e n e r a t i n g t h e r u n t i m e m o d u l e w e b p a c k \/ r u n t i m e \/ t h r o w i n g n o n e r r o r \( T h r o w i n g N o n E r r o r R u n t i m e M o d u l e \) f o r h a s h i n g f a i l e d : / ,
6+ / g e n e r a t e o f t h e t h r o w i n g r u n t i m e m o d u l e f a i l e d /
7+ ] ,
8+ [ / g e n e r a t e o f t h e t h r o w i n g r u n t i m e m o d u l e f a i l e d / ]
9+ ] ;
Original file line number Diff line number Diff line change 1+ it ( "should name the runtime module that threw a non-Error value" , ( ) => {
2+ expect ( 1 ) . toBe ( 1 ) ;
3+ } ) ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ const { RuntimeModule } = require ( "../../../../" ) ;
4+
5+ const PLUGIN_NAME = "ThrowingNonErrorRuntimeModulePlugin" ;
6+
7+ class ThrowingNonErrorRuntimeModule extends RuntimeModule {
8+ constructor ( ) {
9+ super ( "throwing non error" ) ;
10+ }
11+
12+ /**
13+ * Generates runtime code for this runtime module.
14+ * @returns {string } runtime code
15+ */
16+ generate ( ) {
17+ // eslint-disable-next-line no-throw-literal
18+ throw "generate of the throwing runtime module failed" ;
19+ }
20+ }
21+
22+ /** @type {import("../../../../").Configuration } */
23+ module . exports = {
24+ plugins : [
25+ {
26+ apply ( compiler ) {
27+ compiler . hooks . thisCompilation . tap ( PLUGIN_NAME , ( compilation ) => {
28+ compilation . hooks . additionalTreeRuntimeRequirements . tap (
29+ PLUGIN_NAME ,
30+ ( chunk ) => {
31+ compilation . addRuntimeModule (
32+ chunk ,
33+ new ThrowingNonErrorRuntimeModule ( )
34+ ) ;
35+ }
36+ ) ;
37+ } ) ;
38+ }
39+ }
40+ ]
41+ } ;
You can’t perform that action at this time.
0 commit comments