browserify / browser-pack

pack node-style source files from a json stream into a browser bundle
Other
174 stars 58 forks source link

cache sourcemaps for faster watchify #65

Closed darky closed 9 years ago

darky commented 9 years ago

For my (has many dependencies) project it reduce ~3sec watchify

zertosh commented 9 years ago

That doesn't work. Not only isn't it actually caching anything, but you can't "cache" source maps because they depend on the previous one. The slow part is the concatenation of source maps. I have a fast implementation that I'm still testing around https://github.com/substack/browser-pack/tree/sm-fast

ForbesLindesay commented 9 years ago

I agree. This doesn't work.

darky commented 9 years ago

Not agree. Call sourcemap.addFile summary on each dependency took time ~3.2sec, but sourcemap.comment only ~1.2sec Also, before I try https://github.com/substack/browser-pack/tree/sm-fast and it's not help me with performance. I learn very deep this sutiation and debug how it works in combine-source-map and source-map libraries. Noticed, that it's mostly reused existing sourcemap. Maybe can leak in this place https://github.com/mozilla/source-map/blob/master/lib/source-map/mapping-list.js#L58-L64, but node-inspector not show it. Anyway please measure sourcemap.addFile and make sure, that it's big performance problem place.

zertosh commented 9 years ago

sourcemap.addFile calls are very expensive - nobody denies that. For sourcemap.comment() to generate a correctly concatenated sourcemap, it must first be fed each source content (with its source map, if available). So you can't just not call sourcemap.addFile. What my sm-fast branch does, is that is uses my inline-sourcemap-concat, which is a lot like combine-source-map, but it's optimized for linear source map concatenation (that's exactly what being done in browser-pack).

darky commented 9 years ago

May cannot call sourcemap.addFile, because sourcemap object placed outside of scope https://github.com/substack/browser-pack/pull/65/files#diff-168726dbe96b3ce427e7fedce31bb0bcR14 and save earlier generated privated hashes about sourcemaps. Other problem, that sourcemap object can leaked. Anyway, in https://github.com/substack/browser-pack/tree/sm-fast not used sourcemap.addFile, but I afraid, that similar API https://github.com/substack/browser-pack/blob/sm-fast/index.js#L62-L64 can have this problem too.

darky commented 9 years ago

https://github.com/substack/browser-pack/tree/sm-fast was created 18 May. When it will merged in master branch?