Please have a look at the example repository, where I was able to reproduce the behavior: https://github.com/apendua/htmlparser2-sourcemaps
When bundle is generated, the source maps from
htmlparser2 package should be included in a separate
The source maps are being inlined in the codebase. This is of course affecting the bundle size.
Version of Node.js:
I am using
react-scripts, which relies on
[email protected]. I haven't tried other bundlers yet, so it may just be specific to
I suspect that this is somehow related to
sourceRoot parameter which is being passed to
This behavior wasn't present in versions prior to that patch, e.g.
7.2.0 seems to be completely fine.
wouldn't know how to tackle this
As a matter of interest, why do you have to set
sourceRoot while building for
cjs to point to the repository path? I think that this is exactly what is directly contributing to the problem, because seeing this non-standard value WebPack probably thinks that the only way to properly ingrate source map with the codebase is to inline them.
@fb55 Thanks for your suggestion. This sounds reasonable to look into potential issues with
webpack as well.
My only concern is that I have quite a libraries heavy project and really
htmlparser2 is the only one that exposes this issue. So I am wondering if other packages are not even bothering about
sourceRoot or perhaps they're just generating source maps quite differently. I think I will spend a bit more time next week trying to understand where this discrepancy is coming from.
I think a lot of packages aren't including source maps because it isn't incredibly straight-forward. All of my packages use this pattern, and webpack's source-map-loader intends to support the pattern: webpack-contrib/source-map-loader#186. Reading this issue, it also seems like webpack will just forward the source map URL and not actually load files.
Looking at the file sizes, they don't seem particularly large: See https://unpkg.com/browse/[email protected]/lib/generated/ for the sizes as part of the
entities module. Unfortunately an HTML parser needs to have a listing of all HTML entities, and this data takes about 47kb (which is already compressed a lot — see https://github.com/fb55/entities/blob/master/scripts/trie/README.md for some context).
Closing this here as there is nothing that can be done in this repo.
|Issue Title||Created Date||Updated Date|