functions-framework-nodejs icon indicating copy to clipboard operation
functions-framework-nodejs copied to clipboard

Typescript function source location can only be referenced from `main` field in `package.json`?

Open legendsjohn opened this issue 1 year ago • 1 comments

It seems like the --source flag in gcloud functions deploy can't be used with Typescript unless you copy over your package.json to the build output directory? This also seems to apply to the deploy cloud functions action.

This seems to be because the referenced source folder must also contain your package.json file. With Typescript, this is likely to be two different folders (ie. /build vs /).

Thus, the only way to reference the cloud function source is in main of package.json like https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/master/docs/typescript.md describes.

I wanted to ensure this is expected behavior? If so, could the docs stress this? I spent a many hours figuring this out, as the cause of this problem wasn't immediately clear.

legendsjohn avatar Jul 13 '22 19:07 legendsjohn

This may be a duplicate of https://github.com/GoogleCloudPlatform/functions-framework-nodejs/issues/254, but I wanted to double check this understanding of the --source flag

legendsjohn avatar Jul 13 '22 19:07 legendsjohn

I updated the docs. You should configure the main field to point to your compiled source code.

matthewrobertson avatar Nov 19 '22 00:11 matthewrobertson