Problem with multiple files (like default router/proxy template) and NPM install &/or worker deploy

I'm trying to setup a worker with separate /path functions as separate files just like the router/proxy template. However, I need to be able to install NPM packages to one or some of these separate worker scripts.. that seems impossible, since I cannot do it from the Web Code Editor nor can I work with multiple files in Wrangler, it can only handle one per folder? Is this not possible??
7 Replies
Cyb3r-Jak3
Cyb3r-Jak36mo ago
The web editor can not install packages. You need to use wrangler locally to be able to do so. And not sure what you mean by multiple files with wrangler
Jürgen B
Jürgen B6mo ago
But if I use wrangler locally multiple files seems not to be supported at all i have more than one .js file in my /src folder (as you get by default) when you use the proxy/router template I like to route my request for different paths to different scripts I've also noticed when Im doing edits in the Web Editor new files aren't saved.. so it works when youre in a session but as soon as you exit the Web Editor and do some other stuff all your files are restored to default setup... ?!
Cyb3r-Jak3
Cyb3r-Jak36mo ago
So I have use my index file to route requests to functions in other scripts by use importing them. And correct. Web editor isn’t designed to be a full dev experience as it is a quick editor
Jürgen B
Jürgen B6mo ago
but I like to have all files in the same function so I don't get so many in the dashboard view.. but it seems very odd that wrangler still doesn't supporting more than one worker file when templates consists of multiples.. and the webeditor should def not have options to create files when they are not saved... makes you easily waste time there..
Cyb3r-Jak3
Cyb3r-Jak36mo ago
What do you mean all files in same function? You can have as many or as little files as you want. You just need to import them as only pages functions supports path based routing.
Jürgen B
Jürgen B6mo ago
reproduce by 1) setting up the default router/proxy template 2) sync to your localhost 3) your /src folder now contains 4 files 4) worker deploy /select one file 5) all other files are gone in your deployed worker if you only use the Web Code Editor you're stuck with not be able to install NPM packages.. so a bit of a catch 22 for me.. don't understand how I can use with multiple functions/file otherwise without setting up multiple workers
No description
Cyb3r-Jak3
Cyb3r-Jak36mo ago
Oh I see, it creates all the examples for the worker. Yeah that's a bug in the getting started. It should just use the one you select