This is a problem for us because we deploy to Cloudflare Pages and when wrangler checks the final server code (_worker.js), it throws an error because of the const reassignment.
Ideally, Cloudflare wouldn't throw this error because the handlers never run(as far as I can tell), but here we are. If you think it makes more sense to try and resolve this on the Cloudflare Pages/wrangler side I'm happy to do that instead.
Possible Fix
The easiest fix would be to change the let tag to output a let instead of a const on the server. I'm happy to make that change if it's the correct change.
@AngusMorton I think changing the output to a let on the server could be good. Feel free to give it a shot, I'm happy to give pointers here or on discord 😃
Version: 0.7.4
The following marko template, when compiled for the server, will compile into code that reassigns a const variable.
Compiles to:
This is a problem for us because we deploy to Cloudflare Pages and when
wrangler
checks the final server code (_worker.js
), it throws an error because of the const reassignment.Ideally, Cloudflare wouldn't throw this error because the handlers never run(as far as I can tell), but here we are. If you think it makes more sense to try and resolve this on the Cloudflare Pages/wrangler side I'm happy to do that instead.
Possible Fix
The easiest fix would be to change the
let
tag to output alet
instead of aconst
on the server. I'm happy to make that change if it's the correct change.Playground https://markojs.com/playground/#NobwRAdghgtgpmAXGAlhAJnAHgOhlAJwGsB7MAGjAAcoAXACyTAHoBjEmKkiOCWgZ2ZpMufMTKV2fXrSYAeADZxazAGYkSAI0IBeADph1JA8wB8eiHPQoAbhYAE9nM7RUArrQf3uAYQUpWIgAKAEp7EHsjbQJ7HXsDaIMAbnsAXwszMFSAXSA