Retool released very recently the beta version of their new custom component and I guess there's something you can exploit for your use-case:
Otherwise, I usually solve that issue by packaging the component into a single js file, that is responsible to create everything. It requires a bit of tooling, though.