indutny / webpack-common-shake

CommonJS Tree Shaker plugin for WebPack
918 stars 13 forks source link

Support recursive imports #8

Open indutny opened 7 years ago

indutny commented 7 years ago

Instead of bailing out on code like this:

// root.js
require('./lib').a.b

// lib.js
exports.a = require('./a');

// a.js
exports.b = 1;

We should recognize recursive pattern and store uses in a.js.

indutny commented 7 years ago

It is supported as of webpack-common-shake@1.3.0.

indutny commented 7 years ago

Oh, actually the thing that it supported is more limited:

// a
exports.a = require('./b').b;

// b
exports.b = 1;

If exports.a is unused - exports.b will be removed too.

indutny commented 7 years ago

Recognizing recursive pattern as in the issue description is harder, will keep this issue just in case.