You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having to manually transform the output .js.map file after building because otherwise it does not work with c8. The generated .map file has invalid file paths within it that cause c8 to not work correctly producing invalid coverage reports (regardless of the output report format). The faulty paths begin with something like ../webpack:// (clearly an invalid filesystem path).
What I learned (I think), is that c8 uses these generated paths in the sources key of the .map file in order to retrieve the actual (pre-compile) source content from the filesystem. So, when these filesystem paths are incorrect/malformed because they begin with ../webpack://, c8 will produce inaccurate/faulty coverage reports (in my case, in my tests, it was being reported (via c8) that the compiled file was never even loaded/run, even though it was, and to make matters even worse, c8 was not making it obvious that there was any kind of error).
Context/Env
My project is a fairly standard and vanilla node project using only js (no typescript), the latest versions of all dependencies including ncc (i.e. v0.34.0), and only has a few dependencies. I'm not using any other bundlers or transpilers. Project is "type": "module" and uses es module syntax.
I then mv all build outputs in dist, except for the emitted package.json, to the project root.
Sidenote: Another thing I've noticed is that ncc fails to minify my project and prints a message saying as much. This failure/message doesn't appear when I build in CI/GitHub Actions however.
The text was updated successfully, but these errors were encountered:
I'm having to manually transform the output
.js.map
file after building because otherwise it does not work with c8. The generated.map
file has invalid file paths within it that cause c8 to not work correctly producing invalid coverage reports (regardless of the output report format). The faulty paths begin with something like../webpack://
(clearly an invalid filesystem path).Now, I was ultimately able to get my coverage reports working correctly after a couple days of constant debugging and headaches. The solution I came up with is to manually transform the
.map
file post-build/post-compile in order to fix the faulty file paths myself. The faulty paths appear in thesources
key of the.js.map
file. You can view my temporary fix here: https://github.com/tmillr/breaking-change/blob/c432a9474cf9f5ee4a47f9945583fbb5a9869683/scripts/fix-sourcemap-sources.js#L1-L13What I learned (I think), is that c8 uses these generated paths in the
sources
key of the.map
file in order to retrieve the actual (pre-compile) source content from the filesystem. So, when these filesystem paths are incorrect/malformed because they begin with../webpack://
, c8 will produce inaccurate/faulty coverage reports (in my case, in my tests, it was being reported (via c8) that the compiled file was never even loaded/run, even though it was, and to make matters even worse, c8 was not making it obvious that there was any kind of error).Context/Env
My project is a fairly standard and vanilla node project using only js (no typescript), the latest versions of all dependencies including ncc (i.e. v0.34.0), and only has a few dependencies. I'm not using any other bundlers or transpilers. Project is
"type": "module"
and uses es module syntax.I then
mv
all build outputs indist
, except for the emittedpackage.json
, to the project root.The text was updated successfully, but these errors were encountered: