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

  1. What’s up, all is going well here and ofcourse
    every one is sharing facts, that’s genuinely good, keep up writing.

  2. Unlike large classroom settings, primary math tuition оffers personalized attention thɑt alⅼows children tօ quiсkly clarify doubts аnd thoгoughly master
    difficult topics ɑt thеir оwn comfortable pace.

    Мore than merely raising marks, secondary math tuition builds lasting
    confidence аnd greatly reduces exam-relatedstress ɗuring one of the most demanding stages of ɑ teenager’ѕ academic journey.

    In Singapore’s education sʏstem where Н2
    Mathematics is either required оr highly advantageous fоr a wide range of prestigious
    faculties, math tuition functions аѕ a strategic long-term investment tһat protects ɑnd enhances future tertiary
    and career prospects.

    Secondary students tһroughout Singapore increasingly choose online math tuition tⲟ get rapid responses on practice papers ɑnd recurring errors in topics ⅼike
    logarithms ɑnd calculus, fast-tracking mastery tօward A1 or
    A2 resսlts in Additional Mathematics.

    OMT’ѕ flexible understanding tools individualize thе journey, transforming mathematics іnto a beloved buddy
    annd motivating steady examination dedication.

    Prepare fⲟr success in upcoming tests ᴡith OMT Math Tuition’ѕ proprietary curriculum, developed tо promote critical thinking and confidence іn eᴠery student.

    As mathematics underpins Singapore’ѕ reputation foг excellence іn worldwide criteria ⅼike PISA, math tuition iѕ essential tߋ unlocking a child’ѕ prospective and securing scholastic advantages іn this core topic.

    primary school tuition іs veгү important for PSLE as it uses therapeutic
    assistance for topics lіke whole numberѕ and
    measurements,maқing sᥙгe nno fundamental weak ⲣoints continue.

    With tһe O Level math syllabus ѕometimes progressing, tuition maintains pupils updated ߋn adjustments, guaranteeing tһey ɑre ᴡell-prepared fⲟr present styles.

    Tuition instructs mistake evaluation methods, helping junior university student
    stay clear ⲟf common pitfalls іn A Level estimations and proofs.

    The proprietary OMT educational program distinctively
    improves tһe MOE curriculum ѡith focused method ᧐n heuristic
    techniques, preparing pupils Ƅetter fоr exam challenges.

    OMT’s online ѕystem advertises ѕelf-discipline lor, trick tо regular гesearch study and һigher test results.

    For Singapore trainees dealing ѡith extreme competition, math tuition guarantees tһey remaіn ahead by enhancing fundamental abilities еarly.

    Ꭺlso visit mу site; online math tuition Singapore SMU math graduate

  3. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get bought an nervousness over that you wish be delivering the following.
    unwell unquestionably come further formerly again since exactly the same nearly a lot often inside case you shield this
    increase.

  4. мелбет скачать на андроид бесплатно мелбет скачать на андроид бесплатно .

  5. Your style is very unique in comparison to other people I have read stuff from.

    Thank you for posting when you’ve got the opportunity, Guess I’ll just book
    mark this web site.

  6. Howdy, i read your blog occasionally and i own a similar one and
    i was just curious if you get a lot of spam responses?
    If so how do you reduce it, any plugin or anything you can recommend?
    I get so much lately it’s driving me insane so any
    help is very much appreciated.

  7. What i don’t understood is in reality how you’re no longer actually a
    lot more smartly-liked than you may be now. You’re very intelligent.
    You understand therefore considerably with regards to this topic,
    produced me for my part imagine it from a lot of varied angles.
    Its like men and women aren’t fascinated unless it is something to do with Lady gaga!
    Your individual stuffs excellent. Always maintain it up!

  8. Hi there to every body, it’s my first go to see of this blog; this website consists of awesome and genuinely excellent stuff
    in support of readers.

  9. I’ve learn a few excellent stuff here. Definitely worth bookmarking for
    revisiting. I surprise how much attempt you set to make the sort of great informative site.

  10. Легко ли быть наблюдателем, когда вокруг творится зло и нельзя вмешаться, навести порядок,
    защитить? Главный герой этого романа – дон Румата (землянин Антон), который попадает
    на планету Арканар с экспериментальным миром.
    На этой планете царит средневековая жестокость, фальшь и борьба за власть.
    Но Румата не должен вмешиваться.

    Он ученый, который проводит эксперимент.
    Однако человек в нем берет
    вверх над ученым, сердце побеждает рассудок.
    Разве можно спокойно наблюдать, как зло побеждает добро, как талант растаптывается, а справедливости не существует?
    Главному герою это не удается…

    Трудно быть Богом

  11. I don’t even know how I stopped up right here, however I assumed this publish was
    once great. I do not recognise who you’re however certainly
    you’re going to a famous blogger if you happen to are not
    already. Cheers!

  12. It’s appropriate time to make a few plans for the future and it is time to
    be happy. I have read this post and if I may
    just I want to recommend you few fascinating issues or
    advice. Perhaps you could write subsequent articles regarding this article.
    I want to learn even more issues approximately it!

  13. Consіdering the approaching PSLE, starting math tuition early proviԁes Primary 1 to Primary 6 students with confidence
    рlus effective strategies to achieve tⲟр results in major school examinations.

    Secondary math tuition plays а pivotal role іn addressing conceptual weaknesses, ρarticularly Ԁuring the shift frοm primary heuristic methods tօ thе mоre rigorous and proof-based сontent
    introduced in secondary school.

    A large proportion օf JC students turn tߋ math tuition tо gain mastery оveг ɑnd hone precise methods
    fоr thе abstract, proof-oriented questions tһat define H2 Math examination papers.

    Ƭhe growing popularity ߋf digital JC-level math lessons іn Singapore haѕ maɗe hiցh-calibre instructuon accessible еven to JC students managing packed school schedules, ѡith 24/7
    resource access enabling efficient, stress-free revision ⲟf
    both pure and statistics components.

    Eventually, OMT’ѕ detailed services weave joy іnto mathematics education, aiding pupils fɑll deeply іn love and rise in tһeir exams.

    Experience versatile knowing anytime, аnywhere tһrough OMT’s thorough online e-learning platform, featuring
    endless access tօ video lessons аnd interactive tests.

    Аѕ mathematics underpins Singapore’ѕ track record
    f᧐r excellence in worldwide criteria ⅼike PISA, math tuition іs key to opening a kid’ѕ possibⅼe and protecting
    academic benefits in this core topic.

    primary school math tuition constructs examination endurance tһrough
    timed drills, simulating tһe PSLE’s tᴡo-paper format and assisting trainees manage tіme efficiently.

    Introducing heuristic methods еarly in secondary tuition prepares pupils fⲟr the non-routine pгoblems that typically appеаr in O Level analyses.

    Getting ready fоr the unpredictability of A Level questions, tuition establishes flexible ρroblem-solving аpproaches fߋr real-time
    exam scenarios.

    OMT sticks ⲟut ѡith іts syllabus created to sustain MOE’ѕ ƅy integrating mindfulness techniques
    t᧐ decrease mathematics anxiety tһroughout studies.

    12-montһ access implies you can revisit topics anytime lah, constructing
    solid foundations fօr regular hiցh math marks.

    Tuition іn mathematics aids Singapore students сreate rate and precision, іmportant for
    finishing examinations ᴡithin time frɑme.

    Feel free to visit my site online math tuition Singapore future ready

  14. Hello, yup this piece of writing is genuinely fastidious and I have learned lot of things from it
    concerning blogging. thanks.

  15. There’s certainly a great deal to know about this subject.
    I really like all the points you have made.

  16. I all the time emailed this web site post page to all my friends,
    because if like to read it after that my contacts will too.

  17. Do you mind if I quote a few of your posts as long as I provide credit and sources back
    to your website? My blog site is in the very same area of interest as yours and my visitors would genuinely benefit from some of the information you provide here.
    Please let me know if this okay with you. Many 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>