@@ -49,7 +49,6 @@ async function createRealm(sourceCode: string, filename, additionalLibs = {}) {
4949 return pathLibrary
5050 case 'react' :
5151 return React
52-
5352 }
5453 if ( path in additionalLibs ) return additionalLibs [ path ]
5554 console . warn ( 'require: ' , path )
@@ -107,8 +106,19 @@ const fetchBabelPlugin = createEffect<string, {[key: string]: any}, any>({
107106 } ,
108107} )
109108
110- const shimName = 'use-sync-external-store/shim/index.js'
111- const withSelectorName = 'use-sync-external-store/shim/with-selector.js'
109+ function getShimDefinition ( shim : any ) {
110+ const result = { }
111+ result [ 'use-sync-external-store/shim/index.js' ] = shim
112+ result [ 'use-sync-external-store/shim' ] = shim
113+ return result
114+ }
115+
116+ function getShiSelectorDefinition ( shimSelector : any ) {
117+ const result = { }
118+ result [ 'use-sync-external-store/shim/with-selector.js' ] = shimSelector
119+ result [ 'use-sync-external-store/shim/with-selector' ] = shimSelector
120+ return result
121+ }
112122
113123const fetchEffectorSolid = createEffect < any , { [ key : string ] : any } , any > ( {
114124 async handler ( effector ) {
@@ -148,19 +158,21 @@ const fetchEffectorReact = createEffect<any, {[key: string]: any}, any>({
148158 'https://unpkg.com/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js'
149159 const withSelectorUrl =
150160 'https://unpkg.com/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js'
161+ const shimName = 'use-sync-external-store/shim/index.js'
162+ const shimSelectorName = 'use-sync-external-store/shim/with-selector.js'
151163 const shim = await getLibraryCode ( shimName , shimUrl )
152164 const withSelector = await getLibraryCode (
153- withSelectorName ,
165+ shimSelectorName ,
154166 withSelectorUrl ,
155- { [ shimName ] : shim } ,
167+ getShimDefinition ( shim ) ,
156168 )
157169 const effectorReact = await getLibraryCode (
158170 `effector-react.cjs.js` ,
159171 effectorReactUrl ,
160172 {
161173 effector,
162- [ shimName ] : shim ,
163- [ withSelectorName ] : withSelector ,
174+ ... getShimDefinition ( shim ) ,
175+ ... getShiSelectorDefinition ( withSelector ) ,
164176 } ,
165177 )
166178 return { effectorReact, shim, withSelector}
@@ -239,15 +251,17 @@ export async function evaluator(code: string) {
239251 if ( $version . getState ( ) === 'master' ) {
240252 const additionalLibs = await Promise . all ( [
241253 fetchForest ( effector ) ,
242- $viewLib . getState ( ) === 'react' ? fetchEffectorReactSSR ( {
243- effector,
244- [ shimName ] : shim ,
245- [ withSelectorName ] : withSelector ,
246- } ) : fetchEffectorSolidSSR ( {
247- effector,
248- 'solid-js' : solidJs ,
249- 'solid-js/web' : solidJsWeb
250- } ) ,
254+ $viewLib . getState ( ) === 'react'
255+ ? fetchEffectorReactSSR ( {
256+ effector,
257+ ...getShimDefinition ( shim ) ,
258+ ...getShiSelectorDefinition ( withSelector ) ,
259+ } )
260+ : fetchEffectorSolidSSR ( {
261+ effector,
262+ 'solid-js' : solidJs ,
263+ 'solid-js/web' : solidJsWeb ,
264+ } ) ,
251265 fetchPatronum ( effector ) ,
252266 ] )
253267 forest = additionalLibs [ 0 ]
0 commit comments