-
Notifications
You must be signed in to change notification settings - Fork 54
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
[BUG] cannot import Device or Call #204
Comments
I notice that web-test-runner is trying to the es5 files, which use I see import {assert} from '@open-wc/testing';
import {Call, Device} from '@twilio/voice-sdk/esm';
describe('Twilio Call and Device', () => {
it('are defined', () => {
assert.isDefined(Call);
assert.isDefined(Device);
});
}); And now I get "Importing binding name 'EventEmitter' is not found." errors. |
Importing from either of the (Btw this is coming from an attempt at upgrading from the V1 api) |
Further errors after making hacky fixes:
It appears that that this Twilio package is simply not expected to be used in the web without a significant build process in front of it. Workaround for now: detect when tests are being run and use mock Twilio objects in that case. We'll have to write the mock ourselves (since I don't see one in any of these docs?), which will be cumbersome but at least possible. |
Thanks for submitting @electrovir . Can you please confirm that you're only seeing this when using the web-test-runner? <script type="text/javascript" src="twilio.min.js"></script> Once loaded, the SDK attaches a global const Device = Twilio.Device;
const Call = Twilio.Call; |
It's only happening with |
We are also facing similar issue with the voice device import statement (tried with voice sdk 2.8.0 ): import { Device } from "@twilio/voice-sdk/esm". This is blocking us from updating the SDK to latest versions. |
@electrovir @srtella we're going to start looking at this in the next couple of weeks. To speed up the process, do you have any example application that we can download and run to reproduce the issue without us having to build something from scratch? |
I can set that up for you. |
@electrovir that would be great! Thank you. |
Here it is: Note that you can see an example test failure here: |
@electrovir @srtella looking at this more, it seems @web/test-runner is not properly handling CommonJS modules. Unlike webpack, even when using ESM, everything works fine. Does @web/test-runner have any config that stops treating CommonJS as ESM? Anyway, we can try to update all our dependencies to use ESM but that would take a significant amount of time and effort. I don't see it happening soon. In the meantime, I see that @electrovir has a workaround. You can either:
|
@electrovir @srtella by the way, you have mentioned you observed this issue since you're upgrading to v2 of the voice sdk. Are you not seeing this on v1? |
or sensitive account information (API keys, credentials, etc.) when reporting this issue.
Code to reproduce the issue:
Expected behavior:
I can run tests for my browser code that imports Twilio Call or Device using web-test-runner
Actual behavior:
Safari (WebKit), Firefox, and Chrome (Chromium) all throw various errors about not being able to import Call or Device:
Software versions:
The text was updated successfully, but these errors were encountered: