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,447 thoughts on “Using RequireJS exports with CoffeeScript

  1. Howdy! Someone in my Myspace group shared this site with us so I came to look it over.
    I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers!
    Exceptional blog and excellent design.

  2. I was excited to find this website. I need to to thank you for your time due to this fantastic
    read!! I definitely really liked every bit of
    it and I have you book-marked to see new things on your
    web site.

  3. Sweet blog! I found it while searching on Yahoo News.
    Do you have any suggestions on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!

    Thank you

  4. hello there and thank you for your information – I have certainly picked up anything
    new from right here. I did however expertise a few technical
    points using this website, since I experienced to
    reload the site lots of times previous to I could get it
    to load properly. I had been wondering if your web hosting is OK?
    Not that I am complaining, but sluggish loading instances times will sometimes affect your placement in google and can damage
    your high-quality score if advertising and marketing with Adwords.
    Anyway I am adding this RSS to my e-mail and
    can look out for much more of your respective
    interesting content. Ensure that you update this
    again very soon.

  5. One of the most noticeable trading systems in the online trading landscape is MetaTrader 5, typically referred to
    as MT5. The change from the initial MetaTrader 4 to its successor, MT5,
    was noted by significant improvements in functionality, allowing for much more complicated order types,
    deeper market evaluation, and integrated tools for
    mathematical trading.

  6. This is a very good tip especially to those new to the blogosphere.
    Short but very accurate information… Thanks for sharing this
    one. A must read article!

  7. Hey just wanted to give you a brief heads up and let you
    know a few of the pictures aren’t loading correctly.
    I’m not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both show
    the same outcome.

  8. Howdy! I know this is kinda off topic but I was wondering which blog
    platform are you using for this website? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at options for
    another platform. I would be awesome if you could point me in the
    direction of a good platform.

  9. установка газового пожаротушения для промышленного объекта установка газового пожаротушения для промышленного объекта .

  10. Hello it’s me, I am also visiting this website on a regular basis, this website is
    actually good and the people are in fact sharing pleasant thoughts.

  11. I think this is among the most significant info for me. And i’m satisfied reading your article.
    However want to observation on some common things, The website taste is wonderful, the
    articles is really great : D. Excellent task, cheers

  12. Hello this is somewhat of off topic but I was wondering if
    blogs use WYSIWYG editors or if you have to manually
    code with HTML. I’m starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

  13. Link exchange is nothing else except it is just
    placing the other person’s website link on your page
    at proper place and other person will also do same in favor of you.

  14. I didn’t see it coming at all, but the day I stepped into the backend of the
    sports world, 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 massive digital
    economy, I honestly felt overwhelmed.

    What hit me hardest was realizing that cybercriminals weren’t going after “IT servers” anymore.
    They were attacking everything — contract files.
    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 ransomware attack almost froze an entire club.
    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 ultra-sensitive digital ecosystems. 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.

  15. Hi there, this weekend is fastidious for me, since this point in time i am
    reading this wonderful informative post here at my home.

  16. An impressive share! I have just forwarded this onto a colleague who has been doing a little homework on this.

    And he in fact ordered me lunch due to the fact that
    I found it for him… lol. So let me reword
    this…. Thanks for the meal!! But yeah, thanks for spending the time to talk about this topic
    here on your web page.

  17. My brother suggested I might like this website. He was totally right.
    This post actually made my day. You can not imagine simply how much time I
    had spent for this information! Thanks!

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>