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
Isomorphic build support #9436
Comments
|
An interesting thread about moving to pure ESM package.
I don't fully agree, even if it's clearly not the main usage, Chart.js is used server side (though I don't know how it's imported). So whatever solution is adopted, we should make sure to still support server-side use cases in pure node environment. |
|
I recall a few threads of folks doing server side rendering using node-canvas to generate images for reports |
|
@benmccann Does #10525 solve this issue? |
|
Yes! Thanks |
|
@dangreen any idea when it will be released? |
|
@rpf3 it will be released in v4. You can follow the progress here |


benmccann commentedJul 18, 2021
Chart.js does not work with Vite / SvelteKit out of the box. This is because Chart.js provides a build via the
mainfield inpackage.jsonwhich provides just a default export. Meanwhile it provides a build inmodulewhich provides named exports. Vite tries to use themodulebuild on the client and themainbuild on the server which causes the build to fail because you can't write code that is compatible with both these packages. To work around this, you can specify the optionvite.ssr.noExternal: ['chart.js'], but this is hard for users to figure out and it'd be much nicer to provide builds that are the same shapteThere are a couple things we could do:
mainthat uses the same entry file as our ESM build and add"type": "module"topackage.json. This is probably the best optionmain. Chart.js isn't really that useful on the server-side, so we could just stop telling Vite that we have a server-side build. It would still try to build it on the server, but would fallback to the ESM implementationThe text was updated successfully, but these errors were encountered: