Open michael-brade opened 6 years ago
livescript-esm-loader
is meant for runtime loading modules into node.js and it is very WIP at the moment.
The easiest way to accomplished what you are asking would be to use livescript-transform-esm (loader is using it under the hood)
Give few minutes and I'll ensure it works from cli and then I'll write how to use it.
lovely! :)
Ok got it working with little gotchas (livescript from git is required and need to specify source-map type)
livescript-transform-esm
has register
file which hooks into livescript compiler. So to make it work simply require it during compilation.
First install livescript and transfrom-esm
npm i -D https://github.com/gkz/LiveScript livescript-transform-esm
next assuming transpilation from src
to tmp
node_modules/.bin/lsc -r livescript-transform-esm/register -cm linked -o tmp src
Amazing! This looks perfect. Will try soon and report back.
Wow, how simple! It works rather good, thanks for all your work! I was fighting with babel and some other issues for hours :( So that's why I'm answering late. I found just one thing worth changing: this export
export class HtmlGenerator
is transpiled to
var export$;
export { export$ }
export$ = HtmlGenerator = (function(){
which means I have to require('html-generator').export$
. And I'm not even sure it would work with babel since it would expect export$
to be called HtmlGenerator
. So should this be renamed? If I do export default ...
I get the expected result: export { export$ as default }
I've created issue at livescript-transform-esm repo. I'll work in the morning (UTC+01:00)
No worries! Same here, I need sleep....
Hi, this looks like great work!
Now I would like to try it by compiling a LiveScript source with import statements to JavaScript, ideally so that webpack can create a bundle for the browser.
I understand how to start node and load ls files on the fly. But how can I get hold of the transpiled code? Do you have any examples? Thanks :)