Safari console show error when sourcemap is unavailable?
Asked Answered
C

1

7

Sometimes we want to get sourcemaps from production server. But we only want developers get those sourcemaps, so there will be some strategy to avoid any other people get sourcemaps, such as limit IP for sourcemap requests.

When sourcemaps are unavailable, Chrome and Firefox won't show any error message. But Safari will show 403/404 errors for those sourcemaps.

My question is: Is there any way to let Safari not show those messages?

Cutinize answered 4/1, 2016 at 14:31 Comment(1)
Where you able to solve this?Joppa
Y
-1

If you're willing to debug your code in Chrome, you could omit the reference to the source-map so that it's not initially requested at all, then request the source-map manually from the Sources pane of dev tools.

Webpack has this option:

hidden-source-map - Same as source-map, but doesn’t add a reference comment to the bundle.

https://webpack.github.io/docs/configuration.html#devtool

The Webpack / Chrome combo is working well for me. See the my question for a thorough description of how to apply a hidden source-map.

It may be possible to achieve hidden source-maps with uglify by specifying a blank source-map-url, but I haven't tried this.

--source-map-url - The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.

https://github.com/mishoo/UglifyJS2

If you need to debug in Safari or Firefox, then watch for answers here: How to apply a hidden / remote sourcemap in Safari?

Yukoyukon answered 1/2, 2017 at 12:7 Comment(2)
The question was "Is there any way to let Safari not show those messages?"Nutwood
@VadymK this does actually answer the question as I interpreted it: "how to prevent safari throwing 403/404 errors?" Using a hidden-source-map will achieve this: safari won't make the request, hence no 404. It's a compromise, though, cos hidden source maps are a bit of a pain.Yukoyukon

© 2022 - 2024 — McMap. All rights reserved.