Skip to content

Drop AMD support from plotly.js bundles in v3 #7228

Closed
@archmoj

Description

@archmoj

Plotly.js bundles used to have a UMD header which supports various contexts including "synchronous" module system known as CommonJS as well as "asynchronous" module system called AMD.
By introduction of native ES6 import in new browsers as well as modern node.js runtimes; which is now the standard way of loading "asynchronous" modules, RequireJS which is an implementation of AMD is no longer under active development. See requirejs/r.js@2.3.6...2.3.7

In this context keeping the AMD support as part of the header we add to the esbuild bundle here could potentially break pages when RequireJS is loaded to the page.

To avoid this situation, it is suggested that we remove the AMD part of the header from the bundles so that the bundle could successfully be loaded via script tags both synchronously and asynchronously using CJS require and ESM import commands

Examples of asynchronous loading

<script type="module">
    import "https://cdn.plot.ly/plotly-3.0.0.min.js"
    Plotly.newPlot("gd", [{ y: [1, 2, 3] }])
</script>
<script type="module" src="https://cdn.plot.ly/plotly-3.0.0.js"></script>

Example of synchronous loading

<script src="https://cdn.plot.ly/plotly-3.0.0.js"></script>
var Plotly = require('plotly');

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions