Skip to content
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

How to have two meydas in the same program #847

Open
hughrawlinson opened this issue May 29, 2021 · 0 comments
Open

How to have two meydas in the same program #847

hughrawlinson opened this issue May 29, 2021 · 0 comments

Comments

@hughrawlinson
Copy link
Member

here's a link to a runkit I'll be referencing

Right now it's possible to have two Meydas, but it's tricky. Meyda is actually a singleton, so the same top-level defaults are shared across the entire running program. Because we tell people to set these parameters to whatever they need, it's possible that one part of a program sets them, then another part of the program imports Meyda expecting defaults, but receiving whatever was previously set by whichever random other part of the program previously used Meyda. This is demonstrated in RunKit.

It's possible to do a second Meyda by running const secondMeyda = Object.assign({}, Meyda); - but I'm not actually sure that the functions end up bound to the correct this. Also, unless you have a really deep understanding of your build process, all your dependencies, and your own entire codebase, you can't be sure that the Meyda you import has the correct defaults - or will have them in the future after patches and updates. Demonstrated in RunKit.

You can wrap the above hack in a constructor, but of course it faces the same problems.

There's not much of a way around this without overhauling the whole API. So I think this might just be the realization that sparks an enormous amount of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant