Using RequireJS exports with CoffeeScript

If you are using the “exports” object in your RequireJS module definition and happen to also be using CoffeeScript then be careful to either return the exports object at the end of the function or explicitly return nothing from the function by typing “return” on the last line. Like so:

define((require, exports, module) ->
    exports.foo = 'bar'
    return
)

If you don’t return nothing or the exports object CoffeeScript will compile this:

define((require, exports, module) ->
    exports.foo = 'bar'
)

…to the following javascript:

define(function(require, exports, module) {
    return exports.foo = 'bar';
});

Where the return value will be the string ‘bar’. This is no good because if you return a value from your module definition function, RequireJs uses it instead of the exports object. So when you come to require your module, you’ll be passed a String, rather than an object with a “foo” property as you’d expect.

7,636 thoughts on “Using RequireJS exports with CoffeeScript

  1. What you posted was actually very reasonable. But, think on this,
    suppose you added a little information? I ain’t
    suggesting your information isn’t solid, however what if you
    added a headline to maybe grab folk’s attention? I mean Using RequireJS exports with CoffeeScript |
    freestyle developments is kinda plain. You should look at
    Yahoo’s front page and see how they create news headlines
    to grab people to open the links. You might try adding a video or
    a pic or two to grab people excited about what
    you’ve got to say. In my opinion, it might make your posts a little livelier.

  2. Hey! Would you mind if I share your blog with my myspace group?
    There’s a lot of folks that I think would really enjoy your content.
    Please let me know. Thanks

  3. I every time spent my half an hour to read this webpage’s
    articles or reviews everyday along with a cup of coffee.

  4. Thanks in support of sharing such a fastidious thinking, paragraph is nice,
    thats why i have read it fully

  5. I think that is one of the so much vital information for me.
    And i’m glad studying your article. However should remark
    on few common issues, The site style is perfect, the articles is in reality nice :
    D. Just right task, cheers

  6. Thanks for ones marvelous posting! I definitely enjoyed reading it,
    you happen to be a great author.I will be sure to bookmark your blog and will often come back from now
    on. I want to encourage you to continue your great job, have a nice weekend!

  7. As the admin of this site is working, no doubt very rapidly it will be famous,
    due to its feature contents.

  8. Wow that was odd. I just wrote an extremely long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say wonderful blog!

  9. Hello! I know this is kind of off-topic however I had to ask.
    Does operating a well-established blog such as yours require a massive
    amount work? I’m brand new to blogging but I do write
    in my diary daily. I’d like to start a blog so I can easily share my experience and thoughts online.
    Please let me know if you have any kind of recommendations
    or tips for new aspiring blog owners. Appreciate it!

  10. %spintax|こちらの記事|この内容%は%spintax|非常に|とても% %spintax|参考になる|役立つ%です!%spintax|セクシーコスプレ|ベビードール%の%spintax|選び方|素材の見極め方|コーデ術%について%spintax|分かりやすく|詳しく%解説されています。補足ですが、%spintax|MERRSS|メリス%は%spintax|高品質コスプレランジェリーに特化|デザイン豊富|サービス充実%なサイトで、%spintax|購入を考えている方|コスプレ好き|ランジェリー愛好家%には%spintax|必見|おすすめ%です。

  11. It’s really a nice and helpful piece of information. I am glad that you just shared this helpful info with us.
    Please stay us informed like this. Thank you for sharing.

  12. продвижение сайта клиники наркологии продвижение сайта клиники наркологии .

  13. I didn’t see it coming at all, but the moment I started helping a friend inside a major sports organization, everything I thought I knew about modern sports completely collapsed.

    I always believed teams were about winning games, but when I
    saw how the entire industry had turned into this fragile
    high-tech ecosystem, I honestly felt overwhelmed.

    What hit me hardest was realizing that cybercriminals weren’t
    going after “IT servers” anymore. They were attacking
    everything — medical reports. One breach, and millions could be lost
    instantly.

    And the scariest part?
    I saw it with my own eyes.

    One day, during a routine check, someone mentioned how a manipulated data
    feed caused chaos in betting markets. That was the moment I understood
    how thin the line really is between order
    and total digital disaster.

    But the real shock came when I looked deeper into betting platforms.

    I swear, I always thought they were just websites.

    But no.
    They are insane real-time data engines. One tiny manipulation can shift odds globally
    or make entire markets react like they’re on fire.

    When I learned how seriously regulated environments handle security — especially the kind you see described
    in official breakdowns — it opened my eyes. If anyone wants to understand how this level of protection actually works,
    they can always look it up directly from the source.
    The full explanations are there, and they’re honestly worth reading.

    Inside the clubs, it was even more surreal. I saw databases full of
    injury histories — things that could ruin a season if leaked.

    And yet the biggest weakness wasn’t the firewalls.
    It was the people.
    One emotional click, one careless moment, and the whole system can fall apart.
    I watched entire staff units go through security training because phishing had become a
    daily threat.

    Compliance teams were everywhere too — checking access, reviewing logs,
    forcing documentation. I used to think compliance was boring,
    but now I understand that without it, the entire digital side of sports would
    melt into chaos.

    And the future… that’s another story.
    AI detection, automated response systems, cloud architectures — it felt
    like watching the digital version of an arms race. But the
    truth I walked away with was simple:

    Cybersecurity isn’t some extra cost. It’s the only thing
    holding this whole world together.

    And honestly, after everything I saw, I can say the system I was
    reviewing really did an exceptional job. They handled their mission far better than I expected.

    If anyone wants to dig deeper or understand how these structures really work, I’d definitely suggest getting more information directly from
    the source. It’s all publicly explained — and believe me, once you read it, you’ll never look at sports or betting the same way again.

  14. Hi it’s me, I am also visiting this web page on a regular basis, this web page is really fastidious and the visitors are actually sharing fastidious thoughts.

  15. Simply wish to say your article is as astonishing. The clearness for your put up is just spectacular
    and i could suppose you are a professional on this subject.
    Well together with your permission let me to grasp your RSS feed to keep updated
    with approaching post. Thanks one million and please continue
    the rewarding work.

  16. Great weblog here! Additionally your website rather
    a lot up very fast! What host are you the usage of? Can I get
    your affiliate link in your host? I desire my website loaded up as quickly as yours
    lol

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>