Best starter for es modules and durable objects (with TS)

Not sure why but I can’t get the Typescript starter to convert to using es modules syntax. I tried following the blog post:

But I keep getting some type of Webpack error. A thrown error in LoaderRunner.

I bring this up because currently there does not seem to be a es modules starter in the docs. And I can’t get this TS start converted. I don’t know a lot about Webpack.

But there is this starter I found on Github:

I am using this and it works.

Is this the best way to start a worker that can use durable objects?

I’m assuming wrangler 2.0 will make this a moot point… but until then.

The docs will be getting a lot more info on es modules. I’m not sure when but there definitely will be

That wiill definitely work so should be fine.

Wrangler 2 is available to use by the way, just not production ready right now. npx [email protected] to use it.

1 Like

Thanks! Can’t wait for more. I love using this in testing although I am running into some issues. But very cool technology!

If you need any help, the Discord is a great place for that: Cloudflare Workers

I am off for the night but there’s still quite a lot of people online.

Check out this template that uses ES Modules syntax for CF Workers with TypeScript/Babel/Rollup:

It’s also pre-configure with multi-worker setup, and environment variables loaded from *.env files.

import { handleError } from "core"; // Local module (NPM/Yarn workspace)

export default {
  fetch: handleError((req) => {
    const url = new URL(req.url);

    url.protocol = "https:";
    url.hostname = "";

    return fetch(url.toString(), req);
} as ExportedHandler;