Closed
Description
Bug description
The code doesn't compile using tsc
when using the Logger module without middy.
Expected Behavior
Should be able to use Logger without the need to import middy when its not used. This is possible by importing the submodule via import { Logger } from "@aws-lambda-powertools/logger/lib/Logger";
. If this is the solution maybe the documentation should reflect that.
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
Logger
usingimport { Logger } from "@aws-lambda-powertools/logger";
- Build project using
tsc
- Expect this error
Cannot find module '@middy/core' or its corresponding type declarations.
package.json
{
"scripts": {
"build": "npm i && tsc logger-demo.ts"
},
"dependencies": {
"@aws-lambda-powertools/logger": "1.2.0",
"@types/aws-lambda": "8.10.101"
},
"devDependencies": {
"typescript": "4.7.4"
}
}
logger-demo
import { Logger } from "@aws-lambda-powertools/logger/lib/Logger";
const logger = new Logger();
logger.info("Testing logger");
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