1amageek / pring.ts

Cloud Firestore model framework for TypeScript - Google
https://firebase.google.com/docs/firestore/
MIT License
108 stars 7 forks source link

Deployment error. Function load error #35

Open jerryOkafor opened 5 years ago

jerryOkafor commented 5 years ago

I am trying to deploy my cloud function after updating pring and this is wha I get.

Pring version : 0.22.0

Function load error: Code in file lib/index.js can't be loaded. Is there a syntax error in your code? Detailed stack trace: /user_code/node_modules/pring/lib/batch.js:110 async commit() { ^^^^^^

SyntaxError: Unexpected identifier at createScript (vm.js:56:10) at Object.runInThisContext (vm.js:97:10) at Module._compile (module.js:549:28) at Object.Module._extensions..js (module.js:586:10) at Module.load (module.js:494:32) at tryModuleLoad (module.js:453:12) at Function.Module._load (module.js:445:3) at Module.require (module.js:504:17) at require (internal/module.js:20:19) at Object. (/user_code/node_modules/pring/lib/index.js:4:17)

jerryOkafor commented 5 years ago

I was trying to use Pring with cloud function when this error occurred. Everything built fine and lint ran well.

1amageek commented 5 years ago

Thanks.

I fixed.

for example.

import * as functions from 'firebase-functions';
import * as Pring from "pring"

const admin = Pring.Admin

admin.initializeApp()
const app = admin.app()

Pring.initialize(app.firestore(), admin.firestore.FieldValue.serverTimestamp())

import { User } from "./user"

export const userSave = functions.https.onRequest(async (request, response) => {

    const user: User = new User()
    await user.save()

});
jerryOkafor commented 5 years ago

How can I guarantee that the version of firebase-admin Prin is using is the latest version. It ties everything to Pring.

1amageek commented 5 years ago

This time firebase-admin now includes @ google-cloud / firestore so this is the implementation

In the future we will change to implementation that does not depend on firebase-admin.

1amageek commented 5 years ago

@jerryOkafor I released 0.23.0 not dependent on Admin.

jerryOkafor commented 5 years ago

Ok, I will check that, but it pointed to the async commit() function in batch.ts.

jerryOkafor commented 5 years ago

It is still happening even after upgrading to the latest version.

1amageek commented 5 years ago

@jerryOkafor Hi.

I create pring-admin https://github.com/1amageek/pring-admin.ts try this