-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compressed source-maps have non-terminated segments #342
Fix compressed source-maps have non-terminated segments #342
Conversation
a60ff77
to
904002f
Compare
I second @filipesilva in his comment, so please do change that one thing :) I very much appreciate the effort that went into this PR. Source map issues are pesky, hard to debug, hard to track the origin of, and just a major pain in the backside in terms of DX. |
Currently when `terser` compresses a given input file that comes with a source-map, but the source-map does not have mappings for all code parts in the input file. e.g. the input file has been generated and some specific code-parts have been generated which are not originating from any source-file. In that case if mappings before the "generated code" are collected, and the original file location for the "generated code" comes after previous segments for the same line, Terser just ignores the fact that there is no original location and the previous segment is not terminated. This causes the "generated code" incorrectly to be mapped to the previous segment/ original source location.
904002f
to
4c7b61d
Compare
@fabiosantoscode Sure. I just didn't have time to address that comment until now. Thanks for the feedback you all! Updated now! 😄 |
Hi @fabiosantoscode, is there anything I could do to move this forward? Happy to help in case something is unclear, or if you have any concerns in regards to increased source-map size due to more mappings. |
@devversion thanks for the ping, I'm merging this. Thank you very much for your contribution! |
Thank you! @fabiosantoscode 😄 |
This reverts commit 7d47254.
Currently terser is in a broken state where technically unmapped bytes in the input file are randomly mapped back to source files. "unmapped bytes" are bytes in the input file (that should be minified), which cannot be mapped back to any source file. This is totally valid as some code will be generated by rollup in order to create bundles of multiple files. These bytes do not originate from any source-file and therefore do not map. In the current state of Terser where unmapped bytes are mapped to random source-files, size tracking tools are not able to determine accurate payload size contribution numbers of individual source-files, nor do the broken source-maps help with debugging Angular packages as some bytes are incorrectly mapping to a wrong file (this is not a big deal though as the generated code is not likely to be debugged). For context why we try to fix the terser bug on our side now: A PR to fix this bug on the terser side has been submitted but it had to be reverted due to a bug in the latest `mozilla/source-map` library. Terser reverted the fix that hit the bug in `mozilla/source-map` as they wanted to unblock consumers that use the latest `source-map` package. Problem is that the bug in the `source-map` package is widely spread and there doesn't seem to be a fix for it any time soon. Meaning that source-maps needs to stay broken/incorrect as fixing them would always cause developers to hit the `source-map` bug... See `source-map` bug: mozilla/source-map#385 See Terser fix: terser/terser#342.
Currently terser is in a broken state where technically unmapped bytes in the input file are randomly mapped back to source files. "unmapped bytes" are bytes in the input file (that should be minified), which cannot be mapped back to any source file. This is totally valid as some code will be generated by rollup in order to create bundles of multiple files. These bytes do not originate from any source-file and therefore do not map. In the current state of Terser where unmapped bytes are mapped to random source-files, size tracking tools are not able to determine accurate payload size contribution numbers of individual source-files, nor do the broken source-maps help with debugging Angular packages as some bytes are incorrectly mapping to a wrong file (this is not a big deal though as the generated code is not likely to be debugged). For context why we try to fix the terser bug on our side now: A PR to fix this bug on the terser side has been submitted but it had to be reverted due to a bug in the latest `mozilla/source-map` library. Terser reverted the fix that hit the bug in `mozilla/source-map` as they wanted to unblock consumers that use the latest `source-map` package. Problem is that the bug in the `source-map` package is widely spread and there doesn't seem to be a fix for it any time soon. Meaning that source-maps needs to stay broken/incorrect as fixing them would always cause developers to hit the `source-map` bug... See `source-map` bug: mozilla/source-map#385 See Terser fix: terser/terser#342.
Currently terser is in a broken state where technically unmapped bytes in the input file are randomly mapped back to source files. "unmapped bytes" are bytes in the input file (that should be minified), which cannot be mapped back to any source file. This is totally valid as some code will be generated by rollup in order to create bundles of multiple files. These bytes do not originate from any source-file and therefore do not map. In the current state of Terser where unmapped bytes are mapped to random source-files, size tracking tools are not able to determine accurate payload size contribution numbers of individual source-files, nor do the broken source-maps help with debugging Angular packages as some bytes are incorrectly mapping to a wrong file (this is not a big deal though as the generated code is not likely to be debugged). For context why we try to fix the terser bug on our side now: A PR to fix this bug on the terser side has been submitted but it had to be reverted due to a bug in the latest `mozilla/source-map` library. Terser reverted the fix that hit the bug in `mozilla/source-map` as they wanted to unblock consumers that use the latest `source-map` package. Problem is that the bug in the `source-map` package is widely spread and there doesn't seem to be a fix for it any time soon. Meaning that source-maps needs to stay broken/incorrect as fixing them would always cause developers to hit the `source-map` bug... See `source-map` bug: mozilla/source-map#385 See Terser fix: terser/terser#342.
Currently terser is in a broken state where technically unmapped bytes in the input file are randomly mapped back to source files. "unmapped bytes" are bytes in the input file (that should be minified), which cannot be mapped back to any source file. This is totally valid as some code will be generated by rollup in order to create bundles of multiple files. These bytes do not originate from any source-file and therefore do not map. In the current state of Terser where unmapped bytes are mapped to random source-files, size tracking tools are not able to determine accurate payload size contribution numbers of individual source-files, nor do the broken source-maps help with debugging Angular packages as some bytes are incorrectly mapping to a wrong file (this is not a big deal though as the generated code is not likely to be debugged). For context why we try to fix the terser bug on our side now: A PR to fix this bug on the terser side has been submitted but it had to be reverted due to a bug in the latest `mozilla/source-map` library. Terser reverted the fix that hit the bug in `mozilla/source-map` as they wanted to unblock consumers that use the latest `source-map` package. Problem is that the bug in the `source-map` package is widely spread and there doesn't seem to be a fix for it any time soon. Meaning that source-maps needs to stay broken/incorrect as fixing them would always cause developers to hit the `source-map` bug... See `source-map` bug: mozilla/source-map#385 See Terser fix: terser/terser#342.
…ts (terser#342)" (terser#381)" This reverts commit 7c1e9cc.
…ts (terser#342)" (terser#381)" This reverts commit 7c1e9cc.
…ts (terser#342)" (terser#381)" This reverts commit 7c1e9cc.
Currently when
terser
compresses a given input file that comeswith a source-map, but the source-map does not have mappings for
all code parts in the input file. e.g. the input file has been generated
and some specific code-parts have been generated and are not
originating from any source-file (i.e. rollup boilerplate to create bundle)
In that case if real mappings before the "generated code" are collected, and
the original file location for the "generated code" is determined after previous
mappings for the same line have been recorded, Terser just ignores the fact that
there is no original location and the previous segment is not terminated. Meaning that the"generated code" incorrectly maps to the previous segment.