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

  1. В этой статье рассматриваются различные аспекты избавления от зависимости, включая физические и психологические методы. Мы обсудим поддержку, мотивацию и стратегии, которые помогут в процессе выздоровления. Читатели узнают, как преодолеть трудности и двигаться к новой жизни без зависимости.
    Уникальные данные только сегодня – Похмельная служба Краснодар

  2. Этот обзор сосредоточен на различных подходах к избавлению от зависимости. Мы изучим традиционные и альтернативные методы, а также их сочетание для достижения максимальной эффективности. Читатели смогут открыть для себя новые стратегии и подходы, которые помогут в их борьбе с зависимостями.
    Где можно узнать подробнее? – стоп алко краснодар

  3. I don’t know if it’s just me or if perhaps everyone else experiencing problems with your website.

    It appears like some of the written text in your content are running off the screen. Can somebody else please provide feedback and let me know
    if this is happening to them too? This might be a issue with my web browser because I’ve had this happen previously.

    Thank you

  4. Everything is very open with a precise description of the issues.
    It was definitely informative. Your site is very helpful.
    Thanks for sharing!

  5. Hiya! Quick question that’s totally off topic. Do you know how to make your site mobile friendly?
    My website looks weird when viewing from my iphone 4.
    I’m trying to find a theme or plugin that might be able to correct this issue.
    If you have any suggestions, please share. Cheers!

  6. من خودم خیلی حرفه‌ای نیستم و
    بیشتر از زاویه یک کاربر کنجکاو این سایت رو
    بررسی کردم. سلام، چون چند وقتیه درباره این فضا
    کنجکاو شدم گفتم اینجا هم نظرم رو ثبت کنم.
    دیروز وقتی می‌خواستم قبل از
    هر تصمیمی اطلاعات بیشتری داشته باشم به این سایت رسیدم.
    اولش حس کردم برای آشنایی اولیه می‌تونه مفید باشه.
    راستش برای من مهمه که شفافیت اطلاعات خیلی مهمه.
    یکی از بچه‌ها قبلاً درباره بازی انفجار زیاد سوال می‌پرسید.
    برای همین من هم با دقت بیشتری بررسی کردم.

    از نظر من نکته مثبتش این بود که متن‌ها خیلی خشک و تبلیغاتی
    نبودن. ولی خب هنوز هم جای بررسی بیشتر وجود داره.
    برای افرادی که قصد دارن قبل از شروع
    اطلاعات بیشتری داشته باشن به موضوع
    کازینو آنلاین علاقه دارن، ارزش
    یکنگاه دقیق‌تر رو داره. گاهی
    هم اسم‌هایی مثل enfejaronline آنلاین در کنار sibbet.com برای خیلی‌ها تبدیل به
    اسم‌های آشنا شدن. یکی از بچه‌ها که اسمش مهدی بود، می‌گفت مشکل خیلی از
    سایت‌ها اینه که فقط شعار می‌دن ولی توضیح درست نمی‌دن؛ برای
    همین من هم بیشتر به متن‌ها دقت کردم.
    جمع‌بندی من اینه که ارزش وقت گذاشتن داشت.
    فکر می‌کنم منطقی‌تره عجله نکنه و چند گزینه رو مقایسه کنه.

    جمع‌بندی من اینه که تجربه بدی نبود و حداقل برای آشنایی اولیه ارزش وقت گذاشتن داشت،
    مخصوصاً اگر کسی بخواد قبل از
    تصمیم‌گیری دید بهتری پیدا کنه.

    Here is my web-sitе: سوالات متداول در مورد تعبیر خواب تخته نرد

  7. Эта публикация исследует взаимосвязь зависимости и психологии. Мы обсудим, как психологические аспекты влияют на появление зависимостей и процесс выздоровления. Читатели смогут понять важность профессиональной поддержки и применения научных подходов в терапии.
    Это ещё не всё… – Наркологическая клиника «Похмельная служба» в Краснодаре

  8. It’s really a cool and helpful piece of information. I’m satisfied
    that you just shared this helpful information with us.
    Please keep us up to date like this. Thanks
    for sharing.

  9. Heya i am for the first time here. I came
    across this board and I to find It really helpful & it helped me out much.
    I’m hoping to give one thing back and aid others like you aided me.
    betflik

  10. I really like it when individuals get together and share views.
    Great site, keep it up!

  11. В статье рассматриваются различные стратегии борьбы с зависимостями включая проверенные методы и реальные истории успеха. Читатель узнает какие подходы наиболее эффективны и как начать путь к выздоровлению. Изучить аспект более тщательно – стоп алко краснодар

  12. Thanks , I have recently been searching for information approximately this topic
    for a while and yours is the greatest I have found out till
    now. However, what in regards to the conclusion? Are you positive
    concerning the source?

  13. Обзор посвящён процессу восстановления после зависимостей. Мы расскажем о различных этапах реабилитации, поддерживающих ресурсах и важности мотивации в достижении устойчивого выздоровления.
    Лови подробности – «Похмельная служба» в Краснодаре

  14. Эта статья освещает различные аспекты освобождения от зависимости и пути к выздоровлению. Мы обсуждаем важность осознания своей проблемы и обращения за помощью. Читатели получат практические советы о том, как преодолевать трудности и строить новую жизнь без зависимости.
    Связаться за уточнением – Похмельная служба в Краснодаре

  15. Текст посвящён распространённым мифам о зависимости и их развенчанию. Мы предоставим научно обоснованную информацию и дадим рекомендации по выбору эффективного способа борьбы с зависимым поведением.
    Читать полностью – стоп алко краснодар

  16. В этой статье мы рассматриваем разные способы борьбы с алкогольной зависимостью. Обсуждаются методы лечения, программы реабилитации и советы для поддержки близких. Читатели получат информацию о том, как преодолеть зависимость и добиться успешного выздоровления.
    Читать далее > – капельница от запоя на дому

  17. Этот краткий обзор предлагает сжатую информацию из области медицины включая ключевые факты и последние новости. Мы стремимся сделать информацию доступной и понятной для широкой аудитории что позволит читателям оставаться в курсе актуальных событий в здравоохранении. А что дальше? – стоп алко краснодар

  18. Hello There. I found your weblog the usage of msn. This is a really well written article.
    I will make sure to bookmark it and return to
    read more of your useful information. Thank you for the post.

    I will certainly return.

  19. Hi! I know this is kinda off topic but I wass wondering which blog platform are you using for this site?
    I’m getting sick and tired of WordPress because I’ve had problems with hwckers and I’m looing aat options for
    another platform. I would be great if you could point
    me in thee direction of a good platform.

  20. Minedrop — захватывающий слот в стиле Minecraft!
    Копайте блоки, собирайте ресурсы и выигрывайте крупные призы.

    Уникальная механика падающих символов создаёт цепочки побед слот майндроп.
    Погрузитесь в пиксельный мир приключений и богатств!

  21. Way cool! Some very valid points! I appreciate you penning this
    post and the rest of the site is very good.

  22. Hello there! I could have sworn I’ve been to this site before but after
    going through some of the articles I realized it’s new to
    me. Nonetheless, I’m certainly delighted I
    discovered it and I’ll be bookmarking it and checking back regularly!

  23. Hello there! This is kind of off topic but
    I need some advice from an established blog.
    Is it difficult to set up your own blog? I’m not very techincal but I can figure
    things out pretty fast. I’m thinking about making my own but I’m
    not sure where to begin. Do you have any tips or suggestions?
    Thank you

  24. Wonderful blog! Do you have any suggestions for aspiring writers?
    I’m planning to start my own blog soon but I’m a little lost on everything.

    Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m totally overwhelmed ..

    Any tips? Bless you!

  25. โพสต์นี้ ให้ข้อมูลดี ค่ะ
    ผม ไปเจอรายละเอียดของ ข้อมูลเพิ่มเติม
    สามารถอ่านได้ที่ Minnie
    สำหรับใครกำลังหาเนื้อหาแบบนี้
    มีตัวอย่างประกอบชัดเจน
    ขอบคุณที่แชร์ บทความคุณภาพ นี้
    และอยากเห็นบทความดีๆ แบบนี้อีก

  26. I was wondering if you ever considered changing the page layout of your website?
    Its very well written; I love what youve got to say. But maybe
    you could a little more in the way of content
    so people could connect with it better. Youve got an awful
    lot of text for only having one or two pictures. Maybe you could space it out better?

  27. Hello everyone I came across a 174 very cool site that I think you should take a look at. This platform is packed with a lot of useful information that you might find helpful. It has everything you could possibly need so be sure to give it a visit https://themazatlanpost.com/2022/10/01/game-development-with-unity/ And remember not to forget guys which a person at all times are able to within this piece find responses for your the absolute tangled queries. The authors tried to lay out all data using the most understandable way.

  28. справка от гематолога купить справка от гематолога купить спб

  29. You really make it seem so easy with your presentation but I find this matter to be actually something that
    I think I would never understand. It seems too complex and extremely broad for me.
    I am looking forward for your next post, I’ll
    try to get the hang of it!

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>