Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have an option to hide the sourceMappingURL, similar to hidden-source-map in WebPack #7873

Open
YoranBrondsema opened this issue Jun 12, 2018 · 2 comments

Comments

@YoranBrondsema
Copy link

Rationale

As I do not want to expose the full deobfuscated code in production, I do not upload the sourcemaps to our asset server on S3. However, since I do want access to them in our error monitoring tool, I do generate them and upload them separately to Sentry. So the source files end with

...
//# sourceMappingURL=https://xyz-s3.com/assets/vendor-abc.map

but since they are not uploaded to the asset server, that link returns a 404.

This is not too much of an issue but the Chrome Developer Tools can automatically load the asset maps. It sees the sourceMappingURL and downloads it. Since it returns a 404, this prints an error in the console.

Proposal

I was looking for an option similar to hidden-source-map in WebPack. From https://webpack.js.org/configuration/devtool/#production:

hidden-source-map - Same as source-map, but doesn't add a reference comment to the bundle. Useful if you only want SourceMaps to map error stack traces from error reports, but don't want to expose your SourceMap for the browser development tools.

I couldn't find it so I'm proposing to add it. The option hiddenSourceMap would then not write the sourceMappingURL line. This would prevent Chrome Developer Tools from fetching the sourcemaps while still generating them and allowing to separately upload them to an error monitoring tool.

In ember-cli-build.js, it would look something like:

new EmberApp(defaults, {
  sourcemaps: {
    enabled: true,
    hiddenSourceMap: true // defaults to 'false'
  }
});

Implementation

When I go down the chain of dependencies in ember-cli, I see that the sourcemaps are generated in fast-sourcemap-concat. Specifically, if I'm correct, the lines around https://github.com/ef4/fast-sourcemap-concat/blob/d5984e180bbab6fde0c4a5310c776f3119f56f84/lib/source-map.js#L446 write the sourceMappingURL to the source file. The option hiddenSourceMap would then be propagated all the way down to this module.

I don't mind doing this extension myself but would like to get an OK on the proposal beforehand to avoid doing work for nothing.

@Frank3K
Copy link

Frank3K commented May 26, 2023

The fast-sourcemap-concat package already has a property mapCommentType (source). One could add support for a value none to achieve this goal with only just a few lines.

@BvG-Gynzy
Copy link

Created a PR for this in fast-sourcemap-concat ef4/fast-sourcemap-concat#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants