fix(compiler): align generated apps and typed IR#787
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31e9feaa49
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ImportBase: legacyGeneratedAppModulePath, | ||
| BuildDir: absApp, | ||
| } | ||
| appModule, err := currentAppModule() |
There was a problem hiding this comment.
Resolve app modules from the generated app directory
When gowdk build --project-root /path/to/app --app /path/to/app/.gowdk/site --bin ... is invoked from any directory other than the project root, this still asks go list -m in the process cwd. The build path does not chdir to ProjectRoot, so .gowdk apps inside the application module fall back to a nested go.mod or use the wrong module; generated backend imports such as example.com/site/internal/... then fail to resolve or trip Go internal visibility, which is the case this change is trying to fix. Resolve the module relative to absApp/project root instead of the current working directory.
Useful? React with 👍 / 👎.
| }) | ||
| return | ||
| } | ||
| blocks.ServerFields = fields |
There was a problem hiding this comment.
Report empty server loads as diagnostics
When a non-empty server {} body has setup/Go lines but no => { ... } load declaration, parseServerFields returns an empty slice and this assignment leaves ServerFields empty without adding a diagnostic. The following invariant check now reports internal compiler error: ... has server body but no typed load fields for a user-authored validation mistake in gowdk check/build --ssr; emit a normal validation diagnostic when no fields are parsed from a non-empty server block instead of letting it become an ICE.
Useful? React with 👍 / 👎.
| if colon := indexTopLevelByte(element, ':'); colon >= 0 { | ||
| name = element[:colon] | ||
| } |
There was a problem hiding this comment.
Reject malformed keyed server load fields
For keyed server declarations, everything after the top-level colon is discarded without any validation, so inputs like server { => { title: } } or => { title: missing( } are accepted as a load field named title instead of producing a parse diagnostic. This lets malformed authoring syntax reach SSR generation/checks as if it were valid; either reject colon syntax here or validate that the keyed expression is present and syntactically valid before appending the field name.
Useful? React with 👍 / 👎.
Summary
Issues
Fixes #663.
Refs #664.
Refs #639.
Verification