Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve source-map addon: safely enable sourceMap in tsconfig with JSON parsing and fallback#10

Open
Manas-Dikshit wants to merge 1 commit intowebpack:mainfrom
Manas-Dikshit:main
Open

Improve source-map addon: safely enable sourceMap in tsconfig with JSON parsing and fallback#10
Manas-Dikshit wants to merge 1 commit intowebpack:mainfrom
Manas-Dikshit:main

Conversation

@Manas-Dikshit
Copy link

This PR enhances the addons/source-map.js script for better robustness and maintainability.

Changes Made

Safe JSON parsing for the tsconfig.json file before it's updated.
CompilerOptions creation if it does not exist.
Cleaner usage of regex for falling back on JSON parsing.
Consistent JSON formatting for the tsconfig.json file.
Simplified the code with only the most important comments.

Why

The original code only used regex replacement, which could result in an incorrect tsconfig.json file, especially if the JSON formatting was different.
This updated code ensures that the JSON output is always valid, providing a better experience for the user.

Result

The updated addon successfully adds "sourceMap": true to compilerOptions and then reverts the changes on teardown.

Refactor setup and teardown functions to handle sourceMap option in tsconfig.json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant