eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 110 forks source link

`this` has been rewritten to `undefined` #36

Open vladshcherbin opened 2 years ago

vladshcherbin commented 2 years ago

When using rollup, a warning is shown:

image

It leads to https://rollupjs.org/guide/en/#error-this-is-undefined

Is there a way to prevent this error?

No other packages in project produce errors or warnings.

supnate commented 2 years ago

Suggest preventing the error from rollup config side: https://stackoverflow.com/questions/43556940/rollup-js-and-this-keyword-is-equivalent-to-undefined . Since nice modal uses tsc command to compile the code, suppose it generates some kind of "standard" code.

vladshcherbin commented 2 years ago

I saw this solution and would love to use it only if no other choice.

Two places use this in compiled code - __assign and __rest at the top. I believe this are polyfills to quite popular functions.

Wondering what other libraries do since I haven't seen this warning with other packages and I do think they use this functions 🕵️