From fb6e6739b501bf39c0d0e3a63af71cfaafd36728 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Sat, 29 Jul 2023 23:58:49 +0200 Subject: [PATCH] Fixed exports and compiled function to ESM --- examples/firebase/functions/package.json | 1 + examples/firebase/functions/src/index.ts | 8 +++++--- examples/firebase/functions/tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/firebase/functions/package.json b/examples/firebase/functions/package.json index 20969d9..5cc1366 100644 --- a/examples/firebase/functions/package.json +++ b/examples/firebase/functions/package.json @@ -16,6 +16,7 @@ "engines": { "node": "16" }, + "type": "module", "main": "lib/index.js", "dependencies": { "axios": "^1.2.6", diff --git a/examples/firebase/functions/src/index.ts b/examples/firebase/functions/src/index.ts index 3a2ea46..4fb6626 100644 --- a/examples/firebase/functions/src/index.ts +++ b/examples/firebase/functions/src/index.ts @@ -1,11 +1,13 @@ -import functions from "firebase-functions"; +import * as functions from "firebase-functions"; import admin from "firebase-admin"; -import { PKPass } from "passkit-generator"; +import passkit from "passkit-generator"; import type { Barcode, TransitType } from "passkit-generator"; import fs from "node:fs"; import path from "node:path"; import os from "node:os"; +const PKPass = passkit.PKPass; + // Firebase init admin .initializeApp @@ -57,7 +59,7 @@ declare global { } } -exports.pass = functions.https.onRequest(async (request, response) => { +export const pass = functions.https.onRequest(async (request, response) => { const newPass = await PKPass.from( { // Get relevant pass model from model folder (see passkit-generator/examples/models/) diff --git a/examples/firebase/functions/tsconfig.json b/examples/firebase/functions/tsconfig.json index 9659573..01135cc 100644 --- a/examples/firebase/functions/tsconfig.json +++ b/examples/firebase/functions/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2016", + "target": "ESNext", "module": "NodeNext", "rootDir": "src", "moduleResolution": "NodeNext",