Created
February 26, 2021 08:04
-
-
Save mizchi/ae646ae7f1da39e3e37e184f02ec3a34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Patch typescript to run in snowpack. | |
I added this workaround for perf_hooks. | |
Add this task in package.json | |
"scripts": { | |
// ... | |
"postinstall": "node scripts/rewrite-ts.js", | |
} | |
*/ | |
const fs = require("fs"); | |
const path = require("path"); | |
const ts_path = path.join( | |
__dirname, | |
"../node_modules/typescript/lib/typescript.js" | |
); | |
const code = fs.readFileSync(ts_path, "utf-8"); | |
const rewrote = code.replace('require("perf_hooks")', "{}"); | |
fs.writeFileSync(ts_path, rewrote); | |
console.log("patched", ts_path); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment