improve usability of global_defs in minify() (#1987)

Use `@key` to `parse()` string value as `AST_Node`.

fixes #1986
This commit is contained in:
Alex Lam S.L
2017-05-22 01:38:43 +08:00
committed by GitHub
parent a1dedeb3ce
commit efdb65913b
4 changed files with 70 additions and 4 deletions

View File

@@ -181,4 +181,19 @@ describe("minify", function() {
assert.strictEqual(err.col, 12);
});
});
describe("global_defs", function() {
it("should throw for non-trivial expressions", function() {
var result = Uglify.minify("alert(42);", {
compress: {
global_defs: {
"@alert": "debugger"
}
}
});
var err = result.error;
assert.ok(err instanceof Error);
assert.strictEqual(err.stack.split(/\n/)[0], "Error: Can't handle expression: debugger");
});
});
});