nylki / lindenmayer

Feature complete classic L-System library (branching, context sensitive, parametric) & multi-purpose modern L-System/LSystem implementation that can take javascript functions as productions. It is not opinionated about how you do visualisations.
MIT License
183 stars 14 forks source link

How to make this library work in Internet Explorer? #24

Closed pkrumins closed 5 years ago

pkrumins commented 5 years ago

Thanks for making this great library!

I created a website about fractals and used your library to generate L-System rules for various fractal types. Lately the website has gotten very popular and there are thousands of Internet Explorer uses who use it. Unfortunately as your library uses the latest JavaScript tricks, it doesn't work in Internet Explorer.

Is there any way to make use this library in Internet Explorer?

pkrumins commented 5 years ago

Hey there,

I just made this library work in IE and deployed it to my users.

In case anyone else needs IE version, then here is the library in gist form: https://gist.github.com/pkrumins/ab58506c225d1c388b85665609026a9e

Just drop it in place of the original version and it will work in IE.

Here's the summary of the changes that I made to the library to make it work in IE again:

nylki commented 5 years ago

Hey @pkrumins, Thanks for reaching out!

It seems like my transpile target to support everything above Edge 15 was probably a bit too optimistic, since the library got a bit more popular than expected.

Looks like you already found a workable solution though! :) However, I will anyways take a look at updating my babel and rollup configs to transpile the *.browser version to ES5 for IE compatibilty. I'll leave the regular and *.es/module build as they are though.

Btw. I am curious to check out what you have build. If you got any public address, feel free to share :)

pkrumins commented 5 years ago

I'd love the transpiled ES5 version. When you release it, I'll drop it in place of my quick modifications. The website that I built is https://onlineMATHtools.com. There are over 40 fractals in there.

nylki commented 5 years ago

@pkrumins nice collection! Btw. I have compiled a new version (1.5.1) with IE11 support for the browser build. Please try it out and see if its working.

pkrumins commented 5 years ago

Thanks! Which dist version do I use? Should I try the lindenmayer.browser.min.js file?

nylki commented 5 years ago

Thanks! Which dist version do I use? Should I try the lindenmayer.browser.min.js file?

Yep, both lindenmayer.browser.min.js and lindenmayer.browser.js should work in IE11 now.

pkrumins commented 5 years ago

Thanks! I just tried and unfortunately it doesn't work because of Object.entries function missing in IE11.

TypeError: Object doesn't support property or method 'entries'

Can you add a polyfill and release one more time? I'll then try again.

nylki commented 5 years ago

@pkrumins ah, missed that one. I prepared a new release 1.5.2 with the Object.entries polyfill for both browser builds. Let me know if it works. :)

For the curious: I tried to auto-polyfill missing IE11 stuff via babel and core-js by using its feature detection, but the resulting build turned out to be immensely overblown compared to the libraries size itself. (about 5x vs. the non-auto-polyfilled size). Thats because core-js adds a bunch of helper functions and glue code to integrate and process its polyfills. Thats useful if you polyfill a bit more and its also not that grave for bigger bundles than this lib, where 60KB more wouldnt be that bad. But for this project it wasn't really a viable solution for me.

Long story short, I decided to manually drop in the polyfill for Object.entries and import it only in the browser builds via a small automated preprocessing step, to make the bundle as small as possible.

pkrumins commented 5 years ago

Thanks for the new release and your background comments. Unfortunately, there's a new error:

ReferenceError: 'Symbol' is undefined

Can you please look into this? I'll be happy to try it again.

nylki commented 5 years ago

@pkrumins hey there, I pushed a new release that should fix this issue. Please let me know if there is anything else coming up.

nylki commented 5 years ago

@pkrumins Just wanted to check back if the release worked for you in the end, or if there still are language features missing. Unfortunately I currently do not have a good testing environment myself to properly test IE11.

pkrumins commented 5 years ago

Thanks for checking back. I just tested the library in dist/lindenmayer.browser.min.js and it worked in IE. Hooray!

I'll put it in math tools website now.

Also, here's how you can test things in IE. Try this link: browserling.com/ie/11 - this opens a live IE 11 session.

nylki commented 5 years ago

@pkrumins perfect, thanks! :)