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

Vue devtools doesn't show setup state for a component imported from a Vite built Vue library #2061

Closed
segevfiner opened this issue May 1, 2023 · 9 comments · Fixed by #2091

Comments

@segevfiner
Copy link

segevfiner commented May 1, 2023

Vue devtools version

6.5.0

Link to minimal reproduction

https://github.com/segevfiner/vite-devtools-lib-issue

Steps to reproduce & screenshots

  1. pnpm build in packages/foo
  2. pnpm dev in apps/bar
  3. Open the browser & the Vue devtools.
  4. Check the inspector for the HelloWorld component.

If you switch the import in apps/bar/src/App.vue to import the HelloWorld component from ./components/HelloWorld.vue instead, the setup state does show in the Vue devtools.

What is expected?

It shows setup state for the component imported from the foo library.

image

What is actually happening?

It doesn't.

screenshot

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 104.58 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
    npm: 9.6.5 - ~/.nvm/versions/node/v16.20.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.137
    Safari: 16.4

Any additional comments?

No response

@Azurewarth0920
Copy link
Contributor

It is the limitation on the production build.

The devtool relies on the property setupState in the instance when development.
But the setupState is not exposed in the production mode. In other words, you cannot inspect the internal state of compiled component.

@segevfiner
Copy link
Author

Can we tweak the build to produce a build conditional on process.env.NODE_ENV for production vs development build so that the library has debugging available when built as such?

@Azurewarth0920
Copy link
Contributor

Can we tweak the build to produce a build conditional on process.env.NODE_ENV for production vs development build so that the library has debugging available when built as such?

Nope, most of the libraries are pre-built, so when importing the libraries they are already in "production mode".

Then I found another approach to solve this and pulled a request.

@segevfiner
Copy link
Author

segevfiner commented Aug 13, 2023

I'm talking about tweaking the build process of my own library to support such a mode. As a flag to vite plugin for vue or something.

@Azurewarth0920
Copy link
Contributor

I'm talking about tweaking the build process of my own library to support such a mode. As a flag to plugin vue or something.

At this time, due to the limitation of the compiler. The answer is NO.
Or you can try not to compile your library and import .vue file directly.

@segevfiner
Copy link
Author

So I guess this is a feature request to the compiler. I'll figure out what's the right repo to request that

@Azurewarth0920
Copy link
Contributor

Somehow I think it is the mis-implementation on devtool.

It will be fixed by #2091

@segevfiner
Copy link
Author

So this might also tie into vitejs/vite-plugin-vue#36 which was about the name but I guess there are also other differences in building components between release and debug.

@s-nesbigall
Copy link

Any news on this? I still have this problem in 6.5.1. It seems the merge request never got accepted.

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