Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can one include another LiveScript file in LiveScript?

Tags:

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?

like image 320
Lokkij Avatar asked May 14 '15 15:05

Lokkij


1 Answers

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).

like image 158
igl Avatar answered Oct 19 '22 17:10

igl