4 ms·
I have not heard of it but I think the main benefit of ESM over a bunch of `script` tags (what I used before CJS came about) is that the individual modules file
by tomashubelbauer 3y ago
I have not heard of it but I think the main benefit of ESM over a bunch of `script` tags (what I used before CJS came about) is that the individual modules files are isolated and do not share globals which was a common pain point when using `script` tag soup and something that IMO drove a lot of people to use bundlers to avoid this who did not benefit from bundling otherwise (intranet web apps and low traffic Internet apps - their debugability went downhill and stayed there for a long time and even with the introduction of source maps and such, those weren't supported right away in all tooling). If the thing you describe solved this back then I regret not having come across it.
- TheAceOfHearts 3y agoIt's been a really long time since I last used this tool, but I think it always executed asynchronously within a callback function. So doing stuff like `var foo` wouldn't affect the global scope, since your code was always supposed to be placed inside a function call which receives all dependencies as a parameter. https://requirejs.org/docs/api.html https://requirejs.org/docs/api.html
- WorldMaker 3y agoAMD modules (the name of the types of modules that RequireJS and other loaders, there were multiple competitors) were very much a thing. (Still are in the ArcGIS world that bet heavily on ancient framework Dojo and will take years still to migrate to ESM. Though luckily for them they get to skip CommonJS altogether.) Bundlers made people forget the pains but also the useful lessons of AMD modules.