Does single-spa root require AMD? #271
-
Hey @joeldenning, have noticed that One of our microfrontend apps conflicts with Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The amd.js extra is not needed in every case, but it was included because it's often needed. For example, loading the official versions of react properly is easiest to do with the amd.js extra (although using the esm-bundle version of react also works). The amd.js extra creates the The UMD format, which is popular for libraries published to npm, first checks whether In my own projects and consulting, I sometimes just remove the amd.js extra entirely because then there are no compatibility issues like that. However, the downside is that you can't reliably load UMD libraries like react or vue2 without finding a System.register version of them. The https://github.com/esm-bundle project exists to help people find, and you can also use the JSPM CDN which has System.register versions of all libraries on npm. See https://single-spa.js.org/docs/recommended-setup#sharing-with-import-maps and https://github.com/systemjs/systemjs/blob/master/docs/module-types.md for more info. |
Beta Was this translation helpful? Give feedback.
The amd.js extra is not needed in every case, but it was included because it's often needed. For example, loading the official versions of react properly is easiest to do with the amd.js extra (although using the esm-bundle version of react also works). The amd.js extra creates the
window.define
global variable, which can cause problems for apps using requirejs, or for apps that load global libraries via script tag but are in UMD format.The UMD format, which is popular for libraries published to npm, first checks whether
window.define
is present. If so, it calls window.define. Otherwise, it creates a global variable. In the case of popular libraries like jQuery that are usually needed as…