Skip to content

Commit

Permalink
fix(lambda-nodejs): local tsc detection with pre compilation (#19266)
Browse files Browse the repository at this point in the history
The package name is `typescript`, the bin is `tsc`.

Closes #19242


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold committed Mar 7, 2022
1 parent b3c5fe8 commit 5de7b86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/bundling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class Bundling implements cdk.BundlingOptions {
this.packageManager = PackageManager.fromLockFile(props.depsLockFilePath, props.logLevel);

Bundling.esbuildInstallation = Bundling.esbuildInstallation ?? PackageInstallation.detect('esbuild');
Bundling.tscInstallation = Bundling.tscInstallation ?? PackageInstallation.detect('tsc');
Bundling.tscInstallation = Bundling.tscInstallation ?? PackageInstallation.detect('typescript');

this.projectRoot = props.projectRoot;
this.relativeEntryPath = path.relative(this.projectRoot, path.resolve(props.entry));
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ beforeEach(() => {
jest.resetAllMocks();
jest.restoreAllMocks();
Bundling.clearEsbuildInstallationCache();
Bundling.clearTscInstallationCache();

jest.spyOn(Code, 'fromAsset');

Expand Down Expand Up @@ -602,6 +603,8 @@ test('esbuild bundling with pre compilations', () => {
],
}),
});

expect(detectPackageInstallationMock).toHaveBeenCalledWith('typescript');
});

test('throws with pre compilation and not found tsconfig', () => {
Expand Down

0 comments on commit 5de7b86

Please sign in to comment.