Iroh icon indicating copy to clipboard operation
Iroh copied to clipboard

ES6 support

Open maierfelix opened this issue 8 years ago • 10 comments
trafficstars

maierfelix avatar Aug 24 '17 20:08 maierfelix

I think it's good to use babel It supports new syntaxes (ES7 / ES8 / stage-X / jsx / flow / ...) He also has a developed and convenient API for transformations

Please look at my prototype, how could this project look like using babel https://github.com/Gvozd/Iroh/commit/21b45448f54f3b7f1ccfb1800943c30aec63650b#diff-166fafb4696a306abbebc2eb37ec80b4

Also it seems to me that moving to Babel will simplify the code of transformations In particular, the task will simplify https://github.com/maierfelix/Iroh/issues/1

This is a draft prototype - I almost did not use the existing code, but implemented a new implementation next to it

If you like the idea, I could help translate the project into a babel

PS separately pay attention to the test pattern https://github.com/Gvozd/Iroh/commit/26c050dea2ef7e501c8f96fd56e4eb259b7fcbe5#diff-623a568601cc9823c80b885448c341cc It can be used independently of this task

Gvozd avatar Aug 28 '17 19:08 Gvozd

If you could provide an example on how to insert a variable before a loop and then access it inside the loop's body, then I'm willed to start working with babylon - it looks really promising.

maierfelix avatar Aug 28 '17 21:08 maierfelix

something like this? https://astexplorer.net/#/gist/8a13b6fe10fdacfde3a74ca7b39e6ba3/992f85f791f8e0db7cfa70ae3da55184954410d9

About users transpilation: If use babel, may do any transpilation, defined in .babelrc (or as argument to Iroh.Stage) - I have TODO to this I think, good idea do transpilation after Iroh sub-plugins, because transpilations create more additional function calls, temp variables, switch-cases and other. That not really user source, and not need debug it. Instead this need debug user source, like AsyncFunction, or another syntax

Also, babel has plus: you may use only needed transformation. If user handled on Iroh.LOOP, not need wrap function call

UPD: https://astexplorer.net/#/gist/8a13b6fe10fdacfde3a74ca7b39e6ba3/126dfc8887ee7e64ece373ff1af575e74d65da84 I found ensureBlock method, instead manual BlockStatement createing

Gvozd avatar Aug 29 '17 07:08 Gvozd

Babel documentation Plugin Handbook https://babeljs.io/docs/core-packages/babel-types/

Gvozd avatar Aug 29 '17 08:08 Gvozd

Thanks, very helpful!

maierfelix avatar Aug 30 '17 22:08 maierfelix

I'm pretty new to rollup, could you extend your fork to support babel-traverse with npm run browser? It's the only thing holding me back to start working on it

maierfelix avatar Aug 31 '17 18:08 maierfelix

Sorry, I've never worked with a rollup

But I can work with webpack+babel bundling If you want I can configure bundling with webpack

Gvozd avatar Sep 03 '17 14:09 Gvozd

Thanks, I would appreciate it!

maierfelix avatar Sep 03 '17 14:09 maierfelix

OK Until Wednesday I will transfer the assembly to Webpack

Also I'll make a cleaner version of my prototype - now it's a bit dirty, and it duplicates your existing code I will correct, that changes were only in the code of transformations

Gvozd avatar Sep 03 '17 14:09 Gvozd

@maierfelix Please look PR #10

I'm sorry that I disappeared for a long time I research rollup in comparison with webpack(I liked rollup for less bundle size), and try build project with rollup Study rollup and attempt to build babel-core took a long time

Gvozd avatar Sep 16 '17 10:09 Gvozd