davestewart / vuex-pathify

Vue / Vuex plugin providing a unified path syntax to Vuex stores
https://davestewart.github.io/vuex-pathify
MIT License
1.37k stars 57 forks source link

require('vue-class-component') breaks bundle #116

Closed johannes-z closed 3 years ago

johannes-z commented 3 years ago

Describe the bug I'm bundling a library as UMD that uses vuex-pathify. This line breaks the build however:

var createDecorator$1 = require('vue-class-component').createDecorator;

This should be an import-statement inside the .esm build, I guess. See https://unpkg.com/browse/vuex-pathify@1.4.1/dist/vuex-pathify.esm.js Line 1100.

Expected behaviour I'm already using vue-class-component in my bundle. This should not break my build.

Additional context This probably only works in a cjs environment, not UMD/AMD.

Fixing version to 1.2.0 creates a working bundle. Every newer version breaks it.

davestewart commented 3 years ago

Hey Johannes.

Sorry about this.

Vue Class Component was added by a contributor to support Vuex Pathify decorators for vue-class-component.

At the time I was super-busy and hadn't used vue-class-component. There was some discussion around it here:

Eventually, this PR was the one that added it:

I'm happy to take a look at this again now, perhaps involve in original collaborator; it may be that I know more than I did then.

Do you have any thoughts on what would be a good way to move forward?

johannes-z commented 3 years ago

Shouldnt changing this line:

const createDecorator = require('vue-class-component').createDecorator (https://github.com/davestewart/vuex-pathify/blob/master/src/helpers/decorators.js#L18)

to this:

import { createDecorator } from 'vue-class-component'

fix the issue? This way the dependency will actually be added in the final bundle.

davestewart commented 3 years ago

My expertise in how rollup does its thing is not good enough to know if that will do the job, but you can have a crack yourself if you like.

You can use npm link to make this pretty easy:

That should at least get it running for you locally.

Want to have a go?

johannes-z commented 3 years ago

Sure I'll try. I'll come back to you when I have results.

johannes-z commented 3 years ago

I just tested it. It worked when I changed it to an import statement. I've opened a PR.

davestewart commented 3 years ago

Good man!

I'm a little stacked for the next few days, but I will get to it.

You can use your link in the meantime.

If I haven't got to it by next week, bug me here :)

johannes-z commented 3 years ago

ping @davestewart