Commit d600957a authored by Kevin Decker's avatar Kevin Decker Committed by Arunoda Susiripala

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
parent 4ee0dc90
......@@ -247,8 +247,23 @@ export default async function createCompiler (dir, { dev = false, quiet = false,
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 {
content: transpiled.code,
content: output,
sourceMap: transpiled.map
}
}
......
......@@ -29,6 +29,14 @@ const blockedPages = {
export default class Server {
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.dev = dev
this.quiet = quiet
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment