@react-router/dev 0.0.0-experimental-7a19e47ea → 0.0.0-experimental-8fdb14ec6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @react-router/dev v0.0.0-experimental-8fdb14ec6
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+
12
+ // vite/profiler.ts
13
+ import fs from "node:fs";
14
+ import path from "node:path";
15
+ import colors from "picocolors";
16
+ var getSession = () => global.__reactRouter_profile_session;
17
+ var start = async (callback) => {
18
+ let inspector = await import("node:inspector").then((r) => r.default);
19
+ let session = global.__reactRouter_profile_session = new inspector.Session();
20
+ session.connect();
21
+ session.post("Profiler.enable", () => {
22
+ session.post("Profiler.start", callback);
23
+ });
24
+ };
25
+ var profileCount = 0;
26
+ var stop = (log) => {
27
+ let session = getSession();
28
+ if (!session) return;
29
+ return new Promise((res, rej) => {
30
+ session.post("Profiler.stop", (err, { profile }) => {
31
+ if (err) return rej(err);
32
+ let outPath = path.resolve(`./react-router-${profileCount++}.cpuprofile`);
33
+ fs.writeFileSync(outPath, JSON.stringify(profile));
34
+ log(
35
+ colors.yellow(
36
+ `CPU profile written to ${colors.white(colors.dim(outPath))}`
37
+ )
38
+ );
39
+ global.__reactRouter_profile_session = void 0;
40
+ res();
41
+ });
42
+ });
43
+ };
44
+
45
+ export {
46
+ getSession,
47
+ start,
48
+ stop
49
+ };