Fix SourceMaps not including the original *.ts files#2540
Draft
Fix SourceMaps not including the original *.ts files#2540
Conversation
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [BUG] SourceMaps are not including the original *.ts files
Fix SourceMaps not including the original *.ts files
May 20, 2025
MSNev
reviewed
May 28, 2025
| @@ -0,0 +1,186 @@ | |||
| // Simple test to verify source map handling in updateDistEsm.js | |||
Collaborator
There was a problem hiding this comment.
Create a test folder called tools/updateDistEsm/src and put all test code in there, also convert to TypeScript so that this can be compiled and added as a task.
Contributor
Author
There was a problem hiding this comment.
Done. Created tools/updateDistEsm/src folder and moved the test code there as test-sourcemap.ts with TypeScript conversion and added a tsconfig.json for compilation. Commit: 1c5681b
| export const STR_PATH = "path"; | ||
|
|
||
| export const STR_NOT_DYNAMIC_ERROR = "Not dynamic - "; No newline at end of file | ||
| export const STR_NOT_DYNAMIC_ERROR = "Not dynamic - "; |
Collaborator
There was a problem hiding this comment.
reemove all changes from this PR that are just newline changes at the end of the file.
Contributor
Author
There was a problem hiding this comment.
Removed the newline change from shared/AppInsightsCore/src/JavaScriptSDK/InternalConstants.ts by reverting to the original state. Commit: 1c5681b
…and remove newline changes Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
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.
Issue
Source maps were not including references to the original TypeScript (.ts) files, but rather were referencing the rewritten JavaScript (.js) files from the build process. This issue occurred during the
updateDistEsmscript execution, which modifies JavaScript files to replace tslib references with shims (to support IE).Root Cause
In the
updateDistEsm.jsscript, when generating new source maps, it was setting thesourceproperty to the path of the JavaScript file being processed:This caused the source maps to reference the JavaScript files instead of the original TypeScript files.
Solution
Modified the source map generation process to:
Additional Improvements
Testing
Created a test script (
test-sourcemap.js) that simulates the source map update process and verifies that TypeScript references are preserved in all scenarios.Fixes #2440.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.ionode install.mjs(dns block)https://storage.googleapis.com/chrome-for-testing-public/136.0.7103.92/linux64/chrome-headless-shell-linux64.ziphttps://storage.googleapis.com/chrome-for-testing-public/136.0.7103.92/linux64/chrome-linux64.zipnode install.mjs(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.