Skip to content

Commit

Permalink
use astring instead of escodegen to circumvent estools/escodegen#396
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiosantoscode committed Sep 5, 2019
1 parent 8af091d commit 8520103
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"devDependencies": {
"acorn": "^7.0.0",
"astring": "^1.4.1",
"csv": "^5.1.2",
"escodegen": "^1.12.0",
"eslint": "^6.3.0",
"eslump": "^2.0.0",
"mocha": "^5.2.0",
Expand Down
7 changes: 3 additions & 4 deletions test/mocha/spidermonkey.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var assert = require("assert");
var fs = require("fs");
var acorn = require("acorn");
var escodegen = require("escodegen");
var astring = require("astring");
var Terser = require("../..");

describe("spidermonkey export/import sanity test", function() {
Expand Down Expand Up @@ -128,12 +128,11 @@ describe("spidermonkey export/import sanity test", function() {
);
});

it("should produce an AST compatible with escodegen", function() {
it("should produce an AST compatible with astring", function() {
var code = fs.readFileSync("test/input/spidermonkey/input.js", "utf-8");
var terser_ast = Terser.parse(code);
var moz_ast = terser_ast.to_mozilla_ast();
var generated = escodegen.generate(moz_ast)
.replace(/\[object Object\].\[object Object\]/g, "new.target"); // escodegen issue
var generated = astring.generate(moz_ast);
var parsed = acorn.parse(generated, {
sourceType: "module",
ecmaVersion: 9
Expand Down

0 comments on commit 8520103

Please sign in to comment.