[PATCH] D66584: [clang-format] Support .mjs module javascript extension in clang-format

Fergal Daly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 20:01:49 PDT 2019


fergald added a comment.

"why .mjs is so common that it justifies a clang-format change?"

I don't have data but Module JS is the future, it's supported by all major browsers for some time and also Node.js, it solves the problem of everything being lumped into one namespace.

Why does it need a different suffix? It adds the "export" and "import" keywords and so it incompatible with common JS. Forcing everyone to keep using js for both is not helpful (clang-format is not forcing of course but applying clang-format with --assume-filename is pretty awkward).

Node specifies .mjs as the suffix

https://medium.com/@nodejs/announcing-a-new-experimental-modules-1be8d2d6c2ff
https://nodejs.org/api/esm.html

So the use of the .mjs suffix is going to grow in volume as people modernize their project. It would be great for clang-format to be enabling that migration.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66584/new/

https://reviews.llvm.org/D66584





More information about the cfe-commits mailing list