Skip to content

[labs/ssr] ModuleLoader linker fails with multiple concurrent entrypoints #2549

@aomarks

Description

@aomarks

Given two modules that both import lit, this approach works fine:

new ModuleLoader(...);
for (const mod of modules) {
  await loader.importModule(module, referrer);
}

But this approach consistently fails:

new ModuleLoader(...);
await Promise.all(modules.map((module) =>
  loader.importModule(module, referrer));
);

with an error 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)
        at AsyncEventEmitter.<anonymous> (/home/aomarks/work/wireit-lit/packages/labs/eleventy-plugin-lit/src/index.ts:85:7)
        at async Promise.all (index 0)
        at async Eleventy.executeBuild (/home/aomarks/work/wireit-lit/packages/labs/eleventy-plugin-lit/node_modules/@11ty/eleventy/src/Eleventy.js:971:7)

Decent chance there is a timing issue in the ModuleLoader class

export class ModuleLoader {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions