Error: Unexpected token "=", on Safari (=< 13.1)
QuentinCharlie opened this issue ยท 12 comments
Hello there,
Using your ^2.2.0 version, i got the error screenshoted below on older safari (from 14.1 it works fine). I don't have the error with your 2.1.2 version tho.
I guess it's related to this https://stackoverflow.com/questions/60026651/safari-unexpected-token-expected-an-opening-before-a-methods-paramet
Hi @QuentinCharlie,
thanks for flagging this! It might have been my mistake when migrating from tsdx
to tsup
: I set the target
option to node12
, thinking that Next.js would transpile everything anyway. Now I'm not sure about that anymore, let me check...
I wasn't wrong, it does ๐ So this is not a config thing in next-redux-cookie-wrapper, luckily. Next.js targets Safari 12+ by default. Which version did you try?
Thanks for the quick response.
You meant the Next.js version we use ? It's the 12.3.0.
Sorry for not being clear, I meant the Safari version, given that Savari >= 12 should be supported (at least in latest Next.js). Did you try explicitly setting a browserslist config like defaults, Safari >= 11
in your package.json
?
Closing this issue since transpiling production code for outdated browsers is up to Next.js/Babel ๐
It was for all Safari versions =<13.1 yes, i tried different ones, regardless of my browerslist config (including the one you said while running 12.1).
It's only when i run the 2.1.2 version of your package that my application works on those older safari versions (even without browserslist config btw).
Well, that's annoying. Out of curiosity, if you put
class Foo {
bar = 0;
}
new Foo();
into one of your project's files, you would get the same error, right? Does manually adding @babel/plugin-proposal-class-properties
in a custom babel config change anything?
Adding the Foo code doesn't trigger any error and seems to works fine. (I can display the bar value on the app).
I tried to add a custom babel config to see if it solved the main issue, but sadly doesn't.
Any chance you can find out what causes the syntax error in next-redux-cookie-wrapper
?
Does it make any difference when you change the target in main/package.json
to
"target": [
"node12",
"safari11"
],
and run npm run build -w main
?
Seems to works !
Also did just to be sure :
- Started from a fresh clone of your repo
- Changed the tsup's target value with your snippet
npm install
thencd demo && npm start
Works like a charm ๐
Next.js v12.3.0 (just like latest v13) uses @swc/core@1.2.203
. The next step should be to check what causes the syntax error and if it was fixed in @swc/core
by now โ I couldn't find any existing SWC issues on it. I can't research this myself, unfortunately, since I don't have access to Safari and don't know which exact syntax causes it. If you have some time available, please feel free to file an upstream issue.
Anyway, since fixing things upstream may take some time, LMK if you'd like me to publish a patch release of next-redux-cookie-wrapper
for the time being.