-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
fix(plugin-vue): respect __VUE_PROD_DEVTOOLS__ setting #4984
fix(plugin-vue): respect __VUE_PROD_DEVTOOLS__ setting #4984
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't commit style-only changes on files irrelevant to the PR.
# Conflicts: # packages/playground/ssr-vue/example-external-component/ExampleExternalComponent.vue
OK, it's done. |
packages/plugin-vue/src/main.ts
Outdated
@@ -58,6 +58,7 @@ export async function transformMain( | |||
// inlined template cannot be individually hot updated. | |||
const useInlineTemplate = | |||
!devServer && | |||
!devToolsEnabled && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems exposing __file
is enough for the devtool to display the component name, why do you want to disable inlineTemplate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because for component with script setup, inlineTemplate as true doesn't expose any setup binding. Vue devtools relies on this to display component setup binding correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it.
I have discussed this with Evan today.
As the inlineTemplate
option has an impact on the app performance, we believe that it shouldn't be disabled.
We need to find another way to fix this issue. Maybe in another package.
packages/plugin-vue/src/main.ts
Outdated
@@ -108,7 +109,7 @@ export async function transformMain( | |||
if (hasScoped) { | |||
attachedProps.push([`__scopeId`, JSON.stringify(`data-v-${descriptor.id}`)]) | |||
} | |||
if (devServer && !isProduction) { | |||
if (devToolsEnabled || (devServer && !isProduction)) { | |||
// expose filename during serve for devtools to pickup | |||
attachedProps.push([`__file`, JSON.stringify(filename)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to safety concerns, the full path should not be used in production. Please use path.basename(filename)
.
The development bundle should still use the full path so that users can open the file directly from devtools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I've just started using @vitejs/plugin-vue2
in my rollup project, and was surprised to see the full filepath to my modules included in the generated output (as __component__.options.__file
), and have not found a way to disable this. Can you advise on how to remove these filepaths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the changes related to inlineTemplate
.
We need to open an issue in the vue-next
repo to provide the ability required by Vue DevTools, rather than work around the issue in the Vite plugin.
The __file
fix looks good to me.
Has the |
Raised in vuejs/core#5496 |
@sodatea is this one ready to merge? |
@patak-dev Yeah, I forgot to approve it after pushing… |
Description
If user defines VUE_PROD_DEVTOOLS to true, plugin-vue should respect this to make sure the generated code can be compatible with Vue devtools (inlineTemplate and filename)
Additional context
script setup with inlineTemplate as true is not compatible with Vue devtools since it doesn't expose any bindings.
Vue devtools relies on filename to infer the component name for the component using script setup.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).