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

Libraries built using vue-cli produce "$attrs/$listeners/props are readonly" errors when consumed in Electron apps #1583

Closed
TAGC opened this issue Jun 15, 2018 · 2 comments

Comments

@TAGC
Copy link

TAGC commented Jun 15, 2018

Version

3.0.0-rc.1

Reproduction link

https://github.com/TAGC/vue-electron-bug

Steps to reproduce

  1. Go into lib, install dependencies and build it with npm run build.
  2. Go into app, install dependencies.
  3. Serve the app in the browser with npm run serve. Open the browser devtools and check for errors in the console while clicking the button.
  4. Serve the app in an Electron shell with npm run electron:serve. Repeat the above procedure, monitoring for errors in the Electron devtools console.

What is expected?

No console errors should appear in either case.

What is actually happening?

When serving as an Electron app, three errors appear every time the button is clicked.

[Vue warn]: $attrs is readonly.
...
[Vue warn]: $listeners is readonly.
...
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "message"

I've done some digging and it seems a number of projects have encountered this problem when their libraries are used in Electron apps. It has something to do with the Electron renderer process using a different version of the Vue bundle than the one the library uses - these two Vue bundles conflict with each other.

This issue comment sheds some light on the issue, although I haven't yet tried the solution the person proposes. The reason I'm opening this as a vue-cli issue is that I was able to reproduce this bug with a minimal app & library created directly through vue-cli, and I'm wondering if it would be possible to change something in the webpack config that vue-cli generates by default that will make Vue component libraries built with it work in Electron apps without this sort of difficulty. If this isn't possible, maybe an alternative could be documenting this behaviour somewhere, with suggestions to workaround it.

@Akryum
Copy link
Member

Akryum commented Jun 15, 2018

I fail to see how this is related to @vue/cli. Maybe open an issue in the vue-cli-plugin-electron package (which is 3rd-party).

@Akryum Akryum closed this as completed Jun 15, 2018
@TAGC
Copy link
Author

TAGC commented Jun 15, 2018

Fair enough, I'll try there.

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

2 participants