File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ class ServerlessWebpack {
2626 this . options = options ;
2727
2828 if (
29- ( _ . has ( this . serverless , 'service.custom.webpack' ) &&
30- _ . isString ( this . serverless . service . custom . webpack ) &&
31- _ . endsWith ( this . serverless . service . custom . webpack , '.ts' ) ) ||
32- ( _ . has ( this . serverless , 'service.custom.webpack.webpackConfig' ) &&
33- _ . endsWith ( this . serverless . service . custom . webpack . webpackConfig , '.ts' ) )
29+ (
30+ ( _ . has ( this . serverless , 'service.custom.webpack' ) &&
31+ _ . isString ( this . serverless . service . custom . webpack ) &&
32+ _ . endsWith ( this . serverless . service . custom . webpack , '.ts' ) ) ||
33+ ( _ . has ( this . serverless , 'service.custom.webpack.webpackConfig' ) &&
34+ _ . endsWith ( this . serverless . service . custom . webpack . webpackConfig , '.ts' ) )
35+ ) && ! process [ Symbol . for ( 'ts-node.register.instance' ) ]
3436 ) {
3537 try {
3638 require ( 'ts-node/register' ) ;
Original file line number Diff line number Diff line change @@ -80,6 +80,15 @@ describe('ServerlessWebpack', () => {
8080 expect ( Module . _load ) . to . have . been . calledWith ( 'ts-node/register' ) ;
8181 } ) ;
8282
83+ it ( 'should not register ts-node if it has already been registered' , ( ) => {
84+ _ . set ( serverless , 'service.custom.webpack.webpackConfig' , 'webpack.config.ts' ) ;
85+ process [ Symbol . for ( 'ts-node.register.instance' ) ] = 'foo' ;
86+ new ServerlessWebpack ( serverless , { } ) ;
87+ delete process [ Symbol . for ( 'ts-node.register.instance' ) ] ;
88+ expect ( Module . _load ) . to . not . have . been . called ;
89+ expect ( Module . _load ) . to . not . have . been . calledWith ( 'ts-node/register' ) ;
90+ } ) ;
91+
8392 it ( 'should throw an error if config use TS but ts-node was not added as dependency' , ( ) => {
8493 moduleStub . throws ( ) ;
8594
You can’t perform that action at this time.
0 commit comments