Make sure dependencies are available for any consuming project that locally links the SDK #1100
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Make sure dependencies are available for any consuming project that locally links the SDK
Unfortunately, if you
npm link hydrogen-view-sdkin another project, it won't install any of the child dependencies ofhydrogen-view-sdkon it's own. And will actually remove any child dependencies if you previously hadhydrogen-view-sdkinstalled 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-jsonweren't being found when Vite was bundling things becausenpmwas removing those dependencies when linking and Vite doesn't resolve from../hydrogen-web/node_modulesThis 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 npm/cli#2339 (comment) which is to use
npm install --install-links ../hydrogen-web/targetbut it doesn't create a symlink (whereasnpm install ../hydrogen-web/targetcreates a symlink) and it wrecks the monorepofile:./sharedependency that we also have. (usingnpm@9.5.1which 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.