diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index f2373992d4..8e6265c524 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -245,6 +245,15 @@ var runWebAppServer = function () { }; // Send the SourceMap header when the source file is served. staticFile.sourceMap = sourceMapRootUrl; + + // Now register all the sources from this source map to be served, under + // the source map's URL. + _.each(item.sources, function (x, pathForSourceMap) { + staticFiles[sourceMapRootUrl + pathForSourceMap] = { + path: x.source, + cacheable: true + }; + }); } staticFiles[url.parse(item.url).pathname] = staticFile; } @@ -293,7 +302,9 @@ var runWebAppServer = function () { // Tell the client where to find the source map for this file. if (info.sourceMap) { - res.setHeader('SourceMap', info.sourceMap); + // This should just be SourceMap, but slightly more browsers support the + // older X-SourceMap. + res.setHeader('X-SourceMap', info.sourceMap); } send(req, path.join(clientDir, info.path)) diff --git a/tools/bundler.js b/tools/bundler.js index 10a2a7bbb2..51b4ecb350 100644 --- a/tools/bundler.js +++ b/tools/bundler.js @@ -902,7 +902,16 @@ _.extend(ClientTarget.prototype, { data: new Buffer(file.sourceMap.toString(), 'utf8') }); - // XXX write sources too + manifestItem.sources = {}; + _.each(file.sources, function (x, pathForSourceMap) { + manifestItem.sources[pathForSourceMap] = { + package: x.package, + sourcePath: x.sourcePath, + source: builder.writeToGeneratedFilename( + path.join('sources', pathForSourceMap), + { data: x.source }) + }; + }); } manifest.push(manifestItem);