Migrating an old worker to module format
Hi, as far as the worker code goes, I have updated my old worker to use the module format, but I don't understand how to tell CF it is now a module format worker. I haven't used Wrangler to create the worker, it was done via the dashboard
15 Replies
My worker only have a single file in the editor (see image)
When I create a new worker in module format (default) it has more files in the editor:
Anyone know how to upgrade an existing worker to use module format ?
It should just auto-detect the change
Thanks for replying. It doesn't look like it auto-detected anything
Only indication I have that it's not on module format is this dropdown:
Does that say anything about your selected syntax?
Yes
What if you deploy it?
Detecting might occur on deploy
I can't deploy it because
This is because it doesn't understand that the worker now has this syntax:
So it's kinda stuck on the old syntax
I did try to create a new worker, it was created with the module syntax and that was working okay, but looks like the old worker is stuck on the worker syntax
I tried working with wrangler on the project by running
And this is the toml file: (some identifiers renamed)
And package.json
If you do a deploy there(with the module syntax script), does it show up correctly in the dash?
Haven't tried that, will try to deploy from wrangler
It seems that has done the trick and now it is a module syntax worker...
Now I just need to understand why my worker is not working, but that might have to do with the changes to the code I did
It did add some code for me, for example, first line of the worker is
And last line is now
I didn't add these...
Actually, it did more than that, looks like it's trying to add some es compatibiilty
That's wrangler bundling your code