FormidableLabs / inspectpack

An inspection tool for Webpack frontend JavaScript bundles.
MIT License
592 stars 20 forks source link

Sizes action fails if bundle is generated with devtool: 'eval' #34

Closed kkerr1 closed 7 years ago

kkerr1 commented 7 years ago

When inspectpack tries to calculate minified/gzipped sizes for a bundle that is created with the devtool option set to eval uglify trips over the embedded sourcemapping info and throws an error like

SyntaxError: Unexpected token: eof (undefined)
    at JS_Parse_Error.get (eval at <anonymous> (...inspectpack/node_modules/uglify-js/tools/node.js:27:1), <anonymous>:86:23)

For most standalone inspect pack uses this could simply be documented, but it may be a bigger problem for webpack-dashboard users. It may be possible to cleanup in toParseable()

ryan-roemer commented 7 years ago

This also begs the question of "what is the real code size?"

Would it be too interventionist of a solution to just have webpack-dashboard set devtool: false?

For inspectpack and the current issue here, we should still make this not break. But the code size value is totally inaccurate when there's a sourcemap wrapped around the whole thing... Definitely need to document what's up with that...

kkerr1 commented 7 years ago

It seems like overriding a user's selected devtool when webpack dashboard is pretty heavy-handed. I put up a ☝️ proposed short and sweet fix that just tweaks the existing parsing cleanup regex.

In terms of "real code size" it seems that any inline sourcemaps bits will be included in the code metric but stripped out in minified metrics, which is accurate as far as I can think about it. But, perhaps there is something I am missing?

ryan-roemer commented 7 years ago

Fixed in #35