Closed francescoagati closed 6 years ago
@francescoagati I can't figure out any way to do this but will merge a PR to do it if somebody supplies one.
Is because wisp can have differenti targets that Theresa isnt a RAW emitter of js? Shoild be nice emittenti new js for es6 async await generatore typescript ecc...
@francescoagati I am not 100% sure what you mean but you can generate raw Javascript by doing:
wisp < myfile.wisp > myfile.js
for example this in sibilant js https://github.com/jbr/sibilant/blob/master/src/macros/lambda.sibilant#L56
I'm afraid this code is beyond me. I do not know of a way in Wisp to inject raw Javascript. It may be possible but I am not sure. Perhaps @Gozala can advise?
I'm afraid this code is beyond me. I do not know of a way in Wisp to inject raw Javascript. It may be possible but I am not sure. Perhaps @Gozala can advise?
It's being a while since I have looked at the code base so there's a risk I may get some things wrong, but I'll try to below.
Is because wisp can have differenti targets that Theresa isnt a RAW emitter of js?
Short answer is yes. More elaborate follows below
for example this in sibilant js https://github.com/jbr/sibilant/blob/master/src/macros/lambda.sibilant#L56
I'm getting an impression that sibilant macros emit JS source, which are at some point concatenated and evaluated. This is also how originally wisp worked when it got forked from lispyscript. Later on I have changed design as I had an ambition to have many different back-ends it could compile to, which is why right now wisp compilation consists of following phases:
Shoild be nice emittenti new js for es6 async await generatore typescript ecc...
I agree! That being said you do not really need to emit raw JS for that. To make it work you'd need to do following:
await
, have some form for async
functions and include that info AST node of the function. Same with generators and whatever else you might support.It's worth pointing out that while it does seem more difficult than just emitting JS strings it has few advantages:
If above advantages is not something you care about there is also a possibility to do something along the lines of what sibilant does, by doing following:
js
so you could write things like (js "async funciton() {" ...))` which reader will be able to understand.With this option you'd be able to get what sibilant does but I'd recommend former approach instead.
@Gozala thank you so much for taking the time to write this great info up.
I think it makes sense to merge a PR which can inline raw JS.
@francescoagati since Wisp can require
native JS directly could that be an option and then pass the result through browserify
or similar? You could put your native parts into a separate .js file.
@chr15m no i think that in this case using inline raw js is not compatible with the philosophy of wisp. is better modify the target for add new features of es6
hi, is possible from a macro emit custom js in raw mode? like coffeescript that use `` for inject javascript raw code inside the code
Thanks