Closed tptee closed 7 years ago
Some rough edges left, but probably worth an initial pass!
Looking great so far! Let me know when this hits complete and what specific types of examples you need for the smoke tests.
I've neutered the versions
smoke test for now, since doing it right requires some nasty postinstall
ing or heavy mocking 😬
Should be ready for a final peek!
@tptee -- The fixtures are huge and I'd rather they not be part of this git repo. Can we move them to a separate published packaged? Like inspectpack-test-fixtures
or something?
Done!
I ran into this when integrating with
webpack-dashboard
: https://github.com/webpack/webpack/blob/93ac8e9c3699bf704068eaccaceec57b3dd45a14/lib/Template.js#L118Turns out that Webpack bundles can contain either an array of modules or an object of id keys/module values. The object version seems rare, but I caught one in a simple lodash + entrypoint bundle, and inspectpack can't currently understand it.
This PR parses the bundles with
babylon
, traverses the AST, and createsCode
objects from AST data. It parses both the array and object forms of bundles. Most string manipulation is gone, save for a bit of trickery in extracting data from module header comments. I figure this approach will make inspectpack more resistant to changes in the Webpack bundle format in the future.I also modified the
Code
API a little, since we know more about the type ofCode
objects a priori during traversal. I've updated its usage inmodels/bundle.js
andactions/sizes.js
, but need to update the remainder of the action files.@ryan-roemer Do you have example bundles that trigger non-empty cases for duplicates/files/parse/pattern/versions? I added some super-basic smoke tests for each action, but they won't be meaningful unless they're run against a bundle with positive results.