diff --git a/packages/evasive-transform/package.json b/packages/evasive-transform/package.json index f4c22cf1a7..64b81f3e4a 100644 --- a/packages/evasive-transform/package.json +++ b/packages/evasive-transform/package.json @@ -75,7 +75,7 @@ "timeout": "2m" }, "dependencies": { - "@agoric/babel-generator": "^7.17.6", + "@babel/generator": "^7.17.6", "@babel/parser": "^7.23.6", "@babel/traverse": "^7.23.6", "source-map-js": "^1.2.0" diff --git a/packages/evasive-transform/src/generate.js b/packages/evasive-transform/src/generate.js index 468ca255d9..43de4fd1af 100644 --- a/packages/evasive-transform/src/generate.js +++ b/packages/evasive-transform/src/generate.js @@ -4,7 +4,7 @@ * @module */ -import babelGenerator from '@agoric/babel-generator'; +import babelGenerator from '@babel/generator'; // TODO The following is sufficient on Node.js, but for compatibility with // `node -r esm`, we must use the pattern below. @@ -66,12 +66,17 @@ export const generate = // TODO Use options?.sourceUrl when resolved: // https://github.com/Agoric/agoric-sdk/issues/8671 const sourceUrl = options ? options.sourceUrl : undefined; - const result = generator(ast, { - sourceFileName: sourceUrl, - sourceMaps: Boolean(sourceUrl), - retainLines: true, - compact: true, - }); + const source = options ? options.source : undefined; + const result = generator( + ast, + { + sourceFileName: sourceUrl, + sourceMaps: Boolean(sourceUrl), + retainLines: true, + preserveFormat: true, + }, + source, + ); if (sourceUrl) { return { diff --git a/packages/evasive-transform/src/index.js b/packages/evasive-transform/src/index.js index cb3cc0025e..0dc60bba94 100644 --- a/packages/evasive-transform/src/index.js +++ b/packages/evasive-transform/src/index.js @@ -72,7 +72,7 @@ export function evadeCensorSync(source, options) { if (sourceUrl) { return generate(ast, { sourceUrl }); } - return generate(ast); + return generate(ast, { source }); } /** diff --git a/packages/evasive-transform/src/parse-ast.js b/packages/evasive-transform/src/parse-ast.js index 9bb74dbe2d..e93fa37f90 100644 --- a/packages/evasive-transform/src/parse-ast.js +++ b/packages/evasive-transform/src/parse-ast.js @@ -33,7 +33,11 @@ const { parse: parseBabel } = babelParser; * @param {ParseAstOptions} [opts] - Options for underlying parser * @internal */ -export function parseAst(source, opts) { +export function parseAst(source, opts = {}) { // Might not want to pass `opts` verbatim, but also might not matter! - return parseBabel(source, opts); + return parseBabel(source, { + tokens: true, + createParenthesizedExpression: true, + ...opts, + }); }