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

Don't mutate options object. Fixes #1341 #1342

Merged
merged 1 commit into from Feb 17, 2023

Conversation

robhogan
Copy link
Contributor

Writes source_map, _destroy_ast, etc, to a shallow copy of the options.format || options.output object. This allows an options object to be reused safely in multiple minify calls, without subsequent calls clobbering earlier results.

Fix: #1341

lib/minify.js Outdated Show resolved Hide resolved
@fabiosantoscode
Copy link
Collaborator

I really appreciate this PR. And it's a nice catch too, as I didn't notice that bug before.

@robhogan
Copy link
Contributor Author

Thanks for the quick review - amended.

@fabiosantoscode fabiosantoscode merged commit 3c9fc4c into terser:master Feb 17, 2023
@fabiosantoscode
Copy link
Collaborator

Merged! Thanks again :)

@robhogan robhogan deleted the fix/no-mutate-input branch February 17, 2023 19:39
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.

Mutating options.format is unsafe when config is re-used
2 participants