What you want is a "bundler", it's a tool that frontend devs use to get their code ready to ship in a browser. The bundler compiles and bundles all your scripts into a single generated "dist" JS file. Then you put that dist JS into your extension bundle, and that file is your extension's content script or background script.
ESBuild is a good choice for this (there's other choices like Webpack, Parcel, etc). Here's my ESBuild script:
yup I import a few packages including React.js .
What you want is a "bundler", it's a tool that frontend devs use to get their code ready to ship in a browser. The bundler compiles and bundles all your scripts into a single generated "dist" JS file. Then you put that dist JS into your extension bundle, and that file is your extension's content script or background script.
ESBuild is a good choice for this (there's other choices like Webpack, Parcel, etc). Here's my ESBuild script:
That's interesting