webpack-common-shake icon indicating copy to clipboard operation
webpack-common-shake copied to clipboard

Support recursive imports

Open indutny opened this issue 7 years ago • 3 comments

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 avatar Jul 04 '17 20:07 indutny

It is supported as of [email protected].

indutny avatar Jul 08 '17 17:07 indutny

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 avatar Jul 08 '17 17:07 indutny

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

indutny avatar Jul 08 '17 18:07 indutny