MV3: How to properly export common.js to background.js script?

I am migrating my browser extension to Manifest V3. My background.js and content script reuse a common JS function.

I can’t find any way to import/export that function into background.js, as detailed in my question on StackExchange (ready to duplicate its contents here if required).

What am I doing wrong?

In Chrome MV3, the following code just works fine:


export function commonFunction()
	return 1;


import { commonFunction } from './common.js';


  "background": {
    "service_worker": "background.js",
    "type": "module"

  "web_accessible_resources": [
      "resources": ["common.js"],
      "matches": ["https://**"]
1 Like