I don't understand what actual concrete benefit there is to using .mjs on client-side JavaScript modules. It seems to only cause problems with tools that .js completely avoids. What's the specific upside?
-
-
With .js for client-side modules, the mental model becomes: // Decide which extension to use: extension = (isBrowserOnlyCode || !isModule) ? '.js' : '.mjs' // Is the given file a module: isModule = extension === '.mjs' || (isBrowserOnlyCode && lookWhereAndHowFileGetsLoaded);
-
If you’re willing to jump through configuration and mental model hoops, feel free to use a different extension. I think avoiding the hassle is a fair recommendation and a sensible default.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.