FranckFreiburger / http-vue-loader

load .vue files from your html/js
MIT License
1.49k stars 275 forks source link

import an external ESM module inside a .vue file #84

Closed nestarz closed 4 years ago

nestarz commented 5 years ago

Hello 👋

I would like to import an ESM module from my SFC vue file. But require with absolute url and ES6 import doesn't work at all.

Is there any method to achieve it ?

Thanks for your work ! 🙏

nestarz commented 5 years ago

Ok, for now I'm using this

module.exports = {
  components: {
    foo: async () => {
      const { Foo } = await import(
        "http://localhost:63622/dist/index.es.js"
      );
      return Foo;
    },
    bar: async () => {
      const { Bar } = await import(
        "http://localhost:63622/dist/index.es.js"
      );
      return Bar;
    }
  }
};

Any suggestion for a better handling ? Thanks 😊

jdelrue commented 5 years ago

++ need this

SharkFourSix commented 1 year ago

foo: async () => { const { Foo } = await import( "http://localhost:63622/dist/index.es.js" ); return Foo; }

Using this exactly this method and format, I get this error

image

Vanilla JS, no other libraries. Vue 2