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

Add ESM installation method #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add ESM installation method #12

wants to merge 1 commit into from

Conversation

TomasHubelbauer
Copy link

@TomasHubelbauer TomasHubelbauer commented Aug 27, 2020

Hi! I really like UZIP.js, thanks for making it! I used to just drop it in my project and call it a day, but recently I've been really getting into ESM (ES Modules - using import and export to refer to other scripts). This is not to be confused with CJS, AMD and other import/export solutions which require compilers and bundlers. ESM is a browser standard and can be used from plain JavaScript. I decided to make UZIP.js available as an ESM module so that I and other people can use it this modern way.

In this PR I contribute an installation method using my ESM module to the readme. The module is automatically updated daily so it will automatically contain any new changes you make in UZIP.js without needing anyone to manually update it. This should save you the influx of issues requesting you update the ESM version like we can see with the NPM version uploaded once by someone else and then not updated anymore.

Hope you like this and all the best!

@101arrowz
Copy link

101arrowz commented Aug 29, 2020

Currently, no browsers truly implement ES Modules, so a transpiler like Babel converts ESM exports to CommonJS before bundling. Therefore there is no difference between the uzip NPM package and the linked repo. The only reason ESM is useful over CommonJS is for tree shaking, but UZIP uses a singular global object containing all of its internal methods, and methods inside objects cannot be tree shaken. Therefore, IMO adding support for ES Modules is not particularly useful.

EDIT: What I said above still applies for build tooling, but importing directly from the browser with ES Modules is now actually possible, so this would be a useful addition.

@TomasHubelbauer
Copy link
Author

TomasHubelbauer commented Aug 29, 2020

I am using ESM in Safari, Firefox, Chrome and Edge in my plain Javascript projects daily. Not sure what you mean about the lack of support. Can you elaborate? Bundling and tree shaking IMO is beside the point here as I'm specifically using ESM to avoid needing to use any bundler or compiler. I write plain JS, save and reload. ESM is useful today.

Edit: I believe I still address your post even when edited, the main point being that this is specifically to support scenarios where additional web dev tooling is not used, plain JS is.

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.

2 participants