I am able to successfully use RxJs 7.8.0 from my Chrome Extension's popup.js and options.js by importing RxJS from their corresponding popup.html and options.html files like this:
<script type="text/javascript" src="./libs/rxjs.umd.js"></script>
<script type="module" src="options.js"></script>
However, I also have background.js from which I would like to use RxJs. This is service worker and does not have html file. So when I try to import RxJs like this:
import * as rxjs from "./libs/rxjs.umd.js";
My chrome extension gets following error:
Uncaught TypeError: Cannot set properties of undefined (setting 'rxjs')
libs/rxjs.umd.js:416 (anonymous function)
Which corresponds to following code:
413:(function (global, factory) {
414: typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
415: typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) :
416: (factory((global.rxjs = {})));
417:}(this, (function (exports) { 'use strict';
I am able to successfully import other libraries from my background.js file. So this seems to be something specific to RxJs. If it matters I got RxJs from this CDN