Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transcrypt 3.7 for IE11 - Convert with rollup.js or with babel? #751

Closed
halloleo opened this issue Aug 11, 2020 · 5 comments
Closed

Transcrypt 3.7 for IE11 - Convert with rollup.js or with babel? #751

halloleo opened this issue Aug 11, 2020 · 5 comments

Comments

@halloleo
Copy link

I need to make Transcrypt output available on IE11 - which does not understand JS modules. :-( What's the best tool for this? rollup.js? Babel?

Following issue #634 I tried to convert the modules via rollup.js to scripts, but I encountered the following problem: In the original Transcrypt output calls to document.getElementsByTag work as expected returning the elements on teh page the module is imported from, howeverin the rolled-up code this call gives me always an empty list. So the document object exists but it doesn't have the elements from the page on it.

Do I do something wrong when feeding the Transcrypt JS code to rollup.js? Anybody been sucessful with rolling up Transcrypt code for browsers?

Or is Babel the way to go to make Transcrypt available under IE? Anybody done this?

@halloleo
Copy link
Author

Ok, I got more details from the rollup.js guys (thanks Frank Lemanschik!). Rollup on its own cannot do the job because it does not take out things like for...of constructs. Rollup only takes the module construct away.

So Babel seems to be the way to go...

@fzzylogic
Copy link

It's worth noting that Transcrypt uses Google's Closure for minification (-n switch, requires java), which could be another option for transpiling down to a lower ES level using the --language_out flag. See https://github.com/QQuick/Transcrypt/blob/master/transcrypt/modules/org/transcrypt/minify/__init__.py (it's statically set to ECMASCRIPT6_STRICT atm, but it used to be ECMASCRIPT5_STRICT).

@halloleo
Copy link
Author

Interesting idea!

However I tried it and it doesn't seem to work:

In site-packages/transcrypt/modules/org/transcrypt/minify/__init__/py I set hardcoded

'--language_out=ECMASCRIPT5_STRICT'

and compile with

transcrypt -b main.py

but the resulting main.js is then empty (it only conatins teh lines:


//# sourceMappingURL=main.map

My hunch is that the Closure compiler cannot handle module constructs when compiling to ECMASCRIPT5_STRICT...

@fzzylogic
Copy link

fzzylogic commented Aug 13, 2020

Looks like it, thanks for the update. Some workarounds. I've not tried any of this yet, just adding notes here as i hope to cross this bridge myself some time.

@JennaSys
Copy link
Collaborator

Closing since no further comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants