abhijithvijayan / web-extension-starter

đŸ–„đŸ”‹Web Extension starter to build "Write Once Run on Any Browser" extension
MIT License
2.03k stars 172 forks source link

source mapping to enhance the debugging process #29

Closed princesust closed 4 years ago

princesust commented 4 years ago

Is it possible to show the actual file contents inside source map without including webpack import. which sometimes difficult to debug

webextension_polyfill__WEBPACK_IMPORTED_MODULE_2___default.a.runtime.onMessage.addListener(function (msg) {
  var action = msg.action;
  console.log("msg::", msg);

  if (action == _message_actions__WEBPACK_IMPORTED_MODULE_7__["default"].IS_SCRIPT_INJECTED) {
    return Promise.resolve(true);
  }
});
abhijithvijayan commented 4 years ago

Let me look into that.

abhijithvijayan commented 4 years ago

I am not sure if this is even possible, but I will try to change webpack configuration, hoping to resolve this.

slhck commented 4 years ago

Any updates on this? This would be really crucial to have. Otherwise, awesome project!

abhijithvijayan commented 4 years ago

Sorry, I was engaged in some projects.

I will try to find if this is possible asap.

Also open for a PR if anyone comes up with the solution.

slhck commented 4 years ago

I found that devtool: "source-map", in the WebPack config at least generates the source maps for the browser polyfill, however it creates the following issue:

DevTools failed to parse SourceMap: chrome-extension://biipfmkokfahmjfnnbpegccidgoldhom/js/background.bundle.js.map
abhijithvijayan commented 4 years ago

The option `devtool: 'source-map', should work.

Could you see it this error pops up on firefox?

Try: https://stackoverflow.com/questions/44267503/devtools-failed-to-parse-sourcemap

abhijithvijayan commented 4 years ago

Also, on a quick look, the solution you suggested should work.

Could you add that line at top and submit a PR?

slhck commented 4 years ago

I am not sure this works. I tried the solution suggested in the SO post to no avail.

Looks as follows in Chrome:

image

And here in Firefox:

image

Basically I think that the hot reloading module is interfering here.

abhijithvijayan commented 4 years ago

I think it is the issue with webextension-polyfill messing with reloader

There is a similar issue here

abhijithvijayan commented 4 years ago

@slhck Could you see if everything works with the devtool option enabled and the reloader disabled?

slhck commented 4 years ago

I tested that, and I get the same error. The source code shown is basically the same bundled code, except for the reloader message on top. So the issue is a different one, and probably has to do with webpack itself not providing the source map correctly.

abhijithvijayan commented 4 years ago

@slhck @princesust It's an upstream (issue](https://github.com/webpack/webpack/issues/1194)

I have fixed the issue.

Screenshot_20200417_162259

abhijithvijayan commented 4 years ago

@princesust @slhck

See if the fix 23cc204 works

Closing for now.

Feel free to re-open or comment if the issue still persist.

Thanks for reporting the issue

slhck commented 4 years ago

This seems to work! Thank you! :tada: