2

This https://vuejs.org/guide/components/async.html does all i want for Components but not being able to load them from a Server.

Is there any way to load Components from external Source?

  • I want project 1 to build a single component.
  • I want project 2 to load this component on runtime.
Nick
  • 66
  • 6
  • " but not being able to load them from a Server" - why? The case isn't explained, a way it can be solved depends on it. Check module federation for starters. – Estus Flask Feb 01 '23 at 11:19
  • i want a base client in vuejs and extend it via plugins or similar on runtime. explained here: https://stackoverflow.com/questions/74233925/vue3-extenable-client-after-build-plugin-like see Example below the picture – Nick Feb 01 '23 at 14:59
  • You can try a multi-app project, all of which are built. Try module federation for scenarios where some apps (plugins) are supposed to be optionally loaded but have to use the deps from the main app. – Estus Flask Feb 01 '23 at 15:45
  • i dont know how to explain it more clear and im still not getting to the point where i can implement anything working. module federation still requires to know the to be imported .js files after all. i'm not aware of the location from later added so called plugins. users will simply add these. In the client should be a upload feature for new components, then they should popup in the client, no build, no previously known locations. – Nick Feb 01 '23 at 19:14
  • you can use `defineAsyncComponent(() => import('https://location-to-the/file.js'))`. Some build tools might have problems with this, but also they have workarounds for this kind of imports. – Leif Marcus Feb 01 '23 at 19:41
  • i tried that and even after changing `babel.config.js` to add `@babel/plugin-syntax-dynamic-import` it results in `The target environment doesn't support dynamic import()`. its served by a express webserver running on localhost. – Nick Feb 01 '23 at 21:05

0 Answers0