diff --git a/packages/projen/component/awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts b/packages/projen/component/awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts index f366a968..6a9ab57b 100644 --- a/packages/projen/component/awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts +++ b/packages/projen/component/awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts @@ -8,6 +8,7 @@ import { type Project, TextFile, typescript, + javascript, } from 'projen' export interface AwsCdkTsEsmLambdaOptions { @@ -52,12 +53,13 @@ export class AwsCdkTsEsmLambda extends Component { } this.tsFile = new TypeScriptSourceFile(this.project, this.lambdaFile.path, { - marker: true, + marker: false, recreate: true, source, - format: true, + format: false, }) this.applyTransforms() + javascript.Eslint.of(project)?.addIgnorePattern?.(this.tsFile.path) } /** @@ -78,8 +80,9 @@ export class AwsCdkTsEsmLambda extends Component { throw new Error('Could not find class constructor in entrypoint file') functionCtor.insertStatements(0, [ 'const __filename = fileURLToPath(import.meta.url);', - 'const __dirname = dirname(__filename);', + 'const __dirname = path.dirname(__filename);', ]) + sourceFile.formatText() }) } } diff --git a/packages/projen/component/awscdk-ts-esm-lambda/test/awscdk-ts-esm-lambda.spec.ts b/packages/projen/component/awscdk-ts-esm-lambda/test/awscdk-ts-esm-lambda.spec.ts index 03210eb9..2139d3c6 100644 --- a/packages/projen/component/awscdk-ts-esm-lambda/test/awscdk-ts-esm-lambda.spec.ts +++ b/packages/projen/component/awscdk-ts-esm-lambda/test/awscdk-ts-esm-lambda.spec.ts @@ -46,8 +46,7 @@ describe('AwsCdkTsEsmLambda', () => { const synth = Testing.synth(ctx.project) expect(synth['src/test-function.ts']).toBeDefined() expect(synth['src/test-function.ts']).toMatchInlineSnapshot(` - "// ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". - + " // ~~ Generated by projen. To modify, edit .projenrc.js and run \\"npx projen\\". import * as lambda from 'aws-cdk-lib/aws-lambda'; import { Construct } from 'constructs'; @@ -64,19 +63,20 @@ describe('AwsCdkTsEsmLambda', () => { * An AWS Lambda function which executes src/test. */ export class TestFunction extends lambda.Function { - constructor(scope: Construct, id: string, props?: TestFunctionProps) { - const __filename = fileURLToPath(import.meta.url); - const __dirname = dirname(__filename); - super(scope, id, { - description: 'src/test.lambda.ts', - ...props, - runtime: new lambda.Runtime('nodejs18.x', lambda.RuntimeFamily.NODEJS), - handler: 'index.handler', - code: lambda.Code.fromAsset(path.join(__dirname, '../assets/test.lambda')), - }); - this.addEnvironment('AWS_NODEJS_CONNECTION_REUSE_ENABLED', '1', { removeInEdge: true }); - } - }" + constructor(scope: Construct, id: string, props?: TestFunctionProps) { + const __filename = fileURLToPath(import.meta.url); + const __dirname = path.dirname(__filename); + super(scope, id, { + description: 'src/test.lambda.ts', + ...props, + runtime: new lambda.Runtime('nodejs18.x', lambda.RuntimeFamily.NODEJS), + handler: 'index.handler', + code: lambda.Code.fromAsset(path.join(__dirname, '../assets/test.lambda')), + }); + this.addEnvironment('AWS_NODEJS_CONNECTION_REUSE_ENABLED', '1', { removeInEdge: true }); + } + } + " `) })