Skip to content

[FEATURE]: Allow using v4 bundled types for the browser #7996

Description

@sbarfurth

Description

It's great that Plotly v4 adds types to the core package. However, the current best way to use Plotly for the browser still seems to be using plotly.js-dist-min since bundling plotly.js fails without Node externs (e.g., Could not resolve "assert"). If I do want to use plotly.js-dist-min though, using the types from the main package is not longer possible (or easy). I need to revert to @types/plotly.js-dist-min, which isn't updated for v4 as of writing.

Why should this feature be added?

Using Plotly in the browser is a fairly common use case. Modern browser apps use build pipelines based on tools like esbuild to bundle and minify their code. Making the experience of this smooth with the built-in types seems useful. This would also allow potentially dropping plotly.js-dist-min and the @types/plotly.js* packages eventually.

Mocks/Designs

n/a

Notes

To reproduce, one can create a simple Angular/React/whatever TypeScript application and add plotly.js as a dependency (and use it somewhere). Trying to run the build will fail. Here's a Stackblitz with Angular:

https://stackblitz.com/edit/stackblitz-starters-teetmqjw?file=src%2Fmain.ts

You can run npm run build there to see issues. There is no advanced setup, this is pretty much vanilla Angular with esbuild for bundling.

Metadata

Metadata

Assignees

Labels

P2considered for next cyclefeaturesomething newsize: 3

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions