-
Notifications
You must be signed in to change notification settings - Fork 161
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedmetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utility
Description
Bug description
The code doesn't compile using tsc when using the Metrics module without middy.
Expected Behavior
Should be able to use Metrics without the need to import middy when its not used. Unlike Logger
importing the submodule via import { Metrics } from '@aws-lambda-powertools/metrics/lib/Metrics';
fails to compile too.
Current Behavior
Middy is required atleast as the dev dependency while compiling with tsc. This is not a problem when esbuild or ts-node is used.
Possible Solution
Steps to Reproduce
Steps:
- npm install and import Metrics using
import { Metrics } from "@aws-lambda-powertools/metrics";
- Build project using tsc
- Expect this error
Cannot find module '@middy/core' or its corresponding type declarations.
package.json
{
"scripts": {
"build": "npm i && tsc metrics-demo.ts"
},
"dependencies": {
"@aws-lambda-powertools/metrics": "1.2.0",
"@types/aws-lambda": "8.10.101"
},
"devDependencies": {
"typescript": "4.7.4"
}
}
metrics-demo
import { Metrics } from '@aws-lambda-powertools/metrics/lib/Metrics';
const metrics = new Metrics({ namespace: 'serverlessAirline', serviceName: 'orders' });
tsconfig.json
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "ES2021",
"module": "CommonJS"
}
}
Environment
- Powertools version used: 1.2.1
- Packaging format (Layers, npm): npm
- AWS Lambda function runtime: node16
- Debugging logs: n/a
Related issues, RFCs
sl-florianadam and renatoargh
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedmetricsThis item relates to the Metrics UtilityThis item relates to the Metrics Utility