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.

19,013 thoughts on “Using RequireJS exports with CoffeeScript

  1. Today, while I was at work, my cousin stole my iphone and tested to see if it can survive a 40 foot drop,
    just so she can be a youtube sensation. My apple ipad is now
    broken and she has 83 views. I know this is completely off topic but I had to share it with someone!

  2. Hola! I’ve been following your web site for a long time now and finally got the
    courage to go ahead and give you a shout out from Porter
    Tx! Just wanted to tell you keep up the fantastic work!

  3. It’s amazing in favor of me to have a website, which is beneficial
    designed for my know-how. thanks admin

  4. certainly like your website but you need to test 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 reality on the other hand I’ll certainly come back again.

  5. I don’t even know how I stopped up right here, however
    I assumed this submit was good. I do not know who you’re however definitely you’re going to a well-known blogger when you aren’t already.
    Cheers!

  6. With havin so much content and articles do you ever run into any issues of plagorism or copyright
    violation? My blog has a lot of unique content I’ve
    either written myself or outsourced but it appears a lot of it is popping it up all over the internet without my agreement.
    Do you know any ways to help reduce content from being ripped off?
    I’d really appreciate it.

  7. Its such as you learn my thoughts! You seem to grasp so
    much approximately this, such as you wrote the e-book
    in it or something. I feel that you simply can do with a few
    p.c. to pressure the message house a bit, however other than that, this is
    excellent blog. A fantastic read. I will definitely be back.

  8. With unrestricted access tⲟ exercise worksheets, OMT equips students tⲟ grasp math tһrough rep, building love f᧐r
    tһе subject and examination confidence.

    Enroll tοdaү іn OMT’s standalone е-learning programs and enjoy yoսr grades soar througһ limitless access
    tⲟ top quality, syllabus-aligned material.

    Αs mathematics underpins Singapore’ѕ track record fоr
    quality іn international standards lioe PISA, math tuition іs crucial to opening a child’s prospective аnd protecting scholastic benefits іn this core subject.

    primary math tuition builds test stamina thrоugh timed drills, imitating tһе PSLE’s two-paper format and assisting
    students handle time efficiently.

    Ⲣresenting heuristic methods eаrly in secondary tuition prepares trainees for
    tһе non-routine prоblems that typically аppear іn O Level evaluations.

    Ultimately, junior college math tuition іs vital to protecting toρ A Level
    results, opening uⲣ doors to distinguished scholarships аnd college possibilities.

    OMT sticks out with its exclusive math educational program, tһoroughly designed tօ complement the Singapore MOE syllabus
    Ƅy filling in theoretical spaces tһɑt common school lessons mɑy ignore.

    Recirded sessions іn OMT’s ѕystem aⅼlow уou
    rewind аnd replay lah, ensuring yoᥙ understand every principle for excellent
    test resᥙlts.

    Math tuition іn smаll teams ensures personalized focus, commonly lacking іn lаrge Singapore school classes fοr test prep.

    My website :: make money through maths tuition

  9. Wow, that’s what I was looking for, what a information! present here at
    this web site, thanks admin of this website.

  10. Hmm is anyone else experiencing problems with the pictures on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  11. Thanks for the good writeup. It in truth was once a entertainment account it.
    Glance advanced to far delivered agreeable from you!
    However, how can we keep up a correspondence?

  12. I don’t even know the way I ended up here, but I assumed this post was once great.
    I don’t recognize who you are but definitely you’re going
    to a well-known blogger in the event you are not already.
    Cheers!

  13. Howdy! This post couldn’t be written any better!

    Reading through this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this post to him.
    Fairly certain he will have a good read. Thank you for sharing!

  14. 1C-Bitrix: Управление сайтом — редакция Стандарт — это мощная платформа для создания и управления корпоративными сайтами. Переходите по запросу Битрикс Стандарт стоимость. Подходит для компаний, которым нужен функциональный сайт с каталогом, формами, SEO-инструментами и удобной системой администрирования. Решение обеспечивает высокую безопасность, производительность и гибкость масштабирования бизнеса в интернете.

  15. My relatives every time say that I am killing my time here
    at net, but I know I am getting knowledge all the time by reading thes pleasant content.

  16. Hi there to all, how is everything, I think every one is
    getting more from this site, and your views are fastidious
    in favor of new viewers.

  17. Your style is unique compared to other people I have read stuff
    from. Many thanks for posting when you have the opportunity,
    Guess I’ll just book mark this page.

  18. legal gambling sites in australia, free 10 no deposit casino
    usa and australian online no deposit casino, or most legit online casino united states

    Visit my webpage: golden nugget roulette chips, Aracely,

  19. Its not my first time to visit this website, i am visiting this web site dailly and get good facts from here
    daily.

  20. I simply could not go away your website before suggesting that I really loved the standard info a person provide in your guests?
    Is going to be back regularly to check up on new posts

  21. OMT’s standalone e-learning choices empower independent exploration, nurturing ɑn individual love for mathematics аnd exam ambition.

    Discover tһe convenience of 24/7 online math tuition аt OMT, ᴡhere appealing resources mаke discovering fun аnd reliable for aⅼl levels.

    Wіth math integrated flawlessly int᧐ Singapore’s classroom settings tо benefit
    both teachers and trainees, committed math tuition enhances tһesе gains ƅy offering customized
    support fⲟr sustained achievement.

    Ƭhrough math tuition, students practice PSLE-style concerns
    оn averages and graphs, enhancing precision ɑnd speed ᥙnder test
    conditions.

    Linking mathematics ideas tօ real-worlԁ circumstances witһ tuition grows understanding, mаking O Level application-based concerns mߋre approachable.

    Planning for the unpredictability ߋf A Level concerns, tuition develops flexible ρroblem-solving methods fοr real-timе exam scenarios.

    OMT’ѕ custom-designed educational program distinctively boosts tһe
    MOE structure Ьy supplying thematic systems tһаt
    attach math topics ɑcross primary to JC degrees.

    OMT’ѕ on the internet ѕystem advertises seⅼf-discipline lor, secret to regular reseɑrch study
    ɑnd higher exam outcomes.

    Tuition centers іn Singapore concentrate օn heuristic techniques,
    essential fоr tackling tһe difficult woprd рroblems іn mathematics exams.

    Feel free tⲟ surf to my website … h2 math private tuition

  22. Wanted to drop a long note 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 unexpected 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.

    As she told me, 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.
    Jane even joked it was easier than ordering sushi.

    Once the crypto hit her wallet, she jumped straight into her trading platform — zero friction. And because she’s Jane, she
    turned it into a personal speed-challenge. She kept notes on each step, 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 casually dropped 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.

    In the end, Jane’s whole experience using Paybis was refreshingly easy, 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.

  23. Hey there! Do you use Twitter? I’d like to follow you if that would be
    okay. I’m definitely enjoying your blog and
    look forward to new posts.

  24. Casino X поддерживает связь с игроками через телеграм. Подписывайтесь на канал: https://t.me/casinox2026 для получения бонусов и зеркал.

  25. What i do not understood is in fact how you are now
    not actually a lot more neatly-preferred than you might be now.
    You are very intelligent. You already know thus considerably
    in relation to this subject, made me personally imagine it from so many various angles.
    Its like men and women are not involved until it’s one thing to do
    with Girl gaga! Your individual stuffs outstanding. All the time
    handle it up!

  26. Hey just wanted to give you a quick heads up and let you know a few of
    the images aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different internet browsers and both show the same results.

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>