googlemaps / googlemaps/js-region-lookup

Cannot use import statement outside a module

Open
#68 2 comments 1 reaction 1 assignee Claimed by @amuramoto View on GitHub
Dominant language
TypeScript
Stars
8
Forks
6
PR merge metrics
No merged PRs in 30d

Description

While deploying a TypeScript Firebase Cloud Function with the command:

firebase deploy --only functions:mapsRegionSearch

I'm seeing the error:

Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module

I've isolated the issue / error to the specific cloud function shown below where I am using "@googlemaps/region-lookup"; all the other Cloud Functions in the project deploy without error when this Cloud Function is removed from the set.

Any insight on how to work around this error? I've followed the `[documentation](https://developers.google.com/maps/documentation/javascript/dds-boundaries/region-lookup)`, but I'm stuck.

Node version 16.20.0
Firebase CLI version 12.2.1

```
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";

import { searchRegion, SearchRegionRequestData, SearchRegionResponse } from "@googlemaps/region-lookup";

export const mapsRegionSearch = functions.firestore
.document("responses/{responseId}")
.onCreate((change, context) => {
if (change.data().coordinate) {
return regionSearch(change, context);
} else {
console.log("this response did not have any coordinates attached");
return;
}
});

async function regionSearch(change: any, context: any) {

// Headers
const headers: any = {
"X-Goog-Api-Key": "XXXXX",
};

const data: SearchRegionRequestData = {
search_values: [
{
latlng: change.data().coordinate,
place_type: "administrative_area_level_1",
},
],
};

const response: SearchRegionResponse = await searchRegion({ headers, data });

console.log("region search returned this place id or error: ", response);

if (response) {
const db = admin.firestore();
// do stuff

}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.