Closed aversini closed 1 year ago
I had a similar problem and could solve it by slightly modifying my imports
/* main index.js */
import aaa from "./aaa/index"; // add index
import bbb from "./bbb/index"; // add index
export { aaa, bbb };
I have the same issue. The solution which @adrienpoly suggests did fix it. Having said that it would be wonderful not to have to add /index in each import.
I am facing the same issue. What I am trying todo is check every packages my project using are tree-shakeable, and forbid to add new package if it is not shakable. @Rich-Harris Is this a rollup problem?
Is this a rollup problem?
No. Agadoo assumes it's testing an ESM entry point. ESM requires you to be specific about what file you're importing; consequently, so does Rollup. Rollup is in fact too liberal — for the file to be valid ESM it must specify the .js
file extension — but that's a design mistake that would be hard to undo at this point.
If it's failing because it's not finding an index
file imported from the entry point, it means that the import is invalid in the first place, and won't run natively in Node. For some projects that's fine (i.e. if the code will only ever be consumed via tooling) but since best practice is to be specific about what files you import, Rollup/Agadoo's behaviour won't change.
Hello @Rich-Harris , I love the idea of running Agadoo on our CI server to make sure the library we are building is fully tree-shakable. However, while I believe it is currently tree-shakable (we tried it with webpack 4 and made sure bundles were correctly limited to what was needed and no more), Agadoo is throwing errors I do not really understand.
Here is a super simple simplification of our lib (after building):
There is a bunch of components, so imagine
ccc
,ddd
folders in the same vein.And here are the content of each files:
With this setup, when I run
node node_modules/.bin/agadoo
the following error message is thrown:Any idea what's wrong? Is it us and our weird sub-folder organization? Or is it Agadoo? Any pointers would be great, thanks!!
PS: I tried with node 8.11.4 and 10.9.0