-
Notifications
You must be signed in to change notification settings - Fork 185
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
[Bug]: charts-react SSR render fails starting with 1.13.10 #1856
Comments
Hi @David-Yuen - thanks for this detail. Let's figure out how to get you working with 1.16.9 (and beyond). The way I'm reading the most recent error is that you're requiring node_modules/@carbon/charts-react/dist/index.js and getting a message that it's an ES module and not UMD. But if we look at that file, we can visually see it's UMD because the file starts out with an IIFE. It's being treated as an ES module because Can you try a quick experiment?
Also, can you share what version of webpack you are using as well as your webpack config? Separate question, are you able to use |
@David-Yuen - we changed the exports for the UMD to use CJS in 1.16.10. Can you please check that and see if it solves your issue? |
@nstuyvesant I just tested I was going to try your quick experiment but you guys already fixed and delivered the 1.16.10, and that's working, so i think i dont need to test this now.. and answering the other questions: We are using and we generally use |
Hi @David-Yuen - I am not inside of IBM so not on Slack but glad the update solved your issue. Something that I have seen among Webpack users is inadvertent use of a cjs-loader. Normally, this is to convert ES modules to CJS. But if you wrote everything using import, you may not need it. For sure, your generated bundles are CJS. You could look into whether that's really required. The benefit for going pure ESM is better tree-shaking. Of course, you are doing SSR so you would need to be using a recent version of node.js that supports ESM. In any case, glad this blocker has been overcome. All the best. |
Relevant package(s)
Carbon Charts Version
1.13.10 to latest
Which bundler are you using?
Webpack
What happened and what did you expect to happen?
Our application uses server side rendering of our pages, and starting with 1.13.10, the page fails to render.
The last working build is
"@carbon/charts-react": "1.13.8",
. (I tried1.13.9
but npm could not find it, doesnt seem to exist anymore)..Starting with
1.13.10
, when we render our page in the browser, the page fails to render, and on the server side terminal i see this error:On the latest build
1.16.9
, the server side message is slightly different showing:I'm not sure what changed, but starting with patch updates, something broke between
1.13.8
and1.13.10
, and this issue is related to importing chart components. Seems like something changed and on SSR side cannot import chart components properly withimport { LineChart } from "@carbon/charts-react";
.More details:
Code use to work in carbon v10, and I am currently updating to carbon v11.. in carbon charts v11, things worked until
1.13.8
but breaks after1.13.10
.Since we use server side rendering.. normally is after i install all packages (
npm install
), we build our application withnpm run build
(which builds both server and client side), the build succeeds.Then I start up the server with
npm start
, while in local dev i have hot-module replacement so it rebuilds automatically in-memory for client-side code. Both starting up and re-building succeeds.Then i load a page with charts on it, and the page fails to render. On server side I can see server-side rendering errors (above).
If i comment out the import charts and render charts lines.. like:
I re-run the build for both server and client (
npm run build
), start the server, and then load the page, everything loads and renders fine.Then, since i am in dev mode, I can un-comment those lines, the code will auto-rebuild (this is in-memory and for client side only), and i reload the page.. The charts will load and render fine as well.
I have also asked in carbon-charts channel for help, I also got an example using DonutCharts and same error occurs..
So I've narrowed the problem down to only on server side, there are issues with importing charts components.
Chart data and options (automatically formatted so no need for backticks)
JavaScript console or build output (if relevant)
StackBlitz repro
No response
IBM Application/Team (if relevant)
No response
What priority level would this be in your opinion?
P1 (High)
The text was updated successfully, but these errors were encountered: