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

Filenames include query string making them invalid #23

Closed
jeppe-smith opened this issue Mar 23, 2022 · 4 comments
Closed

Filenames include query string making them invalid #23

jeppe-smith opened this issue Mar 23, 2022 · 4 comments
Assignees
Labels
bug Something isn't working released

Comments

@jeppe-smith
Copy link

jeppe-smith commented Mar 23, 2022

I have an issue with the filenames containing an appended query string (eg. src/views/UsersIndex.vue?vue&type=template&lang.js) in the instrumentation. This causes our CI to fail when it tries to upload our coverage.

After looking around I changed transform method to the following to get rid of the query string.

if (exclude.shouldInstrument(id)) {
  // Remove querys strings from file names.
  const filename = id.replace(/\?.+$/, '')
  const sourceMap = sanitizeSourceMap(this.getCombinedSourcemap());
  const code = instrumenter.instrumentSync(srcCode, filename, sourceMap);
  const map = instrumenter.lastSourceMap();

  // Required to cast to correct mapping value
  return { code, map } as TransformResult;
}
@iFaxity iFaxity self-assigned this Apr 3, 2022
@iFaxity iFaxity added the bug Something isn't working label Apr 3, 2022
@iFaxity
Copy link
Owner

iFaxity commented Apr 3, 2022

Hi @jeppe-smith, great finding!

I will create a pull request with this change and run some tests to see if it works in my setup aswell.

@iFaxity
Copy link
Owner

iFaxity commented Apr 3, 2022

There appears to be an official way to get the file name from the reference id. As Vite uses Rollups plugin system in the background, it shares some of it's API: this.getFilename. I will try this and see if it gets the desired results.

@iFaxity
Copy link
Owner

iFaxity commented Apr 8, 2022

This will be fixed when the PR #27 gets merged. I'll hopefully do some testing during the weekend.

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 2.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants