esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Exclude JSON from sourcemaps

Open znewsham opened this issue 1 year ago • 2 comments

I'm trying to exclude JSON files from sourcemaps - I've already looked at https://github.com/evanw/esbuild/issues/1685 and implemented the suggested solution - however this only works for JS files as you can't append a comment to a JSON file (esbuild complains about this if I do add the comment). Unfortunately these files are still added to the client sourcemap, making it quite large.

Is there a way to exclude JSON files from the sourcemap?

znewsham avatar Aug 14 '24 13:08 znewsham

I guess you can just run a script after esbuild that replaces the json fields in sourcemap with null.

hyrious avatar Aug 19 '24 06:08 hyrious

This would be tricky - since the filenames aren't retained - or if they are the order is lost - since the code mapping portion of the sourcemap contains hundreds of empty ;; segments.

Seems like a reasonable feature to add though, rather than forcing the use of an onLoad hook that modifies the code (which I have to believe is wildly inefficient) instead make it part of the return of the onResolve hook - excludeFromSourcemap: true (or similar)

znewsham avatar Aug 23 '24 14:08 znewsham