Open andreubotella opened 2 years ago
One issue is how to represent
JsRuntime
identity in those maps.
Does it need to be represented? We can solve this easily by storing GraphData
on instance of CliModuleLoader
which is passed by MainWorker
/WebWorker
down to JsRuntime
. If you need to keep blobs accounted for I believe storing them on the CliModuleLoader
would be the way to go, although I don't know all the nitty gritty details. I'll be tackling this refactor, so if you have any particular requirements, please let me know.
I suspect the requirements for blobs would be the same as for GraphData
: that the graph/blob data must be accessible when resolving and loading every module in a module graph, not just the initial module which is directly handled by CliModuleLoader
.
I suspect the requirements for blobs would be the same as for
GraphData
: that the graph/blob data must be accessible when resolving and loading every module in a module graph, not just the initial module which is directly handled byCliModuleLoader
.
All modules that are loaded are handled by CliModuleLoader
via the load
method - the whole "module graph" is just a requirement for type-checking, if we did not have it the same analysis would be performed (and actually is) by V8 when requesting all modules to be loaded. So this shouldn't be a problem, you'll be able to access state of module loader from within load
method.
Module maps are conceptually specific to an instance of
JsRuntime
, yet part of the module map mechanics in our current implementation is maintained inProcState
, which is shared across multipleJsRuntime
s. An implementation of #12248 would needProcState
to keep a per-JsRuntime
url → blob map, and according to @bartlomieju, something similar would be needed to cache resolved modules.One issue is how to represent
JsRuntime
identity in those maps.JsRuntime
is not cloneable or a reference type, and it is not typically used with a reference-counted pointer type. What's more, if aJsRuntime
is dropped –if a worker is terminated, for example– the blob references and cached modules associated with thatJsRuntime
should be dropped as well, but there doesn't seem to be any obvious way to do this, sinceJsRuntime
has no concept ofProcState
.