-
Notifications
You must be signed in to change notification settings - Fork 53
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
[FEATURE] Avoid using nodejs modules #55
Comments
Also related to #28 (anything with Webpack >=5) |
Thank you for surfacing this, I have added a ticket for this internally and intend to start investigating sometime this week. |
We're experiencing problems with v2.1.1, which I assume stems from the same issue. We recently migrated from CRA to Vite, and since then we're not able to run After setting the log level to debug and following the logs, I can see that https://github.com/twilio/twilio-voice.js/blob/master/lib/twilio/wstransport.ts#L8 resolves the import of WebSocket through I've experienced similar issues with other libraries (https://github.com/aws-amplify/amplify-js/issues/7499#issuecomment-804386820 as well as contentful/contentful.js#422) which requires us to insert the following into our
I don't think any of that should affect the behavior of Twilio though, just including my experience of these types of issues in case it matters somehow. What's interesting is that the issue only occurs when we run Vite in development/watch mode - when we build and serve the code, everything works as expected. Would be great to get your thoughts on this and how we can get this to work in development as well! |
Any ETA for this one? |
We where migrating from wepack to vite to work vue project and all works on production but on local development this function not broke but not return anything
|
I'm having this issue. Is there any progress? It does not work with vitejs |
I solved this by dynamically importing the minified js. Not the most elegant solution but it works for now. I'm using SvelteKit. const intitializeDevice = async () => {
await import("@twilio/voice-sdk/dist/twilio.min.js");
const Device = window["Twilio"].Device;
}
|
@alexvdvalk I think your code sample got cut off however it was very helpful -- I ended up doing this as the (hopefully temporary) workaround: let Device;
(async () => {
await import("@twilio/voice-sdk/dist/twilio.min.js");
Device = window["Twilio"].Device;
})(); Then later waiting for |
I had build problems with the above so I ended up rolling back our vite version for now (from v3 to v2.9). I'm really surprised at the lack of maintenance of this module by Twilio. It's very disappointing. |
@ryan-rowland Did anything come out of the internal ticket? |
cc: @mhuynh5757 |
@ryan-rowland @mhuynh5757 In addition there are super old dependencies such as: @twilio/voice-sdk 2.1.1 WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. For those of us using this package in the browser to make/receive phone calls this needs a big cleanup/overhaul. Please advise. |
Hello everyone. Apologies for the delay in response. There is plan to modernize this SDK but there is no timeline yet due to other higher priority items. |
I use Vite 3, React + TS. The solution that works for me is to add Node.js polyfill to Vite. First, install these packages: Then add the polyfill config to your vite.config.js. Here is link of the code: https://medium.com/@ftaioli/using-node-js-builtin-modules-with-vite-6194737c2cd2. Because I use React, I still need to add Now you can do |
@herosimo Nice! Thanks for the information. Did you experience a growth like that? Twilio (a developer focused company) seems to show little interest in what developers need and to produce a high quality standards based client library. @charliesantos is there any timeline? |
@waynebrantley I didn't check the bundle size. Just looking temporary solution that works. |
Apologies for the inconvenience. We plan to modernize this SDK and prioritizing discussion is in progress. We will get back to you as soon as the decision is made. Thanks for being patient with us and again apologies for the delay. |
Hello everyone, thank you all for providing feedback regarding this issue. In the meantime, can you please try @alexvdvalk 's workaround?
You can also download the minified versions from this repo which you can load using the above method, or put in a script tag if possible. |
Yes we are making that dynamic load work. However @charliesantos as a developer centric company this should be addressed long ago. |
I completely agree @waynebrantley . We definitely understand your pain. As @kbagchiGWC mentioned, there is a lot of discussion regarding modernization of the SDK. Please stay tuned. |
@charliesantos @kbagchiGWC I understand the tough position that you're in, but this ticket has been open for over a year. About 10 months later you mentioned "plan to modernize this SDK". Another 3 months later there are still discussions and apparently higher priority items. I don't think most folks chose Twilio for the competitive pricing but for the developer experience - I just spent 6 hours today trying to implement in browser calling and couldn't figure out why this isn't working until I finally found this ticket. I really expected more from Twilio here, how can you ship the "next version of Twilio's Javascript Client SDK" that relies on NodeJS and doesn't work in the browser |
TL;DR we've escalated the broader issue (not just this specific one) and prioritized for early Q2; it is our immediate next-up batch of work. @AxelTheGerman (and all others in this thread) - I'm the PM responsible for the Voice SDK suite, and therefore responsible for the prioritization decisions our teams have made. I won't bore you with the myriad reasons behind those priority calls because they're basically excuses and ultimately you're right - we've failed the developer community here. We've adjusted our internal roadmap to prioritize this as our immediate next working item. To set expectations, that probably means we're looking at Q2 to get a wholistic solution out given the repackaging/retooling required. I realize that might be too long of a wait for some customers, and understand that you'll need to make the best decision for you/your company/your customers. Thank you for the feedback - my apologies it's taken so long to get the attention it deserves. We haven't forgotten about this community and what makes Twilio special. We're committed to fixing this and look forward to getting something into your hands soon. |
Chiming in to say I burned two entire days on this before finding this thread. I had to totally hack our Rails 7 app to get For anyone working with import maps and Rails 7:
|
Hi @jordanful , sorry to hear about your troubles. This issue has been prioritized and will be worked on very soon. |
I didn't see any errors, despite attempting to log out as much as possible. Perhaps I should have had |
@jordanful thanks for the quick response. I assume that your workaround is to use the minified js artifact because you're having issue using the npm module. Please correct me if my assumption is incorrect. |
@jordanful thanks for sharing your workaround.
Which minified JS file did you copy? Probably the browser SDK? I haven't touched any of this in a couple of months |
@AxelTheGerman this guy: https://unpkg.com/@twilio/[email protected]/dist/twilio.min.js |
Hey everyone, this issue should be fixed in the upcoming release (version 2.6.0). We have an RC that is currently being validated and will be promoted to GA once it's ready. We performed some initial testing on Svelte+Vite and Angular 16 and everything is working as expected. In the meantime, you can verify if it works in your environment by installing the RC version from a github tag.
Changes in this release include:
Thank you for your contributions and for bearing with us. I will close this ticket now since the original issue has been addressed. Please feel free to follow up if you have any questions. |
@charliesantos
This correctly resulted in a split file added to my build like this: Now that I have used the new RC above, it is of course just included directly in my bundle (which is fine or I can split of course) My new bundle size decreased around 20k from what you see above, which is a nice benefit. |
We just released 2.6.0 which contains the fix for this issue. |
Is your feature request related to a problem? Please describe.
The library is using the
util
module, which is a module from nodejs. Recent bundlers like Vite and Webpack 5 don't shim nodejs modules anymore, so this would fail to bundle for them.Describe the solution you'd like
Refactor the code to avoid the
util
module, maybe with a custom implementation of theinherits
function specifically, since that's the only utility used.Describe alternatives you've considered
Document that this library does not work without shimming nodejs modules.
Additional context
Initially reported at sveltejs/kit#2548. Related #37. May be related #52
The text was updated successfully, but these errors were encountered: