Unable to use plotly in Gatsby.js

I am unable to figure out how to use plotly in my gatsby.js (a react framework) project.
I get build error when I use import * as px from plotly.express .
Can you please guide me as to how I can use plotly in gatsby. js

in ionic framework, i am using

import * as Plotly from ‘plotly.js-dist’;

maybe this helps?