I want to implement my own javascript library in an andular4-cli project. Because its my own library, its not possible to include the library with npm.
tsconfig.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
I implemented the library in angular.cli.json
"assets/myownlib.js"
The component i want to use the library:
import { Component, OnInit } from '@angular/core';
import {DataService} from './tempdatagia.service';
import {MyLib} from '../../assets/myownlib';
@Component({
selector: 'app-paho',
templateUrl: './paho.component.html',
styleUrls: ['./paho.component.css']
})
export class PahoComponent {
// Create a client instance
client: any;
constructor(private tempdata: DataService) {
this.client = new MyLib.MQTT.Client('wpsdemo.gia.rwth-aachen.de', 8080, 'Steffen');
this.onMessage();
this.onConnectionLost();
// connect the client
this.client.connect({onSuccess: this.onConnected.bind(this)});
}
.
.
.
}
ERROR
in line import {MyLib} from '../../assets/myownlib';:
"allow js is not set"
"cannot find namespace 'MyLib'."