Importing Vue runtime dynamically in Angular

28 views
Skip to first unread message

me

unread,
Jan 29, 2021, 11:32:58 AM1/29/21
to Angular and AngularJS discussion
Hi, 

I have an Angular app (let's name it "B") which runs either standalone or in another "container" as a web component with ng elements (let's name the container "A").

The application (B) might load a module lazily (let's call this module "C"). The module contains / runs a Vue app. The Vue runtime _might_ be already provided (by A, if the Angular app runs in that container).

So what I want to do: just load the Vue runtime if necessary. I thought that should be possible with a dynamic import, but cannot get this running. 

The idea: 
===
if (!window['Vue']) {
  import(....)...
}
===

- is this generally possible?
- some webpack magic required?
- do I need to add this snippet in the module or in the component?
- any hints how to do this?

Thank you!

BTW: Stack: ng 11, Vue 2.6.x. esnext already configured.
Reply all
Reply to author
Forward
0 new messages