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.
The
Source.size
method computes the size from the buffer length, where the defaultSource.buffer
method allocates a new buffer from the string source. By implementingSourceMapSource.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 fromSource.size
.Before:
After: