MarcellPerger1 / adblock-bookmarklet

A bookmarklet to remove ads.
MIT License
6 stars 3 forks source link

Add source maps for debugging #22

Closed MarcellPerger1 closed 8 months ago

MarcellPerger1 commented 1 year ago

Add source maps for debugging.
Things to check:

MarcellPerger1 commented 1 year ago
  • Do web browsers recognize sourceMapURL in bookmarklets?

Not sure, will have to test it. If not I can always use an inline source map but that sort of defeats the point of a source map.

  • Can terser generate source maps?

Yes, see https://github.com/terser/terser#source-map-options

MarcellPerger1 commented 1 year ago

This could be a bit complicated: where does the sourceMapURL point to?

It needs to be a unique location for each version/build.
The easiest option is the raw.github.com/.../<commit hash>/file.js.map. But how do we get the commit hash before all the changes have been made? We can't.

Perhaps 2 commits: the first one (let's call it A) contains the source map and a built version without the sourceMapURL and a second one, B, which contains the built version with the sourceMapURL containing the hash of commit A. This is rather annoying as it uses 2 commits instead of the 1 commit I'd prefer.

Perhaps have the URL include the hash of the commit that triggered the build and have some way of using the URL to refer to the child of that commit. This would be ideal, but I doubt it's possible.

MarcellPerger1 commented 1 year ago

Perhaps have a 2nd repo that stores all the source maps so only 1 commit is required in the main repo, and the URL refers to the other repo.

Perhaps have some sort of server/database with all the source maps.

However, I think it's better if the source maps are also in the main repo.

MarcellPerger1 commented 1 year ago

Perhaps have the URL include the hash of the commit that triggered the build and have some way of using the URL to refer to the child of that commit. This would be ideal, but I doubt it's possible.

Parent commit is possible but child commit doesn't seem to be. https://docs.github.com/en/pull-requests/committing-changes-to-your-project/viewing-and-comparing-commits/comparing-commits#comparisons-across-commits

MarcellPerger1 commented 8 months ago

I don't really think I need a source map as I can just copy the src/bookmarklet.js into a Devtools Snippet if I need to debug it.