Can I use ES6 Modules in a WebExtension without webpack or similar?

I want to import a file from another file and I want to do it with plain old JS. Here is the error I’m getting

And here is the code

Just execute ./ to run it locally.

What am I doing wrong?

You have to load background.js as type=“module”. So you need a HTML page instead of directly pointing to the js file in the manifest.


Yes, see the same problem here:

1 Like