ESM modules in Cloudflare Workers

I tried to see if importing an ESM module would work in Workers:

await import('https://...')

But it produces a non-descript “Not supported” error.

I assume this means ESM modules are not supported in Cloudflare Workers, because the script is not run in a module context?

Is there a roadmap for ESM module support in workers? Implementing/enabling exports is unnecessary, but being able to import (synchronously and asynchronously) a dependency by an URL using ESM import would come in handy.


I’d assume that since eval and function invocations are disabled, then EMS wouldn’t be possible.

1 Like

They are not supported today, and it is something we would like to support.


I see Steve no longer works at Cloudflare. Could anyone else working at the company clarify whether this feature is still something that is considered for future roadmap?

Cloud we get an update please?

I am attempting to use a third party library within my worker with durable objects and am unable to do so with either require or imports. Could someone please point me in the right direction?

I am trying to utilize JWT’s within my worker for basic authentication and would like to import a small jet library.

You can do this, see this example project for modules + DO: GitHub - cloudflare/durable-objects-rollup-esm: Template for durable objects, rollup, es modules

Thank you for the reply. This is interesting.

Is this perhaps the important part I’m missing:

command = “npm install && npm run build”

What exactly is this doing.

This would be a huge boon as it does away with the need to bundle. Modules could be included in similar fashion to Deno. If security is a concern, additional layers could be implemented: e.g. user must approve trusted sources.

And no need for await since the imports need not be dynamic.

You have a big PLEASE from me.