Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
fix(parser/js): hasImports discovery for modules without extension
Browse files Browse the repository at this point in the history
  • Loading branch information
zanona committed Nov 19, 2017
1 parent c50e30b commit 03eb106
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions parser/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ exports.setContent = function (content, file) {
* replace require or import statements module names ending with
* .js or .json so these won't get renamed by the general parser
*/
const requireMatch = /require\((['"])(.*?)\.(?:js|json)\1\)/gm,
importMatch = /import((?:.*?from)? +)(["'])(.+?)\.(?:js|json)\2/gm;
const requireMatch = /require\((['"])(.*?)(?:\.js|\.json)?\1\)/gm,
importMatch = /import((?:.*?from)? +)(["'])(.+?)(?:\.js|\.json)?\2/gm;

if (requireMatch.test(content) || importMatch.test(content)) {
file.hasImports = true;
file.hasImports = true;
}

return content.replace(requireMatch, 'require($1$2$1)')
Expand Down

0 comments on commit 03eb106

Please sign in to comment.