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
TypeScriptでつくるNode.jsパッケージ
Search
Yusuke Hirao
May 15, 2019
Technology
3
600
TypeScriptでつくるNode.jsパッケージ
Fukuoka.js #8「TypeScript」
Yusuke Hirao
May 15, 2019
Tweet
Share
More Decks by Yusuke Hirao
See All by Yusuke Hirao
ユニバーサルHTMLとWebのポテンシャル
yusukehirao
1
790
READMEにバッヂが欲しくてテストを書き始めました
yusukehirao
1
740
ユニバーサルなマークアップをしよう
yusukehirao
2
870
アクセシビリティチェックを自動化するためのmarkuplintのロードマップ
yusukehirao
2
2.1k
本当に必要ですか?そのJavaScript 〜スクロールイベント・リサイズイベント編〜
yusukehirao
0
580
コードレビュー なんてしてられるかッ!!
yusukehirao
24
14k
自動化をデザインしよう
yusukehirao
1
870
JSONの型のはなし
yusukehirao
0
590
トランスパイラという文化(…とその後) - PHPカンファレンス福岡2016
yusukehirao
1
2.6k
Other Decks in Technology
See All in Technology
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
日本版とグローバル版のモバイルアプリ統合の開発の裏側と今後の展望
miichan
1
130
.NET 9 のパフォーマンス改善
nenonaninu
0
780
開発生産性向上! 育成を「改善」と捉えるエンジニア育成戦略
shoota
1
290
ハイテク休憩
sat
PRO
2
140
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
170
オプトインカメラ:UWB測位を応用したオプトイン型のカメラ計測
matthewlujp
0
170
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
13
3.6k
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
150
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Optimizing for Happiness
mojombo
376
70k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Making the Leap to Tech Lead
cromwellryan
133
9k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Code Review Best Practice
trishagee
65
17k
KATA
mclloyd
29
14k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Embracing the Ebb and Flow
colly
84
4.5k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Transcript
5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ
©2019 Yusuke Hirao גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ 5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn
©2019 Yusuke Hirao ࣗݾհ ฏඌ༏యʢͻΒ͓Ώ͏ͯΜʣ גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ϑϩϯτΤϯυΤϯδχΞ #-0(IUUQTOPUFNVZVTVLFIJSBP Yusuke
Hirao @cloud10designs
©2019 Yusuke Hirao ͜Μͳͷ࡞ͬͯ·͢ KBDPKTຊޠ༻จࣈมϥΠϒϥϦ NBSLVQMJOU)5.-ϦϯλʔόϦσʔλʔ
©2019 Yusuke Hirao ࠓͳ͢͜ͱ ࠷ݶͷϛχϚϜͳ tsconfig.json packge.json ઃఆʹ͍ͭͯ
©2019 Yusuke Hirao ࠓͳ͞ͳ͍͜ͱ ܕͷͳ͠ NPOPSFQPʹ͍ͭͯ
©2019 Yusuke Hirao ΞδΣϯμ ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ઃఆ Ϗϧυ͢Δ ύϒϦογϡ͢Δ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ +BWB4DSJQUϑΝΠϧ ܕఆٛϑΝΠϧʢ*.d.tsʣͳͲͷॻ͖ग़͠ઌ w OQNͰެ։͢ΔϑΝΠϧ܊ΛೖΕΔɻ w
HJUͰআ֎͢Δɻ w ໊લlibͰdistͰԿͰ͓ΈͰɻϞδϡʔϧʹύεࢀ রͰ͖Δύοέʔδʢ5SFF4IBLJOHͷͨΊͩͬͨΓʣʹ͍ͨ͠ ߹ɺσΟϨΫτϦ໊ͪΐͬͱॏཁɻʢྫKBDPKTʣ import toHiragana from "jaco/fn/toHiragana"; toHiragana("ΧλΧφΛͻΒͳ͕ʹ");
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ 5ZQF4DSJQUϑΝΠϧͳͲιʔείʔυஔ͖ w OQNͰެ։͠ͳ͍ʢ͍͍ͯ͠ʣɻ w ໊͜͜લ͓ΈͰɻ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ϦϙδτϦͷσΟϨΫτϦߏ ϑΥϧμผʑ͕Φεεϝ w HJUOQNͷআ֎ઃఆָ͕ɻ w ܕఆٛϑΝΠϧʢ*.d.ts.mapʣͷιʔεϚοϓΛར༻Ͱ͖Δɻ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ॻ͖ग़͢+4ͷόʔδϣϯʢtargetʣ es5 es2017 esnext ϝϦοτ
ͲΜͳڥͰಈ͘ /PEFKTWҎ্ ͳΒಈ͘ import.metaରԠ ʢ&4.ʹඞਢʣ σϝϦοτ async/await for..ofͳͲ͕ ϨΨγʔίʔυม͞ΕΔ ϒϥβͰ͏߹ CBCFMͳͲ͕ඞཁʹͳΔ ී௨ʹ͏ͳΒ CBCFMͳͲ͕ඞཁ
©2019 Yusuke Hirao ίʔυΛॻ͘લʹܾΊ͓ͯ͘͜ͱ ॻ͖ग़͢+4ͷϞδϡʔϧγεςϜʢmoduleʣ commonjs esnext ͦͷଞ ϝϦοτ
ݱࡏͷඪ४ import.metaରԠ ʢ&4.ʹඞਢʣ ͠ΒΜ σϝϦοτ &4.Ͱ͑ͳ͍ ී௨ʹ͏ͳΒ CBCFMͳͲ͕ඞཁ Θ͔ΒΜ
©2019 Yusuke Hirao ઃఆ
©2019 Yusuke Hirao ઃఆ $ yarn init { "name": "@yusukehirao/sample",
"version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT" } ࣮ݧͷࡍ4DPQFEQBDLFHFʹ͠·͠ΐ͏ ઌʹܾΊͨσΟϨΫτϦͷΤϯτϦʔϑΝΠϧ import sample from "@yusukehirao/sample"; ௨ৗͷimport࣌ͷࢀরઌʹͳΔ package.json
©2019 Yusuke Hirao ઃఆ $ yarn add -D typescript ίϯύΠϥΛΠϯετʔϧ
{ "name": "@yusukehirao/sample", "version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "devDependencies": { "typescript": "^3.4.5" } } package.json
©2019 Yusuke Hirao ઃఆ $ ./node_modules/.bin/tsc —init { "compilerOptions": {
"target": "es2017", "module": "commonjs", "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true } } tsconfig.json ܾΊͨॻ͖ग़͠ઌͱιʔείʔυஔ͖ ܾΊͨ&4όʔδϣϯϞδϡʔϧγεςϜ
©2019 Yusuke Hirao ઃఆ $ ./node_modules/.bin/tsc —init { "compilerOptions": {
"target": "es2017", "module": "commonjs", "declaration": true, "declarationMap": true, "sourceMap": true, "outDir": "./lib", "rootDir": "./src", "strict": true, "esModuleInterop": true } } tsconfig.json ܕఆٛϑΝΠϧͱιʔεϚοϓϑΝΠϧͷ ੜΛ༗ޮʹ͓ͯ͘͠
©2019 Yusuke Hirao ઃఆ ίϯύΠϧίϚϯυΛొ tsc ίϚϯυΛొ͓ͯ͘͠ { "name": "@yusukehirao/sample",
"version": "0.1.0-alpha.0", "main": "lib/index.js", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "scripts": { "build": "tsc", "prepack": "tsc" }, "devDependencies": { "typescript": "^3.4.5" } } package.json w Φϓγϣϯtsconfig.jsonʹॻ͍͓͚ͯ جຊ͍Βͳ͍ɻ w prepackεΫϦϓτύοέʔδެ։࣌ͷ ϏϧυΕࢭɻ
©2019 Yusuke Hirao ઃఆ ܕఆٛϑΝΠϧΛొ ΤϯτϦʔϑΝΠϧͷܕఆٛϑΝΠϧͷύε { "name": "@yusukehirao/sample", "version":
"0.1.0-alpha.0", "main": "lib/index.js", "types": "lib/index.d.ts", "author": "Yusuke Hirao <
[email protected]
>", "license": "MIT", "scripts": { "build": "tsc", "prepack": "tsc" }, "devDependencies": { "typescript": "^3.4.5" } } package.json w ܕใΛఏڙͰ͖Δɻ w Α͘ @types/xxxxxͰࢀর͢Δ %FpOJUFMZ5ZQFE%FpOJUFMZ5ZQFEʹ13 ૹΔඞཁͳ͍ɻ
©2019 Yusuke Hirao Ϗϧυ͢Δ
©2019 Yusuke Hirao Ϗϧυ͢Δ $ yarn build
©2019 Yusuke Hirao Ϗϧυ͢Δ $ yarn build
©2019 Yusuke Hirao ύϒϦογϡ͢Δ
©2019 Yusuke Hirao ύϒϦογϡ͢Δ $ touch .npmignore ύοέʔδʹؚ·ͳ͍ϑΝΠϧͷআ֎ઃఆΛ͢Δ src tsconfig.json
tsconfig.tsbuildinfo .npmignore w package.jsonͷfilesʹύοέʔδʹؚΊ ͍ͨϑΝΠϧͷϗϫΠτϦετΛॻ͍ͯΑ ͍ɻ w .npmignore͔files͕ͳ͍ͱɺ.gitignore Λআ֎ઃఆͱΈͳ͢ͷͰɺॻ͖ग़͠ઌͷσΟϨ ΫτϦ͕ύοέʔδʹೖΒͳ͍൵ࢂͳ͜ͱʹͳ Δ
©2019 Yusuke Hirao ύϒϦογϡ͢Δ $ npm publish
©2019 Yusuke Hirao ύϒϦογϡ͢Δ ܕఆٛϑΝΠϧެ։͍ͯ͠ΔͷͰɺ 5ZQF4DSJQU͔ΒͪΖΜɺ+BWB4DSJQUͰܕΛࢀরͰ͖Δ
5ZQF4DSJQUͰ ར༻ͯ͠Β͑·͢Αʔʹ
גࣜձࣾσΟʔθϩ 8FCΞΫηγϏϦςΟΤϯδχΞ ฏඌΏ͏ͯΜ 5ZQF4DSJQUͰͭ͘Δ /PEFKTύοέʔδ 'VLVPLBKTň5ZQF4DSJQUʼn