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

jsx2js_js2jsx

 jsx2js_js2jsx

天下一ajtjs武闘会LT発表資料

Yosuke Furukawa

June 08, 2014
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. JSX͸ܕ͕͋ΔaltJS interface Animal {// interfaceΛఆٛͰ͖Δ function say () : void;

    } ! class Duck implements Animal { // interfaceΛimplementsͰ͖Δ override function say () : void {// ࣮૷ log("quack!"); } } ! class Dog implements Animal { override function say () : void { log("bow!"); } }
  2. JSX͸ܕ͕͋ΔaltJS interface Animal {// interfaceΛఆٛͰ͖Δ function say () : void;

    } ! class Duck implements Animal { // interfaceΛimplementsͰ͖Δ override function say () : void {// ࣮૷ log("quack!"); } } ! class Dog implements Animal { override function say () : void { log("bow!"); } } طଘͷJSΛ࢖͏ʹ͸binding͕ඞཁʂʂ
  3. JSXόΠϯσΟϯάͷॻ͖ํ native class JSON5 { static function parse(str:string) : variant;

    static function stringify(json:variant) : string; } = "require('json5')"; ͜͜ʹ+BWB4DSJQUͰ࣮૷Λॻ͚Δ ܕఆٛΛॻ͘
  4. JSXόΠϯσΟϯά͸୯ͳΔόΠϯσΟϯά͡Όͳ͍ native class JSON5 { static function parse(str:string) : variant;

    static function stringify(json:variant) : string; static function strictParse (st:string) : variant; } = """ (function(){ var json5 = require(‘json5’); var json5x = { parse : json5.parse, stringify : json5.stringify, strictParse : JSON.parse }; return json5x; }()); """; ৽͍͠ػೳ௥Ճͨ͠Γɺ ΠϯλϑΣʔεม͑ͨΓɺ όΠϯσΟϯά͡Όͳ͘ ͯϥούʔʹ͍ۙ
  5. JSX-linkerΛ࢖͏ // require͔ΒಡΊΔΑ͏ʹͳΔɻ $ jsx test.jsx | jsx-linker -t commonjs-lib

    --stdin -o test.js // global͔ΒಡΊΔΑ͏ʹͳΔ $ jsx test.jsx | jsx-linker -t export-global --stdin -o test.js // amd͔ΒಡΊΔ $ jsx test.jsx | jsx-linker -t amd-lib --stdin -o test.js // closure compiler ͔Β $ jsx test.jsx | jsx-linker -t closure-lib --stdin -o test.js // webworker͔Β $ jsx test.jsx | jsx-linker -t webworker --stdin -o test.js
  6. JSX-linkerΛ࢖͏ // require͔ΒಡΊΔΑ͏ʹͳΔɻ $ jsx test.jsx | jsx-linker -t commonjs-lib

    --stdin -o test.js // global͔ΒಡΊΔΑ͏ʹͳΔ $ jsx test.jsx | jsx-linker -t export-global --stdin -o test.js // amd͔ΒಡΊΔ $ jsx test.jsx | jsx-linker -t amd-lib --stdin -o test.js // closure compiler ͔Β $ jsx test.jsx | jsx-linker -t closure-lib --stdin -o test.js // webworker͔Β $ jsx test.jsx | jsx-linker -t webworker --stdin -o test.js cool isn’t it !? :D