fix(cli,framework): make scaffolded projects build and run out of the box#121
Merged
antosubash merged 2 commits intomainfrom Apr 23, 2026
Merged
fix(cli,framework): make scaffolded projects build and run out of the box#121antosubash merged 2 commits intomainfrom
antosubash merged 2 commits intomainfrom
Conversation
… box
sm new project produced a project that failed to compile, install, and
run. This fixes the full chain so a fresh scaffold works end-to-end via
the standard npm install && npm run build && dotnet run flow.
Generator (SimpleModule.Generator):
- AgentExtensions.g.cs and SettingsExtensions.g.cs unconditionally
referenced SimpleModule.Agents.AgentRegistry / SimpleModule.Rag.*
types. Projects that don't depend on those assemblies failed with
CS0234. Gate the emissions on new HasAgentsAssembly / HasRagAssembly
symbol-presence checks so lean hosts compile.
Host runtime (SimpleModule.Hosting):
- Dev/SQLite startup called MigrateAsync on the Host DbContext, but
scaffolded apps ship no migrations, so module tables were never
created and the first API call returned 500 ("no such table").
Fall back to EnsureCreatedAsync when no migrations exist; projects
with migrations still call MigrateAsync unchanged.
CLI templates (SimpleModule.Cli):
- Root package.json used lowercased workspace path
(src/testapp.Host/ClientApp) that only resolves on case-insensitive
filesystems. Use the actual project casing; npm name field stays
lowercase.
- Missing @simplemodule/tsconfig and esbuild peer deps caused vite
config load failures. Add both.
- @inertiajs/react (^2 -> ^3), vite (^6 -> ^8), @vitejs/plugin-react
(^4 -> ^6), cross-env (^7 -> ^10), typescript (^5 -> ^6),
tailwindcss (4.2.1 -> 4.2.2), @biomejs/biome (2.4.6 -> 2.4.10)
bumped to match the framework packages peer deps.
- Starter module package.json used vite build without
--configLoader runner, which fails loading TS configs under vite 8.
Wrap with cross-env VITE_MODE and add --configLoader runner on
build/build:dev/watch to match the in-repo module script shape.
- Starter module vite.config.ts used __dirname (CJS); vite 8
configLoader=runner loads configs as ESM where __dirname is
undefined. Use import.meta.dirname instead.
Deploying simplemodule-website with
|
| Latest commit: |
ecb3e55
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d2df0eca.simplemodule-website.pages.dev |
| Branch Preview URL: | https://feature-quirky-jennings-068f.simplemodule-website.pages.dev |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
sm new projectproduced a project that failed to compile,npm install, or serve API traffic. This PR fixes the full chain so a freshly-scaffolded app works end-to-end via the standardnpm install && npm run build && dotnet runflow — no manual patching.Root causes & fixes
Source generator emitted references to assemblies that lean hosts don't reference
AgentExtensionsEmitter.cs and SettingsExtensionsEmitter.cs unconditionally emitted
global::SimpleModule.Agents.AgentRegistryandglobal::SimpleModule.Rag.RagSettingsDefinitions. A scaffolded host only referencesSimpleModule.Hosting, which does not transitively pull in Agents/Rag, so builds failed withCS0234: The type or namespace name 'Agents' does not exist in the namespace 'SimpleModule'.Gated both emissions on new
HasAgentsAssembly/HasRagAssemblysymbol-presence flags in CoreSymbols.cs and plumbed them through DiscoveryData. In-repo host (which does reference Agents/Rag) still gets the full emission.Startup DB init never created module tables for scaffolded apps
SimpleModuleHostExtensions.cs:146 called
MigrateAsyncon the Host DbContext, but scaffolded apps ship no migrations so no tables were created. FirstGET /api/itemsreturned 500 withSQLite Error 1: 'no such table: Items_Items'.Fall back to
EnsureCreatedAsyncwhen the context has no migrations; projects with migrations callMigrateAsyncunchanged.CLI
sm new projectgenerated a broken rootpackage.jsonProjectTemplates.cs:704 had multiple issues:
src/testapp.Host/ClientApp) — only resolves on case-insensitive filesystems.@simplemodule/tsconfigdep → viteTSConfckParseError: failed to resolve "extends":"@simplemodule/tsconfig/base".esbuildpeer dep → vite config load fails withCannot find module 'esbuild'.@inertiajs/react@^2.0.0vs peer^3.0.0,vite@^6.2.0vs peer^8.0.0— both causednpm installto ERESOLVE.Bumped all deps to match the framework packages' peer requirements:
@inertiajs/react^2.0.0^3.0.0vite^6.2.0^8.0.3@vitejs/plugin-react^4.4.0^6.0.1cross-env^7.0.3^10.1.0typescript^5.8.0^6.0.2tailwindcss+@tailwindcss/vite^4.2.1^4.2.2@biomejs/biome^2.4.6^2.4.10esbuild^0.27.0@simplemodule/tsconfigStarter module's vite config + scripts were incompatible with vite 8
NewProjectCommand.cs:494-506:
vite.config.tsused__dirname, which is undefined under vite 8'sconfigLoader=runnerESM loader. Switched toimport.meta.dirnameto match the in-repo module convention.package.jsonhad"build": "vite build"with no--configLoader runnerflag, causing TS config loads to fail. Updated scripts tocross-env VITE_MODE=prod vite build --configLoader runner(and matchingbuild:dev/watch), matching the in-repo module package.json shape.Test plan
dotnet build framework/SimpleModule.Generatorsucceeds with new HasRagAssembly symbol plumbingdotnet build template/SimpleModule.Hoststill succeeds (in-repo host references Agents/Rag)sm new project DemoAppscaffoldsnpm installresolves cleanly with no ERESOLVE errors (191 packages, no--legacy-peer-depsneeded)npm run buildproduceswwwroot/js/app.js+Items.pages.jsdotnet buildon the scaffolded project succeeds (0 errors) — generator no longer emits dangling Agent/Rag referencesdotnet runstarts the host;EnsureCreatedcreatesItems_Itemstable on first bootGET /api/itemsreturnsHTTP 200[]GET /returnsHTTP 200with the Inertia welcome pageGET /swagger/v1/swagger.jsonexposes/api/items