-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
Mutating options.format
is unsafe when config is re-used
#1341
Comments
robhogan
added a commit
to robhogan/terser
that referenced
this issue
Feb 17, 2023
This was referenced Feb 17, 2023
robhogan
added a commit
to robhogan/metro
that referenced
this issue
Feb 17, 2023
Summary: Mitigates terser/terser#1341 Terser sets properties inlcuding `source_map` and `_destroy_ast` on the given `options.output` (or `options.format`) object, which can affect subsequent calls where we re-use the same config object. Here we take a shallow copy of the given configuration, so `terser` doesn't mutate `metro-minify-terser`'s input. Changelog: [Fix] Mitigate potential source map mismatches with concurrent transformations (Terser [facebook#1341](terser/terser#1341)) Reviewed By: jacdebug, motiz88 Differential Revision: D43362977 fbshipit-source-id: 019f417aa8cc7897c71a6ab2c7db5d0cf916e59d
robhogan
added a commit
to robhogan/terser
that referenced
this issue
Feb 17, 2023
fabiosantoscode
pushed a commit
that referenced
this issue
Feb 17, 2023
facebook-github-bot
pushed a commit
to facebook/metro
that referenced
this issue
Feb 17, 2023
Summary: Mitigates terser/terser#1341 Terser sets properties inlcuding `source_map` and `_destroy_ast` on the given `options.output` (or `options.format`) object, which can affect subsequent calls where we re-use the same config object. Here we take a shallow copy of the given configuration, so `terser` doesn't mutate `metro-minify-terser`'s input. Changelog: [Fix] Mitigate potential source map mismatches with concurrent transformations (Terser [#1341](terser/terser#1341)) Reviewed By: jacdebug, motiz88 Differential Revision: D43362977 fbshipit-source-id: 940e6209273cdd382513aea2f2a8aeca12daa2e3
robhogan
added a commit
to facebook/metro
that referenced
this issue
Feb 18, 2023
Summary: Mitigates terser/terser#1341 Terser sets properties inlcuding `source_map` and `_destroy_ast` on the given `options.output` (or `options.format`) object, which can affect subsequent calls where we re-use the same config object. Here we take a shallow copy of the given configuration, so `terser` doesn't mutate `metro-minify-terser`'s input. Changelog: [Fix] Mitigate potential source map mismatches with concurrent transformations (Terser [#1341](terser/terser#1341)) Reviewed By: jacdebug, motiz88 Differential Revision: D43362977 fbshipit-source-id: 940e6209273cdd382513aea2f2a8aeca12daa2e3
robhogan
added a commit
to facebook/metro
that referenced
this issue
Feb 19, 2023
Summary: Mitigates terser/terser#1341 Terser sets properties inlcuding `source_map` and `_destroy_ast` on the given `options.output` (or `options.format`) object, which can affect subsequent calls where we re-use the same config object. Here we take a shallow copy of the given configuration, so `terser` doesn't mutate `metro-minify-terser`'s input. Changelog: [Fix] Mitigate potential source map mismatches with concurrent transformations (Terser [#1341](terser/terser#1341)) Reviewed By: jacdebug, motiz88 Differential Revision: D43362977 fbshipit-source-id: 940e6209273cdd382513aea2f2a8aeca12daa2e3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report or Feature request?
Bug report
Version (complete output of
terser -V
or specific git commit)Confirmed on
5.15.0
and current main (e062dc8)Description
Terser stores its source map output on the input config object, under
options.format.source_map
. The returned value includes a getter for amap
property, which usesoptions.format.source_map
. Ifoptions.format.source_map
changes between theminify
result and the use of the getter, the output may be incorrect.In particular, a second call to
minify
using the same config object will clobbersource_map
.Failing test
Expected result
Test passes - reusing a config object should not affect previous output.
The text was updated successfully, but these errors were encountered: