magic-akari / seamless-scroll-polyfill

Scroll Behavior polyfill
https://www.npmjs.com/package/seamless-scroll-polyfill
MIT License
159 stars 12 forks source link

Logical OR Assignment (`||=`) in v2 Causing Browser Compatibility Issues #128

Closed mutewinter closed 2 years ago

mutewinter commented 2 years ago

When moving from v1 to v2, I noticed our build output now contains this line:

proto[backup] ||= proto[method];

Located in: node_modules/seamless-scroll-polyfill/lib/common.js

This is causing issues for some of our users who have browsers that don't support this operator.

I haven't been able to figure out why this isn't transpiled by Babel, where v1 works just fine. I'm assuming it's because of this change from v2:

The output format is only esm(es2021 syntax + es5 lib) and umd

I tried adding https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators, but that didn't resolve it (and I strongly suspect this is already being run on our codebase via @babel/preset-env.

I verified this issue is only present in v2.

magic-akari commented 2 years ago

sorry for the late reply.

The version 2.1.5 change output target to es2020 and removed logical or assignment. If you still encounter similar problems, try transpile this library in your toolchain or use the UMD version.

mutewinter commented 2 years ago

Not late at all. Appreciate the fix!