Skip to content

Instantly share code, notes, and snippets.



Created Feb 26, 2021
What would you like to do?
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(
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