plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.18k stars 1.03k forks source link

RangeError: Maximum call stack size exceeded on build after installing @nivo/radial-bar": "^0.83.0 #2353

Open LironHazan opened 1 year ago

LironHazan commented 1 year ago

Hey! I just started to use Nivo :) and not sure why, but after installing: @nivo/radial-bar": "^0.83.0" I cannot bundle to prod with vite, getting a tsc error, it didn't happen when installed
"@nivo/line": "^0.83.0", I also have

        "@nivo/bar": "^0.83.0",
        "@nivo/core": "^0.83.0",
> tsc && cross-env NODE_OPTIONS=--max-old-space-size=8192 P_ENV=production vite build

/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:96888
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at Object.isPartOfTypeNode (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:11786:30)
    at containsReference (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:52596:53)
    at visitNode (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24472:24)
    at Object.forEachChild (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24621:24)
    at containsReference (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:52607:29)
    at visitNode (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24472:24)
    at Object.forEachChild (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24657:24)
    at containsReference (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:52607:29)
    at visitNode (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24472:24)
    at Object.forEachChild (/Users/lironhazan/dev/cloud-apps/services/dashboard/client/node_modules/typescript/lib/tsc.js:24640:24)

using typescript version: "typescript": "^4.5.4", npm 8.19.3 + node v16.19.1

Will really appreciate any advice

LironHazan commented 1 year ago

@plouc Hey I hope it's ok I'm tagging you, appreciate your effort, Do you have any lead on why this could happen?

echarles commented 1 year ago

Same issue here with compiling with tsc. Works fine with webpack devserver but fails when with tsc. Will need to look to another lib for now...

plouc commented 1 year ago

@LironHazan, I don't know what could cause that, it would need to be investigated.

LironHazan commented 1 year ago

Thanks, I'm looking into more charts of Nivo, will update if see more issues of if I'll have a lead of the root cause

LironHazan commented 1 year ago

@plouc impressive work on the make file! :) I've tried to look into the way the lib is built and couldn't find mention to any active typechecking in the rollup config, I'm not an expert in rollup but maybe using @rollup/plugin-typescript would add the typechecking phase and help tracing such issues?

Xantier commented 1 year ago

This looks to be introduced somewhere in version 0.81.0. Dependencies

    "@nivo/bar": "^0.80.0",
    "@nivo/core": "^0.80.0",
    "@nivo/pie": "^0.80.0",

Compile properly, though additional type dev dependencies need to be added in:

    "@types/d3-scale": "^4.0.3",
    "@types/d3-color": "^3.1.0",
    "@types/d3-scale-chromatic": "^3.0.0",

Bumping @nivo/ deps to 0.81.0, we'll hit the typescript error (due to some introduced recursive typing?)

LironHazan commented 1 year ago

@Xantier I can't downgrade, it causes other conflicts in the project Any chart with arcs has the issue, so far we tested:

Pie Chart Sunburst Chart Radial Bar Chart

benellatalon commented 1 year ago

The errors seems to be coming from @nivo/arcs

plouc commented 1 year ago

@plouc impressive work on the make file! :) I've tried to look into the way the lib is built and couldn't find mention to any active typechecking in the rollup config, I'm not an expert in rollup but maybe using @rollup/plugin-typescript would add the typechecking phase and help tracing such issues?

Thank you 😊 The type checking is done via pkgs-types, and it's run on CI via:

pkgs-build: pkgs-types ##@1 packages build all packages

Initially @rollup/plugin-typescript didn't support type checking, that's why I used another approach.

Xantier commented 1 year ago

Here is a minimal reproduction: https://github.com/Xantier/nivo-ts-stackoverflow

Xantier commented 1 year ago

Flipping around version on the minimal reproduction, this actually looks to work on 0.81.0 version as well. 0.82.x doesn't build at all so my assumption is that the issue was introduced in 82 or 83

Jule- commented 1 year ago

Hi, same issue here.

I have debugged tsc and it crashes when evaluating this file: @nivo/arcs/dist/types/centers.d.ts.

In fact, when you look at it there is a loooooot of import stuff from @react-spring/*, I am pretty sure this is what is killing the stack.

Can you see a quick fix or workaround for this? :grimacing:

Jule- commented 1 year ago

I think this issue appears due to: #2280 (released in v0.82.0)

Jule- commented 1 year ago

Unfortunately downgrading @react-spring/web@9.4.5 is not enough, maybe a false lead... I think the generation of the centers.d.ts file should be responsible for this issue.

https://github.com/plouc/nivo/blob/2671ca4df614190f597bb63030bb794d3106c36e/packages/arcs/src/centers.ts#L54-L72

Maybe if you can type the transition property with a less wordy type than the one generated it could help tsc to compile. And I am not sure if/how we should report this to the @react-spring/web project.

Jule- commented 1 year ago

Same issue here:

https://github.com/plouc/nivo/blob/2671ca4df614190f597bb63030bb794d3106c36e/packages/arcs/src/useArcsTransition.ts#L21-L39

stale[bot] commented 10 months ago

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

Jule- commented 10 months ago

bump

acrylicode commented 9 months ago

The issue is still there. For anyone interested, I deleted the types folder before running the tsc and it works. So under node_modules/@nivo/bar there is a types folder. Just delete that. Do the same for all the charts you are using. If you want to get fancy you can wrap the tsc in another command that automatically deletes the types, executes tsc and then reinstalls it again.

HendrikGrobler commented 1 month ago

Bump. This issue is prevent us from using Nivo.