Browserify a mix of coffeescript and livescript files

541 Views Asked by At

I have a main coffee file and a mix of other coffee and livescript files.

# main.coffee
require 'LiveScript'
one = require './one.coffee'
two = require './two.ls'
console.log one.fun(), two.fun()

# one.coffee
module.exports.fun = -> 1

# two.ls
module.exports.fun = -> 2

I can run

coffee main.coffee

But trying to run

browserify -t coffeeify main.coffee

Gives an error:

module.exports.fun = -> 2
                      ^
ParseError: Unexpected token >

The only workaround I see is to compile ls files to js first. Is there a simpler, direct way to mix ls and coffee files?

2

There are 2 best solutions below

0
On

require 'LiveScript' is only sufficient for Node.js. Browserify does not support require.extensions, and is trying to parse the LiveScript as JavaScript.

You need a transform for LiveScript as well, for example Liveify.

0
On

You might try Webpack. With proper loaders, e.g. livescript-loader, coffee-loader and others, you can compose your program with different js flavors.