From e4a90e18bf7a42706e4758f53bf5d0fdffc7cffd Mon Sep 17 00:00:00 2001 From: Edward Jiang Date: Fri, 22 Sep 2023 13:26:18 -0700 Subject: [PATCH] Fix escape strategy for newer versions of metro --- src/plugin/html.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugin/html.js b/src/plugin/html.js index a32b992..d556533 100644 --- a/src/plugin/html.js +++ b/src/plugin/html.js @@ -1,9 +1,9 @@ import { ROOT_ID } from "../common"; -const escape = (src) => src.replace(/`/g, "\\`"); - -export const createContent = (js) => - `export default String.raw\`${escape(wrapByHtml(js))}\`;`; +export const createContent = (js) => { + js = js.replace(/([`$])/g, '\\$1'); + return "export default String.raw`\n"+wrapByHtml(js)+"\n`.replace(/\\\\([`$])/g, '\\$1')"; +} const wrapByHtml = (js) => `