-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example not working #5
Comments
I believe the issue is that you haven't configured the environment to be able to load Marko templates. Marko is not understood by node or any environment by default and has to be preprocessed. In node you can use the Marko require hook I added a note to the docs here about this as well. |
Hi, Beginner here, can I use "import "@marko/compiler/register" " to use the Marko required hook? |
@mikko-severo we highly recommend avoiding using the Marko compiler hook. Marko is designed to be used with a bundler since one of the points of Marko is to be able to load just the JS needed for the client. I'd recommend starting from one of our Vite template projects, eg
|
@DylanPiercey Thanks for the insight and fast reply. I mainly needed Marko for the server rending (no need for a bundler, I think), but I couldn't just get it to work. I keep getting the error the OP posted when using Fastify w/ESM or CMJ syntax. Although I got it working with Express w/ CMJ syntax by requiring the "Marko/compiler/register." Any idea how I can get it to work with Fastify for server rendering? Thanks |
@mikko-severo I still think even if you just want to use Marko for the server you should use a bundler. Here is vite express example which only bundles the server side https://github.com/DylanPiercey/marko-vite-express-ssr-only Benefit here is that in prod your server startup doesn't need to go through the Marko compiler, and in dev you get cool things like hot reloading for your server code. It also has an incremental path to using the client side bundler when/if you want to. |
Hi @DylanPiercey `require('@marko/compiler/register'); // fastify.register(markoPlugin); // Run the server! |
Version: 1.0.2
Details
Example fails with
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".marko" for <path to template.marko>
Expected Behavior
rendered Marko when calling server
Your Environment
Steps to Reproduce
Run the example in README, in the above environment.
The text was updated successfully, but these errors were encountered: