Using Multiple Marko Versions
marko@6is not backward compatiblemarko@5is forward compatible- In Marko 5, heuristics determine the runtime version per file
Marko 5 uses the Class API, and current versions use the Tags API. Marko 6 is not backwards compatible, so if marko@6 is installed an application cannot use class components out of the box. Instead, Marko 5 is forward compatible. To use multiple versions of Marko together, ensure that Marko 5 is installed at the project root.
Marko 5 and 6 use runtimes which are interoperable but distinct. As such, the compiler determines which runtime to use based on a set of heuristics. Switching between the two runtimes should be avoided as often as possible, so it is preferable to ensure that Tags API components mostly reference other Tags API components.
Limitations
Attributes, content, attribute tags, and tag parameters all cross between the runtimes. A pending promise does not: when content containing an unsettled <await> crosses between the runtimes, rendering fails with Cannot serialize promise across tags/class compat layer. Keep each <await> and the content it renders within a single API.
Contributors
Helpful? You can thank these awesome people! You can also edit this doc if you see any issues or want to improve it.
Comment Opt-In
Files can be explicitly marked to use a specific API with a
/* use [api] */comment. Any comment type is acceptable, and the comment can be anywhere in the file.These explicit opt-ins are only necessary if a
.markofile isn't an auto-discovered tag and its contents are ambiguous (i. e. none of the following heuristics apply) so in practice they are rarely needed except for sometimes in Marko Run's+page.markoand+layout.marko.