mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
0350774d47
Earlier, we introduced GetBaseURI to the module loader. This allows us to get the BaseURI for a dynamic import even after the importing script/module's ScriptLoader has been cleaned up. However, we now need to be able to handle the case where we need to run the dynamic import and load it. In order to do this, we need to create a scriptloader configured for dynamic import. The most important difference between this scriptloader and the one that is normally used for script loading in workers is that we *do not have a syncLoopTarget* to which we return. There are a couple of reasons for this: * Dynamic import (and modules in general) relies on the event loop to resolve. If we create a syncLoop here, we will end up pausing execution, and this breaks the StartModuleLoad algorithm. We will never complete and the result will be that we are in the wrong state when we return here. * We do not have perfect knowledge of the future, so we cannot keep the existing script loader alive in the case that it might be used for loading in the future. * We cannot migrate the ModuleLoader to not use sync loading without significantly changing other aspects of how loading scripts on workers works. This becomes particularily evident with error handling (https://searchfox.org/mozilla-central/rev/00ea1649b59d5f427979e2d6ba42be96f62d6e82/dom/workers/WorkerPrivate.cpp#383-444), and in addition, for reasons I wasn't able to discern, using the CurrentEventTarget results in hard to identify errors. When there is time to investigate this fully, the ModuleLoader may move away from using a syncLoop itself. For now, all main-script loads (whether they are modules or classic scripts) will use the sync loop, and all dynamic imports will create a new script loader for their needs that is not using the sync loop. The book keeping for this is in the next patch. Differential Revision: https://phabricator.services.mozilla.com/D171685 |
||
---|---|---|
.. | ||
ImportMap.cpp | ||
ImportMap.h | ||
LoadContextBase.cpp | ||
LoadContextBase.h | ||
LoadedScript.cpp | ||
LoadedScript.h | ||
ModuleLoaderBase.cpp | ||
ModuleLoaderBase.h | ||
ModuleLoadRequest.cpp | ||
ModuleLoadRequest.h | ||
moz.build | ||
ResolveResult.h | ||
ScriptKind.h | ||
ScriptLoadRequest.cpp | ||
ScriptLoadRequest.h |