VisBOL / visbol-js

SBOLv rendering in JavaScript
visbol.org
BSD 2-Clause "Simplified" License
10 stars 3 forks source link

crash in minified version #110

Closed FilippoPolo closed 5 years ago

FilippoPolo commented 5 years ago

Hi all,

We're using visbol-js as part of a compbio tool, and we have problems when attempting to bundle it for production. We are using webpack with a standard production configuration, which includes minification through uglifyjs.

After minification, the function named "fire" in svg.js no longer works. The error we see in the browser console is as follows: TypeError: "e is not a constructor"

In this case, that 'e' is actually the constructor for CustomEvent, which the minifier is supposed to have shortened. In debug, "new CustomEvent" works normally; in production, "new e" fails with the error above.

I've tried upgrading webpack and uglifyjs to the latest versions, but the problem persists.

PrashantVaidyanathan commented 5 years ago

@cjmyers Just for some additional context. We are facing this issue only when visbol-js is minified. When we use it normally, we don't encounter this issue.

To recreate this issue (at-least based on how we encounter it), if you minify visbol-js using uglify-js you should encounter this issue. Please let us know if you require any additional details to recreate this error.

cjmyers commented 5 years ago

Hmm, this one is really outside my wheelhouse. @udp @3ach do either of you have any thoughts?

cjmyers commented 5 years ago

@udp @3ach James/Zach: do either of you have any thoughts on this?

jamesamcl commented 5 years ago

Would it be possible to send your minified svg.js? I tried running uglifyjs on svg.js alone, and CustomEvent is still CustomEvent.

jamesamcl commented 5 years ago

svg_and_minified.zip

FilippoPolo commented 5 years ago

I believe it only happens if you bundle first, i.e. with webpack. It looks like some kind of bad interaction with the module system.

FilippoPolo commented 5 years ago

We couldn't figure this out, but it turns out the issue is no longer present in the most recent version of Visbol. We're just going to use that.

cjmyers commented 5 years ago

That's good.