Skip to content

Commit cbbc2d3

Browse files
committed
Enable verbatimModuleSyntax
1 parent e06a427 commit cbbc2d3

File tree

6 files changed

+40
-24
lines changed

6 files changed

+40
-24
lines changed

.changeset/gold-carpets-yell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"pprof-it": patch
3+
---
4+
5+
Enable verbatimModuleSyntax

package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@changesets/cli": "^2.29.5",
3131
"@eslint/js": "^9.33.0",
3232
"@tsconfig/node18": "^18.2.4",
33+
"@tsconfig/strictest": "^2.0.5",
3334
"@types/foreground-child": "^2.0.2",
3435
"@types/node": "^18.19.122",
3536
"dprint": "^0.50.1",

src/index.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ if (!isPreloading()) {
1616
exitError("pprof-it must be required using the --require flag");
1717
}
1818

19-
import assert from "node:assert";
20-
import fs from "node:fs";
21-
import path from "node:path";
22-
import { isMainThread } from "node:worker_threads";
23-
24-
import * as pprof from "@datadog/pprof";
25-
import { serializeTimeProfile } from "@datadog/pprof/out/src/profile-serializer";
26-
import { TimeProfilerOptions } from "@datadog/pprof/out/src/time-profiler";
27-
import { TimeProfiler as PProfTimeProfiler } from "@datadog/pprof/out/src/time-profiler-bindings";
28-
import { Profile } from "pprof-format";
29-
import { onExit as signalExit } from "signal-exit";
19+
import assert = require("node:assert");
20+
import fs = require("node:fs");
21+
import path = require("node:path");
22+
import worker_threads = require("node:worker_threads");
23+
24+
import pprof = require("@datadog/pprof");
25+
import pprofProfileSerializer = require("@datadog/pprof/out/src/profile-serializer");
26+
import type { TimeProfilerOptions } from "@datadog/pprof/out/src/time-profiler";
27+
import pprofTimeProfilerBindings = require("@datadog/pprof/out/src/time-profiler-bindings");
28+
import type { Profile } from "pprof-format";
29+
import signalExit = require("signal-exit");
3030

3131
enum ProfilerName {
3232
Heap = "heap",
@@ -254,7 +254,7 @@ const DEFAULT_OPTIONS: TimeProfilerOptions = {
254254
};
255255

256256
class TimeProfiler extends Profiler {
257-
private _timeProfiler: typeof PProfTimeProfiler;
257+
private _timeProfiler: typeof pprofTimeProfilerBindings.TimeProfiler;
258258

259259
constructor() {
260260
super(ProfilerName.Time, Options.timeOut);
@@ -267,14 +267,17 @@ class TimeProfiler extends Profiler {
267267
lineNumbers: Options.lineNumbers,
268268
};
269269

270-
this._timeProfiler = new PProfTimeProfiler({ ...options, isMainThread });
270+
this._timeProfiler = new pprofTimeProfilerBindings.TimeProfiler({
271+
...options,
272+
isMainThread: worker_threads.isMainThread,
273+
});
271274
this._timeProfiler.start();
272275
}
273276

274277
protected _stop(): Profile {
275278
const profile = this._timeProfiler.stop(false);
276279

277-
const serialized_profile = serializeTimeProfile(
280+
const serialized_profile = pprofProfileSerializer.serializeTimeProfile(
278281
profile,
279282
Options.timeInterval,
280283
/*gSourceMapper*/ undefined,
@@ -288,7 +291,7 @@ class TimeProfiler extends Profiler {
288291

289292
function onExit(fn: () => void) {
290293
if (Options.signalExit) {
291-
signalExit(fn);
294+
signalExit.onExit(fn);
292295
} else {
293296
process.on("exit", fn);
294297
}

src/main.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
2-
import path from "node:path";
2+
import path = require("node:path");
33

4-
import { foregroundChild } from "foreground-child";
4+
import foregroundChild = require("foreground-child");
55

66
const args = [...process.execArgv, `--require=${path.join(__dirname, "index.js")}`, ...process.argv.slice(2)];
77

8-
foregroundChild(process.execPath, args);
8+
foregroundChild.foregroundChild(process.execPath, args);

tsconfig.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
"extends": "@tsconfig/node18/tsconfig.json",
2+
"extends": ["@tsconfig/node18", "@tsconfig/strictest"],
33
"compilerOptions": {
44
"outDir": "./dist",
55
"declaration": true,
6-
"noImplicitReturns": true,
7-
"noImplicitOverride": true,
8-
"noPropertyAccessFromIndexSignature": true,
9-
"newLine": "lf"
6+
"newLine": "lf",
7+
"verbatimModuleSyntax": true,
8+
"rootDir": "./src"
109
},
11-
"exclude": ["dist", "node_modules"]
10+
"include": ["src"]
1211
}

0 commit comments

Comments
 (0)