Skip to content

Hosting.targets uses undefined $(RepoRoot) + monorepo-relative paths → consumer frontend build never runs; app.js 302s to login #221

Closed

Description

@antosubash

Summary

The shipped SimpleModule.Hosting.targets (Tailwind + Vite build integration) references an undefined $(RepoRoot) and monorepo-relative paths, so in a downstream consumer the integrated frontend build never runs — and a follow-on MapStaticAssets interaction causes the app's bootstrap script to 302-redirect to the login page (blank app).

Details

build/SimpleModule.Hosting.targets uses:

<TailwindSourceFiles Include="$(RepoRoot)packages/SimpleModule.Theme.Default/theme.css" />
...
Condition="Exists('$(TailwindInput)') And !Exists('$(RepoRoot)node_modules')"
...
Command="node &quot;$(RepoRoot)scripts/extract-ts-types.mjs&quot; ... &quot;$(RepoRoot)modules&quot;"

$(RepoRoot) is not defined anywhere in a sm new project scaffold, and $(RepoRoot)packages/... / $(RepoRoot)modules are monorepo-only layouts (a consumer has src/modules and gets the theme from the @simplemodule/theme-default npm package). Result:

  1. Even with node_modules present at the repo root, the build prints
    warning : node_modules not found. Tailwind CSS will not be compiled. and
    ... Frontend JavaScript will not be compiled.
  2. The integrated Tailwind/Vite build is skipped, so the consumer must run npm run build manually.
  3. If npm run build runs after dotnet build, the MapStaticAssets manifest (generated during dotnet build) does not contain wwwroot/js/app.js. At runtime the <script src="/js/app.js"> request is not a static-asset endpoint, falls through to the FallbackPolicy = RequireAuthenticatedUser, and 302-redirects to /Identity/Account/Login → Failed to load module script: Expected a JavaScript module but the server responded with text/html → blank page.

Repro

sm new project X && cd X && npm install
dotnet build            # manifest captured here, before app.js exists
npm run build           # now wwwroot/js/app.js exists, but not in the manifest
dotnet run --project src/X.Host
# browse the app -> /js/app.js 302 -> login, React never hydrates

Suggested fix

  • Define $(RepoRoot) in the scaffold (e.g. Directory.Build.props) and make the Tailwind/Vite targets consumer-aware (theme from the npm package, src/modules, the repo-root node_modules), or ship a consumer profile that drives the frontend build via npm run build and documents the required ordering.
  • Consider letting MapStaticAssets().AllowAnonymous() also serve the host wwwroot so a missing/late asset 404s anonymously instead of redirecting to login.

(Related closed scaffold/path issues: #151, #152.)

Workaround

Run npm run build before dotnet build (and before dotnet run).

Environment

  • sm CLI 0.0.37, SimpleModule.Hosting 0.0.37/0.0.38, .NET SDK 10.0.202, Linux.

Activity

  1. antosubash commented on Jun 3, 2026

    @antosubash
    OwnerAuthor

    Fixed in #231 (merged db8be0e). Verified the fix is present on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcli

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions