webpack / webpack-sources

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

consider using krisselden/fast-source-map or something like it #22

Closed webpack-bot closed 6 years ago

webpack-bot commented 7 years ago

Do you want to request a feature or report a bug? feature

What is the current behavior? source-map library is antequated and slow + consumes tons of memory.

If the current behavior is a bug, please provide the steps to reproduce. What is the expected behavior? fast sourcemaps

If this is a feature request, what is motivation or use case for changing the behavior? For larger projects, sourcemap generation is really a large chunk of the total time webpack spends compiling. Having faster sourcemap generation would help with faster builds/incremental builds.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

The library here seems like an interesting alternative: https://github.com/krisselden/fast-source-map According to their benchmarks, they are 10x faster than source-map.


This issue was moved from webpack/webpack#5171 by @sokra. Orginal issue was by @MagicDuck.

sokra commented 7 years ago

According to their benchmarks, they are 10x faster than source-map.

On decoding source maps... webpack encodes source maps.

But I'm open to a PR if it's faster.

MagicDuck commented 7 years ago

@sokra sorry for the long time gap before replying again. I had to debug some source-map code yesterday and can give you a very common example of webpack decoding source maps: when you use babel, the babel sourcemaps are used as input sourcemaps for later steps, so the later steps need to decode them.

An API that does that is https://github.com/mozilla/source-map#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath Like I mentioned before, I was debugging this yesterday, and the code does quite a lot of unnecessary allocation in my opinion (at least the version I was looking at).

Regarding the PR, I would love to help, but I am a bit strapped for time atm. In any case, I thought this would be useful for you guys when looking for places to get performance wins.

I think one major difficulty could also be the fact that various loaders use SourceNode/SourceMapConsumer which makes it difficult to change the dependency. Maybe the way to go is to fix "source-map" library itself using stuff from "fast-source-map".

sokra commented 7 years ago

Maybe the way to go is to fix "source-map" library itself using stuff from "fast-source-map".

@MagicDuck That would be great. This way everybody will benefit from it.

alexander-akait commented 6 years ago

Looks https://github.com/krisselden/fast-source-map abandoned, also original https://github.com/mozilla/source-map was rewritten using wasm and should be very fast, but we can update their right now, because node@6 doesn't supported in source-map@7