From 072d6186815efcc072fc86f6b9a83a0712800c2a Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 30 Aug 2023 09:14:07 -0700 Subject: [PATCH] Use String.prototype.replaceAll in sourcemap removal script Summary: Apply suggestion from D48605129 to have access to "modern" `replaceAll`. Reviewed By: lblasa Differential Revision: D48642120 fbshipit-source-id: 1e273fe5590e7b4a48c9176ef5f1afdab688b7d6 --- .../scripts/remove-sourcemap-reference.tsx | 13 +------------ .../public/reactdevtools/scripts/tsconfig.json | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/desktop/plugins/public/reactdevtools/scripts/remove-sourcemap-reference.tsx b/desktop/plugins/public/reactdevtools/scripts/remove-sourcemap-reference.tsx index 0901d07ce..8641083fc 100644 --- a/desktop/plugins/public/reactdevtools/scripts/remove-sourcemap-reference.tsx +++ b/desktop/plugins/public/reactdevtools/scripts/remove-sourcemap-reference.tsx @@ -22,14 +22,6 @@ import path from 'path'; const SOURCEMAP_REFERENCE = '//# sourceMappingURL=importFile.worker.worker.js.map'; -// Remove this once we're upgrade to a newer JS version. String.prototype.replaceAll is a thing. -function replaceAll(s: string, find: string, replace: string): string { - return s.replace( - new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), - replace, - ); -} - async function main() { const frontendPath = path.resolve( __dirname, @@ -48,10 +40,7 @@ async function main() { return 0; } - await fs.writeFile( - frontendPath, - replaceAll(content, SOURCEMAP_REFERENCE, ''), - ); + await fs.writeFile(frontendPath, content.replaceAll(SOURCEMAP_REFERENCE, '')); console.log('react-devtools-inline patched successfully.'); return 0; diff --git a/desktop/plugins/public/reactdevtools/scripts/tsconfig.json b/desktop/plugins/public/reactdevtools/scripts/tsconfig.json index 7d5fb90c4..a8d67065a 100644 --- a/desktop/plugins/public/reactdevtools/scripts/tsconfig.json +++ b/desktop/plugins/public/reactdevtools/scripts/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2017", + "target": "ES2021", "module": "nodenext", "jsx": "react", "noEmit": true, @@ -9,4 +9,3 @@ "esModuleInterop": true } } -