Skip to content
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

Fix issue with non-supporting ES6 browsers (e.g. IE11) and webpack #166

Merged
merged 3 commits into from Dec 19, 2019

Conversation

Zhephyr54
Copy link
Contributor

@Zhephyr54 Zhephyr54 commented Dec 18, 2019

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.

Added browser conditional export for overlayscrollbars-react
Added browser conditional export for overlayscrollbars-vue
Added browser conditional export for overlayscrollbars-ngx
@KingSora
Copy link
Owner

Good day!

Thanks a lot, I didn't know that until now. I'll try to publish the new version as fast as possible.

@KingSora KingSora merged commit 4efdab4 into KingSora:master Dec 19, 2019
@KingSora
Copy link
Owner

@Zhephyr54 The new versions are out now, so you can use your own fix. :)

@Zhephyr54
Copy link
Contributor Author

Thanks a lot for your quick reaction :)

@KingSora
Copy link
Owner

@Zhephyr54 I wanna let you know, that I'll revert this PR in the next update. Please check out the reasons here: #190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants