fix(plugin-vue): misleading error thrown after refresh or hmr #5870
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
fix #5771
correct error displayed:
after refresh or hmr:
Additional context
The error comes from the result of the execution of
compiler.parse
:vite/packages/plugin-vue/src/utils/descriptorCache.ts
Lines 23 to 26 in f1b8b5f
compiler.parse
will cache the execution results:https://github.com/vuejs/vue-next/blob/2d4f4554349db6b07027d0c626f56c48d0233f67/packages/compiler-sfc/src/parse.ts#L105-L110
https://github.com/vuejs/vue-next/blob/2d4f4554349db6b07027d0c626f56c48d0233f67/packages/compiler-sfc/src/parse.ts#L274-L278
Changing the loc of the cached error here will throw a new error(
Cannot read property 'line' of undefined
) the next time it is executed:vite/packages/plugin-vue/src/utils/error.ts
Lines 12 to 16 in f1b8b5f
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).