webpack / webpack-sources

Source code handling classes for webpack
MIT License
261 stars 71 forks source link

Implement `SourceMapSource.buffer` for efficient size computation #110

Closed JoostK closed 3 years ago

JoostK commented 3 years ago

The Source.size method computes the size from the buffer length, where the default Source.buffer method allocates a new buffer from the string source. By implementing SourceMapSource.buffer this allocation is avoided, as a buffer representation is available on the instance. This results in a noticeable performance improvement for stats computation in Webpack, where chunk sizes are obtained from Source.size.


Before:

Screenshot 2021-05-30 at 01 09 31

After:

Screenshot 2021-05-30 at 01 13 55
sokra commented 3 years ago

Thanks