Skip to content

@simplemodule/client/resolve-page hardcodes 'SimpleModule.${moduleName}' prefix; fails for consumer-built modules #132

@antosubash

Description

@antosubash

@simplemodule/client/src/resolve-page.ts builds the asset URL as:

const assemblyName = `SimpleModule.${moduleName}`;
const mod = await import(`/_content/${assemblyName}/${assemblyName}.pages.js${suffix}`);

This works for framework-published modules (SimpleModule.Users, etc.) but breaks for any module a downstream app builds in its own assembly (Customers, Invoices, MyApp.Orders — anything without the SimpleModule. prefix).

Right now consumers either roll their own resolver (and lose any future framework UX features) or they can't load the framework's React UIs from their own host. Pick one.

Suggested fix

Try the bare name first, fall back to the SimpleModule-prefixed form. Verified working in a downstream consumer:

async function tryImportPages(name: string) {
  try { return await import(`/_content/${name}/${name}.pages.js${suffix}`); }
  catch { return null; }
}

const mod =
  (await tryImportPages(moduleName)) ??
  (await tryImportPages(`SimpleModule.${moduleName}`));

Both local-app modules and framework-published modules resolve correctly, with the harmless cost of one 404 probe before fallback for framework modules. (Could be silenced with a known-prefix list if desired.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions