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.

3,619 thoughts on “Using RequireJS exports with CoffeeScript

  1. In fact no matter if someone doesn’t be
    aware of then its up to other visitors that they will help, so here
    it takes place.

  2. It’s a shame you don’t have a donate button! I’d most certainly
    donate to this outstanding blog! I suppose for now i’ll
    settle for bookmarking and adding your RSS feed to my Google account.
    I look forward to brand new updates and will share
    this blog with my Facebook group. Chat soon!

  3. It’s really a cool and useful piece of info. I’m glad that you simply shared this useful info with us.
    Please stay us informed like this. Thanks for sharing.

  4. By linking mathematics tߋ imaginative jobs, OMT awakens ɑan enthusiasm
    in trainees, motivating them to accept tһe subject аnd
    strive fⲟr examination mastery.

    Oⲣen your kid’ѕ fuⅼl potential in mathematics ԝith
    OMT Math Tuition’s expert-led classes, tailored t᧐ Singapore’ѕ
    MOE curriculum fоr primary, secondary, аnd JC trainees.

    Aѕ mathematics underpins Singapore’ѕ credibility for excellence in international criteria ⅼike PISA, math tuition іѕ crucial tо unlocking a child’s possible and protecting academic benefits іn tһis core subject.

    primary school school math tuition іs crucial fοr PSLE preparation аs it helps students master the foundational ideas ⅼike
    portions аnd decimals, which are heavily evaluated іn thе examination.

    Ӏn-depth responses from tuition trainers ߋn technique efforts aids secondary trainees
    fіnd out from mistakes, improving precision fοr
    tһe real O Levels.

    Junior college math tuition іs essential fօr A Levels ɑs it
    grows understanding օf innovative calculus topics ⅼike
    assimilation techniques аnd differential formulas, wһiϲh ɑгe central to the exam curriculum.

    Ԝhat sets OMT apɑrt is its customized syllabus that aligns with
    MOE while supplying adaptable pacing, enabling innovative
    trainees tօ increase their discovering.

    OMT’ѕ ѕystem motivates goal-setting ѕia, tracking landmarks tⲟwards achieving hіgher grades.

    Tuition exposes students tօ varied concern kinds, broadening
    tһeir preparedness for unforeseeable Singapore math exams.

    mу web site – math tutor neede new york

  5. These are genuinely fantastic ideas in on the topic of blogging.
    You have touched some fastidious factors here.
    Any way keep up wrinting.

  6. Hi there, just became alert to your blog through Google,
    and found that it’s truly informative. I’m gonna watch out for brussels.

    I’ll appreciate if you continue this in future. Numerous people will be benefited
    from your writing. Cheers!

  7. What’s up, I wish for to subscribe for this blog to get newest updates,
    therefore where can i do it please assist.

  8. Right now it sounds like Drupal is the best blogging platform available right now.
    (from what I’ve read) Is that what you are using on your blog?

  9. Hello there, You have done a fantastic job. I’ll
    definitely digg it and personally suggest to my friends.
    I’m confident they will be benefited from this
    site.

  10. Wow, awesome blog layout! How long have you been blogging for?
    you make blogging look easy. The overall look of your website is
    excellent, let alone the content!

  11. Fantastic beat ! I would like to apprentice while you
    amend your site, how can i subscribe for a blog site? The account aided me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast provided bright
    clear concept

  12. Τhrough timed drills tһat seem lіke adventures,
    OMT builds test endurance ԝhile growing love f᧐r
    thе subject.

    Dive іnto seⅼf-paced math mastery ѡith OMT’s 12-mοnth e-learning courses, ϲomplete ᴡith practice worksheets and
    taped sessions fօr comprehensive revision.

    Ιn a syѕtеm whеre mathematics education һɑѕ аctually evolved to cultivate
    innovation аnd worldwide competitiveness, registering іn math
    tuition guarantees trainees stay ahead ƅy deepening tһeir
    understanding and application օf crucial ideas.

    Ƭhrough math tuition, students practice PSLE-style questions оn averages аnd graphs, improving accuracy ɑnd speed
    under examination conditions.

    Regular mock Ο Level eexaminations in tuition settings replicate genuine conditions, enabling pupils tο
    fine-tune tһeir technique аnd lower errors.

    With A Levels affecting job courses іn STEM
    аreas, math tuition enhances foundational skills fοr future university researсh studies.

    Ꮤhat makeѕ OMT remarkable іs its exclusive educational program tһat lines
    սp with MOE wһile introducing visual һelp lіke
    bar modeling іn innovative methods fοr primary students.

    In-depth services offered ߋn thе internet leh, teaching yοu how to solve
    proƅlems correctly for much better qualities.

    Ԝith mathematics being a core topic tһаt influences oѵerall
    academic streaming, tuition aids Singapore trainees protect
    fɑr better qualities and brighter future possibilities.

    mʏ website :: h2 math tuition

  13. Do you have a spam problem on this site; I also am a blogger, and I was wanting to know your
    situation; many of us have developed some nice methods and we are looking to exchange strategies with others, please shoot me an e-mail if
    interested.

  14. No matter if some one searches for his essential thing,
    thus he/she desires to be available that in detail, so
    that thing is maintained over here.

  15. 順利在個人IG中曾公開表示,《奧林匹斯之門》是他每週固定必玩的一款電子機台。他推薦以下策略: 在奧林匹斯之門《Gates of Olympus™》中,每個符號的賠付計算方式都是根據符號出現的數量以及其對應的賠率來決定的。以下是一般的計算邏輯: 在奧林匹斯之門《Gates of Olympus™》中,倍數球是增強獎金的一大關鍵元素。每局開始時,當宙斯舉起閃電,代表倍數球即將出現,它會直接乘上當前旋轉所獲得的基礎獎金,從而顯著提高最終回報。 順利在個人IG中曾公開表示,《奧林匹斯之門》是他每週固定必玩的一款電子機台。他推薦以下策略: 在奧林匹斯之門《Gates of Olympus™》中,倍數球是增強獎金的一大關鍵元素。每局開始時,當宙斯舉起閃電,代表倍數球即將出現,它會直接乘上當前旋轉所獲得的基礎獎金,從而顯著提高最終回報。
    https://datosabiertos.lastorresdecotillas.es/user/tidatingpea1974
    在奧林匹斯之門《Gates of Olympus™》中,倍數球是增強獎金的一大關鍵元素。每局開始時,當宙斯舉起閃電,代表倍數球即將出現,它會直接乘上當前旋轉所獲得的基礎獎金,從而顯著提高最終回報。 奧林匹斯之門1000 使用 6×5 格式,採取 Pay Anywhere 機制,只要在轉軸上出現 8 個或以上相同符號即可中獎,無需傳統線路。遊戲特點是高波動設計,雖然中獎頻率不高,但一旦觸發連鎖反應或免費遊戲,獲利潛力極高。 Alex 深耕博弈與金融產業超過 10 年,專長於 娛樂城營運模式分析、合法牌照研究與產業趨勢追蹤。在 DUKER 賭博客,他負責撰寫 娛樂城評價與產業專題文章,幫助玩家了解不同平台的背景與可靠性。Alex 相信資訊透明能保護玩家,避免黑網詐騙。

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>