Skip to content

Commit

Permalink
Update sourcemap helper according to @jridgewell feedback. (#35763)
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Aug 23, 2021
1 parent 68b7333 commit b105c05
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions build-system/compile/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {VERSION: internalRuntimeVersion} = require('./internal-version');
* @param {Object} options
* @return {string}
*/
function getSourceMapBase(options) {
function getSourceRoot(options) {
if (argv.sourcemap_url) {
return String(argv.sourcemap_url)
.replace(/\{version\}/g, internalRuntimeVersion)
Expand Down Expand Up @@ -49,12 +49,14 @@ function updatePaths(sourcemaps) {
*/
async function writeSourcemaps(sourcemapsFile, options) {
const sourcemaps = await fs.readJson(sourcemapsFile);

updatePaths(sourcemaps);
const extra = {
sourceRoot: getSourceMapBase(options),
includeContent: !!argv.full_sourcemaps,
};
await fs.writeJSON(sourcemapsFile, {...sourcemaps, ...extra});
if (!argv.full_sourcemaps) {
delete sourcemaps.sourcesContent;
}
sourcemaps.sourceRoot = getSourceRoot(options);

await fs.writeJSON(sourcemapsFile, sourcemaps);
}

module.exports = {
Expand Down

0 comments on commit b105c05

Please sign in to comment.