matrix-org / matrix-org/matrix-js-sdk
Can't import the sdk inside a service worker
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 704
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 40
Description
**Describe the bug**
If I simply import the SDK in a service worker, I get an error
```
import * as sdk from 'matrix-js-sdk';
```
**Error**
> Uncaught ReferenceError: XMLHttpRequest is not defined
**Expected behavior**
Importing the SDK should work
**Additional context**
I'm trying to build a chrome extension, and so have to run the SDK in a background script or a service worker.
Contributor guide
Research direction
Start by reproducing the `import * as sdk from 'matrix-js-sdk'` entry point in a Chrome service worker and trace where the `XMLHttpRequest is not defined` error occurs. Done means the SDK can be imported in that environment without requiring `XMLHttpRequest`; add or update a focused regression test if the repository has coverage for this entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100