fix(processor): resolve malformed URLs and incomplete type mapping#19
Open
moshams272 wants to merge 2 commits intowebpack:mainfrom
Open
fix(processor): resolve malformed URLs and incomplete type mapping#19moshams272 wants to merge 2 commits intowebpack:mainfrom
moshams272 wants to merge 2 commits intowebpack:mainfrom
Conversation
avivkeller
requested changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Issue #3 regarding malformed URLs and incomplete type mapping in the generated type-map.json file.
Problems Solved:
Malformed URLs: TypeDoc sometimes generates URLs with multiple hash fragments (e.g., globals.html#compiler-1#webpack), which leads to broken links in the final documentation.
Incomplete Mapping: The previous implementation failed to resolve nested types or full names, causing gaps in the type-map where JSDoc references couldn't be matched.
Changes:
Modularized the logic by introducing a cleanTypeDocUrl helper function.
Implemented a safe .md to .html extension replacement using Regex to avoid accidental matches in filenames (e.g., utils.md5.md).
Added a hash-cleaning logic that preserves the base path and the final, most specific anchor.
Updated the processor to register both shortName and fullName (via ref.getFullName()) for all reflections, ensuring full coverage for JSDoc references.
What kind of change does this PR introduce?
A fix and refactor. It fixes the broken URL generation and refactors the mapping logic for better maintainability and performance.
Did you add tests for your changes?
Verified the changes by running npm run generate-docs against the webpack source and manually inspecting the resulting type-map.json to ensure all URLs are well-formed and all types are correctly mapped.
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
N/A (This is a fix for the internal documentation toolchain).
Use of AI
I used an AI collaborator to help brainstorm the regex patterns and refactor the code into a more modular structure. The AI assisted in identifying edge cases for URL fragments and ensuring the code adheres to clean-code principles, while All technical investigations, local builds, and final code changes were performed and verified by me manually.