'Import functions into Background.js file Chrome Extension

I'm creating a Chrome extension with React using CRA.

I want to use some helper functions within the /src folder inside of the background.js file, which causes the error Cannot use import statement outside a module because it's in the public folder.

The background.js file has to be in the same folder as the manifest.json file for version 3 of the manifest.json`.

Any suggestions on how to move manifest.json and background.js into the /src folder and still have it build properly with npm run build, which currently uses react-scripts build?

Current Folder Structure: enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source