-
Notifications
You must be signed in to change notification settings - Fork 185
Translate Code-Splitting #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
smikitky
merged 14 commits into
reactjs:master
from
sugoikondo:translate/code-splitting
Feb 10, 2019
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b790b03
WIP translating.
sugoikondo 9d4aa3f
translate complete
sugoikondo 9c920db
lint
sugoikondo 6802a92
fix statements on Browserify.
sugoikondo 936e9b0
delete unnessesary statements.
sugoikondo 5cf1524
delete unnessesary statements.
sugoikondo 6570f0a
fix typo
sugoikondo e0d0623
fix typo
sugoikondo bd73272
resolve conflicts
sugoikondo 2ae259a
Apply suggestions from code review
koba04 34773ec
fix breakings.
sugoikondo 92dc443
Apply suggestions from code review
smikitky 2523d51
fix suggestions.
sugoikondo 2e244fd
fix mistranslation on webpack configuration
sugoikondo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,18 +1,14 @@ | ||||||
| --- | ||||||
| id: code-splitting | ||||||
| title: Code-Splitting | ||||||
| title: コード分割 | ||||||
| permalink: docs/code-splitting.html | ||||||
| --- | ||||||
|
|
||||||
| ## Bundling {#bundling} | ||||||
| ## バンドル {#bundling} | ||||||
|
|
||||||
| Most React apps will have their files "bundled" using tools like | ||||||
| [Webpack](https://webpack.js.org/) or [Browserify](http://browserify.org/). | ||||||
| Bundling is the process of following imported files and merging them into a | ||||||
| single file: a "bundle". This bundle can then be included on a webpage to load | ||||||
| an entire app at once. | ||||||
| 多くの React アプリケーションは、[Webpack](https://webpack.js.org/)や [Browserify](http://browserify.org/) などのツールを使ってファイルを「バンドル」しています。バンドルはインポートされたファイルをたどって、それらを1つのファイルにまとめるプロセスです。このバンドルされたファイルを Web ページ内に置くことによって、アプリ全体を一度に読み込むことができます。 | ||||||
|
|
||||||
| #### Example {#example} | ||||||
| #### 例 {#example} | ||||||
|
|
||||||
| **App:** | ||||||
|
|
||||||
|
|
@@ -40,42 +36,28 @@ function add(a, b) { | |||||
| console.log(add(16, 26)); // 42 | ||||||
| ``` | ||||||
|
|
||||||
| > Note: | ||||||
| > 補足: | ||||||
| > | ||||||
| > Your bundles will end up looking a lot different than this. | ||||||
| > バンドルされたファイルはこれらのファイルとは似ても似つかない見た目をしているでしょう。 | ||||||
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| If you're using [Create React App](https://github.com/facebookincubator/create-react-app), [Next.js](https://github.com/zeit/next.js/), [Gatsby](https://www.gatsbyjs.org/), or a similar tool, you will have a Webpack setup out of the box to bundle your | ||||||
| app. | ||||||
| もしあなたが [Create React App](https://github.com/facebookincubator/create-react-app) や [Next.js](https://github.com/zeit/next.js/), [Gatsby](https://www.gatsbyjs.org/) またはこれらに類するツールを使用している場合、アプリケーションをバンドルするための Webpack の設定が、追加の設定なしにすぐに手に入るでしょう。 | ||||||
|
|
||||||
| If you aren't, you'll need to setup bundling yourself. For example, see the | ||||||
| [Installation](https://webpack.js.org/guides/installation/) and | ||||||
| [Getting Started](https://webpack.js.org/guides/getting-started/) guides on the | ||||||
| Webpack docs. | ||||||
| そうでない場合は、自分でバンドルを設定する必要があります。設定方法に関しては、Webpack のドキュメントにある [Installation](https://webpack.js.org/guides/installation/) や [Getting Started](https://webpack.js.org/guides/getting-started/) などを参照してみてください。 | ||||||
|
|
||||||
| ## Code Splitting {#code-splitting} | ||||||
| ## コード分割 {#code-splitting} | ||||||
|
|
||||||
| Bundling is great, but as your app grows, your bundle will grow too. Especially | ||||||
| if you are including large third-party libraries. You need to keep an eye on | ||||||
| the code you are including in your bundle so that you don't accidentally make | ||||||
| it so large that your app takes a long time to load. | ||||||
| バンドルは確かに素晴らしいですが、アプリが大きくなるにつれて、バンドルのサイズも大きくなります。特にサイズの大きなサードパーティ製のライブラリを含む場合は顕著にサイズが増大します。 | ||||||
| 不用意に大きなバンドルを作成してしまいアプリの読み込みに多くの時間がかかってしまうという事態にならないためにも、常に注意を払い続けなければなりません。 | ||||||
|
|
||||||
| To avoid winding up with a large bundle, it's good to get ahead of the problem | ||||||
| and start "splitting" your bundle. | ||||||
| [Code-Splitting](https://webpack.js.org/guides/code-splitting/) is a feature | ||||||
| supported by bundlers like Webpack and Browserify (via | ||||||
| [factor-bundle](https://github.com/browserify/factor-bundle)) which can create | ||||||
| multiple bundles that can be dynamically loaded at runtime. | ||||||
| 大きなバンドルを不注意に生成してしまわないように、コードを「分割」して問題を回避しましょう。 | ||||||
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| [Code-Splitting](https://webpack.js.org/guides/code-splitting/) は、実行時にロードする複数のバンドルを生成できる Webpack や Browserify([factor-bundle](https://github.com/browserify/factor-bundle) を使用)などのバンドラによってサポートされている機能です。 | ||||||
|
|
||||||
| Code-splitting your app can help you "lazy-load" just the things that are | ||||||
| currently needed by the user, which can dramatically improve the performance of | ||||||
| your app. While you haven't reduced the overall amount of code in your app, | ||||||
| you've avoided loading code that the user may never need, and reduced the amount | ||||||
| of code needed during the initial load. | ||||||
| コード分割は、ユーザが必要とするコードだけを「遅延読み込み」する手助けとなり、アプリのパフォーマンスを劇的に向上させることができます。 | ||||||
| アプリの全体的なコード量を減らすことはできませんが、ユーザが必要としないコードを読み込まなくて済むため、初期ロードの際に読む込むコード量を削減できます。 | ||||||
|
|
||||||
| ## `import()` {#import} | ||||||
|
|
||||||
| The best way to introduce code-splitting into your app is through the dynamic | ||||||
| `import()` syntax. | ||||||
| コード分割をアプリに導入する最も良い手段は動的インポート `import()` を使用することです。 | ||||||
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| **Before:** | ||||||
|
|
||||||
|
|
@@ -93,31 +75,23 @@ import("./math").then(math => { | |||||
| }); | ||||||
| ``` | ||||||
|
|
||||||
| > Note: | ||||||
| > 補足: | ||||||
| > | ||||||
| > The dynamic `import()` syntax is a ECMAScript (JavaScript) | ||||||
| > [proposal](https://github.com/tc39/proposal-dynamic-import) not currently | ||||||
| > part of the language standard. It is expected to be accepted in the | ||||||
| > near future. | ||||||
| > `import()` 構文は ECMAScript (JavaScript) が提案している、現時点ではまだ言語標準として実装されていない構文です。近い将来での標準化が期待されています。 | ||||||
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| When Webpack comes across this syntax, it automatically starts code-splitting | ||||||
| your app. If you're using Create React App, this is already configured for you | ||||||
| and you can [start using it](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting) immediately. It's also supported | ||||||
| out of the box in [Next.js](https://github.com/zeit/next.js/#dynamic-import). | ||||||
| Webpackがこの構文を見つけると、自動的にアプリのコードを分割します。Create React App を使用している場合はすでに設定がされているため、[すぐに使用を開始することができます。](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting)Next.jsも同様です。 | ||||||
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| If you're setting up Webpack yourself, you'll probably want to read Webpack's | ||||||
| [guide on code splitting](https://webpack.js.org/guides/code-splitting/). Your Webpack config should look vaguely [like this](https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269). | ||||||
| もし Webpack を自分でセットアップしていた場合には、Webpack の[コード分割に関するガイド](https://webpack.js.org/guides/code-splitting/)を読むと良いでしょう。きっとあなたの Webpack の設定はおよそ[このように](https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269)なっているはずでしょうから。 | ||||||
|
||||||
| もし Webpack を自分でセットアップしていた場合には、Webpack の[コード分割に関するガイド](https://webpack.js.org/guides/code-splitting/)を読むと良いでしょう。きっとあなたの Webpack の設定はおよそ[このように](https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269)なっているはずでしょうから。 | |
| もし Webpack を自分でセットアップしていた場合には、Webpack の[コード分割に関するガイド](https://webpack.js.org/guides/code-splitting/)を読むと良いでしょう。あなたの Webpack の設定はおおよそ[このような](https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269)ものになるでしょう。 |
文末の「から」は不要だと思います
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
smikitky marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
sugoikondo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.