sagui icon indicating copy to clipboard operation
sagui copied to clipboard

Sagui bundles peerDependency when Importname is not equal peerDependencyname

Open Kadrei opened this issue 7 years ago • 2 comments

I have a libraryproject (lets call it ProjectA) depending on another project (lets call it ProjectB), but I do not want to have ProjectB bundled inside the package so I added it as a peerDependency.

When I only add it as a peerDependency a build fails because it cannot find ProjectB (which is used inside the package). But when I add it as a devDependency it will build everything and also bundle the whole(!) ProjectB in the build. What I would expect is that sagui only bundles the dependencies imported which are not peer- & devdependencies.

When I install ProjectB per hand and only mention it as a peerDependency (so removing it from dev- & dependencies) it will still get bundled.

Expected behaviour would be that sagui bundles only dependencies from the dependencies-field and ignores/excludes dependencies from the peerDependencies-field (even though they may be found in the node_modules. Also as stated before treeshaking does not seem to work.

Kadrei avatar Oct 05 '17 08:10 Kadrei

Further Investigation revealed that the problem is not a general bug but a little more tricky.

We imported stuff from ProjectB like so: import {thing} from 'ProjectB/' The / is required for PHPStorm (and most likely also WebStorm) to find the Package when clicked on (if ProjectB is scoped). But now the import does not match what is inside peerDependencies: 'ProjectB/' != 'ProjectB' So the question is should sagui also externalize ${peerDependency}/?

Kadrei avatar Oct 05 '17 14:10 Kadrei

It also seems to happen when we import from a subdirectory like 'ProjectB/subdir'

Kadrei avatar Oct 06 '17 10:10 Kadrei