@@ -16,7 +16,6 @@ beforeEach(() => {
16
16
jest . resetAllMocks ( ) ;
17
17
jest . restoreAllMocks ( ) ;
18
18
Bundling . clearEsbuildInstallationCache ( ) ;
19
- Bundling . clearTscInstallationCache ( ) ;
20
19
21
20
jest . spyOn ( Code , 'fromAsset' ) ;
22
21
@@ -574,90 +573,36 @@ test('esbuild bundling with projectRoot and externals and dependencies', () => {
574
573
} ) ;
575
574
576
575
test ( 'esbuild bundling with pre compilations' , ( ) => {
577
- Bundling . bundle ( {
578
- entry,
579
- projectRoot,
580
- depsLockFilePath,
581
- runtime : Runtime . NODEJS_14_X ,
582
- forceDockerBundling : true ,
583
- tsconfig,
584
- preCompilation : true ,
585
- architecture : Architecture . X86_64 ,
586
- } ) ;
587
-
588
- // Correctly bundles with esbuild
589
- expect ( Code . fromAsset ) . toHaveBeenCalledWith ( path . dirname ( depsLockFilePath ) , {
590
- assetHashType : AssetHashType . OUTPUT ,
591
- bundling : expect . objectContaining ( {
592
- command : [
593
- 'bash' , '-c' ,
594
- [
595
- 'tsc --project /asset-input/lib/custom-tsconfig.ts --rootDir ./ --outDir ./ &&' ,
596
- 'esbuild --bundle \"/asset-input/lib/handler.js\" --target=node14 --platform=node --outfile=\"/asset-output/index.js\"' ,
597
- '--external:aws-sdk --tsconfig=/asset-input/lib/custom-tsconfig.ts' ,
598
- ] . join ( ' ' ) ,
599
- ] ,
600
- } ) ,
601
- } ) ;
602
-
603
- Bundling . bundle ( {
604
- entry,
605
- projectRoot,
606
- depsLockFilePath,
607
- runtime : Runtime . NODEJS_14_X ,
608
- forceDockerBundling : true ,
609
- tsconfig,
610
- preCompilation : true ,
611
- architecture : Architecture . X86_64 ,
612
- } ) ;
613
-
614
- // Correctly bundles with esbuild
615
- expect ( Code . fromAsset ) . toHaveBeenCalledWith ( path . dirname ( depsLockFilePath ) , {
616
- assetHashType : AssetHashType . OUTPUT ,
617
- bundling : expect . objectContaining ( {
618
- command : [
619
- 'bash' , '-c' ,
620
- [
621
- 'esbuild --bundle \"/asset-input/lib/handler.js\" --target=node14 --platform=node --outfile=\"/asset-output/index.js\"' ,
622
- '--external:aws-sdk --tsconfig=/asset-input/lib/custom-tsconfig.ts' ,
623
- ] . join ( ' ' ) ,
624
- ] ,
625
- } ) ,
626
- } ) ;
627
-
628
- } ) ;
629
-
630
- test ( 'esbuild bundling with pre compilations with undefined tsconfig ( Should find in root directory )' , ( ) => {
631
- Bundling . clearTscCompilationCache ( ) ;
632
576
const packageLock = path . join ( __dirname , '..' , 'package-lock.json' ) ;
633
577
634
578
Bundling . bundle ( {
635
579
entry : __filename . replace ( '.js' , '.ts' ) ,
636
580
projectRoot : path . dirname ( packageLock ) ,
637
581
depsLockFilePath : packageLock ,
638
582
runtime : Runtime . NODEJS_14_X ,
639
- forceDockerBundling : true ,
640
583
preCompilation : true ,
584
+ forceDockerBundling : true ,
641
585
architecture : Architecture . X86_64 ,
642
586
} ) ;
643
587
588
+ const compilerOptions = util . getTsconfigCompilerOptions ( path . join ( __dirname , '..' , 'tsconfig.json' ) ) ;
589
+
644
590
// Correctly bundles with esbuild
645
591
expect ( Code . fromAsset ) . toHaveBeenCalledWith ( path . dirname ( packageLock ) , {
646
592
assetHashType : AssetHashType . OUTPUT ,
647
593
bundling : expect . objectContaining ( {
648
594
command : [
649
595
'bash' , '-c' ,
650
596
[
651
- 'tsc --project /asset-input/tsconfig.json --rootDir ./ --outDir ./ &&' ,
652
- 'esbuild --bundle \"/asset-input/test/bundling.test.js\" --target=node14 --platform=node --outfile=\"/asset-output/index.js\"' ,
653
- '--external:aws-sdk' ,
597
+ `tsc \"/asset-input/test/bundling.test.ts\" ${ compilerOptions } &&` ,
598
+ 'esbuild --bundle \"/asset-input/test/bundling.test.js\" --target=node14 --platform=node --outfile=\"/asset-output/index.js\" --external:aws-sdk' ,
654
599
] . join ( ' ' ) ,
655
600
] ,
656
601
} ) ,
657
602
} ) ;
658
603
} ) ;
659
604
660
- test ( 'esbuild bundling with pre compilations and undefined tsconfig ( Should throw) ' , ( ) => {
605
+ test ( 'throws with pre compilation and not found tsconfig ' , ( ) => {
661
606
expect ( ( ) => {
662
607
Bundling . bundle ( {
663
608
entry,
@@ -668,7 +613,7 @@ test('esbuild bundling with pre compilations and undefined tsconfig ( Should thr
668
613
preCompilation : true ,
669
614
architecture : Architecture . X86_64 ,
670
615
} ) ;
671
- } ) . toThrow ( 'Cannot find a tsconfig.json, please specify the prop: tsconfig' ) ;
616
+ } ) . toThrow ( 'Cannot find a ` tsconfig.json` but `preCompilation` is set to `true` , please specify it via ` tsconfig` ' ) ;
672
617
673
618
} ) ;
674
619
0 commit comments