livescript

How can one include another LiveScript file in LiveScript?


How can one use code in a LiveScript file from another LS file? For example:

# In script-one.ls
foo = 5

# In script-two.ls
bar = -> foo + 3

Simply including both files in the HTML via script tags does not seem to work. Changing the first script to export foo = 5 and using require! './script-one' (or variants) in the second script doesn't work either.

And what about circular dependencies?


Solution

  • LiveScript simply compiles to javascript. The module format is your decision just like in JS.

    The export keyword simply compiles to a commonjs exports.foo = right now and will not work in browsers without using something like browserify (http://browserify.org/) to bundle your modules (ES6 compat is planned in the future).