Support for *.mjs files
See original GitHub issueJavascript 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:
- Created 6 years ago
- Reactions:11
- Comments:6
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To fix this, the default includePattern should be changed to:
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.
It does not make any sense to apply an include pattern on a file, which gets specified in the command line.
It is typical for executable Unix scripts starting with a shebang to avoid the extension. Those scripts need to be documented, too.