Skip to content

Drop AMD support from bundle header #7229

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

Merged
merged 3 commits into from
Oct 17, 2024
Merged

Drop AMD support from bundle header #7229

merged 3 commits into from
Oct 17, 2024

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Oct 17, 2024

Closes #7228.

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');

@plotly/plotly_js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop AMD support from plotly.js bundles in v3
2 participants