-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
RFC: // @factory
#917
Comments
All tools like Babel and SWC work on the File-level, not the project level. When you process a factory call you have just the import statement, and the call itself. You need to resolve import, then read the file, and check the comments. Looks like it will be VERY slow, or not available at all. |
I thought you were suggesting this import {anything} from './factory'
// @effector-factory
const foo = anything()
// @effector-factory
const bar = anything.widget() And it's possible |
This might work too, although it might be more repetitive // @factory
import { factory } from 'smth' So if imported thing is marked as factory, all its calls in this file should be wrapped. Doesn't require reading another file |
This comment has been minimized.
This comment has been minimized.
I suggest using https://withease.pages.dev/factories/ instead. It has runtime checks and does exactly the same without any changes in plugins. |
In current state, you might sometimes get weird bugs and spend a couple of hours troubleshooting just to end up discovering that some store has missing sid and/or some factory isn't wrapped
Then you get fun time figuring out what paths you need to add to babel plugin
Here's the list of what I need to add just for a single factory that uses local clone of
keyval
libraryAnd getting to this config takes time. Add path -> wait for a full rebuild -> sid not affected -> search for more -> repeat
There're also cases when babel plugin won't even help
Which means you need to wrap it into
withFactory
, which is a secret method with no types and no documentationAnd frameworks like Next.js with their weird bundlers might patch imports/exports so this function might not even exist for some reason
That's a really poor DX, and sometimes you might spend a really long time fixing it
Proposal
Like I proposed long ago, I think it's better to accept the fate and add extra optional
// @factory
comment support which helps plugins to easier detect factoriesSomething like:
Pros:
Cons:
Questions:
The text was updated successfully, but these errors were encountered: