Make htmx a peer dependency of each extension #173
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.
Description
PR #123 made htmx a dependency of each extension instead of a dev dependency.
One reason given was to ensure a minimum version of htmx is installed that's compatible with the extension.
Unfortunately this doesn't work in practice, so rather than flagging any version mismatch, if there's a conflict NPM will instead create its own nested version of htmx for the extension and that will end up in the bundle as well.
Changing the dependency to a peer one solved the problem and extensions/plugins are the intended use case for peer dependencies.
With my own test specifying a v1 release for htmx with a v2 of the SSE extension,
both a v1 and v2 release of htmx ended up in the final bundle, increasing bundle size from 65K to 115K.
Htmx version: 1.9.2 / 2.0.6
Used extension(s) version(s): 2.2.3 of SSE, plus a WIP version of my own extension
Testing
I tested with my own extension to verify the behavior of normal vs. peer dependencies.
I ran
npm install
andnpm run test
for each extension.Checklist
npm run test
) and verified that it succeeded