I recommend taking a look at this repository:
Chrome-Extension-Remote-Scripts-Manifest-V3
It shows a way to work around the restriction using JavaScript AST and an interpreter.