New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
effector/babel-plugin
plugin doesn't process factories
field
#732
Comments
Factories field must point to the factory path relative to root folder. So in your case it is fixed by setting factories like this: {
factories: ['./src/shared/lib/effector/store']
} |
No, it doesn't work. In addition, they wrote in the telegram chat that the path should be exactly the same as that written in the import construct. |
Write full path from the root into the https://stackblitz.com/edit/effector-react-otbbgz?file=.babelrc -"factories": ['./shared/lib/effector/store'],
+"factories": ["./src/shared/lib/effector/store"] Also, I removed |
But that doesn't solve the problem... Look at this code. There are comments "It works" and "It doesn't work". That is the meaning of this issue. The factory code doesn't work properly even if there are different sids. |
ezgif-5-f597a5718c.mp4 |
Oh, there wasn't a comment about the expected behavior in the code/issue. Only about |
Because the sids is different, you need to search for problem in your fabric implementation, not in the babel-plugin. |
You made CATASTROPHIC hard code and made a bug inside it: const getIntersectingEvents = <
TargetStore extends Store<any>,
EventMap extends Array<[TargetStore, Event<void>]>
>(
targetStore: TargetStore,
eventMap: EventMap
): Event<void>[] => {
return eventMap
- .filter(([store]) => store.shortName !== targetStore.shortName)
+ .filter(([store]) => store.sid !== targetStore.sid)
.map(toEvent);
}; Proof: https://stackblitz.com/edit/effector-react-otbbgz?file=src%2Fmodel.ts |
I totally recommend rewriting this code without using |
The previous code works well because it really had different short names. But stores made inside fabric will have the same name because inside the fabric function variable has the same name for each fabric instance, there are only changes to the name after fabric call. const $a = createStore(0); // .shortName = "$a" .sid = "1d5fxc2"
const $b = createStore(1); // .shortName = "$b" .sid = "8skdx1s" function factory() {
const $demo = createStore(0) // .shortName = "$demo" .sid = "2i0cm"
return $demo;
}
const $a = factory(); // .shortName = "$demo" .sid = "9ddkba|2i0cm"
const $b = factory(); // .shortName = "$demo" .sid = "sc8abs|2i0cm" That's why you don't need to write code that depends on these internal properties. It is a really fragile way to write code |
Thank you! |
What is the current behavior:
If you add the
factories
field in theeffector/babel-plugin
configuration and specify the actual path of the factory that is imported into the model files, then thesid
for units is specified without additionally specifying thesid
of the factory.Please provide the steps to reproduce and if possible a minimal demo of the problem via https://share.effector.dev, https://codesandbox.io or similar:
https://stackblitz.com/edit/effector-react-1eg5yl?file=src%2Fmodel.ts
What is the expected behavior:
The
factories
field is handled correctly and thesid
of the units created by the factory is different.Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous versions of effector?:
OS: any
Browser: any
I don't know.
The text was updated successfully, but these errors were encountered: