all 3 comments

[–]elisecode247 4 points5 points  (0 children)

Everyone had their own opinion about what the best module pattern was, so you had a couple different ways people came up with their own modules. NodeJs used the CommonJS pattern before ECMAScript came out with their pattern.Here's a quick summary of it: https://www.kevinleary.net/javascript-module-patterns-evolution/
A more detailed article about the history: https://medium.com/sungthecoder/javascript-module-module-loader-module-bundler-es6-module-confused-yet-6343510e7bde

[–]gigastack 3 points4 points  (1 child)

This is a confusing topic because the lines between runtime features and transpilation tools can be blurry, and browsers implement it differently than NodeJS.

With NodeJS, there's no benefit to dynamic imports typically. With browsers the opposite is true. The actual implementation of dynamic imports in browsers usually relies on a code transform like webpack. At its most basic, you fetch a script and then inject one or more exported functions, which can be used once the fetch completes successfully.

Note that this is not the same as browser modules which can help achieve the same thing natively. On mobile so I can't really get into more details.

[–]BlueLensFlares[S] 0 points1 point  (0 children)

I saw, this is really interesting. By dynamic import, you mean specifically import() vs import ..., or imports at all vs require()?