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

Indicating that package is ESM, not classic ES #1776

Open
Pomax opened this issue Mar 15, 2024 · 4 comments
Open

Indicating that package is ESM, not classic ES #1776

Pomax opened this issue Mar 15, 2024 · 4 comments

Comments

@Pomax
Copy link
Contributor

Pomax commented Mar 15, 2024

It looks like https://github.com/cdnjs/packages/blob/master/CONTRIBUTING.md does not cover the syntax necessary to indicate whether a package is an ES module, which means that the cdnjs page for module packages will give people the wrong code to use.

For example, https://cdnjs.com/libraries/graphics-element provides people with

<script src="https://cdnjs.cloudflare.com/ajax/libs/graphics-element/1.11.1/graphics-element.js" integrity="sha512-fz6xdkeMImCEkyHV+HPpg7C9cxoqc0w9RdSzm9ufj2wjFQFz71iJvyazoM9tXRGBzN40GuNY2e5fmimRiBFoJw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

but if they put that on their page, they'll get a dev console error because the code they should have actually used is:

<script type="module" src="https://cdnjs.cloudflare.com/ajax/libs/graphics-element/1.11.1/graphics-element.js" integrity="sha512-fz6xdkeMImCEkyHV+HPpg7C9cxoqc0w9RdSzm9ufj2wjFQFz71iJvyazoM9tXRGBzN40GuNY2e5fmimRiBFoJw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

with an explicit `type="module" so that the browser can correctly load the lirbary. Can the contributor docs be updated to explain how to mark a library as ESM, so that the cdnjs website can then tap into that information and generate the correct HTML code?

(Note that the library in this example is a normal, stand-alone library that happens to be written as ES module to ensure proper scope isolation)

@MattIPv4
Copy link
Member

It is not currently possible to do so, hence it is not documented. I suspect this will need some work across the tools repo as well as the API + website to make happen, and then finally a docs update here and updates to any packages that need it.

@Pomax
Copy link
Contributor Author

Pomax commented Mar 16, 2024

Noted - is there a better place to file this as an overarching issue? (since ESM isn't exactly new at this point, and the sooner the work starts, the sooner it's done, so the sooner people relying on cdnjs benefit =)

@MattIPv4
Copy link
Member

This repo is probably fine 👍 Hopefully someone in the community will be interested in contributing the required changes

@Pomax
Copy link
Contributor Author

Pomax commented Mar 17, 2024

Indeed! (but hopefully it also goes pretty high up on the cdnjs triage board)

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