bugsnag / webpack-bugsnag-plugins

Webpack plugins for common BugSnag actions.
MIT License
32 stars 29 forks source link

Added deleteSourceMaps option #25

Closed SayakMukhopadhyay closed 5 years ago

SayakMukhopadhyay commented 5 years ago

This PR closes #2 . I have added an option deleteSourceMaps which by default is false. On passing true to this option, the plugin will delete all sourcemaps.

N.B.

  1. I have taken the liberty of using my own error messages. If any changes are required, please let me know.
  2. I have made sure to use Node fs and not add an extra dependency.
snmaynard commented 5 years ago

Why not use hidden-source-map as the devtool option and then filter the source map out from your upload to your cdn?

SayakMukhopadhyay commented 5 years ago

Why not use hidden-source-map as the devtool option and then filter the source map out from your upload to your cdn?

Well, for one, it means more maneuvering around webpack, CI/CD and whatever other tooling there is. All of this can avoided by giving an option to delete the sourcemaps. Of course one can(should?) use this option along with hidden-source-map so that the source files are not commented with the sourcemap filename.

In short, this feature adds to the flexibility of this plugin without taking away anything nor modifying existing API.

bengourley commented 5 years ago

@SayakMukhopadhyay thanks for your contribution. We're going to close this (and #2) as we think deleting things off of the file system is beyond the scope of this module's responsibilities (since it did not generate them).

I'm interested in what you mean by:

it means more maneuvering around webpack

and wondered if you revealed a bit more about your build process, we can help solve this problem in the correct place?

SayakMukhopadhyay commented 5 years ago

My use case is with Angular and its CLI (which abstracts webpack). By traditional practice, I did not use to generate sourcemaps at all for production. But for using Bugsnag, I needed to generate sourcemaps. This meant I had to enable sourcemap in the CLI and work around Angular CLI (somewhat) to include this plugin. Now, by default, the sourcemaps are generated in the dist folder along with the static assets. Thus I can't serve the dist folder blindly and I would need to either

  1. Tell my http server not to server .map files
  2. Delete the maps I didn't want to go with 1 as I didn't want the server to have a lot of knowledge of my frontend. So, I decided getting them to auto delete would be a nice option and on searching I found a relevant open issue which is why I decided to put in a PR with the feature.

N.B. One other option could to be make the sourcemaps generate in another folder altogether but I don't know if the plugin can handle that.