soegaard / urlang

Urlang is JavaScript with a sane syntax
303 stars 16 forks source link

How to export default modules? #18

Closed boticello closed 4 years ago

boticello commented 5 years ago

I am hoping to use Urlang to write code for Gatsby. The Gatsby code examples use ES6 syntax. Gatsby pages and components export modules as default.

Is there a way in Urlang to export modules as default rather than named? I don't see any examples. I'm also inexperienced in both Javascript and Racket, so I may be missing something obvious.

soegaard commented 5 years ago

Hi,

I took a look at Gatsby (which I had heard about before).

It looks complicated, so perhaps Urlang is not a good match - if something breaks it will be difficult to track down, where the problem is.

Currently the output of Urlang is strictly ES5. I know that React works with ES5 code, so maybe it's possible to get Gatsby working too.

The first step is to figure out how Gatsby can be used with ES5 and then we can look at getting Urlang to generate the ES5 code.

/Jens Axel

boticello commented 5 years ago

Thank you @soegaard for taking the time to look at Gatsby.

It is complicated. It has its own magic and then there is the hairball complexity of modern JavaScript (webpack etc).

Gatsby generates ES5 code via Babel in its standard build pipeline - the ES6 code is a convention but not a requirement. I will look at the code it generates in ES5 via Babel and share what that looks like.

soegaard commented 4 years ago

In the short term there will be no changes to the modules in Urlang. There is some (not much, but some) support for ES6 modules now, but the state of affair could be improved.

I am closing this for now - and will make a new one for "general improvement to the module story".