Useless exports, and broken IIFE
See original GitHub issue- Echo Version: 1.12.0
- Laravel Version: 9.18.0
- PHP Version: 8.1.7
- NPM Version: 8.11.0
- Node Version: 16.15.1
Description:
In v1.11.5 the IIFE distribution file was broken by https://github.com/laravel/echo/pull/333. In my opinion, the new exports are completely useless given classes are already exported in their own right:
- https://github.com/laravel/echo/blob/master/src/channel/channel.ts
- https://github.com/laravel/echo/blob/master/src/channel/presence-channel.ts
They can be used without modification to the library, by simply:
import { PresenceChannel } from 'laravel-echo/src/channel'
The changes break the IIFE distribution by exporting multiple objects. The change results in new usage:
var myEcho = new Echo.default({});
This was highlighted in https://github.com/laravel/echo/issues/336 already, but closed as unsupported. If that’s the case, then I would suggest that the IIFE distribution is removed. However, that seems unnecessary given the changes in https://github.com/laravel/echo/pull/333 are unnecessary and if they were to be reverted then the IIFE distribution would work again…
Steps To Reproduce:
Use the dist/echo.iife.js
file:
<script src="echo.iife.js"></script>
<script>var myEcho = new Echo({});</script>
Uncaught TypeError: Echo is not a constructor
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Thanks for looking into this @jessarcher ☺️
I disagree with this. I, for example, use the src classes to extend the library https://github.com/supportpal/pollcast-js/blob/master/src/broadcasting/channels/channel.ts. Bandwidth would only really be saved in pulls from npm. Users shouldn’t be shipping node_modules, but using something like webpack
Correct
Thanks @timacdonald !
No troubles at all ❤️