webpack-node-externals icon indicating copy to clipboard operation
webpack-node-externals copied to clipboard

Adding a debug mode

Open DannyvanderJagt opened this issue 3 years ago • 0 comments

While using this externals package I ran into an issue where packages weren't bundled that were suppose too. It turned out to be a mistake by me, but it was far from obvious.

A use case to illustrate:

We are using the package accessible-autocomplete but in the code it's actually imported as accessible-autocomplete/preact. When I added "accessible-autocomplete" to the allowlist it didn't include it in the bundle. After a bit too many hours, I ended up debugging this package and found the problem.

Debug mode

It would be nice to add a debug mode to this package that will output exactly which packages were included and excluded from the bundle.

It could output a simple for formatted list like this:

Included packages: [ ..... , ..... ]
Excluded packages: [ ..... , ..... ]

Or an detailed list of the internal results from these two checks:

 utils.contains(nodeModules, moduleName) &&
 !utils.containsPattern(allowlist, request)

See here. They include regex and string comparison checks that will easily fail on typos or a slightly different naming like the use case above.

What do the contributors think? I'm happy to create a PR and propose something.

DannyvanderJagt avatar Mar 08 '22 13:03 DannyvanderJagt