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
SyntaxError: import not found: default (js.cookie-2.2.0.min.js) #407
Comments
I got it working by using |
Hi, thanks for opening an issue on js-cookie. As stated in the contributing guidelines, in order to take any further action we need a Short, Self Contained, Correct (Compilable), Example that shows a problem with js-cookie. For support, you can create a question in StackOverflow under the tag Closing for now, but once there's enough information that we can act upon just comment here so that we can reopen it. If you create a StackOverflow question, please link it here so that we can help here or make it possible for others to find the answer. If you find a solution for your problem, please post it here too so that we can potentially improve the docs. Don't let this stop you from keep contributing to js-cookie 👍 Thank you! |
Are you kidding me? You need MCVE to reproduce error caused by one line of code? Like if you don't give a damn, just say it. |
AFAIK browsers don't support ES 6 modules and you need a transpiler to make it work. That means it's not one line of code and there's a lot of assumptions about your code snippets: which transpiler you're using, which version that is, what's your config, etc. Did anything change? Do browsers support ES 6 modules now without the need for a transpiler? Are you using a transpiler at all? |
Ping @Darker. |
Yeah, browsers do support ES6 modules. Not all, and some need you to enable it in dev options first, but it works. See my stackoverflow asnwer: https://stackoverflow.com/a/46415925/607407 Some libraries already support ES6 modules in browser too, such as EventEmitter2:
Since JSCookie says in the docs that it supports ES6 modules - and it didn't work for me, I reported that as an issue. Fix might be as simple as adding an example import code in documentation. |
Alright, things have changed then. Does @PerfectlyNormal's answer work? If that's so, can you create a PR to update the docs? Also, how can js-cookie support ES6 modules in a better way conscious of backward compatibility? |
Might be worth a hyperlink to some website that can show the browser support over time. |
I'll test it ASAP and if it works, I'll create PR with docs update. |
@Darker any updates on this one? |
This is what is stated as valid import syntax in documentation:
But that does produce following error:
In the following code:
What is the correct usage?
The text was updated successfully, but these errors were encountered: