mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add node trace source map handling in dev mode (#2816)
* Add node trace source map handling in dev mode Fixes #2285 * Fix typo in comment
This commit is contained in:
parent
4ee0dc90d8
commit
d600957aeb
|
@ -247,8 +247,23 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
|
||||||
inputSourceMap: sourceMap
|
inputSourceMap: sourceMap
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Strip ?entry to map back to filesystem and work with iTerm, etc.
|
||||||
|
let { map } = transpiled
|
||||||
|
let output = transpiled.code
|
||||||
|
|
||||||
|
if (map) {
|
||||||
|
map.sources = map.sources.map((source) => source.replace(/\?entry/, ''))
|
||||||
|
delete map.sourcesContent
|
||||||
|
|
||||||
|
// Output explicit inline source map that source-map-support can pickup via requireHook mode.
|
||||||
|
// Since these are not formal chunks, the devtool infrastructure in webpack does not output
|
||||||
|
// a source map for these files.
|
||||||
|
const sourceMapUrl = new Buffer(JSON.stringify(map), 'utf-8').toString('base64')
|
||||||
|
output = `${output}\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,${sourceMapUrl}`
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: transpiled.code,
|
content: output,
|
||||||
sourceMap: transpiled.map
|
sourceMap: transpiled.map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,14 @@ const blockedPages = {
|
||||||
|
|
||||||
export default class Server {
|
export default class Server {
|
||||||
constructor ({ dir = '.', dev = false, staticMarkup = false, quiet = false, conf = null } = {}) {
|
constructor ({ dir = '.', dev = false, staticMarkup = false, quiet = false, conf = null } = {}) {
|
||||||
|
// When in dev mode, remap the inline source maps that we generate within the webpack portion
|
||||||
|
// of the build.
|
||||||
|
if (dev) {
|
||||||
|
require('source-map-support').install({
|
||||||
|
hookRequire: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.dir = resolve(dir)
|
this.dir = resolve(dir)
|
||||||
this.dev = dev
|
this.dev = dev
|
||||||
this.quiet = quiet
|
this.quiet = quiet
|
||||||
|
|
Loading…
Reference in a new issue