-
Notifications
You must be signed in to change notification settings - Fork 487
Resolve imports without extension #569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ function walkExported(ast, data, addComment) { | |
|
||
function getComments(data, path) { | ||
if (!hasJSDocComment(path)) { | ||
return [addBlankComment(data, path, path.node)]; | ||
var added = addBlankComment(data, path, path.node); | ||
return added ? [added] : []; | ||
} | ||
return path.node.leadingComments.filter(isJSDocComment).map(function (comment) { | ||
return addComment(data, comment.value, comment.loc, path, path.node.loc, true); | ||
|
@@ -136,7 +137,12 @@ function traverseExportedSubtree(path, data, addComments, overrideName) { | |
} | ||
} | ||
|
||
function getCachedData(dataCache, path) { | ||
function getCachedData(dataCache, filePath) { | ||
var path = filePath; | ||
if (!nodePath.extname(path)) { | ||
path = require.resolve(path); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this makes sense. A lot of people use node's resolve mechanism today. |
||
} | ||
|
||
var value = dataCache[path]; | ||
if (!value) { | ||
var input = fs.readFileSync(path, 'utf-8'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,13 @@ function _addComment(visited, data, commentValue, commentLoc, path, nodeLoc, inc | |
}); | ||
|
||
if (path.parentPath && path.parentPath.node) { | ||
context.code = data.source.substring | ||
.apply(data.source, path.parentPath.node.range); | ||
var parentNode = path.parentPath.node; | ||
if (parentNode.range) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure when Babel dropped There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We updated our babel deps pretty recently. I think we should be able to remove this. |
||
context.code = data.source.substring | ||
.apply(data.source, parentNode.range); | ||
} else { | ||
context.code = data.source.substring(parentNode.start, parentNode.end); | ||
} | ||
} | ||
} | ||
return parse(commentValue, commentLoc, context); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids running into a NPE later on when
addBlankComment
does not return a value.