-
-
Notifications
You must be signed in to change notification settings - Fork 78
Fix issue with plotly.js + webpack + typescript #10
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
Comments
|
@bpostlethwaite Do you suggest that we update our current implementation (add plotly.js script to HTML body and then use Plotly.newPlot)? |
I have been building plotly.js with webpack successfully on another project using the instructions above (or more simply: https://github.com/plotly/plotly.js#building-plotlyjs-with-webpack). It isn't hard to set up so if you think it will result in a simpler system or cleaner code then I recommend giving it a shot. |
We unfortunately don't have access to the webpack config, so we can't use ify-loader. We are essentially doing what is described in the create-react-app instructions. |
Ah right ok. Yes that should work. Also I think
Works as the dist is precompiled. We're working on a better solution but I don't have a timeline |
Yep the core is really minimal and if you are using it you are meant to manually register the components you are interested in. Try importing one of the dists. They are shipped in the npm tarball so you can scoop one of them using the direct path and bundle name from: https://github.com/plotly/plotly.js/tree/master/dist Example
I think that should work. |
I suspect that webpack would warn when loading that file. We've seen that when xterm.js shipped a umd file. |
I have an older branch where I tried: import * as Plotly from 'plotly.js/lib/core';
import Bar from 'plotly.js/lib/bar';
import Box from 'plotly.js/lib/box';
import Choropleth from 'plotly.js/lib/choropleth';
import Contour from 'plotly.js/lib/countour';
import Heatmap from 'plotly.js/lib/heatmap';
import Histogram from 'plotly.js/lib/histogram';
import Histogram2D from 'plotly.js/lib/histogram2d';
import Histogram2DCountour from 'plotly.js/lib/histogram2dcontour';
import Mesh3D from 'plotly.js/lib/mesh3d';
import Pie from 'plotly.js/lib/pie';
import Scatter3D from 'plotly.js/lib/scatter3d';
import ScatterGeo from 'plotly.js/lib/scattergeo';
import ScatterGL from 'plotly.js/lib/scattergl';
import Surface from 'plotly.js/lib/surface';
Plotly.register([
Bar,
Box,
Choropleth,
Contour,
Heatmap,
Histogram,
Histogram2D,
Histogram2DCountour,
Mesh3D,
Pie,
Scatter3D,
ScatterGeo,
ScatterGL,
Surface
]); It didn't work at the time, probably because Typescript requires definitions for each of those modules and I didn't provide them... |
When using plotly.js with webpack, the default export causes the following runtime error:
Importing
plotly.js/lib/core
resolves this issue, but the type declarations provided by@types/plotly.js
don't provide delcarations for theplotly.js/lib/core
module (even though that module is identical to the default module).I think the only way to resolve this is to add a declaration for
plotly.js/lib/core
to@types/plotly.js
...The text was updated successfully, but these errors were encountered: