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

  1. united kingdom roulette game download, new uk online casino with
    no bonus (Mindy) king bonus and largest
    casino in australia 2021, or minimum dollar 5 deposit casino australia

  2. Beyond just improving grades, primary math tuition nurtures а positive and enthusiastic attitude tоward
    mathematics, minimizing stress whiⅼe sparking genuine intеrest іn numƄers and patterns.

    Secondary math tuition stops tһe accumulation of conceptual errors tnat coulɗ
    severely jeopardise progress іn JC H2 Mathematics, mаking timely assistance іn Sec 3 ɑnd Sec 4 ɑ veгү wise decision fօr forward-thinking families.

    JC math tuition holds special іmportance for students targeting demanding degree programmes ѕuch as
    medicine, where excellent Н2 Mathematics grades serves аs ɑ key admission requirement.

    Secondary students tһroughout Singapore increasingly choose remote secondary-level math coaching
    tⲟ receive іmmediate corrections on practice papers аnd recurring errors іn topics ѕuch ɑѕ
    vectors ɑnd trigonometry, speeding սp improvement tοward
    A1 oг A2 гesults in Additional Mathematics.

    Ⅴia real-life study, OMT demonstrates math’ѕ impact, helping Singapore pupils develop ɑn extensive
    love and test motivation.

    Discover tһe benefit of 24/7 online math tuition ɑt OMT, wһere engaging resources mɑke
    finding out enjoyable аnd effective for all levels.

    Singapore’ѕ world-renowned mathematics curriculum highlights conceptual understanding οver mere
    calculation, making math tuition vital foг trainees tо comprehend
    deep ideas аnd master national examinations ⅼike PSLE аnd O-Levels.

    Thгough math tuition, trainees practice PSLE-style concerns typicallies аnd graphs,
    improving precision and speed undеr examination conditions.

    Personalized math tuition іn secondary school addresses individual learning gaps іn subjects ⅼike calculus аnd data, avoiding them
    from preventing O Leevel success.

    Тhrough routine mock tests and detailed responses, tuition helps junior college students recognize ɑnd correct
    weaknesses before the actual A Levels.

    What collections OMT apart іs its custom-made syllabus that aligns ѡith MOE whiⅼe using flexible pacing, allowing innovative trainees tо accelerate theіr learning.

    OMT’s е-learning reduces mathematics anxiety lor, mɑking you
    mսch morе certɑin and leading tо һigher test marks.

    Singapore’ѕ emphasis on proƅlem-solving in math tests
    maҝes tuition necessаry for creating crucial thinking skills Ьeyond school һⲟurs.

    my blog post math tuition teacher Singapore

  3. Greetings I am so happy I found your website, I really found you by error,
    while I was browsing on Google for something else, Anyways I am here
    now and would just like to say thanks for a marvelous post and a
    all round entertaining blog (I also love the theme/design), I don’t have time to read it all
    at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a lot more,
    Please do keep up the great work.

  4. Cool blog! Is your theme custom made or did you download it from
    somewhere? A theme like yours with a few simple tweeks would really
    make my blog shine. Please let me know where you got your design. Thanks

  5. It’s difficult to find educated people in this particular topic, however,
    you seem like you know what you’re talking
    about! Thanks

  6. We’re a group of volunteers and opening a new scheme in our community.
    Your web site provided us with valuable information to work
    on. You have done an impressive job and our entire community will be grateful to you.

  7. Hello my friend! I want to say that this article is awesome,
    great written and come with approximately all
    vital infos. I would like to look extra posts like this
    .

  8. Excellent goods from you, man. I have consider
    your stuff previous to and you’re simply too fantastic.
    I really like what you have received right here, certainly like what you are
    stating and the way in which you say it. You make it enjoyable and you continue to take care of
    to stay it wise. I can not wait to read much more
    from you. This is really a great web site.

  9. I never thought I’d end up writing this but here I am.
    Back when the new competitive season started, I got totally consumed
    in online games – Valorant. I wanted to dominate, and I kept searching for shortcuts everywhere.

    After another frustrating match, I stumbled across a
    forum thread talking about “boosting tools”.
    At first I laughed it off, but the more screenshots I saw,
    the more it felt like a secret world.

    Commenters were flexing showing how they climbed from low ranks to high ones in days.
    It looked effortless. And of course, the downside was completely hidden.

    To be honest, I actually got close to buying something.

    One guy tried to explain the “features” to me. That’s when the real consequences showed up.

    I found threads from players who lost their accounts.
    Some even wrote how they couldn’t undo the damage.
    That was my wake-up call.

    Instead of cheating, I walked away and focused on improving the legitimate
    way.

    Now, when I see people chasing cheats, I just think: the crash
    always comes. Hopefully this story saves someone else time.

  10. Thank you for the auspicious writeup. It actually
    used to be a leisure account it. Look complex to more introduced agreeable from you!
    However, how could we keep up a correspondence?

  11. whoah this weblog is excellent i like studying your posts.
    Stay up the good work! You understand, many individuals are looking round for this
    info, you could aid them greatly.

  12. Hmm it looks like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I submitted and say,
    I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still
    new to the whole thing. Do you have any suggestions for
    first-time blog writers? I’d really appreciate it.

  13. It’s an remarkable paragraph designed for all the online viewers; they will obtain advantage from it I am sure.

  14. It’s amazing to pay a visit this website and reading the views of all
    friends about this paragraph, while I am also
    keen of getting know-how.

  15. I never thought I’d end up writing this yet this is exactly where life took me.
    A few months ago, I got way too invested in online games – Valorant.
    I wanted to dominate, and I wasn’t willing to admit
    how impatient I had become.

    Late one night, I stumbled across a forum thread talking about “boosting tools”.
    At first it was harmless reading, but the more I scrolled, the more it felt like a hidden shortcut.

    Users were posting clips showing how they climbed from low
    ranks to high ones in days. It looked like magic. And of course, the downside was completely
    hidden.

    Truth be told, I actually got close to buying something.
    One seller even messaged me privately. That’s when the real consequences showed up.

    I found threads from players who lost thousands of hours
    of progress. Some even wrote how their PCs got infected.
    Everything clicked.

    Instead of taking that dumb risk, I deleted the messages and focused on improving the
    legitimate way.

    Now, when I see people chasing cheats, I just think: it’s never worth it.
    Hopefully this story saves someone else time.

  16. Howdy I am so happy I found your website, I really found you by error, while I was browsing on Bing
    for something else, Anyhow I am here now and would just like to say many thanks for
    a fantastic post and a all round interesting blog (I also love the theme/design),
    I don’t have time to browse it all at the minute but I have saved it
    and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome
    work.

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>