-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic requiring of pusher libraries. #107
Conversation
This probably fixes #108 as well! |
This did not fix for me still getting
|
Are you using webpack or a different bundler? |
webpack via gulp laravel-elixir-webpack |
I'm having the same issue as @lukepolo on a standard laravel-mix compilation. I had to revert back two versions as if I only reverted one, I had the cannot find pusher-react error that this fixed. |
Uncaught Error: Cannot find module 'pusher-js'. Laravel version 5.4.15 |
😦 can I just revert these changes as we obviously don't know how to fix this right now? |
Well it works for my Webpack configuration, so it does resolve some of the issues, but I think that it's not a 100% fix based on the different JS bundling setups devs may be using. This issue has been existent for a while, since pusher-js was added as a dependency, and now with pusher/react-native added, I feel like a precedent has been established that these 3rd party libs should be distributed with laravel-echo. To fix I would suggest removing pusher-js and pusher/react-native from this project and documenting that those files be required in the project they are being used before instantiating laravel-echo. |
Can someone make whatever PR we need in order to make Echo not broken?
|
Sure I'll send in a sec. |
@tlaverdure My problem solved, as you mentioned here 👉 #110, I just added following line:
into "resources\assets\js\bootstrap.js" and it's working fine, |
By default the pusher-js and pusher/react-native packages are required if the pusher broadcaster is selected. This is causing Webpack to fail if the packages are not installed. I'm opposed to installing additional packages when they are not is use, as that potentially leads to a large bundle size. Webpack as a module bundler does not have access to the
window
object at build time to determine if these packages should be required or not.This is the best solution that I could find and it seems to work as intended.
Reference:
https://webpack.github.io/docs/context.html#dynamic-require-rewriting
Closes #40, #52