themotte / rDrama

This code runs https://www.themotte.org. Forked from https://github.com/Aevann1/rDrama
GNU Affero General Public License v3.0
25 stars 30 forks source link

babeljs integration example #710

Open wmill opened 8 months ago

wmill commented 8 months ago

Just a proof of concept showing how to integrate bablejs so that you can use newer JS features.

Edit files/bundles.yaml to control what files are transpiled.

zorbathut commented 8 months ago

Huh. Neat!

So, as I'm reading this, it looks like this is basically being given to Flask as a preprocessing step. Any idea if Flask is smart enough to cache, or is it regenerating every run? Also, if it's caching, is it smart enough to recognize when the underlying files have changed and reprocess it?

wmill commented 8 months ago

@zorbathut So Flask-Assets is built on top of WebAssets. It's supposed to handle caching, rebuilding, and can even upload the files to S3 if you want.

I haven't verified that it's all working correctly, additional configuration might be needed to set up caching properly. Note that if you're looking at the docs Python Babel is completely different from BabelJS. Python Babel does internationalization.

zorbathut commented 8 months ago

Any idea how hard it would be to work typescript into this? It looks like Babel and TS do similar-but-unrelated things.

wmill commented 8 months ago

Babel can compile typescript using @babel/preset-typescript, there are limits because it can't do things like generate .d.ts files. It should work for this.