-
Notifications
You must be signed in to change notification settings - Fork 13
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
Module resolution improvements #60
Module resolution improvements #60
Conversation
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.
I think it makes sense to remove the moduleRoot
config option, and we can publish a major release with that breaking change. No need to deprecate.
Okay, I've removed |
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.
Thanks, @Daniel-Knights
This PR adds support for resolving module paths using explicit module ids (
@module <id>
) and implicit module ids, mirroring the same method JSDoc uses. Thetypescript.moduleRoot
config option is still prioritised over these for backwards compact.This PR also:
../
path segments from module ids (if a referenced module is located outside the cwd), as they cause errors./index.js
for paths that target the parent directory.Changes
typescript.moduleRoot
config option, only if present and the provided path doesn't existmoduleInfos
andfileNodes
instead of module ids to simplify setting and accessinggetImplicitRoot
function for when there's notypescript.moduleRoot
option or explicit module idgetModuleId
functionmoduleInfos
parser
param fromgetDefaultExportName
andgetDelimiter
as it's being passed to theextension
param ofgetModuleInfo
Additional notes
In my opinion, the
typescript.moduleRoot
config option should be deprecated, as it introduces the risk of a mismatch between what JSDoc considers an existing module id and the id this plugin uses internally.I was unsure how to add tests for this - open to any suggestions.