angular/tsickle

New version of tsickle (0.36.0) gives an error trying to build a library using ng build. Works fine with previous version( 0.35.0)

rinavin opened this issue · 6 comments

To reproduce :
Please get the sample repository from : https://github.com/rinavin/Webclient.git
• Do npm install
• Run: ng build mscorelib ( this is a library)
• See the error bellow.

Works fine with version tsickle (0.35.0)
• Delete node_modules and package-lock.json
• Do npm install
• Run: ng build mscorelib ( this is a library)
• See library is created succesfully

BUILD ERROR
: TypeError: Cannot read property 'directoryExists' of undefined
at Object.directoryProbablyExists (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:12206:22)
at nodeLoadModuleByRelativeName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26869:25)
at tryResolve (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26845:34)
at D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:69
at Object.forEach (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:280:30)
at nodeModuleNameResolverWorker (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:25)
at nodeModuleNameResolver (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26808:16)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26590:30)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\googmodule.js:132:29)
at visitImportDeclaration (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\jsdoc_transformer.js:685:51)

Error: : TypeError: Cannot read property 'directoryExists' of undefined
at Object.directoryProbablyExists (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:12206:22)
at nodeLoadModuleByRelativeName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26869:25)
at tryResolve (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26845:34)
at D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:69
at Object.forEach (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:280:30)
at nodeModuleNameResolverWorker (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:25)
at nodeModuleNameResolver (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26808:16)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26590:30)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\googmodule.js:132:29)
at visitImportDeclaration (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\jsdoc_transformer.js:685:51)

at Object.<anonymous> (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ngc\compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ngc\compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ngc\compile-source-files.js:3:12)
at Object.compileSourceFiles (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ngc\compile-source-files.js:19:12)
at Object.<anonymous> (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ng-v5\entry-point\ts\compile-ngc.transform.js:26:32)
at Generator.next (<anonymous>)
at D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\ng-packagr\lib\ng-v5\entry-point\ts\compile-ngc.transform.js:7:71
at new Promise (<anonymous>)

An unhandled exception occurred: : TypeError: Cannot read property 'directoryExists' of undefined
at Object.directoryProbablyExists (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:12206:22)
at nodeLoadModuleByRelativeName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26869:25)
at tryResolve (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26845:34)
at D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:69
at Object.forEach (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:280:30)
at nodeModuleNameResolverWorker (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26815:25)
at nodeModuleNameResolver (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26808:16)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\typescript\lib\typescript.js:26590:30)
at Object.resolveModuleName (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\googmodule.js:132:29)
at visitImportDeclaration (D:\temp\New folder\xpa4.5\Sources\Webclient\node_modules\tsickle\src\jsdoc_transformer.js:685:51)

+1

evmar commented

I think this is maybe an issue in ngc. I found the related angular/angular#26738 maybe.

If you edit

projects/mscorelib/tsconfig.lib.json:    "annotateForClosureCompiler": true,

and change it to false it will not run tsickle, which will avoid this as well.

@mariohtmol it fixed in compiler-cli by adding moduleResolutionHost as I know
angular/angular@6ece7db#diff-3153093ed4c8893b1a1c791b9ad85813R109

Thanks! could make it work upgrading to latest ngpackagr and tsickle.

@evmar..thanks its worked for me