forked from terser/terser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't mutate options object. Fixes terser#1341
- Loading branch information
Showing
2 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import assert from "assert"; | ||
import { minify } from "../../main.js"; | ||
|
||
describe("no-mutate-input", function() { | ||
|
||
it("does not modify the options object", async function() { | ||
const config = { | ||
format: {}, | ||
sourceMap: true, | ||
}; | ||
|
||
await minify('"foo";', config); | ||
|
||
assert.deepEqual(config, { | ||
format: {}, | ||
sourceMap: true, | ||
}); | ||
}); | ||
|
||
it("does not clobber source maps with a subsequent minification", async function() { | ||
const config = { | ||
format: {}, | ||
sourceMap: true, | ||
}; | ||
|
||
const fooResult = await minify('"foo";', config); | ||
const barResult = await minify('module.exports = "bar";', config); | ||
|
||
const fooMap = fooResult.map; | ||
const barMap = barResult.map; | ||
|
||
assert.notEqual(barMap, fooMap); | ||
}); | ||
}); |