Skip to content

Commit dd16cf8

Browse files
authored
fix(lambda-nodejs): ignore noEmit in tsconfig when pre-compiling (#25604)
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*
1 parent ae778cc commit dd16cf8

File tree

11 files changed

+135
-39
lines changed

11 files changed

+135
-39
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/asset.26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/asset.26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314/index.js.map

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/cdk-integ-compilations-lambda-nodejs.assets.json

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@
1414
}
1515
}
1616
},
17-
"f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7": {
17+
"26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314": {
18+
"source": {
19+
"path": "asset.26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314",
20+
"packaging": "zip"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
},
30+
"0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128": {
1831
"source": {
1932
"path": "cdk-integ-compilations-lambda-nodejs.template.json",
2033
"packaging": "file"
2134
},
2235
"destinations": {
2336
"current_account-current_region": {
2437
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25-
"objectKey": "f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
38+
"objectKey": "0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128.json",
2639
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
2740
}
2841
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/cdk-integ-compilations-lambda-nodejs.template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"S3Bucket": {
9797
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
9898
},
99-
"S3Key": "8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32.zip"
99+
"S3Key": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip"
100100
},
101101
"Role": {
102102
"Fn::GetAtt": [

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"validateOnSynth": false,
1818
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
1919
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20-
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f609c920399d40798220bd4c7c34ec9576637e069628e9d575aa4a2feff868a7.json",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0a13784a05b3bc76cde3710cac9f28d66604ea83257766ac78baa985bb92c128.json",
2121
"requiresBootstrapStackVersion": 6,
2222
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
2323
"additionalDependencies": [

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.js.snapshot/tree.json

+30-30
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"id": "ImportServiceRole",
2121
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/ServiceRole/ImportServiceRole",
2222
"constructInfo": {
23-
"fqn": "constructs.Construct",
24-
"version": "10.1.270"
23+
"fqn": "aws-cdk-lib.Resource",
24+
"version": "0.0.0"
2525
}
2626
},
2727
"Resource": {
@@ -59,13 +59,13 @@
5959
}
6060
},
6161
"constructInfo": {
62-
"fqn": "@aws-cdk/aws-iam.CfnRole",
62+
"fqn": "aws-cdk-lib.aws_iam.CfnRole",
6363
"version": "0.0.0"
6464
}
6565
}
6666
},
6767
"constructInfo": {
68-
"fqn": "@aws-cdk/aws-iam.Role",
68+
"fqn": "aws-cdk-lib.aws_iam.Role",
6969
"version": "0.0.0"
7070
}
7171
},
@@ -77,21 +77,21 @@
7777
"id": "Stage",
7878
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/Stage",
7979
"constructInfo": {
80-
"fqn": "constructs.Construct",
81-
"version": "10.1.270"
80+
"fqn": "aws-cdk-lib.AssetStaging",
81+
"version": "0.0.0"
8282
}
8383
},
8484
"AssetBucket": {
8585
"id": "AssetBucket",
8686
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler/Code/AssetBucket",
8787
"constructInfo": {
88-
"fqn": "@aws-cdk/aws-s3.BucketBase",
88+
"fqn": "aws-cdk-lib.aws_s3.BucketBase",
8989
"version": "0.0.0"
9090
}
9191
}
9292
},
9393
"constructInfo": {
94-
"fqn": "@aws-cdk/aws-s3-assets.Asset",
94+
"fqn": "aws-cdk-lib.aws_s3_assets.Asset",
9595
"version": "0.0.0"
9696
}
9797
},
@@ -123,13 +123,13 @@
123123
}
124124
},
125125
"constructInfo": {
126-
"fqn": "@aws-cdk/aws-lambda.CfnFunction",
126+
"fqn": "aws-cdk-lib.aws_lambda.CfnFunction",
127127
"version": "0.0.0"
128128
}
129129
}
130130
},
131131
"constructInfo": {
132-
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
132+
"fqn": "aws-cdk-lib.aws_lambda_nodejs.NodejsFunction",
133133
"version": "0.0.0"
134134
}
135135
},
@@ -145,8 +145,8 @@
145145
"id": "ImportServiceRole",
146146
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/ServiceRole/ImportServiceRole",
147147
"constructInfo": {
148-
"fqn": "constructs.Construct",
149-
"version": "10.1.270"
148+
"fqn": "aws-cdk-lib.Resource",
149+
"version": "0.0.0"
150150
}
151151
},
152152
"Resource": {
@@ -184,13 +184,13 @@
184184
}
185185
},
186186
"constructInfo": {
187-
"fqn": "@aws-cdk/aws-iam.CfnRole",
187+
"fqn": "aws-cdk-lib.aws_iam.CfnRole",
188188
"version": "0.0.0"
189189
}
190190
}
191191
},
192192
"constructInfo": {
193-
"fqn": "@aws-cdk/aws-iam.Role",
193+
"fqn": "aws-cdk-lib.aws_iam.Role",
194194
"version": "0.0.0"
195195
}
196196
},
@@ -202,21 +202,21 @@
202202
"id": "Stage",
203203
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/Stage",
204204
"constructInfo": {
205-
"fqn": "constructs.Construct",
206-
"version": "10.1.270"
205+
"fqn": "aws-cdk-lib.AssetStaging",
206+
"version": "0.0.0"
207207
}
208208
},
209209
"AssetBucket": {
210210
"id": "AssetBucket",
211211
"path": "cdk-integ-compilations-lambda-nodejs/ts-decorator-handler-tsconfig/Code/AssetBucket",
212212
"constructInfo": {
213-
"fqn": "@aws-cdk/aws-s3.BucketBase",
213+
"fqn": "aws-cdk-lib.aws_s3.BucketBase",
214214
"version": "0.0.0"
215215
}
216216
}
217217
},
218218
"constructInfo": {
219-
"fqn": "@aws-cdk/aws-s3-assets.Asset",
219+
"fqn": "aws-cdk-lib.aws_s3_assets.Asset",
220220
"version": "0.0.0"
221221
}
222222
},
@@ -230,7 +230,7 @@
230230
"s3Bucket": {
231231
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
232232
},
233-
"s3Key": "8df6c4f7f61921e6f88f328521b8a71aef10b045b77847bd61cfe75cf3a64c32.zip"
233+
"s3Key": "26114660303fbc916c9e0f48b544e4360bb361bf9a2d87cf720983c8028ef314.zip"
234234
},
235235
"role": {
236236
"Fn::GetAtt": [
@@ -248,50 +248,50 @@
248248
}
249249
},
250250
"constructInfo": {
251-
"fqn": "@aws-cdk/aws-lambda.CfnFunction",
251+
"fqn": "aws-cdk-lib.aws_lambda.CfnFunction",
252252
"version": "0.0.0"
253253
}
254254
}
255255
},
256256
"constructInfo": {
257-
"fqn": "@aws-cdk/aws-lambda-nodejs.NodejsFunction",
257+
"fqn": "aws-cdk-lib.aws_lambda_nodejs.NodejsFunction",
258258
"version": "0.0.0"
259259
}
260260
},
261261
"BootstrapVersion": {
262262
"id": "BootstrapVersion",
263263
"path": "cdk-integ-compilations-lambda-nodejs/BootstrapVersion",
264264
"constructInfo": {
265-
"fqn": "constructs.Construct",
266-
"version": "10.1.270"
265+
"fqn": "aws-cdk-lib.CfnParameter",
266+
"version": "0.0.0"
267267
}
268268
},
269269
"CheckBootstrapVersion": {
270270
"id": "CheckBootstrapVersion",
271271
"path": "cdk-integ-compilations-lambda-nodejs/CheckBootstrapVersion",
272272
"constructInfo": {
273-
"fqn": "constructs.Construct",
274-
"version": "10.1.270"
273+
"fqn": "aws-cdk-lib.CfnRule",
274+
"version": "0.0.0"
275275
}
276276
}
277277
},
278278
"constructInfo": {
279-
"fqn": "constructs.Construct",
280-
"version": "10.1.270"
279+
"fqn": "aws-cdk-lib.Stack",
280+
"version": "0.0.0"
281281
}
282282
},
283283
"Tree": {
284284
"id": "Tree",
285285
"path": "Tree",
286286
"constructInfo": {
287287
"fqn": "constructs.Construct",
288-
"version": "10.1.270"
288+
"version": "10.2.17"
289289
}
290290
}
291291
},
292292
"constructInfo": {
293-
"fqn": "constructs.Construct",
294-
"version": "10.1.270"
293+
"fqn": "aws-cdk-lib.App",
294+
"version": "0.0.0"
295295
}
296296
}
297297
}

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-nodejs/test/integ.compilations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TestStack extends Stack {
2525
minify: true,
2626
sourceMap: true,
2727
sourceMapMode: lambda.SourceMapMode.BOTH,
28-
tsconfig: path.join(__dirname, '..', 'tsconfig.json'),
28+
tsconfig: path.join(__dirname, '..', 'tsconfig-custom.json'),
2929
preCompilation: true,
3030
},
3131
runtime: Runtime.NODEJS_16_X,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"compilerOptions": {
3+
"declarationMap": false,
4+
"inlineSourceMap": true,
5+
"inlineSources": true,
6+
"alwaysStrict": true,
7+
"charset": "utf8",
8+
"declaration": true,
9+
"emitDecoratorMetadata": true,
10+
"experimentalDecorators": true,
11+
"incremental": true,
12+
"lib": [
13+
"es2020",
14+
"dom"
15+
],
16+
"module": "CommonJS",
17+
"newLine": "lf",
18+
"noEmit": true,
19+
"noEmitOnError": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noImplicitAny": true,
22+
"noImplicitReturns": true,
23+
"noImplicitThis": true,
24+
"noUnusedLocals": true,
25+
"noUnusedParameters": true,
26+
"resolveJsonModule": true,
27+
"skipLibCheck": true,
28+
"strict": true,
29+
"strictNullChecks": true,
30+
"strictPropertyInitialization": true,
31+
"stripInternal": false,
32+
"target": "ES2020",
33+
"composite": true,
34+
"tsBuildInfoFile": "tsconfig.tsbuildinfo"
35+
},
36+
"include": [
37+
"**/*.ts"
38+
],
39+
"exclude": [
40+
"node_modules"
41+
],
42+
"references": [
43+
{
44+
"path": "../aws-lambda"
45+
},
46+
{
47+
"path": "../core"
48+
},
49+
{
50+
"path": "../assertions"
51+
},
52+
{
53+
"path": "../aws-ec2"
54+
},
55+
{
56+
"path": "../../../tools/@aws-cdk/cdk-build-tools"
57+
},
58+
{
59+
"path": "../integ-runner"
60+
},
61+
{
62+
"path": "../integ-tests"
63+
},
64+
{
65+
"path": "../../../tools/@aws-cdk/pkglint"
66+
},
67+
{
68+
"path": "../triggers"
69+
}
70+
],
71+
"_generated_by_jsii_": "Generated by jsii - safe to delete, and ideally should be in .gitignore"
72+
}

packages/aws-cdk-lib/aws-lambda-nodejs/lib/util.ts

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export function getTsconfigCompilerOptions(tsconfigPath: string): string {
149149
const compilerOptions = extractTsConfig(tsconfigPath);
150150
const excludedCompilerOptions = [
151151
'composite',
152+
'noEmit',
152153
'tsBuildInfoFile',
153154
];
154155

packages/aws-cdk-lib/aws-lambda-nodejs/test/testtsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
],
1515
"module": "CommonJS",
1616
"newLine": "lf",
17+
"noEmit": true,
1718
"noEmitOnError": true,
1819
"noFallthroughCasesInSwitch": true,
1920
"noImplicitAny": true,

packages/aws-cdk-lib/aws-lambda-nodejs/test/util.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('extractDependencies', () => {
181181
});
182182

183183
describe('getTsconfigCompilerOptions', () => {
184-
test.skip('should extract compiler options and returns as string', () => {
184+
test('should extract compiler options and returns as string', () => {
185185
const tsconfig = path.join(__dirname, 'testtsconfig.json');
186186
const compilerOptions = getTsconfigCompilerOptions(tsconfig);
187187
expect(compilerOptions).toEqual([
@@ -193,7 +193,7 @@ describe('getTsconfigCompilerOptions', () => {
193193
'--incremental false',
194194
'--inlineSourceMap',
195195
'--inlineSources',
196-
'--lib es2020',
196+
'--lib es2020,dom',
197197
'--module CommonJS',
198198
'--newLine lf',
199199
'--noEmitOnError',
@@ -214,7 +214,7 @@ describe('getTsconfigCompilerOptions', () => {
214214
].join(' '));
215215
});
216216

217-
test.skip('should extract compiler options with extended config overriding', () => {
217+
test('should extract compiler options with extended config overriding', () => {
218218
const tsconfig = path.join(__dirname, 'testtsconfig-extended.json');
219219
const compilerOptions = getTsconfigCompilerOptions(tsconfig);
220220
expect(compilerOptions).toEqual([
@@ -226,7 +226,7 @@ describe('getTsconfigCompilerOptions', () => {
226226
'--incremental false',
227227
'--inlineSourceMap',
228228
'--inlineSources',
229-
'--lib es2020',
229+
'--lib es2020,dom',
230230
'--module CommonJS',
231231
'--newLine lf',
232232
'--noEmitOnError',

0 commit comments

Comments
 (0)