Upgrade to Pro — share decks privately, control downloads, hide ads and more …

通用JS时代的模块机制和编译工具

Dexter.Yy
December 18, 2010

 通用JS时代的模块机制和编译工具

Dexter.Yy

December 18, 2010
Tweet

More Decks by Dexter.Yy

Other Decks in Programming

Transcript

  1. • jQueryaYUIaMooToolsaሱ࠭षؿ֥ॿࡏ—— ҂๝֥ ս઒ቆᆮࢲܒa҂๝֥ࢤ१ڄ۬b • ࠒ৆༯֥ս઒Ⴕޓ఼֥၇ঠྟđФ९/ॿࡏඏںđ۲ᇕ ೶ᅐڄ۬đᆺିᄝหקߌ࣢৚گႨb • ଴Ⴟథ၍đ଴Ⴟܵ৘đ଴Ⴟٳཚđ଴ႿԮѬb •

    ۲ሱо૊ᄯӚ੽b ໙ี • భ؊षؿᄀটᄀӮඃđն؟ඔ๶ؒބཛଢ৚׻൐Ⴈਔ ੀྛ֥९ࠇॿࡏb • ሱദս઒९ᇯ҄ࠒ৆đᄀটᄀᇗ൪ս઒گႨބԎའٿ ል——бೂӈႨଆൔa۽ऎaUIቆࡱaࢌ޺ྛູb གྷሑ Sunday, December 19, 2010
  2. • ߌࢫᄀটᄀ؟đቓ൙ᄀটᄀ҂“ᆰࢤ”đषؿބҩ൫э ֤ઐِb • ݖӱ֥ڿࣉ҂ႋھᄹࡆषؿ֥ӮЧb • ݺ֥ݖӱႋھିႅҟگᄖྟđࡨഒԛհ֥ࠏ߶b • ؓս઒ܵ৘֥ေ౰۷ۚđս઒ೂޅٚь֥ٳ৖Ĥೂޅ ٚь֥טႨĤս઒ֆჭބ໓ࡱ֥৬؇ೂޅᅧ॥Ĥ

    ໙ี • ۽ቔੀӱ۷ህြ۷࿸ࣈ——ϱЧ॥ᇅaט൫a࣡෿཮ ဒaֆჭҩ൫aሱ׮ჹӱҩ൫aषؿߌ࣢/ҩ൫ߌ࣢/ ଆ୅ཌഈߌ࣢a࣡෿໓ࡱܵ৘aؿ҃༢๤…… གྷሑ Sunday, December 19, 2010
  3. • Ⴊ߄൭؍ླေٿልđླေ۽ऎ֥ᆦӻđڎᄵಸၞӮູ ߁ཟhack࠯ెބଊߘս઒֥ധძ…… • ۵ഈ၂۱໙ี৚ླေࡆ఼֥ս઒ܵ৘ԛགྷ઱؛Ćିٚ ьषؿaט൫aս઒گႨބົ޹֥ծീ vs ିิۚྟ ି֥ծീ——ࣜӈࢩಖཌྷّb •

    ေಃޙ……ေފྂ…… ໙ี • భ؊ྟିᄀটᄀ൳ᇗ൪bႪ߄ሙᄵ֤ܼ֞ٗႋႨb ——ࡨഒ౨౰ඔđ০Ⴈߏթđх૧ቅೖb • ᆷѓğ൮௠ൈࡗđTTIčႨ޼ॖࢌ޺భ֩րൈࡗĎ ——ླေ࿼ުaοླࡆᄛ֩൭؍b གྷሑ Sunday, December 19, 2010
  4. ༮ၬ֥ CommonJS • ၂สAPI • ၂ᇕܿ۬aླྀၰaࠇჿק • ၂۱൙ൌѓሙčde factoĎ •

    ૫ཟڛༀఖaም૫aଁ਷ྛބᛍফఖ৚ ֥JSषؿ • ଢѓğࡹഡJS֥ള෿༢๤čecosystemĎ <> de jure Sunday, December 19, 2010
  5. Է൓ದ֥ޑ৥ൎ • Kevin Dangoorᄝ09୍Ԛࡹ৫CommonJSษંቆ • uWhat Server Side JavaScript needsv

    • 09୍ࡆೆMozilla֥webषؿᆀ۽ऎ๶ؒb • 08୍10ᄅMozillaܦႛਔAjaxian֥Է൓ದDion AlmaerބBen Galbraithđࡹ৫षؿᆀ۽ऎൌဒ൩đ षؿݖSkywriter/BespinđKevin Dangoorགྷᄝ൞lead • ᄻᄝSitePen۽ቔđTurboGearsބPaverཛଢ֥Է൓ ದb Sunday, December 19, 2010
  6. DEMO: Safariঔᅚ • ۵Chromeঔᅚ٤ӈোරb • ಌكAPIބmoduleࠏᇅđषؿگᄖ ႋႨޓӹ৯b • Chromeഈି֏ളFirebugᆃဢ۳৯ ֥ᇗਈࠩঔᅚહĤ

    • ᆃ۱“૙୆๲׸”Ⴈਔhack൭؍Ҍ ିൌགྷđᄻࣜքྏAppleബނ҂๙ ݖ…… Sunday, December 19, 2010
  7. JSConf.euഈ֥Ѧ๭ JsConf 2009 DC JsConf 2009 Berlin JsConf 2010 DC

    JsConf 2010 Berlin JsConf 2011 DC Sunday, December 19, 2010
  8. ᇔႿ੽֞ڛༀఖ؊֥JS • Ryan Dahlᄝ09୍11ᄅ֥JSConfϣਟഈࢺ കਔNodeJS • ۵Aptana Jaxer֩ڛༀఖ؊JSཌྷбđ NodeJS֥ԛؿׄ҂๝đ෱఼ט֥൞ࠎႿ ൙ࡱ֥ၳ҄щӱđછׄ൞ѩؿބൌൈb

    • ҂ิ܂serverđط൞ิ܂ࠎԤഡീb • ০Ⴈv8ႄౣđФଦট۵erlangбྟିb • CommonJS࡙ಸൌགྷ Sunday, December 19, 2010
  9. ః෰ੀྛე࿽֥module • ၂۱໓ࡱࣼ൞၂۱module • Ⴈലૼეओ֝ೆམေ֥ת༆ • ҂߶ၩຓࠆ֤҂མေ֥ת༆ • ֝ೆభଆॶ҂߶ࢳ༅ᆳྛ •

    ҂๝֥໓ࡱႵ۲ሱ׿৫֥ଁ଀ॢࡗ • ଆॶ໓ࡱଽפҪ֥ଁ଀ॢࡗሇэӮଆॶؓའ • ଆॶ໓ࡱሱջ၇ঠྐ༏ ᛍফఖ৚֥JS҂ژކ಩ၩ၂่ Sunday, December 19, 2010
  10. ః෰ੀྛე࿽֥module • ၂۱໓ࡱࣼ൞၂۱module • Ⴈലૼეओ֝ೆམေ֥ת༆ • ҂߶ၩຓࠆ֤҂མေ֥ת༆ • ֝ೆభଆॶ҂߶ࢳ༅ᆳྛ •

    ҂๝֥໓ࡱႵ۲ሱ׿৫֥ଁ଀ॢࡗ • ଆॶ໓ࡱଽפҪ֥ଁ଀ॢࡗሇэӮଆॶؓའ • ଆॶ໓ࡱሱջ၇ঠྐ༏ ીႵཌྷܱ֥ലૼეओđᆺିႨၳ҄ ࡆᄛ໓ࡱ֥ٚൔଆ୅֝ೆི֥ݔ JSթᄝಆअቔႨთđ҂๝໓ࡱ߶܋ཚ๝၂۱ಆअଁ଀ॢࡗ ֝ೆᆭު҂ܵ୆མ҂མေđପ۱໓ࡱ৚֥ת༆߶ಆ҆ ᇿೆ֞֒భ֥ଁ଀ॢࡗ৚ ॖିႅൔ֥֝ೆޓ؟ಆअэਈđڭۂࠇྩڿ֒భ֥ଽಸ JS໓ࡱሱദ္҂Їݣ၇ঠྐ༏đೂݔႵյЇކѩᆭো֥ Ҡቔđ໡ૌॖି߶Ϝ၇ঠྐ༏ཿᄝਸ਼ຓ֥஥ᇂ໓ࡱ৚ ෮Ⴕ໓ࡱ၂ष൓׻߶ࢳ༅ᆳྛ ᛍফఖ৚֥JS҂ژކ಩ၩ၂่ ޓ଴ϜJS֥໓ࡱ֒ቔmoduleֆჭট൐Ⴈ Sunday, December 19, 2010
  11. ES5 Simple Modules • ۵CommonJS֥ܱ༢҂նđԛؿׄ҂๝ğSimple Modules and Current Modules •

    Վ์֥ҕაᆀğKris ZypčSitepen۽ӱഽđDojo܊ང ᆀĎđAlex RussellčDojoԷ൓ದĎđBrendan EichčJS Է൓ದĎ • Simple Modulesଢభߎᆺ൞“֟Ҥದิσ”čstrawman proposalĎ Sunday, December 19, 2010
  12. ES5 Simple Modules • ཨԢಆअؓའ • ࡙ಸၘթᄝ֥หྟބࣸս઒ • ҂෥ݝwebഈ֥Ⴈ޼ุဒބྟି •

    ௜߁֥ᇗܒࣸս઒ • ѓሙ֥ս઒ٳཚࠏᇅ ໡ૌॖၛ༵ࢹ࡫෰ૌ֥ଢѓğ Sunday, December 19, 2010
  13. RequireJS • ቔᆀJames BurkeđdojoषؿᆀđᄝMozilla۽ ቔb——۵CommonJSഠ౵৳༢ࣅૡ • ໡ᄻࣜत֤෱ᆺ൞௴๙֥script loaderđิ܂ οླࡆᄛۿିb •

    ପ۱ൈީ෱ߎᆺႵrequireٚم • ྍᄹࡆ֥defineٚمಞ෱ӁളᇉэđӮູ CommonJS֥ “AMD”ܿٓčAsynchronous Modules DefinitionĎ Sunday, December 19, 2010
  14. Asynchronous Modules • ҂໪ಙđ္҂൐Ⴈಆअଁ଀ॢࡗ • ሱദЇݣ၇ঠܱ༢ྐ༏đཁൕ֥ലૼ • ၇ঠ֥ଆॶሱ׮ᇿೆ֞ቔႨთ৚đдՎ׿৫ • ࡙ಸԮ๤֥Module

    Pattern • exportsބrequireЧദ္൞moduleđ֝ೆᆭ ުđս઒ڄ۬۵ڛༀఖ؊module၂ᇁ • ೂݔླေ֥moduleໃקၬđሱ׮ࡆᄛཌྷႋ֥ ໓ࡱb Sunday, December 19, 2010
  15. OzJS္൞ၳ҄ଆॶ֥࡙ಸൌགྷđ ԢՎᆭຓ֥Ⴊׄ • require.jsğ5.3K • oz.jsğ1.5K • ᇶေ֥ۿିބࢤ१ഡ࠹ປಆ၂ᇁđଆॶ ଀ӫčMRLĎ֥ႨمႵ҂๝֥ॉ੮ •

    OzJSေ౰Ⴈ .def ٚمཁൕ֥ലૼଆॶ໓ ࡱ֥URIđ؟۱ଆॶॖၛലૼູ๝၂۱໓ ࡱ Sunday, December 19, 2010
  16. OzJS֥ଽ҆ • defᆺᇿҨଆॶđ҂ᆳྛ಩ޅս઒đᄝླေ৫ख़൐Ⴈ֥ൈީҌᆳྛ ଆॶ֥Ԛ൓߄đളӮଆॶؓའ • ଆॶ֥Ԛ൓߄ս઒ᆺᆳྛ၂Ցb • ၇ঠܱ༢֥ຉ௪ࢲܒࣜӈ൞ඎሑമᇀຩሑ֥đླေ༵ቔധ؇Ⴊ༵ ֥ђ৥đ࠺੣ࢫׄሑ෿đቋުᅚषӮ၂۱ஆ྽ݖ֥ؒਙ •

    ђ৥ᇏೂݔმ֞ીႵᇿҨս઒ॶčࠇӫ۽ӌݦඔĎ֥ଆॶđ༵ၳ ҄ࡆᄛؓႋ֥໓ࡱđ۷ྍ࠹ඔఖb֩֞࠹ඔఖ݂ਬުᇗྍष൓ђ ৥b֒࠹ඔఖູਬ౏ђ৥ࢲඏުđҌष൓οඨ྽ᆳྛଆॶؒਙ • ଆॶ໓ࡱѩྛࡆᄛđᆺႵଆॶؓའބԚ൓߄ս઒ॶᆭࡗҌթᄝ၇ ঠܱ༢đଆॶ໓ࡱЧദ҂ႋھթᄝ၇ঠb • ؟۱ϱЧѩթൈđჰ൓ଆॶ଀ሱ׮ᆷཟቋྍϱЧ֥ଆॶ • ಸಧ၇ঠ஥ᇂԛհğޭ੻ໃᇿҨ֥ଆॶđ࿖ߌ၇ঠൈޭ੻ఃᇏ၂ ٚb Sunday, December 19, 2010
  17. Make it easier to share code, and people will share

    more. -- Dave Herman, “JavaScript needs modules” Sunday, December 19, 2010
  18. ીਔ…… • Twitter: http://twitter.com/dexteryy • Google buzzğhttp://www.google.com/profiles/dexter.yy • Blogğhttp://www.limboy.com •

    OzJSğhttps://github.com/dexteryy/OzJS • TUICompilerğhttps://github.com/dexteryy/TUICompiler Sunday, December 19, 2010