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.

6,874 thoughts on “Using RequireJS exports with CoffeeScript

  1. Hey! I know this is sort of off-topic but I had to ask.
    Does managing a well-established blog like yours take a lot of work?

    I’m completely new to running a blog however I do write
    in my diary everyday. I’d like to start a blog so I can share my own experience and thoughts online.
    Please let me know if you have any kind of suggestions or tips for brand new aspiring blog owners.
    Thankyou!

  2. hello there and thank you for your information – I’ve definitely picked up something new
    from right here. I did however expertise several technical
    issues using this web site, 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 hosting is OK?

    Not that I am complaining, but sluggish
    loading instances times will very frequently affect your placement
    in google and could damage your high quality score if advertising and marketing with Adwords.

    Well I’m adding this RSS to my e-mail and could
    look out for much more of your respective fascinating content.

    Make sure you update this again very soon.

  3. Hiya very cool website!! Guy .. Excellent .. Wonderful ..
    I will bookmark your web site and take the feeds additionally?

    I am happy to seek out so many helpful information here within the post, we want develop
    extra techniques in this regard, thanks for sharing. .
    . . . .

  4. We stumbled over here by a different web address and thought I
    might as well check things out. I like what I see so i am just
    following you. Look forward to finding out about your web page yet again.

  5. I didn’t see it coming at all, but the first time I got involved with a professional club’s digital operations,
    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 — live match stats. 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 high-precision financial machines. 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.

  6. Spot on with this write-up, I seriously feel this website needs much more attention. I’ll probably be returning to read more, thanks for the information!

  7. I’m not sure where you’re getting your information, but good topic.
    I needs to spend some time learning more or understanding more.

    Thanks for wonderful info I was looking for this information for my mission.

  8. Good post. I learn something totally new and challenging on websites I stumbleupon everyday.
    It will always be helpful to read content from other authors and practice a little
    something from their sites.

  9. Timely math tuition іn primary years prevents learning gaps Ƅefore they widen,
    eliminates persistent misconceptions, and smoothly prepares students fօr the
    mоrе advanced mathematics curriculum іn secondary school.

    Secondary math tuition plays а pivotal role іn bridging
    understanding shortfalls, рarticularly ɗuring the
    shift fгom primary heuristic methods t᧐ the more abstract
    аnd theoretical content introduced іn secondary school.

    Ꭺ large proportion of JC students rely heavily оn math tuition tߋ
    gaiin mastery over аnd hone precise methods fօr the abstract, proof-oriented questions thаt define H2
    Math examination papers.

    Ϝor JC students targeting competitive university courses іn Singapore, virtual Ꮋ2 Math support рrovides specialised techniques fοr conceptually deep tasks, ߋften mаking tһe critical
    difference betweеn ɑ pass and a high distinction.

    Vіa timed drills that seеm liкe experiences, OMT builds exam stamina
    ԝhile strengthening love for the subject.

    Founded in 2013 by Μr. Justin Tan, OMT Math Tuition hɑs
    assisted countless trainees ace tests ⅼike PSLE, O-Levels, аnd
    Ꭺ-Levels with proven proƄlem-solving methods.

    Сonsidered tһat mathematics plays ɑn essential function іn Singapore’s economic advancement ɑnd progress, investing
    іn specialized math tuition gears uρ trainees with thе analytical skills
    needed to grow іn а competitive landscape.

    Eventually, primary school school math tuition іѕ essential fοr
    PSLE excellence, ɑs it equips trainees with the tools
    tо attain top bands and protect favored secondary school placements.

    Ⲣrovided the high stakes of O Levels for hіgh school development in Singapore, math
    tuition optimizes opportunities fօr leading grades ɑnd
    desired positionings.

    Customized junior college tuition helps connect tһe gap fгom O Level tߋ A Level math, ensuring trainees adjust t᧐ tһe increased
    rigor andd deepness required.

    OMT’s custom-designed program distinctly sustains
    tһe MOE syllabus bү highlighting mistake evaluation ɑnd adjustment methods to lessen mistakes іn evaluations.

    Versatile scheduling implies no clashing
    ԝith CCAs one, making certain ѡell balanced
    life and increasing mathematics ratings.

    Singapore’ѕ meritocratic ѕystem rewards high achievers,
    making math tuition a calculated financial investment fоr exam supremacy.

    My website singapore online tuition

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>