partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
247 stars 61 forks source link

Angular build tools break Kekule.js #152

Open robotoer opened 4 years ago

robotoer commented 4 years ago

When trying to build Kekule.js with angular (installed as a npm dependency) works as long as angular's optimization and buildOptimizer steps are disabled (AOT compilation seems to work). With either (or both) of these steps enabled, I get errors when importing Kekule.

As I understand it Angular's optimization step currently uses the terser-webpack-plugin (https://webpack.js.org/plugins/terser-webpack-plugin/) which performs minification of code. The buildOptimizer step performs additional angular specific code optimization.

I'm not an expert on webpack/angular build tools and am not sure what's breaking here but would love to be able to use these build tools.

partridgejiang commented 4 years ago

I am not familiar with terser too. Maybe the mangling process of terser breaks some "magic" var names in Kekule.js? To avoid it, perhaps you could set the mangle options in terser, for example. terser ... -m reserved=['$super','$origin']. Good luck. :).

robotoer commented 4 years ago

I'll play around with terser's settings when I get some free time next.