MelkorNemesis
MelkorNemesis

Reputation: 3435

Prevent coffeescript from wrapping code into immediately invoked function

I've been going through coffeescript documentation and stackoverflow to find answer for my question to no avail.

I have a javascript file containing just one literal object compiled from coffeescript.

products =
    1:
        name: 'foo'
        id: 1
        description: 'lorem ipsum dolor sit'
        youtube: 'path
    2:
        name: 'bar'
        id: 2
        description: 'lorem ipsum dolor sit'
        youtube: 'path

but what I'm getting back is:

(function() {
    return products = {
      1: {
        name: 'foo lama',
        id: 1,
        ...

I'm loading that file as a resource through ajax and I'm not able to use it as a proper JSON.

Is there a way to prevent coffeescript from wrapping the code into immediately invoked function or (and that'd be the best solution) is there a way to compile only JSON object without naming it?

Thanks

Upvotes: 1

Views: 338

Answers (1)

Andrew Kirkegaard
Andrew Kirkegaard

Reputation: 1684

Compile with option -b or --bare

Upvotes: 9

Related Questions