-
SummaryTurbopack implements a parallel loader by running it in a separate process after a certain amount of time when executing a loader. I need a way to share data within the Turbopack loader, or an option to ensure that only a single process is used. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Hi @owjs3901, turbopack runs each loader in its own worker process to enable parallel execution, which means that global variables and shared memory cannot be directly accessed across different loaders. This process isolation is intentional for performance and stability but prevents sharing in-memory state between loaders. If you need to persist or share data, the recommended approach is to use an external store such as a temporary file, a JSON cache, or a lightweight in-memory database like Redis to coordinate data between processes. However, if your goal is simply to avoid parallelization for debugging or deterministic builds, you can disable Turbopack’s parallel loader by setting the environment variable TURBOPACK_PARALLEL=0. This ensures that all loaders run in a single process. At the moment, Turbopack doesn’t provide an API to share JavaScript memory objects directly between loaders, so using an external synchronization layer or single-process mode is the most reliable solution. |
Beta Was this translation helpful? Give feedback.
-
|
I implement feature |
Beta Was this translation helpful? Give feedback.



Thanks, as I mentioned above, we don't have a timeline for this yet, and because we're not really sure what API we want yet, it likely wouldn't be a good task for an external contributor. We've also got some other architectural issues with how we run loaders that we'd probably want to fix before adding this.