Known Issues - Gozala/method GitHub Wiki
Unfortunately everything comes with a price and this library is not an exception either, but hopefully understanding them would make it less of a problem.
dedup by default
One of the common pitfalls are caused by nodes decision to never share dependencies. In
a way both npm and method library solve very similar issues. npm solves name collision problem
by duplicating dependencies such that if I require("foo")
and my dependency also does
require("foo")
we'll get different copies of foo
and there for we won't have a chance to
step on each others toes. This a lot saner default than one used by other mainstream languages,
although it still not ideal. For example if my dependency provides extends require("foo")
to
adapt to my use case I won't actually get those dependencies as require("foo")
will give me
a different copy no the extended one. Which is exactly what method library does, when you define
method bar
for the type Foo
it guarantees you won't have any conflicts, but if instance of
Foo
I work with is different from the Foo
type that bar
was defined for, obviously I'll
have a problem. Some suggestions have being made to make library smart enough to detect cases
like that and adapt, but that not only is not the concern of this library, but it will not solve
the problem either. Because it's very easy to wind up with two copies of method extensions for
the same types in the dependency graph and then one will have to override other potentially
making behavior non-deterministic and running into exact same name collision issues this library
is aims to solve. Luckily there is a imperfect but solution that had proven itself to work well,
which is setting npm dedup
in postinstall
script of your package, see [fs-reduce example]
(https://github.com/Gozala/fs-reduce/blob/master/package.json#L40) for instance.
Also be aware of npm dedup bugs. If you run npm install foo
in your package directory
dedup
won't be executed and you still may end up with duplicates. In that case best thing to
do is to run npm dedup
manually or npm install
that will run dedup
afterwards. npm also
does not dedup
s linked dependencies which may also cause problems.
does not works for linked dependencies
automatically
run causing
some npm bugs,