11import { createRequire } from "node:module" ;
22import { fileURLToPath } from "node:url" ;
3- import { pulse } from "../dist/index.js" ;
43import {
54 appendMarketRows ,
65 createDeepState ,
@@ -22,6 +21,8 @@ import {
2221
2322const require = createRequire ( import . meta. url ) ;
2423
24+ let pulse ;
25+ let pulseRuntimeError = null ;
2526let legendBatch ;
2627let legendObservable ;
2728let proxy ;
@@ -33,6 +34,12 @@ const ENABLED_COMPARISON_LIBRARIES = new Set([
3334 "valtio" ,
3435] ) ;
3536
37+ try {
38+ ( { pulse } = await import ( "../dist/index.js" ) ) ;
39+ } catch ( error ) {
40+ pulseRuntimeError = error ;
41+ }
42+
3643function ensureComparisonDependencies ( ) {
3744 if (
3845 legendBatch !== undefined &&
@@ -57,6 +64,17 @@ function ensureComparisonDependencies() {
5764 }
5865}
5966
67+ function ensurePulseRuntime ( ) {
68+ if ( pulseRuntimeError === null && pulse !== undefined ) {
69+ return ;
70+ }
71+
72+ throw new Error (
73+ "Pulse benchmark runtime is not built. Run `pnpm build` before executing comparison benchmarks." ,
74+ { cause : pulseRuntimeError ?? undefined } ,
75+ ) ;
76+ }
77+
6078function parseComparisonLibraryName ( benchmarkName ) {
6179 if ( benchmarkName === "pulse" || benchmarkName . startsWith ( "pulse " ) ) {
6280 return "pulse" ;
@@ -2497,6 +2515,7 @@ export function createComparisonBenchmarkSections() {
24972515}
24982516
24992517export function runComparisonBenchmarkSuite ( options = { } ) {
2518+ ensurePulseRuntime ( ) ;
25002519 ensureComparisonDependencies ( ) ;
25012520
25022521 return runBenchmarkSuite (
0 commit comments