Fix issue with non-supporting ES6 browsers (e.g. IE11) and webpack #166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to use your library in one of my project (using Webpack and targetting ES5) and I noticed that using it resulted in a syntax error in IE11.
After investigating about this issue, I found the root cause is that the javascript file being used in the end is overlayscrollbars-react.esm.js which is using ES6 syntax. This esm build should not be used in this situation.
This choice is being made by Webpack because it is picking conditional exports from the package.json file in this priority order: browser, module, main. As your package.json isn't specifying any browser conditional export, the module is picked and the esm build file is imported instead of the ES5 compliant one overlayscrollbars-react.js in my case.
Here are some external discussions regarding this issue happening for other libraries:
webpack/webpack#5756 (comment)
fabiospampinato/cash#291
Useful information regarding the browser property: https://docs.npmjs.com/files/package.json#browser
I was able to handle this issue on my side by specifying the resolve.mainFields property inside the webpack.config.js but this can cause other dependencies to break and can be fixed easily on your side with this PR.
Note: I did the same change for ngx and vue as the issue would be the same.