【问题标题】:Webpacking firebase NativeScriptWebpacking firebase NativeScript
【发布时间】:2017-05-02 11:40:46
【问题描述】:

我无法让firebase plugin 与 webpack 合作。我来了

firebase 未定义

Firebase 包含在一个角度服务中,我正在我的第一个组件中对其进行初始化。 github 上提到的解决方案对我没有帮助。 我正在像这样导入 firebase:

import firebase = require("nativescript-plugin-firebase");

然后像这样使用它:

@Injectable
export class FirebaseService {

    initialize() {    
        firebase.init({
            ...
        })
    }

在我的组件中this.firebaseService.initialize();

这在没有 AOT 的情况下工作正常,这是阻止我使用我的应用程序投入生产的最后一件事。

【问题讨论】:

  • 尝试使用import * as firebase from "nativescript-plugin-firebase"代替require
  • 成功了!谢谢,你能发布一个答案,以便我接受吗?
  • 作为旁注,最好只导入使用的方法而不是整个 firebase 模块(对 TS 中的任何其他模块有效),例如import { init } from "nativescript-plugin-firebase" 直接使用init{{}}

标签: firebase webpack nativescript angular2-nativescript


【解决方案1】:

使用import from 语法(而不是require)将解决这种情况

例如 import * as firebase from "nativescript-plugin-firebase";

【讨论】:

    猜你喜欢
    • 2020-12-17
    • 2015-08-11
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多