Source map issue with New Relic Webpack Plugin
See original GitHub issueDescription
We’re using the New Relic experimental plugin to allow New Relic’s NodeJS Agent to work with webpack compiled server side javascript and it’s causing issues with the source map that’s generated by webpack.
I noticed that the plugin adds a new line with require("newrelic");\n
at the top of the compiled files and this is what’s causing issues. The line added by the newrelic plugin is not taken into account when the source map is generated by webpack.
We fixed the issue by removing the new line (\n
) after the require statement that’s injected by the webpack plugin.
I’m posting this here because I could not find the repository for @newrelic/webpack-plugin
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Source map upload - Browser - New Relic Explorers Hub
We have issue with the upload of the source maps. We are using @edx/new-relic-source-map-webpack-plugin to upload our source map while webpack ...
Read more >@edx/new-relic-source-map-webpack-plugin - npm
Upload source maps to new relic as part of a webpack build.. Latest version: 2.0.0, last published: 6 months ago.
Read more >new-relic-source-map-webpack-plugin - npm package - Snyk
The npm package new-relic-source-map-webpack-plugin was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was ...
Read more >New-relic-source-map-webpack-plugin - npm.io
Upload source maps to new relic as part of a webpack build. Install. yarn add new-relic-source-map-webpack-plugin --dev or npm install new- ...
Read more >Disable @newrelic/publish-sourcemap dependency for MFEs
2 for Bitnami, and we have found that there is a hardcoded dependency on @newrelic/publish-sourcemap within the @edx/frontend-build NPM package, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@etienne-martin (and all following) Thanks again for bringing this to our attention. Until we get this plugin published to GitHub this is the best place for issues. This is still an experimental plugin – if you’d like to see this more officially supported (including a GitHub repo) be sure to file a feature request via our formal support channels.
We’ve just published version 0.4.1 of the plugin, which removes this newline from the compiled output.
https://www.npmjs.com/package/@newrelic/webpack-plugin
We’d be interested in hearing if this helps with your soucemap issue. We can see how this newline would interfere with any line number offsets provided via a source map, but we’re still a little concerned about character offsets. Also, if you (or anyone following) knows whether it’s possible for a plugin to tap into these source maps and provide a proper fix we’d appreciate the information. Our current solution is um – pragmatic? – but there’s a probably a better way to fix this.
Closing for now, but don’t hesitate to open a new issue or keep this conversation going.
Thanks @astormnewrelic and the team for such a quick fix.
I agree that this is a “good enough” solution for our current use case given that our build files are not minified. But yeah, I can see why this can still be an issue with compiled javascript that spans a single line.
Here’s an attempt at dealing with the character offset by @kxlow: https://discuss.newrelic.com/t/experimental-webpack-plugin-for-nodejs/88068/16
And here’s the gist: https://gist.github.com/kxlow/98bfb17e3429a48436219020610f0eb4
Thanks again