You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the eleventy ssr plugin loads modules concurrently, it would previously fail with an error. Something like:
Error: request for '@lit/reactive-element' is not yet fulfilled
at SourceTextModule.link (node:internal/vm/module:198:17)
at ModuleLoader.importModule (/home/aomarks/work/wireit-lit/packages/labs/ssr/src/lib/module-loader.ts:107:7)
at async Promise.all (index 1)
Solution is to closer match the spec. LoadRequestedModules should prepare module for linking by loading all dependencies.
Then when Link is called, LoadRequestedModules must have completed.
However previously our _loadModule method did not load all dependencies, relying on module.link to load the dependencies. This seems to work when not loading multiple modules concurrently.
But, to allow multiple modules to load concurrently I've added some additional module loading logic to _loadModule so dependencies get loaded.
The result is that by the time module.link is reached, all modules should have been loaded.
Test plan
I added a unit test which throws Error: request for 'XXXX' is not yet fulfilled without the fix.
Risk
There is a risk that this adds a regression to the eleventy SSR plugin if something isn't quite right.
AndrewJakubowicz
changed the title
[ssr] fix ModuleLoader failing with multiple concurrent entrypoints
[labs/ssr] fix ModuleLoader failing with multiple concurrent entrypoints
Oct 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #2549
Context
When the eleventy ssr plugin loads modules concurrently, it would previously fail with an error. Something like:
Investigating this issue I found:
Solution is to closer match the spec.
LoadRequestedModulesshould prepare module for linking by loading all dependencies.Then when
Linkis called,LoadRequestedModulesmust have completed.Theory
Before linking our code does:
However previously our
_loadModulemethod did not load all dependencies, relying onmodule.linkto load the dependencies. This seems to work when not loading multiple modules concurrently.But, to allow multiple modules to load concurrently I've added some additional module loading logic to
_loadModuleso dependencies get loaded.The result is that by the time
module.linkis reached, all modules should have been loaded.Test plan
I added a unit test which throws
Error: request for 'XXXX' is not yet fulfilledwithout the fix.Risk
There is a risk that this adds a regression to the eleventy SSR plugin if something isn't quite right.