More and more libraries ship under the UMD format which can be loaded as modules or as "old style" global definition. Some developers do rename them as .cjs'.mjs` within their project, as both extension are supported natively by node.
Currently, retire.js can scan .cjs and .mjs files only if those are renamed as .js (or if they are symlinked).
Expected behaviour:Option 1: One approach could be to update the regexp to cover all cases by default, and ensure nobody gets into the situation where javascript files are ignored:
// If `--ext` option is present, use it.
if (extensionRegExp) {
return extensionRegExp.test(filePath);
}
// `.js` file is target by default.
if (filePath.endsWith(".js")) {
return true;
}
Retire.js version: v2.2.3
node version: v14.5.0
Type: Bug: module files (.cjs and .mjs) are not scanned. Feature: command-line parameter to list which extensions are scanned.
Description: Currently, only
.js
files are detected: https://github.com/RetireJS/retire.js/blob/master/node/lib/resolve.js#L73More and more libraries ship under the UMD format which can be loaded as modules or as "old style" global definition. Some developers do rename them as
.cjs'
.mjs` within their project, as both extension are supported natively by node.Currently, retire.js can scan
.cjs
and.mjs
files only if those are renamed as.js
(or if they are symlinked).Expected behaviour: Option 1: One approach could be to update the regexp to cover all cases by default, and ensure nobody gets into the situation where javascript files are ignored:
https://github.com/RetireJS/retire.js/blob/master/node/lib/resolve.js#L73
Option 2: Alternatively, a list of extensions could be provided via a command-line argument, following what
eslint
is allowing:https://github.com/eslint/eslint/blob/master/lib/cli-engine/file-enumerator.js#L240
The second option is more desirable:
.resource
at Salesforce).