Nextjs - Source mapping failed: A source map could not be applied
See original GitHub issueAnyone using Next.js and has successfully managed to upload source maps to bugsnag?
I have successfully set up my next.config.js file to upload my source maps to bugsnag using webpack-bugsnag-plugins.
However, bugsnag cannot seem to apply the source map to my code as seen in the screenshot below. Also, release stage is recorded as Production even though the issue is triggered from Staging (I’ve tried setting bugsnag releaseStage to process.env.NODE_ENV and it does not work).
next.config.js
const fs = require('fs')
const withSass = require('@zeit/next-sass')
const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')
module.exports = withSass({
webpack: (config, { buildId, dev, isServer }) => {
const oldEntry = config.entry
config.entry = function () {
return oldEntry().then(function (entries) {
if (entries['main.js']) {
entries['main.js'].unshift('babel-polyfill')
}
return entries
})
}
config.module.rules = config.module.rules.map(rule => {
if (rule.loader === 'babel-loader') {
rule.options.cacheDirectory = false
}
return rule
})
config.devtool = 'source-map'
for (const plugin of config.plugins) {
if (plugin['constructor']['name'] === 'UglifyJsPlugin') {
plugin.options.sourceMap = true
break
}
}
config.plugins.push(
new BugsnagSourceMapUploaderPlugin({
apiKey: 'af3a166c839bf6a0e9304c1bae9e5e24',
publicPath: '*/',
overwrite: true
})
)
return config
},
generateBuildId: () => {
const buildId = fs.readFileSync(process.cwd() + '/build/BUILD_ID', 'utf8')
return buildId.trim()
},
poweredByHeader: false
})
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Advanced Features: Source Maps | Next.js
Source Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client,...
Read more >Troubleshooting Source Maps for Next.js
For uploaded source maps to be located and applied, the release needs to be created by the CLI or API (and the correct...
Read more >Error message "DevTools failed to load SourceMap: Could not ...
mine was caused by a webpack-config. I changed the config to include devtool: 'inline-source-map', as aiibe mentioned on github. Just mentioning ...
Read more >Upload sourcemap to the same URL without am unique ...
Background: I am trying to upload my nextjs sourcemap to the browser UI, everything seems fine the first time.
Read more >JavaScript Debugging with Sourcemaps - TrackJS
The main purpose of sourcemaps is to aid debugging. Basically, if there's an error in the generated code file, the map can tell...
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
@mattdyoung and anyone who may need it, the example repo for configuring source map uploads to Bugsnag during the build and deployment process can be found here. Please feel free to reach out for any clarifications.
But we can try to kindly remind this, since the fix was pushed “15 months ago”. So maybe reopening an issue to remind that this is a pain for some users will help on releasing this to the next version