Repository navigation
[2.x] Add a core entry point without pusher-js to the React, Vue and Svelte wrappers - #574
Closed
CaioBGalvao wants to merge 1 commit into
Closed
CaioBGalvao wants to merge 1 commit into
CaioBGalvao wants to merge 1 commit into
Conversation
The React, Vue and Svelte wrappers declare pusher-js as an optional peer, but import it unconditionally, so they fail to load without it. The default entry point keeps importing pusher-js and registering it as the default Pusher client. The new `core` entry point exports the same API without that import. Both entry points share one chunk, and with it one Echo instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
I'm getting weary of AI generated attempts at this. |
Author
|
Sorry about that. I did use AI to help put this together, and I get why that's tiring to deal with. I'll leave it here. Thanks for everything you do for Laravel. @taylorotwell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #570 without breaking anything, unlike #573.
The React, Vue and Svelte wrappers declare
pusher-jsas an optional peer, but import it unconditionally, so they fail to load without it (ERR_MODULE_NOT_FOUND). Apps that broadcast through Mercure, Socket.IO or the null broadcaster have to installpusher-jsand ship it, although they never use it.This adds a
coreentry point to each wrapper:Why it doesn't break anything
@laravel/echo-react,-vue,-svelte) behaves exactly as today: it importspusher-jsand uses it as the Pusher client when the config doesn't pass one.configureEcho({ broadcaster: "reverb" })keeps working with no change.coreexports the same API. It only skips thepusher-jsimport, so Pusher and Reverb users who prefer it pass the client themselves, aslaravel-echoalready expects.How
config/index.tsno longer importspusher-js. It holds a default Pusher client thatconfig/pusher.tsregisters.index.tsimportsconfig/pusher.tsand re-exportscore.ts.indexandcore, plus a./coreexport in eachpackage.json.[name]-[hash].[format].js, to keep the.jsextension the packages already ship.Tests
tests/core.test.tsin each wrapper covers:coreentry point loads whenpusher-jscannot be imported;pusher-jsas the default client;Pusherpassed toconfigureEchowins over the default;I also packed the four packages and installed them in an empty project without
pusher-js:@laravel/echo-{react,vue,svelte}/coreloads, the default entry point fails exactly as it does today, and oncepusher-jsis installed the default entry point works and returns the same instance ascore.If you'd rather just make
pusher-jsa required peer, I'm happy to switch this PR to that.🤖 Generated with Claude Code