diff --git a/packages/evasive-transform/src/generate.js b/packages/evasive-transform/src/generate.js index 468ca255d9..104a3a4b98 100644 --- a/packages/evasive-transform/src/generate.js +++ b/packages/evasive-transform/src/generate.js @@ -66,12 +66,18 @@ 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, + compact: 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, + }); }