Skip to content
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

build: patch terser to create proper source-maps [do not merge] #32277

Conversation

devversion
Copy link
Member

@devversion devversion commented Aug 22, 2019

Currently terser is in a broken state where technically unmapped
bytes in the input file are mapped back to random source files.

To clarify the term "unmapped bytes": In the input file there are bytes
which cannot be mapped back to any source file. This can happen if code
will be generated by tools automatically. e.g. TSC generating decorator helpers, or
rollup creating bundles of multiple files (there will be boilerplate to merge multiple
files into a bundle). These bytes do not originate from any source-file and therefore
are "unmapped". Read more about 1-variable length segments in the source-map spec

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 need to stay broken/incorrect as fixing them would
always cause developers to hit the source-map bug...

This PR should just be an example of how correct source-maps
should look like (helpful when comparing size differences)

See source-map bug: mozilla/source-map#385
See Terser fix: terser/terser#342.

@devversion devversion requested a review from a team as a code owner August 22, 2019 19:20
@mhevery mhevery added the area: build & ci Related the build and CI infrastructure of the project label Sep 3, 2019
@ngbot ngbot bot added this to the needsTriage milestone Sep 3, 2019
@kara kara removed their assignment Sep 9, 2019
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.
@devversion devversion force-pushed the build/patch-terser-output-proper-source-maps branch from 56ca1ea to bf85cd4 Compare October 2, 2019 08:33
@devversion devversion requested a review from a team as a code owner October 2, 2019 08:33
@devversion devversion removed the request for review from a team October 2, 2019 08:33
@jessicajaniuk
Copy link
Contributor

@devversion What's the status with this PR?

@devversion
Copy link
Member Author

@jessicajaniuk This is still an issue with Terser; resulting in incorrect size measurements/goldens in the repo.

Though there isn't a good fix for this yet. I'm closing this for now but want link to terser/terser#382

@devversion devversion closed this Apr 29, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: build & ci Related the build and CI infrastructure of the project cla: yes state: blocked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants