redxtech / vue-plyr

A Vue component for the plyr (https://github.com/sampotts/plyr) video & audio player.
Other
770 stars 136 forks source link

ESLint complains: no-named-as-default #65

Closed dappiu closed 4 years ago

dappiu commented 5 years ago

There are complaints on the build phase with bili:

Using named and default exports together. Consumers of your bundle will have to use bundle['default'] to access the default export, which may not be what you want. Use output.exports: 'named' to disable this warning

But also from the user side when importing VuePlyr without braces (I use eslint with vue/recommended plugin)

Using exported name 'VuePlyr' as identifier for default export.eslint(import/no-named-as-default)

index.js:

  1. imports the default export of VuePlyr.vue calling it VuePlyr
  2. creates a const VuePlyrPlugin
  3. exports the VuePlyr as VuePlyr, VuePlyrPlugin as VuePlyrPlugin
  4. exports VuePlyrPlugin as module default

This is rather confusing. I'm proposing to fix the naming scheme, if the project mantainer would agree, but let's just decide what is the way to go. I do my proposals:

import VuePlyr from './VuePlyr.vue'

VuePlyr.install = function (Vue, options = {}) {
    Vue.component(VuePlyr.name, VuePlyr)
}
// ...parts redacted for brevity...
export default VuePlyr

This way we would stop both the complaints from build phase and from eslint on the user side.

We could also export the named component without the install method as VuePlyr as before, but then we should update documentation regarding imports changing them with import { VuePlyrPlugin as VuePlyr } from 'vue-plyr' to prevent such complaints

dappiu commented 5 years ago

I submitted a fix with this commit https://github.com/redxtech/vue-plyr/pull/64/commits/1f10c2e4d883f0ec183d0912dcb82b96e9bc4283

redxtech commented 5 years ago

Hey thanks for this - I'm sorry for taking a while to look at this, I've been swamped with a bunch of schoolwork. I can probably take a look at this more in depth later today, and get to merging your PR. It's all stuff that I think would make this a lot easier to use and appreciate you taking the time to help out.

redxtech commented 5 years ago

Sorry once again for the delays - I'll be completely free in a few weeks to work on this.

redxtech commented 4 years ago

This should be fixed now.