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

Cannot redefine property: $i18n #402

Closed
jgribonvald opened this issue Jul 27, 2018 · 5 comments
Closed

Cannot redefine property: $i18n #402

jgribonvald opened this issue Jul 27, 2018 · 5 comments

Comments

@jgribonvald
Copy link

vue & vue-i18n version

2.5.16, 8.0.0

Reproduction Link

Steps to reproduce

building 2 web-components importing vue-i18n and deploy it on the same page it tries to redefine the same property

What is Expected?

managing several imports on save Vue instance (or maybe there is a problem that it doesn't create nth instance of vue per web component ?)

What is actually happening?

It tries to redefine the property $i18n whereas it was already initiated into another web component generated by an other build.

@jgribonvald
Copy link
Author

jgribonvald commented Jul 27, 2018

The error come from vue-i18n-esm.js at this line :

Object.defineProperty(Vue.prototype, '$i18n', {
get: function get () { return this._i18n }
});

In my mind there should be a test that this property isn't already initialized

@Ichag
Copy link

Ichag commented Jul 30, 2018

I can confirm that we have the same problem in the same Situation:
image

We tried to avoid loading vue-i18n if its already defined on the prototype in our own code, but that's not working, maybe it's to late in the process:

if (!Vue.prototype.hasOwnProperty('$i18n') {
  Vue.use(VueI18n)
}

Has anyone an idea?

Ichag added a commit to Ichag/vue-i18n that referenced this issue Jul 30, 2018
An error message is thrown if the property '$i18n' is already defined on the Vue prototype. This Commit will hopefully prevents this.
Bug report:
kazupon#402
@nicolasigot
Copy link

Hello,
I have the same issue when using vue-i18n with SSR.
The Vue.use(VueI18n); is imported each time a request is done to the server and I am getting the same error.

"vue": "^2.5.17",
"vue-i18n": "^8.0.0",

@jgribonvald
Copy link
Author

here is a fiddle that reproduce the problem : https://jsfiddle.net/jgribonvald/cmyk6Lua/

@jgribonvald
Copy link
Author

I close the issue as an other issue exist #422 so continue on...

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

No branches or pull requests

4 participants