-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
CDN version of the plain (esm) chart.js cannot be imported? #11592
Comments
May be similar to #10915. |
Just found the same issue and, following the issue mentioned above, solved it by linking the version with "umd" in its name. For example, |
@mukham12 that's a server-side issue though, so probably caused by something else. @hfingler that's not really a solution if you're writing modern JS with ES modules, though. UMD exports are incompatible with ESM, You just end up importing a module that has no exports, which means you still can't do anything. (open dev tools, and run |
Good point. I'm working on a small, simple project, so that was enough for me. |
Same, but I'm only working in modern JS these days (both in the browser and in Node), so it has to be ESM-loadable. |
This does not work nether, even with a very simple example page, basically slightly varied from the first step in the tutorial. I am using Django and had no problem with the version 3. I would prefer not to get back to this version for the new project. Now I get (the server from the browsers error message is my static files server, I have no idea, why/how Firefox looks there):
|
@ludgerh that's a different version with a different problem, though. I've updated the title, but for this particular it'll be better to delete those comments and file a separate one. |
Imagine you are selecting a JS lib do charting for your project and try to run some simple tests in the browser. This bug is a complete dealbreaker. "Moving on to then next lib ... ". Surly hope this is fixed soon. |
I ran into the same issue, which seems to be that the documentation and the CDN deployed scripts suffer from some mismatch. My main "use case" here is that I was trying to avoid having a |
Expected behavior
I expected to be able to import
Chart
from the CDN url https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.jsCurrent behavior
Uncaught (in promise) TypeError: The specifier “@kurkle/color” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
Reproducible sample
no full example necessary
Optional extra steps/info to reproduce
Open a dev console and run
import("https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.js").then(lib => console.log(lib))
. It'll error out.Possible solution
No response
Context
https://www.chartjs.org/docs/latest/getting-started/installation.html suggests that if you don't want to use npm (for instance, you're working on a "classic" web page that's just static HTML, CSS, and JS) you can use one of several CDNs with CDNJS listed as first option, so that's what folks will most likely go for.
https://www.chartjs.org/docs/latest/getting-started/integration.html then teaches people that it's an ES module so
import
works out of the box, and so we run into a problem because instead it errors out.chart.js version
4.4.0
Browser name and version
n/a
Link to your project
n/a
The text was updated successfully, but these errors were encountered: