Make sure dependencies are available for any consuming project that locally links the SDK
Unfortunately, if you npm link hydrogen-view-sdk in another project, it won't install any of the child dependencies of hydrogen-view-sdk on it's own. And will actually remove any child dependencies if you previously had hydrogen-view-sdk installed from npm and then linked the project.
Why should we do this?
I was seeing this problem with the Matrix Public Archive where when locally linking via npm link hydrogen-view-sdk, all of the child dependencies like another-json weren't being found when Vite was bundling things because npm was removing those dependencies when linking and Vite doesn't resolve from ../hydrogen-web/node_modules
This definitely seems like the responsibility of npm to handle but it seems like they're not interested in fixing this. Essentially a bug in npm in my opinion.
I tried the workaround mentioned in https://github.com/npm/cli/issues/2339#issuecomment-1111228605 which is to use npm install --install-links ../hydrogen-web/target but it doesn't create a symlink (whereas npm install ../hydrogen-web/target creates a symlink) and it wrecks the monorepo file:./share dependency that we also have. (using npm@9.5.1 which comes with Node.js v18.16.0)
All this to say, it's probably easier for people to avoid all this pain and not have to think about any of this if we just install node_modules/ for them.
Make sure dependencies are available for any consuming project that locally links the SDK
Unfortunately, if you
npm link hydrogen-view-sdk
in another project, it won't install any of the child dependencies ofhydrogen-view-sdk
on it's own. And will actually remove any child dependencies if you previously hadhydrogen-view-sdk
installed from npm and then linked the project.Why should we do this?
I was seeing this problem with the Matrix Public Archive where when locally linking via
npm link hydrogen-view-sdk
, all of the child dependencies likeanother-json
weren't being found when Vite was bundling things becausenpm
was removing those dependencies when linking and Vite doesn't resolve from../hydrogen-web/node_modules
This definitely seems like the responsibility of npm to handle but it seems like they're not interested in fixing this. Essentially a bug in npm in my opinion.
I tried the workaround mentioned in https://github.com/npm/cli/issues/2339#issuecomment-1111228605 which is to use
npm install --install-links ../hydrogen-web/target
but it doesn't create a symlink (whereasnpm install ../hydrogen-web/target
creates a symlink) and it wrecks the monorepofile:./share
dependency that we also have. (usingnpm@9.5.1
which comes with Node.js v18.16.0)All this to say, it's probably easier for people to avoid all this pain and not have to think about any of this if we just install
node_modules/
for them.