dojo / webpack-contrib

Plugins and loaders for webpack used with Dojo
Other
4 stars 19 forks source link

Run blocks in a separate node context #267

Closed agubler closed 4 years ago

agubler commented 4 years ago

Enhancement

At the moment blocks are executed in the main node context which is shared between all blocks and the jsdom if build time rendering is use the jsdom renderer. This can be problematic given blocks are always executed in node and jsdom attempts to simulate a browser like env. Also it means that we have to currently "evict" modules from the cache in order for blocks to use updated modules.

We should try to use worker_threads for executing the build-time-render blocks, which would give each block an isolated context to run in and ensure that there is no shared state with the main process.

This would also mean we can remove the code that attempts to clear loaded modules.

Note worker_threads are only available from node v12+, this change would put a hard dependency on consumers having node v12 or later.