Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
一休.comにおけるfrontend開発
Search
yusuke sasajima
March 29, 2016
1.3k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
一休.comにおけるfrontend開発
yusuke sasajima
March 29, 2016
More Decks by yusuke sasajima
See All by yusuke sasajima
一休.com を支えるデータ分析基盤
zimathon
3
6.3k
SQLアンチパターン勉強会 #2
zimathon
0
390
Featured
See All Featured
New Earth Scene 8
popppiees
3
2.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
360
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
790
Code Review Best Practice
trishagee
74
20k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
440
Tell your own story through comics
letsgokoyo
1
1k
Leo the Paperboy
mayatellez
8
2.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
590
Transcript
Ұٳ.comʹ͓͚Δϑϩϯ τΤϯυ։ൃʢϞμϯฤʣ גࣜձࣾҰٳ ౡ༞հ @zimathon
ΞδΣϯμ • WebForms => .NET MVCͷҠߦ • ϑϩϯτΤϯυपΓͷٕज़ͷಋೖʹ͍ͭͯ • TypescriptΛ࠾༻ͨ͠ཧ༝
• ͦͷޙͲ͏ͳ͔ͬͨ • ৽͍ٕ͠ज़ΛεϜʔζʹಋೖ͢Δʹ
ࣗݾհ • ౡ ༞հ (@zimathon) • ॓ധࣄۀຊ෦ɹγεςϜ։ൃ෦ • Engineering Manager
WebForms => .NET MVC
෦తʹϦχϡʔΞϧ • ೝূαʔϏε • ձһೝূपΓ͚ͩΛΓग़ͯ͠ɺMVCԽ • Outboundʢւ֎ϗςϧ༧αΠτʣ • ৽αʔϏεʢ͜͏͍͏ͷద༻͍͢͠ʣ
৽͘͠࠾༻ٕͨ͠ज़ • Typescript • ࠷ۙ1.8.7ʹ͋͛·ͨ͠ • Sass/Compass • bower •
gulp
ΫϥΠΞϯτڥߏஙํ๏ • batϑΝΠϧͰߏங • Ұٳͷ։ൃڥ࡞࣌ʹɺ୭͕͠Ұ࣮ ߦ͢ΔbatϑΝΠϧ • choco, npm ʹΑΓΠϯετʔϧ͞Ε·͢
• node.js, gulp, Typescript, sass, etc…
࣮ࡍͷbatϑΝΠϧʢҰ෦ʣ @call npm -g list | findstr /I "
[email protected]
" >
nul 2>&1 @if errorlevel 1 ( %LOGGER% "### Installing TypeScript with npm." @call npm install -g
[email protected]
>> %LOGFILE% 2>&1 ) else ( %LOGGER% "### typescript is installed." ) @call npm -g list | findstr /I "gulp" > nul 2>&1 @if errorlevel 1 ( %LOGGER% "### Installing gulp with npm." @call npm install -g gulp >> %LOGFILE% 2>&1 ) else ( %LOGGER% "### gulp is installed." ) @call npm -g list | findstr /I "
[email protected]
" > nul 2>&1 @if errorlevel 1 ( %LOGGER% "### Installing bower with npm." @call npm install -g
[email protected]
>> %LOGFILE% 2>&1 ) else ( %LOGGER% "### bower is installed." )
Lintಋೖ • TypeScript Lint • Scss Lint • ΄΅σϑΥϧτͷઃఆͰӡ༻͍ͯ͠·͢
bower.json { "name": "Ikyu", "dependencies": { "jquery": "~1.11.3", "underscore": "~1.8.3",
"js-sha256" : "~0.3.0" } }
TypeScriptͷϏϧυʢൈਮʣ var gulp = require('gulp'); var typescript = require('gulp-typescript'); var
uglify = require('gulp-uglify'); var sourcemaps = require('gulp-sourcemaps'); var plumber = require('gulp-plumber'); var notify = require('gulp-notify'); exports.createGulpTask = function (subDir, taskName) { return function () { gulp.src([INPUT_ROOT_DIR + subDir + taskName + '.ts']) .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')})) .pipe(sourcemaps.init()) .pipe(typescript(createTypeScriptConfig(taskName + '.js'))) .js .pipe(uglify()) .pipe(sourcemaps.write('.', { sourceRoot: INPUT_ROOT_DIR })) .pipe(gulp.dest(OUTPUT_ROOT_DIR + subDir)); } }
SassͷϏϧυʢൈਮʣ var gulp = require('gulp'); var compass = require('gulp-compass'); var
plumber = require('gulp-plumber'); var notify = require('gulp-notify'); exports.createGulpTask = function (subDir, taskName) { return function(){ gulp.src(INPUT_ROOT_DIR + subDir + taskName + '.scss') .pipe(plumber({errorHandler: notify.onError('Error: <%= error.message %>')})) .pipe(compass({ config_file: INPUT_ROOT_DIR + 'config.rb', comments: false, css: OUTPUT_ROOT_DIR, sass: INPUT_ROOT_DIR })); } }
࠷ۙͷํੑ • bowerΛ֎͍ͨ͠ • ຊʹඞཁͳநԽϨΠϠʔͳͷ͔ • ϑϩϯτͷϥΠϒϥϦnpmʹἧ͖ͬͯͨ • TypescriptΛطଘͷαʔϏεʹల։͍͖ͯͨ͠ ͍
ϑϩϯτΤϯυपΓͷٕज़ͷ ಋೖʹ͍ͭͯ
None
Γ͍͕ͨͭҾͬுΔελΠϧ • ͋Ε͍Ε͍ͨɺ͜ΕΓ͍ͨΛ࣮ݱ͢Δҝʹ ओಋతʹಈ͘ • νʔϜͱͯ͠։ൃΛਐΊΔҎ্ɺಓࢣͱ͠ ͯؤுΔ • શମͷҙࢥܾఆʹؔͯ͠Λ࣋ͭ
TypescriptΛ࠾༻ͨ͠ཧ༝
Google TrendsΑΓ
ݱঢ়ͷ՝ • ॓ധαΠτϦϓϨΠεͯ͠ɺ6͕ܦա • ൃੜͨ͠՝ • ࠶ར༻͞Εͳ͍ؔʢྨࣅ͕ؔଟ͍ʣ • Ͳ͔͜Βࢀর͞Ε͍ͯΔ͔Θ͔Βͳ͍jsϑΝΠϧ •
1ϖʔδͰࢀর͢ΔjsϑΝΠϧ͕ଟ͗͢Δ • jqueryґଘʢjqueryϥΠϒϥϦଟਿʣ • ΈΜͳ͖উखʹೖΕͯ͠·ͬͯɺԿ͕ਖ਼͍͠ͷ͔Θ͔Βͳ͍ • ࠞࡏ͢Δjqueryͷόʔδϣϯ • lint͕ྲྀͤͳ͍ɻɻɻ
۩ମతͳΞΫγϣϯΛͯ͜͠ ͳ͔ͬͨ
࣮ࡍͷϖʔδͰࢀর͢Δjs
࣮ࡍͷϖʔδͰࢀর͢Δjs
ʊਓਓਓʊ ʼɹ27%ɹʻ ʉY^Yʉ
Α͋͘Δձ ৽ਓʮ͜ͷjsͬͯͳΜͰ͜͜ͰಡΈࠐ·ΕͯΔΜ Ͱ͚ͨͬ͠ʁʯ ϕςϥϯʮͦΕͲ͔͜ΒΑΕͯͳ͍Αʯ ৽ਓʮͳΔ΄Ͳɻ(͡Ό͋ফͯ͘͠ΕΑʂʣʯ
ͳͥTypescript͔ʁ • ࣾͷϑϩϯτΤϯυྗͷ࣮ • ͦΕ΄Ͳߴ͍ͷͰͳ͍ • babelͳͲΛಋೖͯ͠ɺՌ͖ͨͯͬͪ͠Γӡ༻Ͱ͖Δ͔Ͳ ͏͔ • ݴޠʹΑΔ੍ΛͨͤΔ͖
• ܕʹΑΔνΣοΫ • ׳Ε͍ͯΔΫϥεϕʔεͰॻ͚Δ
• Visual Studioͱͷ૬ੑ • VisualStudioCode͍͍͘͢͝Ͱ͢ΑͶʂ • Ϟδϡʔϧ࠶ར༻͍͢͠ • ES6ޓͷॻ͖ํʹͳΔ ͳͥTypescript͔ʁ
TypeScriptΛಋೖͯ͠ى͖ͨ ͜ͱ
ೝূαʔϏε
TypeScript͕ͦͦਁಁ͠ͳ͍ • letͱvar ͷ͍͚ • functionΩʔϫʔυͱΞϩʔγϯλοΫεʹΑΔڍ ಈͷҧ͍ • ܧঝ͖͢෦Ͱܧঝ͠ͳ͍ •
Ͳ͏ͯ͠ݱঢ়ͷjavascriptʹҾͬுΒΕͯ͠·͏
lintͰൃੜͨ͠Τϥʔ͕Θ͔Γͮ Β͍ Error: public\ts\member\xxx.ts(42,56): error TS2345: Argument of type 'JQuery'
is not assignable to parameter of type '(index: number, value: number) => string[]'. toString()ͷఆٛ࿙Ε
ES5ʹݶఆͰ͖ΔڥͰແ͔ͬͨ • ϦϦʔε࣌ͷIEͷαϙʔτόʔδϣϯ • 8Ҏ߱ • ೝূαʔϏεͷϦϦʔεʹΑͬͯαϙʔτ͕ଧͪফ͞Ε ͕ͨɺप͞Εͣ • ϦϦʔεޙɺࠞཚ
• Ϣʔβʔ͔Βͷ͍߹Θͤ͋Γ
গͣͭ͠શମʹਁಁ • ͩΜͩΜ׳Ε͖ͯͨ • ઌۦऀ͕1ਓ͍ͨͷͰɺͦͷϝϯόʔ͕νʔ ϜΛϦʔυ • ࠓ·Ͱͷjavascriptͷ՝ղܾΛ࣮ײ • ϞδϡʔϧԽɺܧঝ
etc
Outbound ʢւ֎༧αʔϏεʣ
.tsͷத͕ੜjs • TypeScriptΛಋೖͨ͠ཧ༝͕ɺɺɺ • σβΠφʔ͕.tsϑΝΠϧΛ࡞ • αʔϏεͷϩʔϯνΛ༏ઌͯ͠ɺٕज़తͳڭ ҭΛߦ͏͕࣌ؒແ͔ͬͨ
Ϧʔυ͢Δਓେࣄʂ • ͲΜͳٕज़Ͱಋೖ͢Δ͚ͩͰ͏·͍͔͘ ͳ͍ • ઌۦऀ͕νʔϜશମʹ͛ΔΑ͏ʹಈ͘͜ͱ • ͍ํΛ͑Δ • ࢥΛ͑Δ
ࠓޙͷΞΫγϣϯ
ࢦ͍ͯ͠Δํ
TypescriptΛಋೖ͢Δ • طଘγεςϜʢ॓ധɺϨετϥϯʣͰTypescriptΛ͏ • .jsΛ.tsʹมߋ͢Δ • ·ͣTypescript Λར༻Ͱ͖ΔڥΛ͑Δ • গͣͭ͠෦ॲཧΛTypescriptʹஔ͖͍͑ͯ͘
• ཧ۶ΑΓʮྑ͘ͳͬͨʯͱ͍͏࣮ײ
jslintΛ࣮ߦ͢Δ function checkOffCoupon(msg) { var input = document.getElementById("<%= x.ClientID %>").value;
var apply = window.document.aspnetForm.elements["<%= Me.b.CdName %>"].value; if (input != '') { if (apply == '') { if (window.document.aspnetForm.elements["<%= Me.b.StatusName %>"].value == "<%= CodeMasterFlg.False %>") { msg = msg + \n"; } else { msg = msg + \n"; } } else if (input != apply) { msg = msg + \n"; } } return msg; }
jslintΛ࣮ߦ͢Δ function checkOffCoupon(msg) { var input = document.getElementById("<%= x.ClientID %>").value;
var apply = window.document.aspnetForm.elements["<%= Me.b.CdName %>"].value; if (input != '') { if (apply == '') { if (window.document.aspnetForm.elements["<%= Me.b.StatusName %>"].value == "<%= CodeMasterFlg.False %>") { msg = msg + \n"; } else { msg = msg + \n"; } } else if (input != apply) { msg = msg + \n"; } } return msg; } ୯७ʹͦͷ··Ͱͷ࣮ߦ͍͠
jslintΛ࣮ߦ͢Δ • ݱঢ়Ͱ͖Δ͜ͱ • αʔόαΠυίϯτϩʔϧͷ෦จࣈྻʹஔ • কདྷతʹ • มͱϩδοΫΛ͢Δ •
jsϩδοΫ͚ͩ lint Ͱ͖ΔΑ͏ʹ͢Δ
·ͱΊ • ٕज़తͳղܾΛߦ͏ʹ • Ϧʔυ͢Δਓ͕େࣄ • ୈೋɺୈࡾͷαϙʔτ͕ग़ͯ͘Εগͣͭ͠νʔ Ϝʹ͕Δ • Λ์ஔ͠ͳ͍
• ͙ͬͱࣃΛ৯͍റͬͯɺͷલͷΛղܾ͢Δ
None
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠