Jsdelivr: Support for ES modules

Created on 11 Nov 2018  路  5Comments  路  Source: jsdelivr/jsdelivr

Could you add option for ES modules as unpkg.com?

Example https://unpkg.com/@material/mwc-button@latest/mwc-button.js?module

All 5 comments

Most likely yes, at some point, but no ETA. The current unpkg implementation shouldn't be used for anything other than quick demos in online code editors because it often results in hundreds of requests causing terrible page load times. Unfortunately not everyone is aware of this and we don't want to encourage people using this in production until it works in some better way.

@MartinKolarik IMO, this is a must-have feature in modern stacks. If you are planning to serve native ESModules to browsers that support it -almost all brosers- you haven't another alternative than using unpkg with the caveats you said before.

@gugadev @MartinKolarik is right. Read more here https://jspm.io/ and here https://jspm.org/about/introduction#cdn

But option can be provided with caution.

I just came across this issue and I've been using ES Modules with jsDelivr for a 3 months now. It works perfectly in my opinion.

Is there something not supported? If not I think this issue could be closed out.

Here is a demo of ES Modules using Web Components from jsDelivr.
https://www.dataformsjs.com/examples/places-demo-web.htm

In DevTools you can see that several modules are loaded from JavaScript files.
DevTools_ES_Module_Loaded_from_jsdelivr

In the code you can see the import statement is used and works as expected with jsDelivr. Note - this print screen is of a non *.min.js file while the above print screen uses *.min.js files.
Code_ES_Module_Import

This now works! https://esm.run/@material/mwc-button@latest/mwc-button.js (details in #18263).

Was this page helpful?
0 / 5 - 0 ratings