Any tips for creating a new application with a worker?


#1

I’m new to creating applications and I’d love any tips on best practices. I cloned the starter app and I’ve been playing around with it. It looks like webpack builds the javascript. Can I use source maps somehow to debug it?

I’ve also created a worker. All I do is return “Hello world” for all requests but it doesn’t seem to do anything:

`async function handleRequest(request) {
return new Response(‘Hello world’);
}

addEventListener(‘fetch’, event => {
event.respondWith(handleRequest(event.request));
});`

Do workers not run in preview? If not how do you test them before deploying an application?

Any other tips for approaching app development?

Thanks!


#2

I’ll reply with what I’ve found so far. I ended up using serverless to build and deploy an a hello world app. Docs are here:

Here’s a link to the serverless plugin. There are a few more details here:

A few debugging tips:

Since webpack builds a single bundle that isn’t especially easy to read I found myself doing a lot of console.log and then checking the console after each deploy. I would still like to see some kind of source map support but for building simple apps console.log works.