File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ export const SSRModule = (config: string | InjectableConfig & { name: string })
11
11
let name : string
12
12
if ( typeof config === 'string' ) {
13
13
if ( configSets . has ( config ) ) {
14
- throw new Error ( `Duplicated Module name: ${ config } ` )
14
+ reportDuplicated ( config )
15
15
}
16
16
name = config
17
17
configSets . add ( config )
18
18
} else if ( config && typeof config . name === 'string' ) {
19
19
if ( configSets . has ( config . name ) ) {
20
- throw new Error ( `Duplicated Module name: ${ config . name } ` )
20
+ reportDuplicated ( config . name )
21
21
}
22
22
configSets . add ( config . name )
23
23
name = config . name
@@ -33,3 +33,11 @@ export const SSRModule = (config: string | InjectableConfig & { name: string })
33
33
return Injectable ( injectableConfig ) ( target )
34
34
}
35
35
}
36
+
37
+ function reportDuplicated ( moduleName : string ) {
38
+ if ( process . env . NODE_ENV === 'production' ) {
39
+ throw new Error ( `Duplicated Module name: ${ moduleName } ` )
40
+ }
41
+ // avoid to throw error after HMR
42
+ console . warn ( `Duplicated Module name: ${ moduleName } ` )
43
+ }
Original file line number Diff line number Diff line change @@ -107,11 +107,13 @@ describe('SSR specs:', () => {
107
107
beforeAll ( ( ) => {
108
108
// @ts -ignore
109
109
process . env . ENABLE_AYANAMI_SSR = 'true'
110
+ process . env . NODE_ENV = 'production'
110
111
} )
111
112
112
113
afterAll ( ( ) => {
113
114
// @ts -ignore
114
115
process . env . ENABLE_AYANAMI_SSR = 'false'
116
+ delete process . env . NODE_ENV
115
117
} )
116
118
117
119
it ( 'should throw if module name not given' , ( ) => {
@@ -172,6 +174,9 @@ describe('SSR specs:', () => {
172
174
expect ( generateException1 ) . toThrow ( )
173
175
expect ( generateException2 ) . toThrow ( )
174
176
expect ( generateException3 ) . toThrow ( )
177
+ process . env . NODE_ENV = 'development'
178
+ expect ( generateException1 ) . not . toThrow ( )
179
+ expect ( generateException2 ) . not . toThrow ( )
175
180
} )
176
181
177
182
it ( 'should run ssr effects' , async ( ) => {
You can’t perform that action at this time.
0 commit comments