common-shakeify icon indicating copy to clipboard operation
common-shakeify copied to clipboard

Does not shake off other modules when importing with default

Open z-vr opened this issue 6 years ago • 1 comments

This plugin works great but unfortunately it does not allow to import default exports only.

Steps to reproduce:

  1. Checkout https://github.com/Sobesednik/bs-sh on github
  2. git clone https://github.com/Sobesednik/bs-sh.git
  3. cd bs-sh
  4. npm i
  5. npm t

z-vr avatar Jan 19 '18 21:01 z-vr

This is most likely because default imports get wrapped in a _interopDefault function call by Babel. common-shake does not know what this function does (it could do anything) so it marks all properties of the entire require() call as "used" just to be safe. common-shake works best with untranspiled CommonJS modules. ES modules will likely get better support in browserify itself after Node settles on an implementation.

goto-bus-stop avatar Jan 19 '18 22:01 goto-bus-stop