Getting to work Janus.js + Webpack + Typescript (create-react-app)

175 views
Skip to first unread message

Jonathan Müller

unread,
Feb 14, 2023, 2:15:27 AM2/14/23
to meetecho-janus
Hi all

I am trying to use janus.js in a React+Webpack+Typescript (create-react-app).
There are also type descriptions in the Janus repo.

I am loading janus.js directly from the Janus git repo in package.json ("janus-gateway": "https://github.com/meetecho/janus-gateway.git#v1.1.2").
I followed the instructions at https://janus.conf.meetecho.com/docs/js-modules.html to get the import to work with Webpack.

However, I am not able to import.

I have a git repo which minimally reproduces the problem (as minimal as you can get with create-react-app eject, anyways...).

Using import { Janus } from 'janus-gateway'; I get

    yarn run v1.22.19
    $ node scripts/build.js
    Creating an optimized production build...
    Failed to compile.

    TS2724: '"janus-gateway"' has no exported member named 'Janus'. Did you mean 'JanusJS'?
        2 | import logo from './logo.svg';
        3 | import './App.css';
      > 4 | import { Janus } from 'janus-gateway';
          |          ^^^^^
        5 |
        6 | function App() {
        7 |   console.log(Janus)

    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

(see at this commit)

I also tried importing JanusJS instead (which is declared in the .d.ts file), but to no avail (commit).

Does anyone have a working setup for this?

Best
Jonathan

Shivansh Talwar

unread,
Feb 14, 2023, 2:18:39 AM2/14/23
to meetecho-janus
You might wanna try this wrapper https://github.com/flutterjanus/JanusJs
Reply all
Reply to author
Forward
0 new messages