Envek / Envek/aws-sam-typescript-layers-example

Local emulator with shared dependencies from a yarn workspace (monorepo)

Open
#16 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
244
Forks
56
PR merge metrics
No merged PRs in 30d

Description

We are having difficulty setting up a local environment, running with `sam local start-api` which uses a shared dependency from our yarn workspace.

## Steps
1. I have updated the make file to use `yarn` and replaced any instance of `prefix` with `cwd`
2. Added our local package, `@claimsgate/core` to the dependencies property in `package.json`

## example.ts
- `ClaimsGatePermissions.Funnels.canEditPages.id` is just a string literal value.
```js
import "source-map-support/register";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";
import { ClaimsGatePermissions } from "@claimsgate/core";
/**
* A simple example includes a HTTP get method.
*/
export const exampleHandler = async (event: APIGatewayProxyEvent): Promise => {
// All log statements are written to CloudWatch
console.debug(ClaimsGatePermissions.Funnels.canEditPages.id);

return {
statusCode: 200,
body: JSON.stringify({
message: ClaimsGatePermissions.Funnels.canEditPages.id,
}),
};
};
```

The following error is thrown when invoking the function.
```
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\Rayyan\\Desktop\\Work\\Media Advancements\\Projects\\claimsgate\\packages\\aws\\node_modules\\@claimsgate\\core\\node_modules\\@claimsgate\\core-types\\node_modules\\@firebase\\database-compat\\node_modules\\@firebase\\database\\dist\\node-esm\\src\\core\\AppCheckTokenProvider.d.ts'
```

Is there something we are missing here? Historically in other packages of ours, to use a local dependency from our monorepo, we have always been able to add it to `package.json` and just begin using its functionality. If there was an issue, it would only be during a deployment pipeline?

Any advice would be much appreciated!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.