-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Production Source Maps #1903
Comments
Looks like #918 (comment) is an answer to your question? |
I tried this config and ran module.exports = {
webpack: config => {
config.devtool = 'source-map'
for (const r of config.module.rules) {
if (r.loader === 'babel-loader') {
r.options.sourceMaps = true
}
}
return config
}
} Source maps in production make tools like Sentry far more useful. |
@Rowno we use inline-source-maps usually. |
What's so bad about exposing them in production? |
You should upload them as a release to sentry instead @Rowno |
I would if I could generate them. 😅 Looks like there's multiple things preventing them from working including Uglify. |
Can we reopen this issue? @arunoda There is a valid use-case for having production source maps. Or at-least built as part of production code build. But we can strip before it is served.
Currently we can achieve the follow -
We want to generate external source maps, but do not seem to have the capabilties with Some help would be beneficial. Regardless what we do, the source maps are ignored within a production deploy of Next. |
Want to point out that we should do the following - https://webpack.js.org/configuration/devtool/
|
This is really important for me too. Different users are going to want different kinds of sourcemaps (e.g., I actually don't want mine to be hidden—I'm not trying to obfuscate my code, and a linked sourcemap is by far the simplest way to get the file to Sentry), so I think a configuration option that lets the user provide a function returning the type of sourcemap to generate would be good. The default in Next could be something like:
And a user who wants production source maps could just do:
|
@ethanresnick - Mostly agree. This is what we found out when we experimented.
We set the above up so it exits the custom config if we don't have
Long story, we would scrape all JS files in We called all this code through a new and special NPM build command. Once it was done, we removed the Long story short, this was a incredible amount of effort, and a total hack. Without changing how next handles production builds, this was the best option we had. |
I've gotten configurable production source maps working by making some changes to the next.js server and build process. I still have some tidy up to do but I'm hoping to submit a pull request in the next week or so. Here's my work in progress: v3-beta...Rowno:production-source-maps |
@Rowno - some feedback - can you make it This does the same thing as This means your user will not download it, but you have it generated to uploaded to Sentry like @albinekb said above. My team uses Rollbar, and would greatly benefit from this. Additionally, @arunoda - if we put a pull request in for this (GJ @Rowno), can we get this on the 2.4.x branch? My team can not switch over to 3.0.0 beta with our live site yet. We need to wait for that set of tags to stabilize. But we need sourcemaps ASAP. We had a hack in to make them sort of work. But the 2.4.1 release broke that effort. We did not go as far as @Rowno to modify next itself. |
You can set it to whatever you want, I made it a config option. But the browser will only download external source maps if you have the DevTools open, so |
So is there clean way of generating separate production source maps ( for Sentry ) in next 3 ? |
+1 we're trying to upload the sourcemap to bugsnag on build and can't seem to do it with the webpack config customization that's made available now. As is, production errors are impossible to debug. @Rowno's work seems promising, but we're hesitant to switch to our own fork and integrate his changes into the most recent next version. |
Hey there. Same here, would really like to have an official feature or a good example to have source maps working in prod for tools like Sentry. |
Any solutions for this issue? |
@arunoda Why exposing source-maps in production is a bad idea? I would like to know reasons. For example in webpack documentation they say:
|
If you're using sentry, I've had good experiences w/ this webpack plugin on create-react-app, though i've yet to implement it in a nextjs project: |
@isBatak @Tomekmularczyk |
Next 5 does add source maps. If you are using You can find it here - https://github.com/WebGrind/buildpack-sentry-sourcemaps The instructions are very easy. Enable source maps. Add config variables. Add build pack. Will take you all of 5 minutes to setup. |
for Next 5.1+ Next.js (version 5.1+)
FYI: #3793 (comment) |
FYI the plugin has changed so that now you have to call it twice as in the readme: const withSourceMaps = require('@zeit/next-source-maps')()
module.exports = withSourceMaps({
webpack(config, options) {
return config
}
}) Caught me out until I saw that new extra call, because it silently fails otherwise |
that extra |
not having source maps in staging and production is very un-intuitive and counter-productive when debugging :( |
Anyone here have success with this for cases like Sentry? I see I guess I can |
@loganfsmyth did you have a chance to remove the source map after build. I need to build them to upload to sentry server, but after that I do not want them on my public server. ( I use @sentry/nextjs ) and I have build script like Edit: On Heroku, I could make it work by |
@loganfsmyth @karianpour found any solution about this? I'm also trying to find a way to get the sourcemap in sentry but not served during deployment |
@loganfsmyth @karianpour @abeauchemin-planned , have you found a solution ? |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Is it possible to generate/serve separate source map files in production?
The text was updated successfully, but these errors were encountered: