Every time I import and use DataWorker in different components, entry-client.tsx is re-executed. This issue does not occur in a basic Vite project, so it seems specific to SolidStart.
Expected behavior 🤔
entry-client.tsx should only execute once, and DataWorker should be reusable across components without causing re-execution of the entire file.
1.Create an empty dataworker.ts file
2.In entry-client.tsx, I initialize a SharedWorker:
import dataWorker from "~/worker/dataWorker?sharedworker";export const DataWorker = new dataWorker;
3.Import the sharedworker in routes/index.tsx:
import { DataWorker } from "~/entry-client";const dw = DataWorker;
4.pnpm dev
5.The problem arises when the component is loaded. The entry-client.tsx file is re-executed, and this happens each time I import and use DataWorker in other components.
Context 🔦
I plan to perform intensive computations in a worker thread and share this data between multiple windows.
Your environment 🌎
System: windows 11
Browser: Chrome 128.0.6613.138
solidjs:1.8.22
@solid-start: 1.0.6
Duplicates
Latest version
Current behavior 😯
Every time I import and use DataWorker in different components, entry-client.tsx is re-executed. This issue does not occur in a basic Vite project, so it seems specific to SolidStart.
Expected behavior 🤔
entry-client.tsx should only execute once, and DataWorker should be reusable across components without causing re-execution of the entire file.
Steps to reproduce 🕹
codesandbox example
Steps:
1.Create an empty dataworker.ts file
2.In entry-client.tsx, I initialize a SharedWorker:
import dataWorker from "~/worker/dataWorker?sharedworker";
export const DataWorker = new dataWorker;
3.Import the sharedworker in routes/index.tsx:import { DataWorker } from "~/entry-client";
const dw = DataWorker;
4.pnpm dev 5.The problem arises when the component is loaded. The entry-client.tsx file is re-executed, and this happens each time I import and use DataWorker in other components.Context 🔦
I plan to perform intensive computations in a worker thread and share this data between multiple windows.
Your environment 🌎