Add error handling and directory safety for type-map generation#65
Open
sangram-2003 wants to merge 2 commits intowebpack:mainfrom
Open
Add error handling and directory safety for type-map generation#65sangram-2003 wants to merge 2 commits intowebpack:mainfrom
sangram-2003 wants to merge 2 commits intowebpack:mainfrom
Conversation
|
Member
|
Can you change this to ensure the out directory at the beginning of execution, and revert everything else? |
ovflowd
reviewed
Mar 29, 2026
Member
There was a problem hiding this comment.
This change seems wrong. Why you're changing this?
ovflowd
reviewed
Mar 29, 2026
ovflowd
reviewed
Mar 29, 2026
ovflowd
reviewed
Mar 29, 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.
Problems:
No error handling
If folder doesn’t exist → crash
If write fails → silent failure
Directory may not exist
out path might not be created yet
Blocking I/O
writeFileSync blocks event loop (not ideal in tools)
made changes in plugins/processor.mjs
The current implementation writes type-map.json using writeFileSync without ensuring the output directory exists or handling potential errors.
This may cause the process to fail if the directory is missing or if file writing encounters an issue.
This PR improves robustness by:
Ensuring the output directory exists using mkdirSync with recursive option
Wrapping file writing in a try/catch block to prevent crashes and provide meaningful error logs