Should `--local` be the default?
See original GitHub issueNow that we have an officially supported “local” development environment, the question begs to be asked - should local mode be the default when you start up? There are plenty of positives -
- You don’t have to login to start developing
- It starts ‘instantly’ (relatively speaking of course)
- In watch mode, it refreshes ‘instantly’
- It’ll ‘work’ automatically in environments like codespaces/csb/etc (excluding devtools etc)
There are drawbacks too, of course -
- Given the chance of implementation drift between miniflare and cloudflare, you want to make sure your code works in production as your developed it, and you maaay miss something in local mode.
- This is exacerbated by things like
compatibility_date
andcompatibility_flags
- It’ll be breaking behaviour from wrangler v1 for commands like
kv:namespace
,kv:key
etc etc, so it may confuse someone who runs the commands and sees nothing happens on their actual production sites
I don’t think the drawbacks outweight the positives, but I’d like to put the idea out there for a while, and get feedback before we commit to it. Of course, you will always be able to use both local and, er, ‘remote’ mode, it’s just a question of what the default starting experience should be.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Local By Default - lua-users wiki
A justification for its design would be useful here. Lua's declarations are described as "global by default", in contrast to "local by default" ......
Read more >Why must local variables, including primitives, always be ...
Yes, variables could have default values - but isn't it better for the compiler to be able to catch your bug instead, if...
Read more >What is default value of a local variables? - Java2Novice
Answer: The local variables are not initialized to any default values. We should not use local variables with out initialization.
Read more >Do local variables in Java have default values? - Tutorialspoint
No, local variables do not have default values. Once we create a local variable we must initialize it before using it.
Read more >Why aren't local variables given initial default values in Java?
There is no default value for local variables, so local variables should be declared and an initial value should be assigned before the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Personally, I would like to default to local. Being able to configure Miniflare to persistent (or not persist) things like KV and DO data is fantastic. It picking up on
.env
and more. It’s also just generally much quicker to develop with Miniflare in my opinion and my workflow very much depends on it these days.There are of course the downsides, for example working with DOs was a pain for quite a while there with Miniflare. Hopefully this drift of implementation and mock is smaller now that Miniflare is official.
It’s also super nice sometimes to have code running on the edge before production just to verify that it does indeed work and there’s no weirdness with Miniflare. That’s when I actually use edge-dev is to make sure things work before a production push. This would be an option either way though and I do not mind specifying
--edge
for when I actually do use this.In my opinion, Miniflare being default makes a lot of sense.
Yep - I know from talking to others that my view isn’t consensus, but here’s why I think this is the case:
wrangler dev
already spins up a subdomain, and then tunnels it back to localhost via cloudflared, but what I’d want is to just access that public domain directly, and be able to configure it and count on it being static.wrangler tail
. But it doesn’t seem crazy to provide these types of tools in development if the code is already running on the same Worker runtime as production. You could do stuff like “visualize a request path through a worker” without having to build anything new into wrangler itself. I think there’s tons of greenfield space here to go after “changes that today can only be tested by pushing a change to production”. Maybe preview deployments are really where that comes in, but why not shorten the feedback loop even further and put it in dev?I know the big tradeoff with all of this (today) is local frontend developer experience - hot reloading magic, instant as-you-type editing are hard to implement with wrangler syncing files to a worker. I love this stuff, it’s what got me excited about frontend and React ~8 years ago! But I will happily trade that 10/10 times for a dev environment that mirrors production 1:1. Saving hours caused by bugs in prod or chasing down dev/prod inconsistencies > saving ms hot reloading. Dev environments that mirror production will help convince a whole engineering team to move to Workers, not just the frontend nerds who are excited about the edge.