|
| 1 | +--- |
| 2 | +title:"2019-11-26のJS: Node.js 13.2.0(ES Modules)、jQueryがAMDからES Modulesへ" |
| 3 | +author:"azu" |
| 4 | +layout:post |
| 5 | +date:2019-11-26T02:19:47.092Z |
| 6 | +category:JSer |
| 7 | +tags: |
| 8 | +-Node.js |
| 9 | +-jQuery |
| 10 | +-Modules |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +JSer.info#463 - 開発版となるNode.js 13.2.0がリリースされました。 |
| 15 | + |
| 16 | +-[Node v13.2.0 (Current) | Node.js](https://nodejs.org/en/blog/release/v13.2.0/) |
| 17 | + |
| 18 | +今までは`--experimental-modules`というフラグ付きで起動したときのみ、[ECMAScript Modules](https://nodejs.org/api/esm.html)をサポートしていませんでした。 |
| 19 | +13.2.0からはこのフラグなしでも、デフォルトで拡張子が`.mjs`のファイルや`package.json`の`"type"`フィールドが`"module"`となっているパッケージをECMAScript Modulesとして`import`できるようになりました。 |
| 20 | + |
| 21 | +-[ECMAScript Modules | Node.js v13.2.0 Documentation](https://nodejs.org/api/esm.html) |
| 22 | +-[Announcing core Node.js support for ECMAScript modules](https://medium.com/@nodejs/announcing-core-node-js-support-for-ecmascript-modules-c5d6dc29b663) |
| 23 | + |
| 24 | +次のような[サンプルコード](https://github.com/azu/node-mjs-example)でECMAScript Modulesがフラグなしで実行できることが確認できます。 |
| 25 | + |
| 26 | +`mod.mjs`: |
| 27 | + |
| 28 | +```js |
| 29 | +exportfunctionadd(x,y) { |
| 30 | +return x+ y; |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +`index.mjs`: |
| 35 | + |
| 36 | +```js |
| 37 | +import {add }from"./mod.mjs" |
| 38 | +console.log(add(1,2)); |
| 39 | +``` |
| 40 | + |
| 41 | +Node.js 13.2.0からはこの`index.mjs`を`--experimental-modules`のフラグなしで実行できるうようになっています。 |
| 42 | +ただし、ExperimentalWarningは自動的に表示されます。 |
| 43 | + |
| 44 | +``` |
| 45 | +$ node src/index.mjs |
| 46 | +(node:97312) ExperimentalWarning: The ESM module loader is experimental. |
| 47 | +3 |
| 48 | +``` |
| 49 | + |
| 50 | +---- |
| 51 | + |
| 52 | +まだリリースはされていませんが、jQueryのコードベースが[AMD](https://requirejs.org/docs/whyamd.html)からECMAScript Modulesを使ったコードに変更されています。 |
| 53 | + |
| 54 | +-[Core: Migrate from AMD to ES modules 🎉 by mgol · Pull Request#4541 · jquery/jquery](https://github.com/jquery/jquery/pull/4541) |
| 55 | + |
| 56 | +最終的な`jquery.js`は[rollup.js](https://rollupjs.org)を使ってbundleしたものを配布する予定となっています。 |
| 57 | + |
| 58 | +<blockquoteclass="twitter-tweet"><plang="en"dir="ltr">The <ahref="https://twitter.com/jquery?ref_src=twsrc%5Etfw">@jquery</a> source is now authored in ES6 modules![1] You can import from `src/jquery.js` directly from the browser without any build process.[2]<ahref="https://twitter.com/RollupJS?ref_src=twsrc%5Etfw">@RollupJS</a> is used to create the final jquery.js file.<br><br>[1] <ahref="https://t.co/mLGFF4n2WE">https://t.co/mLGFF4n2WE</a><br>[2] <ahref="https://t.co/uTWs7URXXW">https://t.co/uTWs7URXXW</a></p>— Michał Gołębiowski-Owczarek (@m_gol) <ahref="https://twitter.com/m_gol/status/1196893162859573250?ref_src=twsrc%5Etfw">November 19, 2019</a></blockquote> <scriptasyncsrc="https://platform.twitter.com/widgets.js"charset="utf-8"></script> |
| 59 | + |
| 60 | +---- |
| 61 | + |
| 62 | +<h1class="site-genre">ヘッドライン</h1> |
| 63 | + |
| 64 | +---- |
| 65 | + |
| 66 | +##Core: Migrate from AMD to ES modules 🎉 by mgol · Pull Request#4541 · jquery/jquery |
| 67 | +[github.com/jquery/jquery/pull/4541](https://github.com/jquery/jquery/pull/4541"Core: Migrate from AMD to ES modules 🎉 by mgol · Pull Request #4541 · jquery/jquery") |
| 68 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">jQuery</span> <spanclass="jser-tag">issue</span> <spanclass="jser-tag">module</span> <spanclass="jser-tag">news</span></p> |
| 69 | + |
| 70 | +jQueryのコードベースがAMDからES modulesに書き換えられた |
| 71 | + |
| 72 | + |
| 73 | +---- |
| 74 | + |
| 75 | +##Release Notes for Safari Technology Preview 96 | WebKit |
| 76 | +[webkit.org/blog/9658/release-notes-for-safari-technology-preview-96/](https://webkit.org/blog/9658/release-notes-for-safari-technology-preview-96/"Release Notes for Safari Technology Preview 96 | WebKit") |
| 77 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">safari</span> <spanclass="jser-tag">ReleaseNote</span></p> |
| 78 | + |
| 79 | +Safari Technology Preview 96リリース。 |
| 80 | +Web Animations APIをデフォルトで有効化、`navigator.clipboard.read()`の実装など |
| 81 | + |
| 82 | + |
| 83 | +---- |
| 84 | + |
| 85 | +##Node v13.2.0 (Current) | Node.js |
| 86 | +[nodejs.org/en/blog/release/v13.2.0/](https://nodejs.org/en/blog/release/v13.2.0/"Node v13.2.0 (Current) | Node.js") |
| 87 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">node.js</span> <spanclass="jser-tag">ReleaseNote</span> <spanclass="jser-tag">module</span></p> |
| 88 | + |
| 89 | +Node.js 13.2.0リリース。 |
| 90 | +`--experimental-modules`のフラグが外れたため、デフォルトでES Modulesが利用できるように。 |
| 91 | +`worker_threads`に`resourceLimits`オプションの追加、`child_process`などに`serialization`オプションの追加など |
| 92 | + |
| 93 | +-[ECMAScript Modules | Node.js v13.2.0 Documentation](https://nodejs.org/api/esm.html"ECMAScript Modules | Node.js v13.2.0 Documentation") |
| 94 | +-[Announcing core Node.js support for ECMAScript modules](https://medium.com/@nodejs/announcing-core-node-js-support-for-ecmascript-modules-c5d6dc29b663"Announcing core Node.js support for ECMAScript modules") |
| 95 | + |
| 96 | +---- |
| 97 | + |
| 98 | +##Node.js 12.x runtime now available in AWS Lambda | AWS Compute Blog |
| 99 | +[aws.amazon.com/jp/blogs/compute/node-js-12-x-runtime-now-available-in-aws-lambda/](https://aws.amazon.com/jp/blogs/compute/node-js-12-x-runtime-now-available-in-aws-lambda/"Node.js 12.x runtime now available in AWS Lambda | AWS Compute Blog") |
| 100 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">aws</span> <spanclass="jser-tag">Lambda</span> <spanclass="jser-tag">node.js</span> <spanclass="jser-tag">news</span></p> |
| 101 | + |
| 102 | +AWS LambdaがNode.js 12.xをサポート |
| 103 | + |
| 104 | + |
| 105 | +---- |
| 106 | + |
| 107 | +##TestCafe v1.7.0 Released | TestCafe |
| 108 | +[devexpress.github.io/testcafe/blog/testcafe-v1-7-0-released.html](https://devexpress.github.io/testcafe/blog/testcafe-v1-7-0-released.html"TestCafe v1.7.0 Released | TestCafe") |
| 109 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">browser</span> <spanclass="jser-tag">testing</span> <spanclass="jser-tag">E2E</span> <spanclass="jser-tag">ReleaseNote</span></p> |
| 110 | + |
| 111 | +TestCafe v1.7.0リリース。 |
| 112 | +テストコード内で実行してるブラウザやOSの情報を取得できる`t.browser`オブジェクトのサポートなど |
| 113 | + |
| 114 | + |
| 115 | +---- |
| 116 | + |
| 117 | +##Web Framework Fastify Joins OpenJS Foundation as an Incubating Project - OpenJS Foundation |
| 118 | +[openjsf.org/blog/2019/11/20/web-framework-fastify-joins-openjs-foundation-as-an-incubating-project/](https://openjsf.org/blog/2019/11/20/web-framework-fastify-joins-openjs-foundation-as-an-incubating-project/"Web Framework Fastify Joins OpenJS Foundation as an Incubating Project - OpenJS Foundation") |
| 119 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">node.js</span> <spanclass="jser-tag">library</span> <spanclass="jser-tag">news</span></p> |
| 120 | + |
| 121 | +Node.jsのウェブアプリケーションフレームワークであるFastifyがOpenJS FoundationのIncubating Projectとなった。 |
| 122 | + |
| 123 | +-[Fastify, Fast and low overhead web framework, for Node.js](https://www.fastify.io/"Fastify, Fast and low overhead web framework, for Node.js") |
| 124 | + |
| 125 | +---- |
| 126 | + |
| 127 | +##CanJS 6.0 |
| 128 | +[www.bitovi.com/blog/canjs-6.0](https://www.bitovi.com/blog/canjs-6.0"CanJS 6.0") |
| 129 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">JavaScript</span> <spanclass="jser-tag">library</span> <spanclass="jser-tag">ReleaseNote</span></p> |
| 130 | + |
| 131 | +CanJS 6.0リリース。 |
| 132 | +WebComponentベースになり、コンポーネントのPropsの型システムの刷新、Proxyを使ったObservableObjectの仕組みなどが導入された。 |
| 133 | +マイグレーションガイドとツールも公開されている。 |
| 134 | + |
| 135 | +-[Migrating to CanJS 6 | upgrade | Guides | CanJS — Build CRUD apps in fewer lines of code.](https://canjs.com/doc/migrate-6.html#MigratetoObservableObjectandObservableArrayformodels"Migrating to CanJS 6 | upgrade | Guides | CanJS — Build CRUD apps in fewer lines of code.") |
| 136 | +-[Using Codemods | upgrade | Guides | CanJS — Build CRUD apps in fewer lines of code.](https://canjs.com/doc/guides/upgrade/using-codemods.html"Using Codemods | upgrade | Guides | CanJS — Build CRUD apps in fewer lines of code.") |
| 137 | + |
| 138 | +---- |
| 139 | + |
| 140 | +##ESLint v6.7.0 released - ESLint - Pluggable JavaScript linter |
| 141 | +[eslint.org/blog/2019/11/eslint-v6.7.0-released](https://eslint.org/blog/2019/11/eslint-v6.7.0-released"ESLint v6.7.0 released - ESLint - Pluggable JavaScript linter") |
| 142 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">ESLint</span> <spanclass="jser-tag">ReleaseNote</span></p> |
| 143 | + |
| 144 | +ESLint 6.7.0リリース。 |
| 145 | +ルールからSuggestionの候補を提供するAPIの追加、設定ファイルに`ignorePatterns`を記述できるようになるなど。 |
| 146 | +また`no-constructor-return`などのルールを新規に5つ追加など |
| 147 | + |
| 148 | +-[ESLint v6.7.0 - Qiita](https://qiita.com/mysticatea/items/377b6ca6558dc253159b"ESLint v6.7.0 - Qiita") |
| 149 | + |
| 150 | +---- |
| 151 | +<h1class="site-genre">アーティクル</h1> |
| 152 | + |
| 153 | +---- |
| 154 | + |
| 155 | +##Cropping Images to a specific Aspect Ratio with JavaScript • PQINA |
| 156 | +[pqina.nl/blog/cropping-images-to-an-aspect-ratio-with-javascript/](https://pqina.nl/blog/cropping-images-to-an-aspect-ratio-with-javascript/"Cropping Images to a specific Aspect Ratio with JavaScript • PQINA") |
| 157 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">JavaScript</span> <spanclass="jser-tag">canvas</span> <spanclass="jser-tag">article</span></p> |
| 158 | + |
| 159 | +Canvasを使って画像を切り抜きするチュートリアル。チュートリアルではカバーできてない画像を扱う際の問題についてなど |
| 160 | + |
| 161 | + |
| 162 | +---- |
| 163 | + |
| 164 | +##Regular expressions in #"diff-f6a03416fd1e1bbf5d27177dac320ed40f514a03b0c93bc0c1255d5a065eb87f-empty-165-0" data-selected="false" role="gridcell" tabindex="-1" valign="top"> | 165 | +[2ality.com/2019/10/regexp-lookaround-assertions.html](https://2ality.com/2019/10/regexp-lookaround-assertions.html"Regular expressions in #"diff-f6a03416fd1e1bbf5d27177dac320ed40f514a03b0c93bc0c1255d5a065eb87f-empty-166-0" data-selected="false" role="gridcell" tabindex="-1" valign="top"> | 166 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">JavaScript</span> <spanclass="jser-tag">RegExp</span> <spanclass="jser-tag">article</span></p> |
| 167 | + |
| 168 | +JavaScriptの正規表現の先読み/後読みのパターンについて。 |
| 169 | + |
| 170 | + |
| 171 | +---- |
| 172 | +<h1class="site-genre">スライド、動画関係</h1> |
| 173 | + |
| 174 | +---- |
| 175 | + |
| 176 | +##Faster apps with JSON.parse (Chrome Dev Summit 2019) - YouTube |
| 177 | +[www.youtube.com/watch?v=ff4fgQxPaO0](https://www.youtube.com/watch?v=ff4fgQxPaO0"Faster apps with JSON.parse (Chrome Dev Summit 2019) - YouTube") |
| 178 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">JavaScript</span> <spanclass="jser-tag">JSON</span> <spanclass="jser-tag">performance</span> <spanclass="jser-tag">video</span></p> |
| 179 | + |
| 180 | +オブジェクトリテラルより`JSON.parse`した方が、パフォーマンスが良い理由についての解説動画。 |
| 181 | +JSONには出現するトークンが限定されているためオブジェクトリテラルよりパースが高速にできること、SSRでのユースケースなどについて紹介している。 |
| 182 | +10kB以上など大きなデータに関しては`JSON.parse`を使うことを推奨している |
| 183 | + |
| 184 | +-[The cost of JavaScript in 2019 · V8](https://v8.dev/blog/cost-of-javascript-2019#json"The cost of JavaScript in 2019 · V8") |
| 185 | + |
| 186 | +---- |
| 187 | +<h1class="site-genre">サイト、サービス、ドキュメント</h1> |
| 188 | + |
| 189 | +---- |
| 190 | + |
| 191 | +##EasyDB |
| 192 | +[easydb.io/](https://easydb.io/"EasyDB") |
| 193 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">DB </span> <spanclass="jser-tag">webservice</span> <spanclass="jser-tag"> node</span> <spanclass="jser-tag">npm</span> <spanclass="jser-tag">python</span></p> |
| 194 | + |
| 195 | +Node.jsやPythonから24時間使えるKVSなDBを作ってくれるウェブサービス。 |
| 196 | +アカウントを作ると72時間使うことができ、永続化したい場合は$5/monthで利用できる。 |
| 197 | +ハッカソンなどの一時的なイベント向けのデータベースサービス。 |
| 198 | + |
| 199 | + |
| 200 | +---- |
| 201 | + |
| 202 | +##liyasthomas/postwoman: 👽 API request builder - A free, fast, and beautiful alternative to Postmanhttps://postwoman.io 🔥 |
| 203 | +[github.com/liyasthomas/postwoman](https://github.com/liyasthomas/postwoman"liyasthomas/postwoman: 👽 API request builder - A free, fast, and beautiful alternative to Postman https://postwoman.io 🔥") |
| 204 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">webservice</span> <spanclass="jser-tag">API</span> <spanclass="jser-tag">Tools</span></p> |
| 205 | + |
| 206 | +REST API、WebSockets、GraphQLに対応したAPIへのリクエスト/レスポンスをテストできるツール。 |
| 207 | + |
| 208 | + |
| 209 | +---- |
| 210 | +<h1class="site-genre">ソフトウェア、ツール、ライブラリ関係</h1> |
| 211 | + |
| 212 | +---- |
| 213 | + |
| 214 | +##jeremydaly/lambda-api: Lightweight web framework for your serverless applications |
| 215 | +[github.com/jeremydaly/lambda-api](https://github.com/jeremydaly/lambda-api"jeremydaly/lambda-api: Lightweight web framework for your serverless applications") |
| 216 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag"> node</span> <spanclass="jser-tag">aws</span> <spanclass="jser-tag">Lambda</span> <spanclass="jser-tag">library</span></p> |
| 217 | + |
| 218 | +AWS Lambda向けのNode,jsフレームワーク。 |
| 219 | +依存がなく、HTTPメソッド対するルーティング、HTTPリクエスト/レスポンスに対する基本的な処理を持っている |
| 220 | + |
| 221 | + |
| 222 | +---- |
| 223 | +<h1class="site-genre">書籍関係</h1> |
| 224 | + |
| 225 | +---- |
| 226 | + |
| 227 | +##Test-Driven React: Find Problems Early, Fix Them Quickly, Code with Confidence by Trevor Burnham | The Pragmatic Bookshelf |
| 228 | +[pragprog.com/book/tbreact/test-driven-react](https://pragprog.com/book/tbreact/test-driven-react"Test-Driven React: Find Problems Early, Fix Them Quickly, Code with Confidence by Trevor Burnham | The Pragmatic Bookshelf") |
| 229 | +<pclass="jser-tags jser-tag-icon"><spanclass="jser-tag">React</span> <spanclass="jser-tag">testing</span> <spanclass="jser-tag">book</span></p> |
| 230 | + |
| 231 | +テスト駆動でのReactアプリケーション開発についての書籍 |
| 232 | + |
| 233 | + |
| 234 | +---- |