Skip to content

Commit

Permalink
Cannot access performance properties at pre-initialization time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Taggart committed Oct 31, 2024
1 parent 4d130a9 commit 79cc63b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cowsay/build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

import { promises as fs } from 'fs';

// https://bun.sh/docs/bundler
await Bun.build({
entrypoints: ['./src/cowsay.ts'],
Expand All @@ -8,4 +11,13 @@ await Bun.build({
// sourcemap: 'inline',
sourcemap: 'none',
});

// Cannot access performance properties at pre-initialization time.
// https://github.com/bytecodealliance/ComponentizeJS/issues/153
// Workaround is to turn off the performance hooks by returning undefined.
// https://github.com/microsoft/TypeScript/blob/main/src/compiler/performanceCore.ts
let js = await fs.readFile('cowsay.js', 'utf8');
js = js.replace('function tryGetPerformanceHooks() {', 'function tryGetPerformanceHooks() { return;');
await fs.writeFile('cowsay.js', js, 'utf8');

export {};

0 comments on commit 79cc63b

Please sign in to comment.