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

Transpile to es5 to support older devices #50

Open
Yankovsky opened this issue Aug 11, 2021 · 4 comments
Open

Transpile to es5 to support older devices #50

Yankovsky opened this issue Aug 11, 2021 · 4 comments

Comments

@Yankovsky
Copy link

Let's provide a transpiled to es5 version of this lib. We can do it before publish on npm for example.
Currently this lib is not usable for devices not supporting some of es6+ syntax like async/await, Promise, const etc.

@LinusU
Copy link
Collaborator

LinusU commented Aug 11, 2021

I think that transpiling code is something that must be done by the end user in this case, since there is no way for us to know exactly which browsers/environments they are targeting. It's my opinion that it's better for all code on npm to use the latest language features, and then someone building a website can configure their build process to transpile accordingly...

@Yankovsky
Copy link
Author

Usual babel setup only transpiles project's source code and doesn't touch node_modules. Most of the libraries target ES5 as a base case and sometimes they also provide additional target like esnext.
I understand what you are saying, but in my opinion it is unexpected of library not to support ES5.

@LinusU
Copy link
Collaborator

LinusU commented Aug 11, 2021

Transpiling async/await syntax comes with a very large overhead, which will probably balloon the size of this library way over the 508 B gzipped that this library currently comes in at. It would be interesting to test and see the difference...

It seems like a bad approach that all newer browsers should pay the price of running older code, even on websites that aren't even supporting older browsers?

@Yankovsky
Copy link
Author

I thought of something like this https://github.com/xobotyi/scrollbar-width/blob/master/package.json#L33
Here you have 3 targets, one of them "main" is es5.

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

No branches or pull requests

2 participants