File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 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 })
1111 let name : string
1212 if ( typeof config === 'string' ) {
1313 if ( configSets . has ( config ) ) {
14- throw new Error ( `Duplicated Module name: ${ config } ` )
14+ reportDuplicated ( config )
1515 }
1616 name = config
1717 configSets . add ( config )
1818 } else if ( config && typeof config . name === 'string' ) {
1919 if ( configSets . has ( config . name ) ) {
20- throw new Error ( `Duplicated Module name: ${ config . name } ` )
20+ reportDuplicated ( config . name )
2121 }
2222 configSets . add ( config . name )
2323 name = config . name
@@ -33,3 +33,11 @@ export const SSRModule = (config: string | InjectableConfig & { name: string })
3333 return Injectable ( injectableConfig ) ( target )
3434 }
3535}
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:', () => {
107107 beforeAll ( ( ) => {
108108 // @ts -ignore
109109 process . env . ENABLE_AYANAMI_SSR = 'true'
110+ process . env . NODE_ENV = 'production'
110111 } )
111112
112113 afterAll ( ( ) => {
113114 // @ts -ignore
114115 process . env . ENABLE_AYANAMI_SSR = 'false'
116+ delete process . env . NODE_ENV
115117 } )
116118
117119 it ( 'should throw if module name not given' , ( ) => {
@@ -172,6 +174,9 @@ describe('SSR specs:', () => {
172174 expect ( generateException1 ) . toThrow ( )
173175 expect ( generateException2 ) . toThrow ( )
174176 expect ( generateException3 ) . toThrow ( )
177+ process . env . NODE_ENV = 'development'
178+ expect ( generateException1 ) . not . toThrow ( )
179+ expect ( generateException2 ) . not . toThrow ( )
175180 } )
176181
177182 it ( 'should run ssr effects' , async ( ) => {
You can’t perform that action at this time.
0 commit comments