From f8ea8f4377ae8bf42811ee53b47234c1d77c480f Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Mon, 21 Oct 2024 19:26:18 -0500 Subject: [PATCH 1/3] fix(projen.component.awscdk-ts-esm-lambda): correctly reference `path.dirname`, format text Signed-off-by: Braden Mars --- .../component/awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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..405b8363 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 @@ -78,8 +78,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() }) } } From 824c13561831838d256b20fe721df32e42394d08 Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Mon, 21 Oct 2024 19:33:57 -0500 Subject: [PATCH 2/3] fix(projen.component.awscdk-ts-esm-lambda): ignore formatting, remove duplicate marker Signed-off-by: Braden Mars --- .../awscdk-ts-esm-lambda/src/awscdk-ts-esm-lambda.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 405b8363..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) } /** From f34682a98a2ec75f6b4985a7d88b166be76de78a Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Mon, 21 Oct 2024 19:34:15 -0500 Subject: [PATCH 3/3] test(projen.component.awscdk-ts-esm-lambda): update snapshots Signed-off-by: Braden Mars --- .../test/awscdk-ts-esm-lambda.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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 }); + } + } + " `) })