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.

10,127 thoughts on “Using RequireJS exports with CoffeeScript

  1. This is a helpful post about betting platforms.
    I found it useful how you explained the importance of finding
    secure systems.

    From what I’ve seen, platforms like UFABET888 are quite popular
    because they have smooth systems and fast withdrawals.

    Many users usually find it difficult to find trustworthy platforms, so content
    like this is extremely useful.

    Thanks for sharing — this will definitely help
    beginners choose better platforms.

  2. Does your website have a contact page? I’m having a tough
    time locating it but, I’d like to shoot you an email. I’ve
    got some suggestions for your blog you might be interested in hearing.

    Either way, great website and I look forward to seeing it
    expand over time.

  3. It’s a shame you don’t have a donate button! I’d most certainly donate to this outstanding blog!

    I suppose for now i’ll settle for bookmarking and adding your RSS
    feed to my Google account. I look forward to brand new updates and will share this blog
    with my Facebook group. Talk soon!

  4. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.

    You definitely know what youre talking about, why throw away
    your intelligence on just posting videos to your site
    when you could be giving us something informative to read?

  5. Timely math tuition іn primary years prevents learning gaps before theу widen, resolves persistent misconceptions,
    ɑnd gently readies students foг the more advanced mathematics curriculum іn secondary school.

    Math tuition during secondary үears strengthens complex рroblem-solving skills,
    whicһ prove essential ƅeyond tests future pursuits іn STEM fields, engineering, economics, ɑnd data-гelated disciplines.

    JC math tuition holds аdded significance fⲟr students targeting
    demanding degree programmes ⅼike computer science,
    economics, actuarial science, ߋr data analytics, whеre excellent Ꮋ2 Mathematics
    grades serves ɑs a critical entry condition.

    Online math tuition stands ⲟut fօr primary students in Singapore ѡhose
    parents ᴡant consistent syllabus reinforcement ᴡithout fixed centre timings, ցreatly easing anxiety ѡhile strengthening early pr᧐blem-solving skills.

    OMT’s vision foг lifelong learning inspires Singapore students tߋ see math as
    a friend, encouraging tһem for test quality.

    Broaden уour horizons witһ OMT’s upcoming brand-neѡ physical аrea opening in September 2025, offering еven morе chances for hands-օn math exploration.

    Aѕ mathematics underpins Singapore’ѕ track record for excellence іn global criteria ⅼike
    PISA, math tuition is key to opening а kid’s prospective and securing scholastic benefits іn thiѕ core subject.

    Math tuition addresses individual finding ⲟut speeds, enabling
    primary school trainees tօ deepen understanding of PSLE topics ⅼike area,
    perimeter, аnd volume.

    Math tuition educates reliable tіme management strategies, assisting secondary trainees ϲomplete O
    Level tests witһin thе designated period wіthout hurrying.

    For those seeking H3 Mathematics, junior college
    tuition ᥙses sophisticated support ⲟn гesearch-level topics t᧐ master tһis tough extension.

    OMT stands ⲟut with itѕ exclusive mathematics educational program, carefully сreated to enhance the Singapore MOE syllabus Ьү filling out theoretical
    spaces tһɑt standard school lessons mіght forget.

    Themed modules mаke learning thematic lor, assisting retain info mᥙch longer foг
    boosted mathematics efficiency.

    Online math tuition ɡives flexibility f᧐r active Singapore trainees, permitting anytime accessibility tto sources fοr better exam prep
    work.

    My site :: online math tuition Singapore for enrichment

  6. When I originally commented I clicked the “Notify me when new comments are added” checkbox and
    now each time a comment is added I get four emails with the same comment.
    Is there any way you can remove me from that service?

    Bless you!

  7. This is a well-written post about betting platforms.
    I found it useful how you explained the importance of
    choosing reliable sites.

    From what I’ve seen, ufabet888 are frequently mentioned
    because they have smooth systems and quick payouts.

    Many users have trouble to find trustworthy platforms, so content like this is great for guidance.

    Thanks for sharing — this will definitely help beginners choose better platforms.

  8. It’s a pity you don’t have a donate button! I’d certainly donate
    to this excellent blog! I guess for now i’ll settle for book-marking and adding
    your RSS feed to my Google account. I look forward to new updates and will talk about this site with my Facebook
    group. Talk soon!

  9. You actually make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand.

    It seems too complex and extremely broad for me.
    I’m looking forward for your next post, I will try to get the hang of it!

  10. Definitely imagine that which you stated. Your favorite
    reason seemed to be on the net the easiest thing to have in mind of.
    I say to you, I definitely get irked while other people think about worries that
    they just do not recognize about. You controlled to hit the nail upon the highest and outlined out the whole thing
    with no need side-effects , other folks could take a signal.

    Will likely be back to get more. Thanks

  11. It’s awesome to go to see this web site and reading the views of all friends about this post, while I am also keen of getting experience.

  12. Hey there! I just wish to give you a huge thumbs up for the excellent info you have got here on this post.
    I will be coming back to your website for more soon.

  13. A fascinating discussion is worth comment. I do believe that you need to write more about this topic, it might not be a taboo subject but usually people do not discuss such topics.
    To the next! Many thanks!!

  14. Outstanding post however , I was wanting to know if you could write a litte more on this subject?
    I’d be very thankful if you could elaborate a little
    bit more. Kudos!

  15. Fantastic goods from you, man. I have understand your stuff previous to and you
    are just extremely great. I really like what you have acquired here, certainly like what you are stating and
    the way in which you say it. You make it entertaining
    and you still care for to keep it sensible.
    I can’t wait to read far more from you. This is actually a great website.

  16. Thank you for every other informative blog. Where else could I am getting
    that type of info written in such a perfect approach?

    I’ve a undertaking that I am just now working on, and I’ve
    been at the glance out for such info.

  17. I used to be suggested this blog by my cousin. I’m no longer
    certain whether this submit is written by him as nobody else realize such distinctive approximately
    my problem. You’re incredible! 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>