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

fix TypeError: Cannot redefine property: $i18n #422

Merged
merged 2 commits into from
Oct 14, 2018
Merged

Conversation

HadiChen
Copy link

@HadiChen HadiChen commented Sep 3, 2018

fix #421

@jgribonvald
Copy link

I confirm this change solves the TypeError !

@HadiChen HadiChen closed this Sep 10, 2018
@jgribonvald
Copy link

Why this was closed ?
even in version 8.1.0 it solves the TypeError !

@HadiChen HadiChen reopened this Sep 11, 2018
@HadiChen
Copy link
Author

I have already solved this problem on the project, and this error will occur in the special use of the project.
I have reopened this pr @jgribonvald

@jgribonvald
Copy link

@HadiChen could you point the commit that should solve the problem ?

After this commit solve the problem in web-component context where you can deploy and try to attach several instance of the vue-i18n component. So it could be usefull to avoid a TypeError for this use case.

Thanks

@cjosh
Copy link

cjosh commented Sep 11, 2018

Just chiming in that I was also waiting for a fix for this. I have a library of Vue components that's using Vue-i18n which is being used in another, larger Vue app that's also using Vue-i18n.

@HadiChen
Copy link
Author

as long as the vue-i18n used in the project is the same, this error will not occur.

@cjosh
Copy link

cjosh commented Sep 13, 2018

I still get the error, with both of my package.jsons using the newest 8.1.0.

Edit: If I remove Vue-i18n from the library components, it seems to work and it will use the main project's Vue-i18n. So I just can't have two copies. I think I misunderstood what you were saying.

Edit 2: And while it does work, my console is now spammed (unsuprisingly with TypeError: "_vm.$t is not a function")

@HadiChen
Copy link
Author

Can you explain the error in detail?

@cjosh
Copy link

cjosh commented Sep 14, 2018

So, like previously mentioned I get TypeError: can't redefine non-configurable property "$i18n" when both my main app and my component library (exported as vue components and used as a node module per https://medium.com/justfrontendthings/how-to-create-and-publish-your-own-vuejs-component-library-on-npm-using-vue-cli-28e60943eed3) is using Vue-i18n.

If I use Vue-i18n only on the library, I can load the app, but I can't use Vue-i18n on it.

If I remove Vue-i18n from the library, and only include it in the main app. It will load, but I get a bunch of console errors:
[Vue warn]: Error in render: "TypeError: _vm.$t is not a function" several times

Along with [Vue warn]: Error in mounted hook: "TypeError: this.$el.getElementsByClassName is not a function" and other errors which point to other components in the library which are now broken since the library is not using Vue-i18n.

Therefore I believe this PR is necessary because there are use cases such as mine where node modules built in vue using the same library will cause a conflict.

@jgribonvald
Copy link

If you want to reproduce the problem I've provided an example in #402
https://jsfiddle.net/jgribonvald/cmyk6Lua/
(Don't consider other errors)

@kazupon kazupon merged commit cb19082 into kazupon:dev Oct 14, 2018
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

Successfully merging this pull request may close these issues.

TypeError: Cannot redefine property: $i18n
4 participants