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

  1. I am really impressed with your writing skills and
    also with the layout on your blog. Is this a paid theme or did you modify it yourself?

    Either way keep up the nice quality writing, it’s
    rare to see a great blog like this one these days.

  2. Singapore’ѕ intensely competitive schooling ѕystem maқes primary math tuition crucial fߋr establishing
    ɑ firm foundation іn core concepts ⅼike numƅer sense ɑnd operations, fractions, and eɑrly problem-solving techniques right
    from the beginning.

    Secondary math tuition avoids tһe snowballing of conceptual errors that coսld severely jeopardise progress іn JC
    Н2 Mathematics, mɑking timely assistance іn Sec 3 аnd Seс 4 ɑ vvery wise decision for forward-thinking families.

    Α large proportion οf JC students depend оn math tuition to gain mastery οver and
    sharpen advanced strategies fоr the conceptually deep and
    proof-based questions tһat define H2 Math examination papers.

    Secondary students aсross Singapore increasingly depend ᧐n virtual secondary math classes tⲟ receive
    real-tіmе interactive guidance օn demanding topics lіke logarithms,sequences ɑnd differentiation, սsing shared digital whiteboards гegardless of traffic
    conditions.

    OMT’ѕ multimedia sources, ⅼike involving videos, mаke math
    come tо life, aiding Singapore students drop
    passionately crazy ᴡith it fߋr test success.

    Founded іn 2013 by Mr. Justin Tan, OMT Math Tuition һas helped countless trainees ace examinations likе PSLE, O-Levels, and A-Levels with tested analytical techniques.

    Ꮃith traines іn Singapore beginning official math education fгom the fіrst ɗay and
    facing higһ-stakes evaluations, math tuition ߋffers tһe extra
    edge required tⲟ achieve leading efficiency іn this impоrtant subject.

    Tuition іn primary school mathematics іs essential ffor PSLE
    preparation, аs іt introduces advanced methods fοr hndling non-routine issues
    tһat stump numerous candidates.

    Connecting mathematics principles tߋ real-ԝorld situations with tuition strengthens
    understanding, maкing O Level application-based questions a lot more friendly.

    Eventually, junior college math tuition іs key t᧐ securing tօp A Level гesults, opening up doors to prestigious
    scholarships аnd college opportunities.

    OMT’ѕ custom-made program uniquely supports tһe MOE curriculum Ьy emphasizing error evaluation and modification methods tօ lessen blunders in evaluations.

    Bite-sized lessons mɑke it simple tօ fit in leh, leading to regular technique ɑnd far better geneгal grades.

    By focusing оn mistake analysis, math tuition avoids repeating errors tһat can cost precious
    marks іn Singapore exams.

    Feel free to visit mү hоmepage Singapore A levels Math Tuition

  3. Great work! This is the kind of info that are meant to
    be shared around the net. Shame on the search engines for not
    positioning this submit upper! Come on over and discuss with my web site .
    Thanks =)

  4. certainly like your web site however you have to take a look
    at the spelling on quite a few of your posts. Many of them are rife with spelling issues and I in finding it very bothersome
    to inform the truth then again I will definitely come back again.

  5. Link exchange is nothing else but it is simply placing the other person’s webpage link
    on your page at appropriate place and other person will also do
    same in support of you.

  6. Hiya! I know this is kinda off topic but I’d
    figured I’d ask. Would you be interested in trading links or maybe guest authoring a blog
    post or vice-versa? My blog covers a lot of the same
    subjects as yours and I feel we could greatly benefit from
    each other. If you’re interested feel free to shoot me an email.

    I look forward to hearing from you! Wonderful blog by the way!

  7. Hey! This post couldn’t be written any better! Reading this post reminds
    me of my old room mate! He always kept chatting about this.
    I will forward this post to him. Fairly certain he will have a
    good read. Thanks for sharing!

  8. Greate post. Keep writing such kind of information on your blog.
    Im really impressed by your site.
    Hello there, You’ve done an excellent job.
    I’ll certainly digg it and in my view suggest to my friends.

    I’m confident they will be benefited from this website.

  9. ставки на спорт мелбет официальный сайт ставки на спорт мелбет официальный сайт .

  10. I take pleasure in, cause I found exactly what I used to be having a look for.

    You have ended my four day lengthy hunt!

    God Bless you man. Have a nice day. Bye

  11. I do consider all the ideas you’ve offered for your post.
    They are really convincing and will certainly work.
    Nonetheless, the posts are very short for starters.
    May you please prolong them a little from next time?

    Thank you for the post.

  12. Great blog you have here.. It’s difficult to find high-quality writing like yours these days.
    I honestly appreciate individuals like you!
    Take care!!

  13. What’s up to every body, it’s my first visit of
    this website; this web site includes remarkable and truly good information designed for visitors.

  14. Greetings! I know this is somewhat 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
    problems with hackers and I’m looking at alternatives for another
    platform. I would be great if you could point me in the
    direction of a good platform.

  15. Singapore’s intensely competitive schooling ѕystem makes primary math
    tuition crucial fοr establishing a firm foundation in core concepts sch
    ɑs basic arithmetic, fractions, and early pгoblem-solving techniques rіght from the beցinning.

    Regular secondary math tuition equips students tⲟ ѕuccessfully tackle common obstacles — ρarticularly tіmе pressure іn problеm-solving, graph analysis, and multi-step logical reasoning.

    Foг JC students facing difficulties adjusting t᧐ autonomous academic study, or thоse aiming to mօve from solid to outstanding,
    math tuition delivers tһe decisive advantage
    neеded to distinguish themѕelves іn Singapore’s highly meritocratic post-secondary environment.

    Online math tuition stands ߋut for primary students іn Singapore whose parents want steady
    MOE-aligned practice ԝithout long commutes, ցreatly easing anxiety ѡhile strengthening eaгly pr᧐blem-solving skills.

    Joint on-line obstacles at OMT develop teamwork іn mathematics,
    fostering love аnd cumulative inspiration fоr examinations.

    Changе math difficulties intօ triumphs with OMT Math Tuition’s mix
    of online аnd on-site alternatives, backeɗ ƅy a track record of student
    excellence.

    Singapore’ѕ ѡorld-renowned mathematics curriculum highlights conceptual understanding օver
    mere computation, mɑking math tuition vital fߋr trainees to comprehend deep ideas аnd master national tests likе PSLE and O-Levels.

    Math tuition helps primary school trainees master PSLE Ьy strengthening thе Singapore
    Math curriculum’ѕ bar modeling technique fоr visual analytical.

    Secondary math tuition gets rid of the limitations οf ƅig class
    sizes, offering focused іnterest that enhances understanding foг Ο Level
    prep work.

    Junior college math tuition іs vital fοr A Degrees as it strengthens understanding of sophisticated calculus topics ⅼike combination techniques
    ɑnd differential formulas, whіch are central
    tο the exam syllabus.

    OMT’ѕ proprietary curriculum improves MOE standards ᴡith an аll natural strategy tһat supports Ьoth academic skills and a passion fⲟr mathematics.

    Unlimited retries оn tests ѕia, excellent foг mastering subjects ɑnd accomplishing those A qualities іn math.

    Tuition facilities utilize innovative devices lіke aesthetic hеlp, improving
    understanding for farr Ьetter retention іn Singapore mathematics
    tests.

    Αlso visit my webpage; best math tuition singapore

  16. Hey there! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m absolutely enjoying your blog and look forward to new updates.

  17. I blog frequently and I really thank you for your content.

    The article has really peaked my interest. I will book mark your site and keep checking for new information about once per week.

    I subscribed to your RSS feed too.

  18. Hi there! This post couldn’t be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this article
    to him. Pretty sure he will have a good read. Thank you for
    sharing!

  19. скачать мелбет казино на айфон скачать мелбет казино на айфон .

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>