MishkaCmsCore.Runtime.Resources.Validations.PageCodeCompiles (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Refuses a page whose code will not compile, at the action boundary, before it is stored.

A page's template, events, infos and helpers are Elixir by the time MishkaCmsCore.Runtime.Compilers.LiveViewCompiler is finished with them, and until this validation existed nothing read them first. What followed was quiet in a way that is worse than a crash: a page whose precompile is false — the default — is not compiled when it is saved, so the save succeeded, MishkaCmsCore.Runtime.RuntimeStatus reported Ready, and the first visitor got the

  1. A page whose module was already loaded kept serving the previous version, because the old code is only purged on the success branch, so the author's change simply never appeared.

Running the check here rather than in a form means every writer gets it — the page form, the builder, the JSON:API and a seed script alike — which is the same reason PathFormat lives here.

The error is attached to the attribute it came from, so a form puts it under the right box. MishkaCmsCore.Runtime.PageBuilder.CodeCheck explains what it can and cannot catch.