Skip to content

Commit ca26c18

Browse files
authored
Merge pull request #44 from mustaphaturhan/mustaphaturhan-code-splitting
code-splitting
2 parents e8abb14 + 67bdb16 commit ca26c18

File tree

1 file changed

+63
-78
lines changed

1 file changed

+63
-78
lines changed

content/docs/code-splitting.md

+63-78
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ title: Code-Splitting
44
permalink: docs/code-splitting.html
55
---
66

7-
## Bundling {#bundling}
7+
## Paketleme {#bundling}
88

9-
Most React apps will have their files "bundled" using tools like
10-
[Webpack](https://webpack.js.org/) or [Browserify](http://browserify.org/).
11-
Bundling is the process of following imported files and merging them into a
12-
single file: a "bundle". This bundle can then be included on a webpage to load
13-
an entire app at once.
9+
Çoğu React uygulaması, dosyalarını [Webpack](https://webpack.js.org/) veya [Browserify](http://browserify.org/) gibi araçlarla "paketler." Paketleme, içe aktarılan dosyaları işleyip tek bir dosyaya, "paket" haline getirme işlemidir. Daha sonra bu paket, uygulamanın tamamını tek seferde yüklemek için kullanılabilir.
1410

15-
#### Example {#example}
11+
#### Örnek {#example}
1612

17-
**App:**
13+
**Uygulama:**
1814

1915
```js
2016
// app.js
@@ -30,7 +26,7 @@ export function add(a, b) {
3026
}
3127
```
3228

33-
**Bundle:**
29+
**Paket:**
3430

3531
```js
3632
function add(a, b) {
@@ -40,86 +36,80 @@ function add(a, b) {
4036
console.log(add(16, 26)); // 42
4137
```
4238

43-
> Note:
39+
> Not:
4440
>
45-
> Your bundles will end up looking a lot different than this.
41+
> Paketleriniz bundan çok daha farklı gözükecektir.
4642
47-
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
48-
app.
43+
Eğer [Create React App](https://github.com/facebookincubator/create-react-app),
44+
[Next.js](https://github.com/zeit/next.js/), [Gatsby](https://www.gatsbyjs.org/)
45+
ya da benzeri bir araç kullanıyorsanız, uygulamanızı paketleyen bir Webpack
46+
kurulumuna sahip olursunuz.
4947

50-
If you aren't, you'll need to setup bundling yourself. For example, see the
51-
[Installation](https://webpack.js.org/guides/installation/) and
52-
[Getting Started](https://webpack.js.org/guides/getting-started/) guides on the
53-
Webpack docs.
48+
Eğer bu araçlardan birini kullanmıyorsanız, paketleyiciyi kendiniz kurmanız gerekir.
49+
Örnek için, Webpack dokümantasyonundan [Kurulum](https://webpack.js.org/guides/installation/)
50+
ve [Başlangıç](https://webpack.js.org/guides/getting-started/) alanlarına göz atınız.
5451

55-
## Code Splitting {#code-splitting}
52+
## Kod Bölümleme {#code-splitting}
5653

57-
Bundling is great, but as your app grows, your bundle will grow too. Especially
58-
if you are including large third-party libraries. You need to keep an eye on
59-
the code you are including in your bundle so that you don't accidentally make
60-
it so large that your app takes a long time to load.
54+
Paketleme güzeldir ama uygulamanız büyüdükçe paketiniz de büyür. Özellikle
55+
büyük üçüncü parti kütüphaneleri dahil ediyorsanız. Paketinizin boyutunun, uygulamanızın yüklenişini
56+
geciktirecek kadar büyük olmaması için paketinize dahil ettiğiniz kodlara
57+
göz kulak olmanız gerekir.
6158

62-
To avoid winding up with a large bundle, it's good to get ahead of the problem
63-
and start "splitting" your bundle.
64-
[Code-Splitting](https://webpack.js.org/guides/code-splitting/) is a feature
65-
supported by bundlers like Webpack and Browserify (via
66-
[factor-bundle](https://github.com/browserify/factor-bundle)) which can create
67-
multiple bundles that can be dynamically loaded at runtime.
59+
Büyük paket boyutlarından kurtulmak için problemin üzerine gitmek ve paketinizi "bölümlemeye" başlamak iyi bir yöntemdir. [Kod Bölümleme](https://webpack.js.org/guides/code-splitting/), Webpack ve Browserify ([factor-bundle](https://github.com/browserify/factor-bundle) ile) gibi paketleyicilerin desteklediği, işleyiş süresince dinamik olarak yüklenen birden çok paket yaratmaya yarayan özelliktir.
6860

69-
Code-splitting your app can help you "lazy-load" just the things that are
70-
currently needed by the user, which can dramatically improve the performance of
71-
your app. While you haven't reduced the overall amount of code in your app,
72-
you've avoided loading code that the user may never need, and reduced the amount
73-
of code needed during the initial load.
61+
Uygulamanıza kod bölümlemesi yapmak, kullanıcının anlık olarak ihtiyaç duyduğu şeylerin
62+
"lazy yüklenmesine" yardımcı olarak uygulama performansını önemli ölçüde
63+
arttırabilir. Uygulamanızdaki toplam kod miktarını azaltmamış olsanız da kullanıcının
64+
hiçbir zaman ihtiyaç duymayacağı kodu yüklemekten kaçınmış ve ilk yükleme sırasında
65+
ihtiyaç duyulan kodu azaltmış olursunuz.
7466

7567
## `import()` {#import}
7668

77-
The best way to introduce code-splitting into your app is through the dynamic
78-
`import()` syntax.
69+
Uygulamanıza kod bölümlemeyi getirmenin en iyi yolu dinamik `import()` sözdiziminden geçer.
7970

80-
**Before:**
71+
**Önce:**
8172

8273
```js
8374
import { add } from './math';
8475

8576
console.log(add(16, 26));
8677
```
8778

88-
**After:**
79+
**Sonra:**
8980

9081
```js
9182
import("./math").then(math => {
9283
console.log(math.add(16, 26));
9384
});
9485
```
9586

96-
> Note:
87+
> Not:
9788
>
98-
> The dynamic `import()` syntax is a ECMAScript (JavaScript)
99-
> [proposal](https://github.com/tc39/proposal-dynamic-import) not currently
100-
> part of the language standard. It is expected to be accepted in the
101-
> near future.
89+
> Dinamik `import()` sözdizimi ECMAScript (JavaScript) [önerisi](https://github.com/tc39/proposal-dynamic-import)
90+
> henüz dil standartlarının bir parçası değildir. Yakın gelecekte kabul edilmesi beklenmektedir.
10291
103-
When Webpack comes across this syntax, it automatically starts code-splitting
104-
your app. If you're using Create React App, this is already configured for you
105-
and you can [start using it](https://facebook.github.io/create-react-app/docs/code-splitting) immediately. It's also supported
106-
out of the box in [Next.js](https://github.com/zeit/next.js/#dynamic-import).
92+
Webpack bu sözdizimine denk geldiğinde, uygulamanızda otomatik olarak kod bölümlemeye başlar. Eğer Create React App kullanıyorsanız,
93+
bu ayar sizin için halihazırda ayarlanmıştır ve [kullanmaya](https://facebook.github.io/create-react-app/docs/code-splitting) hemen
94+
başlayabilirsiniz. Aynı zamanda [Next.js](https://github.com/zeit/next.js/#dynamic-import)'de de desteklenmektedir.
10795

108-
If you're setting up Webpack yourself, you'll probably want to read Webpack's
109-
[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).
96+
Eğer Webpack ayarlarını kendiniz yapıyorsanız, Webpack'in [kod bölümleme rehberini](https://webpack.js.org/guides/code-splitting/)
97+
okumayı tercih edebilirsiniz. Webpack ayarınız hayal meyal [buna benzeyecektir.](https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269)
11098

111-
When using [Babel](https://babeljs.io/), you'll need to make sure that Babel can
112-
parse the dynamic import syntax but is not transforming it. For that you will need [babel-plugin-syntax-dynamic-import](https://yarnpkg.com/en/package/babel-plugin-syntax-dynamic-import).
99+
[Babel](https://babeljs.io/) kullanıyorken, Babel'ın dinamik import sözdizimini çözümleyebildiğinden
100+
fakat dönüştürmediğinden emin olmanız gerekmekte. Bunun için [babel-plugin-syntax-dynamic-import](https://yarnpkg.com/en/package/babel-plugin-syntax-dynamic-import)'a ihtiyacınız var.
113101

114102
## `React.lazy` {#reactlazy}
115103

116-
> Note:
104+
> Not:
117105
>
118-
> `React.lazy` and Suspense is not yet available for server-side rendering. If you want to do code-splitting in a server rendered app, we recommend [Loadable Components](https://github.com/smooth-code/loadable-components). It has a nice [guide for bundle splitting with server-side rendering](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md).
106+
> `React.lazy` ve Suspense henüz server-side rendering için kullanılabilir değildir. Eğer server taraflı görüntülenen uygulamalar için
107+
> kod bölümleme yapmak isterseniz, [Loadable Components](https://github.com/smooth-code/loadable-components)'ı tavsiye ederiz. Çok iyi bir
108+
> [server-side rendering için paket bölümleme rehberi](https://github.com/smooth-code/loadable-components/blob/master/packages/server/README.md) var.
119109
120-
The `React.lazy` function lets you render a dynamic import as a regular component.
110+
`React.lazy` fonksiyonu, dinamik import'u normal bir bileşen gibi render etmeye yarar.
121111

122-
**Before:**
112+
**Önce:**
123113

124114
```js
125115
import OtherComponent from './OtherComponent';
@@ -133,7 +123,7 @@ function MyComponent() {
133123
}
134124
```
135125

136-
**After:**
126+
**Sonra:**
137127

138128
```js
139129
const OtherComponent = React.lazy(() => import('./OtherComponent'));
@@ -147,29 +137,30 @@ function MyComponent() {
147137
}
148138
```
149139

150-
This will automatically load the bundle containing the `OtherComponent` when this component gets rendered.
140+
Bu kod, bileşen render edildiğinde `OtherComponent`'ı içeren paketi otomatik olarak yükler.
151141

152-
`React.lazy` takes a function that must call a dynamic `import()`. This must return a `Promise` which resolves to a module with a `default` export containing a React component.
142+
`React.lazy`, dinamik `import()`'u çağıran bir fonksiyon alır. `default` ile dışarı aktarılan bir React bileşenini içeren modülü çözümleyen
143+
`Promise` return etmelidir.
153144

154145
### Suspense {#suspense}
155146

156-
If the module containing the `OtherComponent` is not yet loaded by the time `MyComponent` renders, we must show some fallback content while we're waiting for it to load - such as a loading indicator. This is done using the `Suspense` component.
147+
`MyComponent` render edildiğinde `OtherComponent`'ı içeren modül yüklenmediyse, yüklenmesini beklerken geçirdiğimiz süre içerisinde yükleme göstergesi gibi bir yedek içerik göstermeliyiz. Bu, `Suspense` bileşeniyle yapılır.
148+
157149

158150
```js
159151
const OtherComponent = React.lazy(() => import('./OtherComponent'));
160152

161153
function MyComponent() {
162154
return (
163155
<div>
164-
<Suspense fallback={<div>Loading...</div>}>
156+
<Suspense fallback={<div>Yükleniyor...</div>}>
165157
<OtherComponent />
166158
</Suspense>
167159
</div>
168160
);
169161
}
170162
```
171-
172-
The `fallback` prop accepts any React elements that you want to render while waiting for the component to load. You can place the `Suspense` component anywhere above the lazy component. You can even wrap multiple lazy components with a single `Suspense` component.
163+
`fallback` prop'u, bileşenin yüklenmesini beklerken göstermek istediğiniz herhangi bir React elemanını kabul eder. `Suspense` bileşenini, lazy bileşeninin üstünde herhangi bir yere yerleştirebilirsiniz. Birden fazla lazy bileşenini tek bir `Suspense` bileşeni içerisine bile alabilirsiniz.
173164

174165
```js
175166
const OtherComponent = React.lazy(() => import('./OtherComponent'));
@@ -178,7 +169,7 @@ const AnotherComponent = React.lazy(() => import('./AnotherComponent'));
178169
function MyComponent() {
179170
return (
180171
<div>
181-
<Suspense fallback={<div>Loading...</div>}>
172+
<Suspense fallback={<div>Yükleniyor...</div>}>
182173
<section>
183174
<OtherComponent />
184175
<AnotherComponent />
@@ -189,9 +180,9 @@ function MyComponent() {
189180
}
190181
```
191182

192-
### Error boundaries {#error-boundaries}
183+
### Hata Sınırları {#error-boundaries}
193184

194-
If the other module fails to load (for example, due to network failure), it will trigger an error. You can handle these errors to show a nice user experience and manage recovery with [Error Boundaries](/docs/error-boundaries.html). Once you've created your Error Boundary, you can use it anywhere above your lazy components to display an error state when there's a network error.
185+
Eğer diğer modül bir nedenden dolayı yüklenmezse (örneğin, ağ sorunu) hata fırlatacaktır. Güzel bir kullanıcı deneyimi sunmak ve kurtarmayı yönetmek için bu hataları [Hata Sınırları](/docs/error-boundaries.html) ile işleyebilirsiniz. Hata Sınırı oluşturduktan sonra, ağ sorunu olduğunda hata göstermek için Hata Sınırını lazy bileşenlerinizin üstünde herhangi bir yerde kullanabilirsiniz.
195186

196187
```js
197188
import MyErrorBoundary from './MyErrorBoundary';
@@ -201,7 +192,7 @@ const AnotherComponent = React.lazy(() => import('./AnotherComponent'));
201192
const MyComponent = () => (
202193
<div>
203194
<MyErrorBoundary>
204-
<Suspense fallback={<div>Loading...</div>}>
195+
<Suspense fallback={<div>Yükleniyor...</div>}>
205196
<section>
206197
<OtherComponent />
207198
<AnotherComponent />
@@ -212,19 +203,13 @@ const MyComponent = () => (
212203
);
213204
```
214205

215-
## Route-based code splitting {#route-based-code-splitting}
206+
## Rota bazlı kod bölümleme {#route-based-code-splitting}
216207

217-
Deciding where in your app to introduce code splitting can be a bit tricky. You
218-
want to make sure you choose places that will split bundles evenly, but won't
219-
disrupt the user experience.
208+
Uygulamanızda nereye kod bölümleme yapacağınıza karar vermek biraz zor olabilir. Paketlerinizi eşit parçalara ayıracak ama kullanıcı deneyimini de engellemeyecek yerler seçtiğinize emin olmalısınız.
220209

221-
A good place to start is with routes. Most people on the web are used to
222-
page transitions taking some amount of time to load. You also tend to be
223-
re-rendering the entire page at once so your users are unlikely to be
224-
interacting with other elements on the page at the same time.
210+
Rotalar, başlamak için güzel yerlerdir. Webteki çoğu insan, yüklenmesi biraz zaman alan sayfa geçişlerine alışıktır. Aynı zamanda tüm sayfayı tek seferde yeniden render etme eğiliminiz vardır ki kullanıcınız, aynı anda sayfanın başka bir elemanıyla etkileşime girmesin.
225211

226-
Here's an example of how to setup route-based code splitting into your app using
227-
libraries like [React Router](https://reacttraining.com/react-router/) with `React.lazy`.
212+
İşte [React Router](https://reacttraining.com/react-router/) gibi kütüphaneler kullanan uygulamalarda rota bazlı kod bölümlemenin `React.lazy` ile nasıl kurulabileceğine dair bir örnek.
228213

229214
```js
230215
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
@@ -235,7 +220,7 @@ const About = lazy(() => import('./routes/About'));
235220

236221
const App = () => (
237222
<Router>
238-
<Suspense fallback={<div>Loading...</div>}>
223+
<Suspense fallback={<div>Yükleniyor...</div>}>
239224
<Switch>
240225
<Route exact path="/" component={Home}/>
241226
<Route path="/about" component={About}/>
@@ -245,9 +230,9 @@ const App = () => (
245230
);
246231
```
247232

248-
## Named Exports {#named-exports}
233+
## İsimlendirilmiş Dışa Aktarımlar {#named-exports}
249234

250-
`React.lazy` currently only supports default exports. If the module you want to import uses named exports, you can create an intermediate module that reexports it as the default. This ensures that treeshaking keeps working and that you don't pull in unused components.
235+
`React.lazy` şu an için sadece default dışa aktarımları desteklemektedir. İçe aktarmak istediğiniz modül, isimlendirilmiş dışa aktarım kullanıyorsa; onu varsayılan olarak tekrar dışa aktaran aracı bir modül yaratabilirsiniz. Bu, ağaçlanmanın çalışmaya devam etmesini ve kullanılmayan bileşenleri çekmemenizi sağlar.
251236

252237
```js
253238
// ManyComponents.js

0 commit comments

Comments
 (0)