Search code examples
javascriptgoogle-closure-compilercryptojs

CryptoJS and Google's Closure Compiler


I'm writing a library and was trying to use Closure Compiler's advanced optimization features to minify my code further.

The library's built with TypeScript and I'm using Google's CryptoJS and am compiling with --allowJS. I've written externs for the methods I'm wanting to expose; but when I am getting errors that are coming from CryptoJS's core library. From what it looks like; it seems annotated for Closure Compiler so I'm confused why it's breaking. I'm taking advantage of the source maps provided by closure compiler so I can inspect the minified code.

Specifically on line 495; this._data.concat(data);. Claims this._data is undefined when minifed.


Solution

  • It appears that while CryptoJS has JSDoc annotations, it wasn't written for compatibility with Closure-Compiler advanced optimizations. I can tell because it's JSDoc annotations for optional parameters are not correct.

    You would most likely want to use CryptoJS as an external library.