Skip to content

Commit

Permalink
fix(lambda-nodejs): ignore noEmit in tsconfig when pre-compiling (#25604
Browse files Browse the repository at this point in the history
)

When building the options to `tsc` for pre-compilation from tsconfig, exclude any `noEmit` compiler option in case it has been set to `true`, which would prevent generation of the compiled .js files. Added `'noEmit'` to the list of excluded options when processing tsconfig.

Closes #25603.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
leestkly committed Jun 5, 2023
1 parent ae778cc commit dd16cf8
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 39 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@
}
}
},
"f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7": {
"26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314": {
"source": {
"path": "asset.26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128": {
"source": {
"path": "cdk-integ-compilations-lambda-nodejs.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
"objectKey": "0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32.zip"
"S3Key": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip"
},
"Role": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"id": "ImportServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/ImportServiceRole",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.Resource",
"version": "0.0.0"
}
},
"Resource": {
Expand Down Expand Up @@ -59,13 +59,13 @@
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-iam.CfnRole",
"fqn": "aws-cdk-lib.aws_iam.CfnRole",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-iam.Role",
"fqn": "aws-cdk-lib.aws_iam.Role",
"version": "0.0.0"
}
},
Expand All @@ -77,21 +77,21 @@
"id": "Stage",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/Stage",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.AssetStaging",
"version": "0.0.0"
}
},
"AssetBucket": {
"id": "AssetBucket",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/AssetBucket",
"constructInfo": {
"fqn": "@aws-cdk/aws-s3.BucketBase",
"fqn": "aws-cdk-lib.aws_s3.BucketBase",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-s3-assets.Asset",
"fqn": "aws-cdk-lib.aws_s3_assets.Asset",
"version": "0.0.0"
}
},
Expand Down Expand Up @@ -123,13 +123,13 @@
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-lambda.CfnFunction",
"fqn": "aws-cdk-lib.aws_lambda.CfnFunction",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
"fqn": "aws-cdk-lib.aws_lambda_nodejs.NodejsFunction",
"version": "0.0.0"
}
},
Expand All @@ -145,8 +145,8 @@
"id": "ImportServiceRole",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/ImportServiceRole",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.Resource",
"version": "0.0.0"
}
},
"Resource": {
Expand Down Expand Up @@ -184,13 +184,13 @@
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-iam.CfnRole",
"fqn": "aws-cdk-lib.aws_iam.CfnRole",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-iam.Role",
"fqn": "aws-cdk-lib.aws_iam.Role",
"version": "0.0.0"
}
},
Expand All @@ -202,21 +202,21 @@
"id": "Stage",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/Stage",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.AssetStaging",
"version": "0.0.0"
}
},
"AssetBucket": {
"id": "AssetBucket",
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/AssetBucket",
"constructInfo": {
"fqn": "@aws-cdk/aws-s3.BucketBase",
"fqn": "aws-cdk-lib.aws_s3.BucketBase",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-s3-assets.Asset",
"fqn": "aws-cdk-lib.aws_s3_assets.Asset",
"version": "0.0.0"
}
},
Expand All @@ -230,7 +230,7 @@
"s3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"s3Key": "8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32.zip"
"s3Key": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip"
},
"role": {
"Fn::GetAtt": [
Expand All @@ -248,50 +248,50 @@
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-lambda.CfnFunction",
"fqn": "aws-cdk-lib.aws_lambda.CfnFunction",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
"fqn": "aws-cdk-lib.aws_lambda_nodejs.NodejsFunction",
"version": "0.0.0"
}
},
"BootstrapVersion": {
"id": "BootstrapVersion",
"path": "cdk-integ-compilations-lambda-nodejs/BootstrapVersion",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.CfnParameter",
"version": "0.0.0"
}
},
"CheckBootstrapVersion": {
"id": "CheckBootstrapVersion",
"path": "cdk-integ-compilations-lambda-nodejs/CheckBootstrapVersion",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.CfnRule",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.Stack",
"version": "0.0.0"
}
},
"Tree": {
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"version": "10.2.17"
}
}
},
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.270"
"fqn": "aws-cdk-lib.App",
"version": "0.0.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestStack extends Stack {
minify: true,
sourceMap: true,
sourceMapMode: lambda.SourceMapMode.BOTH,
tsconfig: path.join(__dirname, '..', 'tsconfig.json'),
tsconfig: path.join(__dirname, '..', 'tsconfig-custom.json'),
preCompilation: true,
},
runtime: Runtime.NODEJS_16_X,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"compilerOptions": {
"declarationMap": false,
"inlineSourceMap": true,
"inlineSources": true,
"alwaysStrict": true,
"charset": "utf8",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"incremental": true,
"lib": [
"es2020",
"dom"
],
"module": "CommonJS",
"newLine": "lf",
"noEmit": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"stripInternal": false,
"target": "ES2020",
"composite": true,
"tsBuildInfoFile": "tsconfig.tsbuildinfo"
},
"include": [
"**/*.ts"
],
"exclude": [
"node_modules"
],
"references": [
{
"path": "../aws-lambda"
},
{
"path": "../core"
},
{
"path": "../assertions"
},
{
"path": "../aws-ec2"
},
{
"path": "../../../tools/@aws-cdk/cdk-build-tools"
},
{
"path": "../integ-runner"
},
{
"path": "../integ-tests"
},
{
"path": "../../../tools/@aws-cdk/pkglint"
},
{
"path": "../triggers"
}
],
"_generated_by_jsii_": "Generated by jsii - safe to delete, and ideally should be in .gitignore"
}
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-lambda-nodejs/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function getTsconfigCompilerOptions(tsconfigPath: string): string {
const compilerOptions = extractTsConfig(tsconfigPath);
const excludedCompilerOptions = [
'composite',
'noEmit',
'tsBuildInfoFile',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
],
"module": "CommonJS",
"newLine": "lf",
"noEmit": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
Expand Down
8 changes: 4 additions & 4 deletions packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ describe('extractDependencies', () => {
});

describe('getTsconfigCompilerOptions', () => {
test.skip('should extract compiler options and returns as string', () => {
test('should extract compiler options and returns as string', () => {
const tsconfig = path.join(__dirname, 'testtsconfig.json');
const compilerOptions = getTsconfigCompilerOptions(tsconfig);
expect(compilerOptions).toEqual([
Expand All @@ -193,7 +193,7 @@ describe('getTsconfigCompilerOptions', () => {
'--incremental false',
'--inlineSourceMap',
'--inlineSources',
'--lib es2020',
'--lib es2020,dom',
'--module CommonJS',
'--newLine lf',
'--noEmitOnError',
Expand All @@ -214,7 +214,7 @@ describe('getTsconfigCompilerOptions', () => {
].join(' '));
});

test.skip('should extract compiler options with extended config overriding', () => {
test('should extract compiler options with extended config overriding', () => {
const tsconfig = path.join(__dirname, 'testtsconfig-extended.json');
const compilerOptions = getTsconfigCompilerOptions(tsconfig);
expect(compilerOptions).toEqual([
Expand All @@ -226,7 +226,7 @@ describe('getTsconfigCompilerOptions', () => {
'--incremental false',
'--inlineSourceMap',
'--inlineSources',
'--lib es2020',
'--lib es2020,dom',
'--module CommonJS',
'--newLine lf',
'--noEmitOnError',
Expand Down

0 comments on commit dd16cf8

Please sign in to comment.