Comments (6)
Aah I see! Given that Vitest manages to pull off the coverage on Vue components, this might be a misconfiguration: Istanbul should maybe instrument the code after and use source maps to refer to the original place
oh cool! thanks, I'll have a look.
but there are many complex reasons leading us to choose the way to instrument the code first.
Supporting SuequenceExpression for @vue/compile-sfc seems like a nice thing too. Maybe I'll try to make a PullRequest for that.
from vue.
have submitted a PullRequest(#13124) about this
from vue.
How did you find this problem? I don’t see why one would write a sequence when defining the emit function?
from vue.
How did you find this problem? I don’t see why one would write a sequence when defining the emit function?
Because of istanbuljs's instrumentation process. The VariableDeclaration code after instrumenting will be compiled to SequenceExpression.
Like this code:
<script setup>
const emits = defineEmits(['input']);
</script>
after intrument, it will become like this:
<script setup>
// some unrelated report init code
const emits = (report(0), defineEmits(['input']));
</script>from vue.
Aah I see! Given that Vitest manages to pull off the coverage on Vue components, this might be a misconfiguration: Istanbul should maybe instrument the code after and use source maps to refer to the original place
from vue.
I'm not convinced that this complexity should be dealt with in Vue - instrumenting raw SFC code just sounds wrong. Only handling sequences also seems like an incomplete fix, as there are other cases where the macros won't be compiled. For example, what if the instrumentation wraps the defineXXX macros in conditional branches?
Even just for sequences, the PR also has even more edge cases:
-
It assumes the
defineXXXalways is the last in the sequence, so it would fail forconst props = (Date.now(), defineProps(['input']), Date.now())
-
In the multi-declaration case, it also doesn't account for duplicated placeholders:
const foo = 1, props = (Date.now(), defineProps(['input'])) const bar = 1, emits = (Date.now(), defineEmits(['input']))
Generated code will error because two variables named
_are declared.In principle,
compileScriptexpects to work with the exact code written by the developer, so we do not account for extremely unlikely usage like sequence expressions. But if the goal is to make the logic robust enough that it can handle unknown instrumentation by other tools, then the complexity will explode and I don't think Vue should be responsible for that.from vue.
Related Issues (20)
- Component caching - wrong type returned in a `set` method HOT 1
- Dynamic component not rendering slot tree HOT 1
- Urgent: Black Duck Vulnerability Fix Needed for 'vue-template-compiler' HOT 1
- Why does manipulating the style property of the DOM not take effect? HOT 1
- Memory leak when using functional components in Vue 2.7.14 HOT 6
- test
- [Feature Request] Be able to skip hydration HOT 1
- Cannot load extension with file or directory name _plugin-vue_export-helper.js. Filenames starting with "_" are reserved for use by the system. HOT 1
- Bug: Controlled components can lead to an inconsistent state between Vue and DOM HOT 3
- v-if and v-else on same element has inconsistent (or undocumented) behaviour HOT 1
- Vue-specific attributes are invalid html HOT 1
- Custom error handler causing recursive error handling leading to Maximum call stack size exceeded error HOT 2
- Custom equality for watch HOT 9
- 自定义事件冒泡问题
- replace lodash with es-toolkit in vue-server-renderer for modern utility and safer maintenance HOT 1
- improve the warning in `inject` HOT 1
- Developer Tools Integration: JSON Formatter for Vue.js Developers HOT 1
- [High] Memory Leak in vue HOT 1
- [Medium] Race Condition in vue HOT 2
- Closed by author
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
OpenClaw
Personal AI Assistant
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue.