-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Source Map issues with Browserify and Webpack #1130
Comments
The issue hasn't had any recent activity because it's never been responded to.... |
Wanted to post an update here as I think I've narrowed down the issue(s) a bit in my latest trial-and-error experiment/investigation:
|
It's never been responded to in over a year
I've debugged it heavily and added lots of details and links and the repo is open-source and quite tiny. The only other thing I can do is dive into the |
I noticed your are using nyc 14, there were some source-map fixes which went into nyc 15 (particularly related to bundled code), please give this a try to see if it improves the ability to ignore parts of the bundle. You should be able to tell istanbul to exclude With regard to browser web workers this is completely out of scope for nyc as nyc does not run in the browser. If you create a simple Sorry this issue has sat for so long without response, istanbul maintainers are spread very thin and integration issues require an additional level of knowledge. I've blocked stale bot from touching this issue in the future. My hope is that someone in the community with knowledge of webpack / browserify can provide some insights. Please understand nyc is designed to test coverage in node.js. nyc does not directly support any other platform, though the instrumented code it generates does try to support running on as many JS platforms as possible. Please be aware source-map handling is probably the most difficult part of istanbul, it's a minefield. That's not completely a reflection of our code but source-maps are just difficult. |
Hey @coreyfarrell, Thanks for your detailed writeup. This is gonna be in response to WebWorkers and I just realized that this comment maybe belongs in a diff repo or issue, but here we go...
So, in a browser-testing setup, Istanbul's transpiled code is running in the browser, while coverage results are sent back over the wire to Node so that NYC can consume and process the results. NYC is still node-side, but because it wraps + kicks off Istanbul, I need to be able to pass in certain options to a given instrumenter. Can you help me figure out how to configure Istanbul's options through NYC? I need to either:
So if I hardcode Istanbul's Workaround patch here for diff --git a/src/visitor.js b/src/visitor.js
index 46c71290d05c04c8f07a4421e9aab6cdbd74ec6e..0cb9f48c9f1dcd01f261e5fb62bc293ff68415ed 100644
--- a/src/visitor.js
+++ b/src/visitor.js
@@ -749,7 +749,8 @@ function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
const T = types;
opts = {
...defaults.instrumentVisitor,
- ...opts
+ ...opts,
+ coverageGlobalScope: 'globalThis'
};
const visitState = new VisitState(
types, How can I pass through |
Link to bug demonstration repository
agilgur5/physijs-webpack#coverage
Relevant files are
browserify.js
andwebpack.js
as well as their respective testsbrowserify.spec.js
andwebpack.spec.js
which are all like 5-10 LoC each.package.json
scripts andnyc.config.js
for config.(vendored files are
physi.js
,physijs_worker.js
, andvendor/ammo.js
, which are mostly ignorable)For context, my library is an integration for bundlers, including out-of-the-box support for
webpack
andbrowserify
, so my tests are literally to ensure that the integration itself works (and not thatphysijs
works). An important aspect of this is WebWorker support for both bundlers.This means that I have to test the bundled code, and not the source files themselves. The source code is all ES5, so no transpilation needed (though the test code is not necessarily). The code can be bundled for both bundlers with
npm run build: test
.It seemed like
nyc
's source map support would handle this use case, but I ran into some issues with both bundlers.Expected Behavior
npx nyc ava browserify.spec.js
to be:npx nyc ava webpack.spec.js
to be:Observed Behavior
There are 2 different, but potentially related bugs, I'm encountering:
browserify
, I have source maps output to a separate.map
file withexorcist
, but none of the bundle itself or the source code ends up being output in the coverage. The output ofnpx nyc ava browserify.spec.js
is:I don't really know why the code in
build/
and the source mapped code isn't included. The file I'm looking to be included without source maps isbrowserify.bundle.js
and with source maps the files arebrowserify.js
(and maybephysijs_worker.js
and/orphysi.js
for further testing). Why are those not included?webpack
, which runs virtually identical code (just a different bundler andworker-loader
instead ofwebworkify
), the output does coverwebpack.bundle.js
and the source mapped files,webpack.js
,physi.js
, andphysijs_worker.js
are shown in the coverage report. The output ofnpx nyc ava webpack.spec.js
is:The
exclude
is set to ignoretest-utils/**
,physi.js
, andphysijs_worker.js
, but they still show up in the reported coverage through the source maps. (I'm also pretty sure the 100% coverage ofphysijs_worker.js
is incorrect, but that's probably unrelated?). The code intest-utils
that's imported directly (not source mapped) is correctly excluded/hidden, but the source mapped code is incorrectly shown. How do I exclude/hide these source mapped files?There doesn't seem to be much documentation for testing source-mapped bundles.
nyc
seems to try to handle it automatically and there is thebabel
preset forbabel
instrumentation, but I'm not transpiling any code, just bundling it.I also have both
webpack
andbrowserify
set to output source maps to a separate.map
file, but I'm not sure if that's necessary.The README says inline source maps are supported, but usingEDIT: it should becheap-eval-source-map
for webpack causes the source maps to not workinline-cheap-source-map
, woops.Troubleshooting steps
cache: false
in my nyc configEnvironment Information
The text was updated successfully, but these errors were encountered: