0

So i am using the Avaya SDK (basically 3 JS files) in my Angular project. When i try to import it i get an error saying that it is not a module? Any idea how to fix that?

my import statement:

import * as AvayaClientServices from '../../../assets/lib/AvayaClientServices.min.js';

declare const AvayaClientServices: any

There is btw no "export" in the JS File so i dont know if thats the issue? The whole file has li 30k Lines of Code so here is the beginning:

! function(T) {
var S = jQuery;
! function(e) {
    "use strict";

    function i(e) {
        this.clientConfiguration = e, this.user = T, this.mediaServicesFactory = T, this.version = "4.8.0.37", i.Base.Logger.clearLoggers()
    }
    i.prototype = {
        createUser: function(e) {
            return this.user || (this.mediaServicesFactory === T && (this.mediaServicesFactory = new i.Base.MediaServicesFactory), i.SDK_VERSION = this.version, this.user = new i.User(e, this.mediaServicesFactory, this.version)), this.user
        },
        registerLogger: function(e, t) {
            i.Base.Logger.addLogger(e, t)
        },
        getMediaServices: function() {
            return this.mediaServicesFactory === T && (this.mediaServicesFactory = new i.Base.MediaServicesFactory), this.mediaServicesFactory.getMediaServices()
        },
        getVersion: function() {
            return this.version
        }
    }, e.AvayaClientServices = i
Mahsum B
  • 23
  • 5

1 Answers1

0

Modules are a mechanism that JavaScript runtime supports to allow the split of huge chunks of code into small reusable pieces that you can use (import) in other programs.

The above error is due to missing export keyword from source-file. The runtime failed to identify what you are pointing to during the interpretation of the reference statement.

As stated in MDN right here

Use of native JavaScript modules is dependent on the import and export statements;

onrails
  • 778
  • 5
  • 10
  • okay i see, but how should i "import" the SDK without an import statement? When using @ts-ignore above the import i dont get an error (obviously) and i can somehow reference Methods from the AvayaClient SDK and command + clicking the method redirects me to the Avaya JS File, so i assumed it would work. But then i get other erros like "i.User is not a constructor" or something like that while using Methods from the JS file – Mahsum B Aug 04 '22 at 12:47