Skip to content

Commit

Permalink
fix: speed up source map generation by only stringiying at the end (#624
Browse files Browse the repository at this point in the history
)

Currently when generating source maps, we stringiyf the in-progress
indexMap once for every. single. file. even though we only care about
the final result (and indeed overwrite our previous stringification each
file). This was likely a typo and intended to be outside the forEach, so
this change moves the stringification to after we're fully done building
up the indexMap. This dramatically speeds up source map generation since
we're doing significantly less work with fewer allocations and GCs.
  • Loading branch information
FuegoFro authored and zamotany committed Aug 9, 2019
1 parent 3088b0d commit 4b003f4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/haul-ram-bundle-webpack-plugin/src/IndexRamBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ export default class IndexRamBundle {
});

lineOffset += countLines(sourceModule.source);

compilation.assets[sourceMapFilename] = new RawSource(
JSON.stringify(indexMap)
);
});
compilation.assets[sourceMapFilename] = new RawSource(
JSON.stringify(indexMap)
);
}
}
}

0 comments on commit 4b003f4

Please sign in to comment.