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
590
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
780
READMEにバッヂが欲しくてテストを書き始めました
yusukehirao
1
740
ユニバーサルなマークアップをしよう
yusukehirao
2
860
アクセシビリティチェックを自動化するための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
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
強いチームと開発生産性
onk
PRO
33
11k
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
ハイパーパラメータチューニングって何をしているの
toridori_dev
0
140
Shopifyアプリ開発における Shopifyの機能活用
sonatard
4
250
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
210
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
AWS Media Services 最新サービスアップデート 2024
eijikominami
0
190
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
170
地理情報データをデータベースに格納しよう~ GPUを活用した爆速データベース PG-Stromの紹介 ~
sakaik
1
150
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
A Philosophy of Restraint
colly
203
16k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Agile that works and the tools we love
rasmusluckow
327
21k
Happy Clients
brianwarren
98
6.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
BBQ
matthewcrist
85
9.3k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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