Support for *.mjs files

See original GitHub issue

Javascript in ES modules with a .mjs file extension are not supported by jsdoc. This is the new extension that’s going to be promoted by NodeJS, and already supported by libraries like @std/esm for ES modules to distinguish them from CommonJS modules. JSDoc should support these files in the same way as *.js files.

JSDoc configuration

{
    "source": {
        "include": ["index.mjs", "lib/**/*"]
    },
    "opts": {
        "destination": "./docs/"
    },
    "plugins": ["plugins/markdown"]
}

JSDoc debug output

$ jsdoc -c jsdoc.conf.json --debug
DEBUG: JSDoc 3.5.4 (Fri, 04 Aug 2017 22:05:27 GMT)
DEBUG: Environment info: {"env":{"conf":{"plugins":["plugins/markdown"],"recurseDepth":10,"source":{"includePattern":".+\\.js(doc|x)?$","excludePattern":"","include":["index.mjs","lib/**/*"]},"sourceType":"module","tags":{"allowUnknownTags":true,"dictionaries":["jsdoc","closure"]},"templates":{"monospaceLinks":false,"cleverLinks":false},"opts":{"destination":"./docs/"}},"opts":{"_":[],"configure":"jsdoc.conf.json","debug":true,"destination":"./docs/","encoding":"utf8"}}}
ERROR: Unable to find the source file or directory /Users/lachlanhunt/Sites/generator-utilities/lib/**/*
There are no input files to process.

Your environment

Software Version
JSDoc 3.5.4
Node.js 8.3.0
npm 5.3.0
Operating system macOS Sierra 10.12.6

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:11
  • Comments:6

github_iconTop GitHub Comments

3reactions
lachlanhuntcommented, Aug 25, 2017

To fix this, the default includePattern should be changed to:

includePattern: '.+\\.(js(doc|x)?|mjs)$',

or equivalent. Given how common mjs files are likely to become once node ships support for ES modules, I believe it justifies adding this to the default.

0reactions
cevingcommented, Nov 10, 2020

It does not make any sense to apply an include pattern on a file, which gets specified in the command line.

$ jsdoc -d doc ./konnektor-mgmt 
There are no input files to process.
$ LC_ALL=C stat ./konnektor-mgmt
  File: ./konnektor-mgmt
  Size: 8533            Blocks: 24         IO Block: 4096   regular file
Device: 801h/2049d      Inode: 3807388     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/     szi)   Gid: ( 1000/     szi)
Access: 2020-11-10 16:46:46.646468000 +0100
Modify: 2020-11-10 16:46:26.202468000 +0100
Change: 2020-11-10 16:46:26.202468000 +0100
 Birth: -

It is typical for executable Unix scripts starting with a shebang to avoid the extension. Those scripts need to be documented, too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use MJS files in Node.js? - DEV Community ‍ ‍
Today I want to show you how to import functions from *.mjs files. You can think of MJS as JavaScript code that is...
Read more >
What is the difference between .js and .mjs files?
mjs an extension for EcmaScript modules · An MJS file is a source code file containing an ES Module (ECMAScript Module) for use...
Read more >
MJS - Node.js ES Module Javascript File
MJS files are saved to disc as plain text format in JavaScript syntax. These can be opened in any text editor and are...
Read more >
Support for *.mjs files · Issue #1430 · jsdoc/jsdoc - GitHub
This is the new extension that's going to be promoted by NodeJS, and already supported by libraries like @std/esm for ES modules to...
Read more >
Files with .mjs extension for JavaScript modules - Medium
mjs is the extension for EcmaScript module files. Node.js or webpack are already handling them and we better know what it means before...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found