I'm learning how to make Chrome extensions, but I'm having trouble figuring out what the best practices are to organize my code. In any other language, I know I would break down my codebase into multiple files and do imports, but when I had a file tree like this:
|
|-background.js
|-someotherfile.js
And someotherfile.js has a function like
export function somefunction(){alert("somefunction was called");}
But in background.js when I do
import * from 'someotherfile';
chrome.runtime.onInstalled.addListener(function() {
somefunction();
});
and I load my unpacked extension, background.js doesn't run, even though it does if I put somefunction in background.js.
What is the right practice for organizing my code in Chrome?