-
Notifications
You must be signed in to change notification settings - Fork 33
Fix route-analyzer not handling equal module basenames #482
Fix route-analyzer not handling equal module basenames #482
Conversation
absolutePath = path.join(programDirectory, moduleFolderPath, loadChildrenImportPath); | ||
} | ||
|
||
// '.ts' is often omitted on TS imports. |
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.
Isn't the ts extension disallowed in imports? The compiler is often looking for .d.ts
files or it could even be a JS file? Can you explain in a comment when .ts
is present?
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 got it mixed up with js. You are correct, this never happens... And never will happen. Found this read to be interesting: microsoft/TypeScript#35589
44d8eb6
to
fd4fd1a
Compare
|
||
// Using absolute path prevents issues when two module files have the exact same name | ||
function getLoadChildrenAbsolutePath(moduleFolderPath: string, loadChildrenImportPath: string): string { | ||
let absolutePath: string; |
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.
Nitpicking since const
is preferred
const absolutePath = path.isAbsolute(moduleFolderPath
? path.join(moduleFolderPath, loadChildrenImportPath)
: path.join(programDirectory, moduleFolderPath, loadChildrenImportPath);
// Must append the file extension, as the TS imports never include it
return `${absolutePath}.ts`;
projects/route-analyzer/CHANGELOG.MD
Outdated
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | |||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
|
|||
## [Unreleased] | |||
- Fix route-analyzer to use absolute paths instead of basenames |
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.
Please add the header and include something that helps the user know what happened instead of a description of the code change.
### [Fixed]
Fixed bug that broke the route-analyzer when two routing modules had the same base name
### Fixed
fd4fd1a
to
26403a9
Compare
Before this commit, the route-analyzer would search for modules by their basenames (my-module.ts). This could match the wrong module in cases where we had two module files with same name but in different folders. This change fixes the issue by matching absolute paths instead of only basenames. Signed-off-by: Davi Barreto <[email protected]>
26403a9
to
be171b0
Compare
Before this commit, the route-analyzer would search for modules by their basenames (eg. my-module.ts). This could match the wrong module in cases where we had two module files with same file name but in different folders.
This change fixes the issue by matching absolute paths instead of only basenames.
Signed-off-by: Davi Barreto [email protected]
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What does this change do?
This change makes the route-analyzer correctly handle duplicate file names by using the absolute path.
What manual testing did you do?
Test new output is unchanged when there are no duplicate module names
Test the old script breaks when duplicate modules are found
Test the new script works when duplicate modules are found
Does this PR introduce a breaking change?