advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
931 stars 130 forks source link

Lazy load #177

Closed qxygene closed 2 years ago

qxygene commented 2 years ago

const Cropper = () => import(/webpackChunkName: "cropper"/ "vue-advanced-cropper");

It seems not working.

qxygene commented 2 years ago

const Cropper = () => import(/webpackChunkName: "cropper"/ "vue-advanced-cropper").then( (module) => { console.log(module); return module.Cropper; } );

now it works. it saved me 82kb while build.

Norserium commented 2 years ago

@qxygene, hello!

It's the normal behavior. The explanation is pretty simple:

  1. The import dynamically load a module, not one of named exports. Therefore to get the named export Cropper you need to process the promise result:
    const Cropper = () =>
    import(/*webpackChunkName: "cropper"*/ "vue-advanced-cropper").then(module => module.Cropper)
  2. The result of the code above is the literally async component. The function that returns Promise whose value is the component options. So you can just pass it to the components list:
    {
    /* ... */
    components: {
       Cropper
    }
    }
Norserium commented 2 years ago

@qxygene, is your issue still actual?

qxygene commented 2 years ago

yes it is

Norserium commented 2 years ago

@qxygene. what's wrong? The example above should work.

Norserium commented 2 years ago

@qxygene, any news?

qxygene commented 2 years ago

version 1.10.1 fixed the issue. thank you.

Norserium commented 2 years ago

@qxygene, frankly, I don't get how it could solve your issue, but all is well that ends well.

I close issue then.