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.

18,974 thoughts on “Using RequireJS exports with CoffeeScript

  1. Oh my goodness! Awesome article dude! Many thanks, However I
    am going through problems with your RSS. I don’t understand why I cannot subscribe to it.
    Is there anybody getting identical RSS problems?
    Anyone that knows the answer will you kindly respond?
    Thanx!!

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

  3. We are a group of volunteers and starting a new scheme in our community.
    Your site offered us with useful information to work
    on. You’ve performed an impressive job and our
    entire group might be grateful to you.

  4. Hello everyone, it’s my first go to see at this web page, and post is genuinely
    fruitful in support of me, keep up posting these types of posts.

  5. What’s up all, here every one is sharing these kinds of experience, therefore it’s fastidious to read this webpage,
    and I used to visit this webpage all the time.

  6. I go to see daily a few web pages and information sites to read content,
    except this webpage gives quality based content.

  7. Superb blog! Do you have any tips for aspiring writers?
    I’m hoping to start my own blog soon but I’m a little lost on everything.
    Would you recommend starting with a free platform like WordPress or go for a paid option? There
    are so many choices out there that I’m totally confused ..
    Any recommendations? Cheers!

  8. Simply want to say your article is as surprising.

    The clarity for your publish is just excellent and that
    i could think you are knowledgeable in this subject.
    Fine with your permission allow me to clutch your feed to stay
    up to date with coming near near post. Thank you 1,000,000 and
    please continue the rewarding work.

  9. OMT’ѕ updated resources kеep mathematics fresh and inteгesting, inspiring Singapore students tⲟ
    accept іt wholeheartedly fօr examination triumphs.

    Unlock үoսr child’s full potential in mathematics wіth OMT Math Tuition’ѕ expert-led classes, tailored tߋ Singapore’s MOE
    syllabus foг primary, secondary, ɑnd JC students.

    Singapore’ѕ focus ߋn vital believing tһrough mathematics
    highlights tһe imⲣortance οf math tuition,
    whidh helps trainees establish tһe analytical skills required Ьy tһe nation’s forward-thinking curriculum.

    Tuition stresses heuristic ρroblem-solving techniques,
    impoгtant foг dealing ԝith PSLE’s difficult word issues that require multiple steps.

    Linking math concepts tо real-ѡorld scenarios through tuition strengthens understanding,
    maкing O Level application-based concerns mοre friendly.

    Tuition educates mistake evaluation methods,
    aiding junior university student ɑvoid common pitfalls іn A Level calculations andd proofs.

    OMT’ѕ exclusive educational program enhances MOE
    standards ѡith a holistic technique tһat nurtures both scholastic skills аnd ɑn enthusiasm fοr mathematics.

    12-mߋnth access meɑns yoᥙ cаn review subjects anytime lah, developing
    solid foundations fоr constant hiɡh math marks.

    Math tuition іn ⅼittle groups maкes cеrtain customized іnterest, frequently lacking іn larցe Singapore school
    courses fߋr examination prep.

    mу web рage … physics and maths tutor chemistry past papers

  10. Hola! I’ve been reading your site for a long time now and finally got the courage to go ahead and give you a shout out from Huffman Tx!
    Just wanted to mention keep up the great work!

  11. Link exchange is nothing else however it is only placing the other person’s website link on your page at suitable
    place and other person will also do similar in support of
    you.

  12. It’s difficult to find educated people about this
    topic, however, you sound like you know what you’re talking about!
    Thanks

  13. united kingdom real money online casino, free chip
    no deposit usa and paypal bingo sites uk, or trusted casino minimum deposit rm1 (Francisca) online usa

  14. Inot long ago wrote about how Jane decided to try Paybis to
    shift her money from her bank into crypto and
    then straight into her trading account, and honestly, her whole story turned out way more entertaining
    than anyone thought.

    Jane isn’t your regular crypto newbie. Fun fact:
    she collects tiny vintage globes and has exactly 27 of them lined
    up behind her desk. Another random thing is that she can solve
    a Rubik’s cube in under 40 seconds. So when she discovered Paybis, she approached it with the same energy
    — fast, efficient, and determined.

    According to her, she wanted a platform that wouldn’t “fight her
    back,” because her bank is already stressful
    enough. Paybis ended up being perfect: super user-friendly onboarding, easy deposit, and she was able to
    convert her bank funds into crypto in literally minutes.
    Jane even joked it was easier than ordering sushi.

    Once the crypto hit her wallet, she jumped straight into her trading platform — no delays.

    And because she’s Jane, she turned it into
    a personal speed-challenge. She measured how long
    every step took, and of course, she made a whole spreadsheet about it.
    Little detail: she names her spreadsheets after planets.

    What surprised her most was how Paybis didn’t overwhelm
    her with complicated menus. She likes things simple — after all, she once returned a coffee machine because it had “too many buttons.” So the clean process from bank → crypto →
    trading felt like a win.

    She mentioned that anyone wanting to try the same flow should check the link inside this comment, but she didn’t want to make
    a big deal of it. Just said it might be helpful.

    Overall, Jane’s whole experience using Paybis was smooth,
    surprisingly fun, and very “Jane-style” — structured, quirky,
    and full of little experiments.

    And if you want to see more details, she said the link in the comment explains
    everything a bit deeper, but that’s totally optional.

  15. I really like what you guys are usually up too.

    Such clever work and exposure! Keep up the superb works guys I’ve included you
    guys to blogroll.

  16. Hello i am kavin, its my first occasion to commenting anywhere,
    when i read this post i thought i could also create comment due to this brilliant piece of
    writing.

  17. Специалисты компании выполнят изготовление этикеток любого формата и сложности: тканых жаккардовых, деревянных, металлических, кожаных и проч.
    Чтобы хлопковы бирки для одежды не утратили своего первоначального вида и были износостойкими, мы используем только качественные материалы.

  18. Here’s a quick share of how Jane decided to try Paybis to move her
    money from her bank into crypto and then straight into her trading account, and honestly, her whole story
    turned out way more entertaining than anyone thought.

    Jane isn’t your regular crypto newbie. Funny thing — she
    collects tiny vintage globes and has exactly 27 of them lined up behind her desk.
    Another random thing is that she can solve a Rubik’s cube in under 40 seconds.
    So when she discovered Paybis, she approached it with the same energy — fast, efficient, and determined.

    According to her, she wanted a platform that wouldn’t “fight her
    back,” because her bank is already stressful enough.
    Paybis ended up being perfect: smooth verification, easy deposit, and she was able to convert
    her bank funds into crypto in literally minutes. She laughed saying
    it was easier than ordering sushi.

    Once the crypto hit her wallet, she jumped straight into her trading platform
    — everything happening instantly. And because she’s Jane,
    she turned it into a personal speed-challenge.
    She measured how long every step took, and of course, she made a whole spreadsheet about it.

    Another fun fact: she color-codes everything in her life.

    What surprised her most was how Paybis didn’t overwhelm her with
    complicated menus. She likes things simple — after all, she
    once returned a coffee machine because it had “too many buttons.” So the clean process from bank →
    crypto → trading felt like a win.

    She mentioned that anyone wanting to try the same flow should check the
    link inside this comment, but she didn’t want to make a big deal of it.

    Just said it might be helpful.

    Overall, Jane’s whole experience using Paybis was smooth,
    surprisingly fun, and very “Jane-style” — structured, quirky, and full of little experiments.

    For anyone interested, she said the link in the comment explains everything
    a bit deeper, but that’s totally optional.

  19. You’re so interesting! I do not think I’ve truly read
    something like this before. So nice to find someone with some original thoughts on this subject.
    Really.. thanks for starting this up. This website is one thing that is needed on the
    internet, someone with some originality!

  20. Aw, this was a really nice post. Taking a few minutes and actual effort to produce a superb article… but what can I say… I hesitate a whole
    lot and never seem to get nearly anything done.

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>