Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Failed attempt to call getLanguage in vue 3 #14

Closed
Shahryar1991 opened this issue Aug 3, 2022 · 8 comments
Closed

Failed attempt to call getLanguage in vue 3 #14

Shahryar1991 opened this issue Aug 3, 2022 · 8 comments
Labels
good first issue Good for newcomers

Comments

@Shahryar1991
Copy link

Hi
I'm trying to get language data from getLanguage function in vue 3 and it return Uncaught TypeError!
My code is:
import { default as getLanguage } from "language-flag-colors";
const portuguese = getLanguage("pt-pt");

if it helps, I've called getLanguage function in setup() hook.

You can see full error message here:
Uncaught (in promise) TypeError: ({default:[{name:"Acholi", nativeName:"Lwo", ids:{locale:"ach-UG", ISO_639_2:"ach", ISO_639_3:"ach", androidCode:"ach-rUG", osxCode:"ach.lproj", osxLocale:"ach", glottolog:"acol1236"}, direction:"ltr", country:"Uganda", countryCode:"ug", flag:{image:"https://crowdin.com/images/flags/ach.png", emoji:"\uD83C\uDDFA\uD83C\uDDEC", primaryColor:{hex:"#D90000", rgb:[217, 0, 0], cmyk:[0, 100, 100, 15], base10:14221312}, flagColors:[{hex:"#FCDC04", rgb:[252, 220, 4], cmyk:[0, 5, 100, 0], base10:16571396}, {hex:"#D90000", rgb:[217, 0, 0], cmyk:[0, 90, 76, 0], base10:14221312}, {hex:"#000000", rgb:[0, 0, 0], cmyk:[0, 0, 0, 100], base10:0}, {hex:"#9CA69C", rgb:[156, 166, 156], cmyk:[50, 34, 27, 11], base10:10266268}]}}, {name:"Afar", nativeName:"Qafaraf", ids:{locale:"aa-ER", ISO_639_1:"aa", ISO_639_2:"aar", ISO_639_3:"aar", androidCode:"aa-rER", osxCode:"aa.lproj", osxLocale:"aa", glottolog:"afar1241"}, direction:"ltr", country:"Eritrea", countryCode:"er", flag:{image:"https://crowdin.com/images/…

My first attempt to import function was this:
import languages, { getLanguage } from "language-flag-colors";
and it gave me different error and shown me this: Uncaught (in promise) SyntaxError: import not found: getLanguage

Still couldn't figure it out how to solve this problem.

@Bas950
Copy link
Owner

Bas950 commented Aug 6, 2022

Interesting... will see if I can re-create the issue.

@ImRodry
Copy link
Collaborator

ImRodry commented Aug 6, 2022

Hey! Thanks for the report and sorry for the delay. Could you tell us what version of the package you’re using and what version this issue started in? Also please tell us what version of vue you’re using

As for the issue, the first attempt is very obviously wrong so the error there is expected. I’m not sure why you’re getting the error on the second one. Have you tried not importing the default object and only importing the function? Try doing it like this import { getLanguage } from "language-flag-colors"

@Shahryar1991
Copy link
Author

I'm using v2.1.0 and that is the only version I've used in Vue v3.2.37.
I've tried this import languages, { getLanguage } from "language-flag-colors"; too, but it gave me this error:
Uncaught (in promise) SyntaxError: The requested module '/node_modules/.vite/deps/language-flag-colors.js?v=f577bf51' does not provide an export named 'getLanguage'

@ImRodry
Copy link
Collaborator

ImRodry commented Aug 8, 2022

While this does seem like an issue with how vue bundles its dependencies we will be looking into improving our ESM support in the next few days but no promises will be made.

@ImRodry ImRodry added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Aug 8, 2022
@ImRodry
Copy link
Collaborator

ImRodry commented Aug 14, 2022

Tested this in vite v3.0.7 and I cannot reproduce this issue, therefore I'm closing this. If the issue persists I recommend looking at vue support because it doesn't seem to be an issue on our end
image
image

@ImRodry ImRodry closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2022
@ImRodry ImRodry removed help wanted Extra attention is needed bug Something isn't working labels Aug 14, 2022
@ImRodry
Copy link
Collaborator

ImRodry commented Aug 14, 2022

Looking further into this, it seems that vite v3.0.7 fixed this issue, so you should update to the latest version. Here's the relevant PR: vitejs/vite#9642

@Shahryar1991
Copy link
Author

Shahryar1991 commented Sep 5, 2022

I'd tried it again in vite 3.1.0, vue 3.0.27 but this time it show me this error:
Uncaught SyntaxError: ambiguous indirect export: getLanguage

@ImRodry
Copy link
Collaborator

ImRodry commented Sep 5, 2022

We tested in vite 3.0.7 and it was working, idk if it broke again but if it did it’s not our fault

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants