-
Notifications
You must be signed in to change notification settings - Fork 17
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
"resolveFilename" causing same named paths in Vue files #96
Comments
Hi @YuWenZhong, thanks for the issue. I will look into this in the coming days. |
i met the same problem. it will generate different window.coverage obj between dev and build enviroment. after build, there are more than 1 function for generate window.coverage.path. function J5() {
var t = "/Users/mistrain/Desktop/xxx/src/components/portalPage/index.vue"// same path
, e = "20bc656318d897e23870f9f0141d90d72f27e666"
, n = globalThis
, r = "__coverage__"
, a = {
// ...
J5();
function Z5() {
var t = "/Users/mistrain/Desktop/xxx/src/components/portalPage/index.vue"// same path
, e = "20bc656318d897e23870f9f0141d90d72f27e666"
, n = globalThis
, r = "__coverage__"
, a = {
// ... |
I ran into the same issue and found that it might be possible to pass the |
like this? window.__coverage__ = {
"xxxx/program/src/App.vue": {...},
"xxxx/program/src/App.vue?vue&type=script&setup=true&xxxxx": {...},
// ...
} |
Yes, exactly. The local change I made was to pass the |
I have the same problem in my project. @sawmurai's solution fixes it for me. |
Reference to issue (179) is wrong, I miss-clicked the real issue I wanted to reference (178). sry |
@iFaxity I've just created a PR for this issue, please do tell me if there's something wrong. If anyone knows how I can use my PR in my project's package.json. Please tell me I can't manage to find anything on google/stackoverflow. |
Thanks for fix. This is debug log of ids what plugin processes:
|
Hi, sorry the fix didn't hell for option API, I've never used it so I don't really know how it works with vite, also, as I've said in the PR, I had trouble at first because when using composition API we get two id's with query params (one of them is the good one) and another without query so we might be able to add an option to ask if user is using the composition api or the option api, but I can't see how to support a hybrid setup line the one you linked. Maybe using @sawmurai 's fix would work but it might break other things and it might also break the links of the coverage reports. If any of you two have an idea please do share it. Also sry for the single block, I'm commenting from my smartphone, i'll fix this later. |
@Nol-go Thanks, I appreciate your work. I tried change Could someone create PR with these changes? |
Great news if this works but are you sure there is no problem with other framework than vueJS, and does it not break links ? l fear tools such as sonarqube will break as they expect filenames in the report and not filename with query. I think issue #67 was made to fix this specific thing. I had an idea this night but won't have time to do it today, maybe you can try. Here is the pseudo-code: const globalVar = [];
factor(srcCode,id,options){
//...
if (isVueFile){
if (id in globalVar && !idHasScriptTypeInQueryParam) {
// transform (should replace the previously transformed code)
} else if (id in globalVar && idHasScriptTypeInQueryParam) {
// transform
} else {
// transform
}
}
//...
} You should get the idea. If you have time to try this go ahead and do it, I'll take care of the PR as soon as I can. PS: If you need to debug add the following where you need. You'll get the logs during logger.warn(`${PLUGIN_NAME}> ${yellow(`${id}\n\t${someOtherVar`)}`); |
…es (#180) * fix: add regex for vue SFC to prevent instrumenting style and templates Single file Components no longer have their html or css instrumented instead of their script Closes #96 #178 #89 * build: add prepare script to build the package when using a git version See https://stackoverflow.com/a/57829251 * build: fix dependencies' vulnerabilities run npm audit fix * build: bump devDependencies (patch version only) * fix: instrument both option and composition API * style: fix sonarlint issues * revert: reverted changes to dependencies and package.json Refs: 1e67efc, ea8fa18, 614a88a * style: changed to single quotes for strings --------- Co-authored-by: Hugo <[email protected]> Co-authored-by: Christian Norrman <[email protected]>
🎉 This issue has been resolved in version 5.0.0-rc.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 6.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
The @vitejs/plugin-vue plugin splits Vue files into three parts, which are template, script, and style. If the resolveFilename function directly removes the query string, It may cause issues with same named paths (different parts of the same named Vue file). Therefore, it is recommended to filter Vue files and only instrument the script part, to generate accurate code coverage reports.
Reproduction
--
Steps to reproduce
yarn build
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: