From 70abc8128acb1d779dc0b155b186f8201c06b23e Mon Sep 17 00:00:00 2001 From: FoxMoss Date: Tue, 15 Aug 2023 17:31:22 -0500 Subject: [PATCH] Prevent (async () => {})() from causing Astring to throw an error. --- lib/global/rewrite/js/process.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/global/rewrite/js/process.ts b/lib/global/rewrite/js/process.ts index 5f30de96..0cf86512 100644 --- a/lib/global/rewrite/js/process.ts +++ b/lib/global/rewrite/js/process.ts @@ -1,14 +1,14 @@ import DynamicRewrites from "../../rewrite"; import js from "./js"; -export default function process (this: js, src: string, config: Object | any = {}, ctx: any, dynamic: Object | any) { - var ast = this.ctx.modules.acorn.parse(src.toString(), {sourceType: config.module ? 'module' : 'script', allowImportExportEverywhere: true, allowAwaitOutsideFunction: true, allowReturnOutsideFunction: true, ecmaVersion: "latest", preserveParens: true, loose: true, allowReserved: true}); +export default function process(this: js, src: string, config: Object | any = {}, ctx: any, dynamic: Object | any) { + var ast = this.ctx.modules.acorn.parse(src.toString(), { sourceType: config.module ? 'module' : 'script', allowImportExportEverywhere: true, allowAwaitOutsideFunction: true, allowReturnOutsideFunction: true, ecmaVersion: "latest", preserveParens: false, loose: true, allowReserved: true }); - this.iterate(ast, (node:any, parent:any = null) => { - this.emit(node, node.type, parent, ctx, dynamic, config); - }); + this.iterate(ast, (node: any, parent: any = null) => { + this.emit(node, node.type, parent, ctx, dynamic, config); + }); - src = this.ctx.modules.estree.generate(ast); + src = this.ctx.modules.estree.generate(ast); - return src; -} \ No newline at end of file + return src; +}