Which should have .mjs extension, the importing file or the exporting file, or both?

I have a silly doubt. Which file, the importing file, the exporting file or both should have the .mjs file extension?

I have searched the web but didn’t get my exact answer.

Thanks in advance!

As far I understand (I’m a lerner myself) the module should have the .mjs extension since they signalize that a module is a module.

I post here a couple of resources I found:

From the MDN article:

Throughout this article, we’ve used .js extensions for our module files, but in other resources, you may see the .mjs extension used instead. V8’s documentation recommends this, for example. The reasons given are:

  • It is good for clarity, i.e. it makes it clear which files are modules, and which are regular JavaScript.
  • It ensures that your module files are parsed as a module by runtimes such as Node.js, and build tools such as Babel.

From the StackOverflow answer:

MJS file:

  • mjs an extension for EcmaScript modules

  • An MJS file is a source code file containing an ES Module (ECMAScript Module) for use with a Node.js application.
    MJS files are written in JavaScript, and may also use the .JS extension outside of the Node.js context.

  • ES Modules allow web and application developers to organize code into smaller reusable components.

Well, this answer conflicts with the answer of my question in stackoverflow! But he isn’t also sure.

… which has 0 (zero) upvotes.

Short and clear answer to your question: modules should have the .mjs extension and not the importing files, if these are not a module.