Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespaced modules' path broken when code is minified #43

Closed
aymasse opened this issue Sep 12, 2019 · 5 comments
Closed

Namespaced modules' path broken when code is minified #43

aymasse opened this issue Sep 12, 2019 · 5 comments

Comments

@aymasse
Copy link
Contributor

aymasse commented Sep 12, 2019

Hello,

While using version 2.0.4, module declaration is kind of broken in minified code due to the path being pulled from the class' name.
Problem is, the class name is being mangled while using vue-cli in its default configuration.

The result (for me) is that my store only has a single module (named t in my output), even if I declare several modules. This single module contains every state property of my modules but only the mutations and actions of the last declared one.

@SaphuA
Copy link

SaphuA commented Sep 30, 2019

For now define your stores the old way:

@Module({ namespacedPath: "foo" })
export default class extends VuexModule { }

You can still define your Vuex-store the new way:

import FooStore from "@/foo/store";
const modules = { ...extractVuexModule(FooStore) };
export const store = new Vuex.Store({ modules });

@danielroe
Copy link

I've closed #42 as it's another expression of this issue - thanks to @SaphuA for the workaround.

If it's useful, see see my repro - and run yarn build && yarn start.

@vizv
Copy link

vizv commented Oct 22, 2019

From

cls.prototype.__namespacedPath__ = cls.prototype.__options__.namespaced.split("/")[0]

I think you setting namespaced to a string should work.

const VuexModule = createModule({
  namespaced: 'foo',
  strict: false,
  target: "nuxt",
})

@michaelolof
Copy link
Owner

Hello @aymasse

I've made an update based on the issue raised.
Thanks to @vizv 's suggestion

interface VuexModuleOptions {
  namespaced ?:string;
  ...
}

I've modified the namespaced option to take only a string.

@SaphuA
Copy link

SaphuA commented Nov 11, 2019

works perfectly now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants