I am developing CMS and main feature is other developers are able to develop extensions. Each extension is a separate bundle file. Use may install those extensions through a special extensions store. After installing it menu element will appear to navigate to it.
So basically I need import based on a variable. Use open URL /users/list where users is the name of extension. So I know bundle is located at /extensions/user/bundle.js so in a router I have to load that bundle and then execute extension router. Something like
let ext = require('./extensions/' + name + '/bundle.js');
ext.route();
is that possible?
Yes, it's called dynamic imports https://v8.dev/features/dynamic-import
If you need this to happen at bundle time: Does this fit your description? https://github.com/parcel-bundler/parcel/issues/125
If you just want to import an arbitary url at runtime, then let ext = await import(...) would work