I'm new to the Typescript world and I'm facing an issue.
I'm trying to create a script to access firebase database functions, but when compiling the script I'm running into :
Uncaught ReferenceError: exports is not defined
if I use "module": "commonjs"
in my tsconfig.json
or
Uncaught SyntaxError: Cannot use import statement outside a module
if I use "module": "es6"
In the second case, I can remove those three lines from the generated index.js
file and everything is working properly :
import firebase from 'firebase/app';
import "firebase/database";
import "firebase/auth";
My question is, how can I use those external libraries in my typescript code, link them in my html without having those import in the compiled js file ?
Edit : Here's my ts file :
import firebase from 'firebase/app';
import "firebase/database"
import "firebase/auth"
class FbManager {
private static instance: FbManager;
firebaseConfig: object;
private constructor() {
this.firebaseConfig = {
...
};
firebase.initializeApp(this.firebaseConfig);
firebase.auth().onAuthStateChanged(function(user) {
console.log("AUTH STATE CHANGED");
if (user) {
console.log("LOGGED IN USER " + user.uid);
console.log(user);
} else {
console.log("SIGN OUT");
}
});
}
public static getInstance(): FbManager {
if (!FbManager.instance) {
FbManager.instance = new FbManager();
}
return FbManager.instance;
}
}
Thank you in advance !
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…