Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic loads #4004

Closed
Serhioromano opened this issue Jan 15, 2020 · 2 comments
Closed

Dynamic loads #4004

Serhioromano opened this issue Jan 15, 2020 · 2 comments

Comments

@Serhioromano
Copy link

❔ Question

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?

@DeMoorJasper
Copy link
Member

Yes, it's called dynamic imports https://v8.dev/features/dynamic-import

@mischnic
Copy link
Member

If you need this to happen at bundle time: Does this fit your description? #125

If you just want to import an arbitary url at runtime, then let ext = await import(...) would work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants