-
-
Notifications
You must be signed in to change notification settings - Fork 389
Closed
Labels
Description
Describe the bug
Hello, I saw the other bugs reported on this issue and how it's normally caused by using CJS in v5 but I've migrated to ES6 completely and still getting this
CustomMessage failed with error No "exports" main defined in /var/task/node_modules/@middy/core/package.json.
To Reproduce
Package.json is using "type": "module"
tsconfig.json has
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"lib": [
"es2022"
],
"outDir": "./dist",
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": [
"./node_modules/@types",
"./types"
],
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
},
"include": [
"src/**/*",
"infrastructure/**/*.ts",
"graphql/**/*.ts",
"lib/**/*.ts",
"test/**/*.ts",
"types/**/*.ts"
],
"exclude": [
"node_modules",
"cdk.out",
"./dist/**/*" // Excluding the output directory
]
}
cdk.json has
"app": "npx tsx infrastructure/Launcher.ts",
"watch": {
"include": ["**"],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true
}
}
my lambda is exported as
import { captureLambdaHandler } from "@aws-lambda-powertools/tracer/middleware";
import { injectLambdaContext } from "@aws-lambda-powertools/logger/middleware";
import { logMetrics } from "@aws-lambda-powertools/metrics/middleware";
export const handler = middy(lambdaHandler)
.use(captureLambdaHandler(tracer))
.use(injectLambdaContext(logger, { clearState: true }))
.use(logMetrics(metrics, { captureColdStartMetric: true }));
Environment
- Node.js: v20.12.2
- Middy: v5.3.2
- AWS SDK v3.569.0
zdvhm, mhoyle-xealth, wilson-ft, Wilson13 and ChrisGrigg