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
Add named exports for createInstance #1681
Conversation
Don't find the issue but we had issues with mixed export in the past. |
Oh I see! Yeah that would not have worked then. |
@adrai what is your opinion? I think either we keep the thing as is - or bring back all named exports (personally I think named exports are overused on things that are objects and not pure functional) |
Personally, I would not mix default exports and named exports... import i18next from 'i18next';
const { createInstance } = i18next; |
/* eslint class-methods-use-this: 0 */
createInstance(options = {}, callback) {
return new I18n(options, callback);
} I still think this one can be safely added as a named export... |
with pure function I mean it is just a function (not part of a class) |
Is there a reason |
|
Not even sure why this is such a big deal...most projects never will need createInstance anyway...there is nothing you gain by the named import |
You're absolutely right, it's not a big deal. It's just a preference man. You gain slightly nicer ergonomics. I think that if anything, the pattern would be to make |
* Fix spelling * Allow using t as a free function This facilitates using t via destructuring or as a callback. Several people have run into this; see #1287. * Use a fixed time zone for automated tests This fixes some test failures in some time zones (such as Eastern US). * Bind all functions, not just t As discussed at #1681 and #1682.
3925199
to
a719dae
Compare
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Solved the merge conflicts and updated to reflect #1682. I actually agree with @jamuhl and don't particularly like #1682, originally all I wanted was to be able to |
This will probably not automatically work for cloneInstance and createInstance now: https://github.com/i18next/i18next/blob/master/src/i18next.js#L569 |
Hm... I think there would be no problem calling those 2... |
I mean the bindMemberFunctions call is probably also needed to be called here: https://github.com/i18next/i18next/pull/1681/files#diff-6859f2a371e0f563ec9c27c5cf64cb82f8d91750467509caaa8f6f0e6d06dec5R565 |
Ah, i see what you mean! I did that on purpose, i think binding on the default export instance is enough... |
what do you think @joshkel @dinosaurjoe @nielsboecker @minodisk @stephent? |
lgtm now... |
For my particular use case, I believe that binding on the default instance would be enough. I would lean toward binding all instances; that feels more consistent and removes any possibility of error. But I'll defer to whatever others decide. Thank you. |
So let's do it for all instance creations ok @perrin4869 ? |
Done! |
thank you for everything you've done @perrin4869 v21.5.0 has just been released |
I've got the warning after upgrading to v21.5.0 with Yarn 3.1.0:
But it seems to work anyway without any problems. |
@stryaponoff it should be better with v21.5.1 |
Updating
i18next-fetch-backend
to be an esm-first module, I found that I could not doimport { createInstance } from "i18next"
like I expected.This PR adds support for this.