-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
import {Device} from "@twilio/voice-sdk" not working #2548
Comments
It's an error on side of that library, as it's incorrectly export for ESM (and is missing exports in package.json). You can work around it by two ways:
const Device = (await import('@twilio/voice-sdk')).default.Device;
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const Device = require('@twilio/voice-sdk').Device; |
Ideally Vite should have a batter warning for this, according to the Vite-prebundled code for click to show prebundled code// browser-external:util
var util_exports = {};
__export(util_exports, {
default: () => util_default
});
var util_default;
var init_util = __esm({
"browser-external:util"() {
util_default = new Proxy({}, {
get() {
throw new Error('Module "util" has been externalized for browser compatibility and cannot be accessed in client code.');
}
});
}
});
// node_modules/.pnpm/@twilio+voice-sdk@2.0.1/node_modules/@twilio/voice-sdk/es5/twilio/shims/mediadevices.js
var require_mediadevices = __commonJS({
"node_modules/.pnpm/@twilio+voice-sdk@2.0.1/node_modules/@twilio/voice-sdk/es5/twilio/shims/mediadevices.js"(exports, module) {
var EventTarget = require_eventtarget();
var inherits = (init_util(), util_exports).inherits;
// ... But the way esbuild transpiles the code skipped the useful error message. Nonetheless, I don't see an easy way to workaround this, and I'm not familiar with shimming nodejs modules in Vite (It's always very iffy). You could open an issue at their repo to properly fix this, and not rely on nodejs modules. Or you could send a PR as well and use this instead of node's |
Hey. Did You have any updates on that? I'm having, what I think might be, a similar error when using Vite 2.6.14 with Vue 3.2.22. The code works perfectly when using vue-cli-service instead of vite, however when I paste the exact same code into vite project, it fails silently (without throwing any errors) at the line:
I've tried to add some console.logs into Did any of you managed to fix this bug? |
I've created twilio/twilio-voice.js#55 to request a fix on the library side. @dziardziel-acaisoft I don't think the issue you reported is related to this, but perhaps twilio/twilio-voice.js#55 might indirectly fix your issue too. Closing this as there's not much we can do. |
Describe the bug
import {Device} from "@twilio/voice-sdk" not working, output from web show the following result:
Reproduction
Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: