Skip to content

Commit d81975a

Browse files
committed
docs: translate single-file-component page
1 parent cbf80de commit d81975a

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/guide/single-file-component.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## 前書き
44

5-
多くの Vue プロジェクトでは、 グローバルコンポーネントは `app.mount('#app')` の後に各ページの body においてコンテナ要素のターゲットすることに続いて、`app.component()` を使用して定義されています。
5+
多くの Vue プロジェクトでは、グローバルコンポーネントは `app.mount('#app')` の後に各ページの body においてコンテナ要素のターゲットすることに続いて、`app.component()` を使用して定義されています。
66

77
これはある view を拡張するためだけに JavaScript が利用された中小規模のプロジェクトにおいてはとても有効です。しかしながら、あなたのフロントエンドで JavaScript 全体を操作するようなもっと複雑なプロジェクトでは、これらの点において不利益になります。:
88

99
- **グローバル宣言**は全てのコンポーネントに一意な名前を強制すること
1010
- シンタックスハイライトがない**文字列テンプレート**と複数行 HTML の時の醜いスラッシュが強要されること
1111
- **CSS サポート無し**だと HTML と JavaScript がコンポーネントにモジュール化されている間、これ見よがしに無視されること
12-
- **ビルド処理がない**と Pug(前 Jade)と Babel のようなプリプロセッサよりむしろ、 HTML や ES5 JavaScript を制限されること
12+
- **ビルド処理がない**と Pug(前 Jade)と Babel のようなプリプロセッサよりむしろ、HTML や ES5 JavaScript を制限されること
1313

1414
これらは全ては Webpack や Browserify のビルドツールにより実現された `.vue`拡張子の**単一ファイルコンポーネント**によって解決されます。
1515

@@ -23,15 +23,15 @@
2323
- [CommonJS モジュール](https://webpack.js.org/concepts/modules/#what-is-a-webpack-module)
2424
- [コンポーネントスコープ CSS](https://vue-loader.vuejs.org/en/features/scoped-css.html)
2525

26-
約束した通り、Pug、Babel (ES2015 モジュールと一緒に) や Stylus など 綺麗で機能が豊富なコンポーネントもプリプロセッサとして利用することができます
26+
約束した通り、Pug、Babel (ES2015 モジュールと一緒に) や Stylus など綺麗で機能が豊富なコンポーネントもプリプロセッサとして利用することができます
2727

2828
<a href="https://codesandbox.io/s/vue-single-file-component-with-pre-processors-mr3ik?file=/src/App.vue" target="_blank" rel="noopener noreferrer"><img src="/images/sfc-with-preprocessors.png" width="563" alt="Single-file component with pre-processors example (click for code as text)" style="display: block; margin: 15px auto; max-width: 100%"></a>
2929

3030
これらの特定の言語は単なる一例です。TypeScript、SCSS、PostCSS などの生産的なプリプロセッサも簡単に使うことができます。もし `vue-loader` で Webpack を使用しているならば、CSS Modules 向けに素晴らしいサポートがあります。
3131

3232
### 関心の分離について
3333

34-
注意すべき重要な点の1つは**関心の分離がファイルタイプの分離とは等しくないことです。** 現代の UI 開発では、私たちはコードベースを互いに織りなす3つの巨大なレイヤーに分割するのではなく、それらを疎結合なコンポーネントに分割して構成する方がはるかに理にかなっていることを発見しました。コンポーネントの内部では、そのテンプレート、ロジック、スタイルが本質的に結合しており、実際にそれらを配置することでコンポーネントの一貫性と保守性が高くなります。
34+
注意すべき重要な点の 1 つは**関心の分離がファイルタイプの分離とは等しくないことです。** 現代の UI 開発では、私たちはコードベースを互いに織りなす 3 つの巨大なレイヤーに分割するのではなく、それらを疎結合なコンポーネントに分割して構成する方がはるかに理にかなっていることを発見しました。コンポーネントの内部では、そのテンプレート、ロジック、スタイルが本質的に結合しており、実際にそれらを配置することでコンポーネントの一貫性と保守性が高くなります。
3535

3636
単一ファイルコンポーネントのアイディアが好きではなくても、JavaScript と CSS を別々ファイルに分けることによってホットリロードとプリコンパイル機能を活用することができます:
3737

@@ -58,68 +58,68 @@
5858

5959
- **ES2015/16 を使ったモダンな JavaScript**: Babel の [Learn ES2015 guide](https://babeljs.io/docs/en/learn)を読んでみてください。今すぐには全ての機能を暗記する必要はないですが、参考として戻れるようにしておいてください。
6060

61-
これらのリソースに没頭した後は、[Vue CLI](https://cli.vuejs.org/)を確認することをお勧めします。 指示に従うことであっという間に `.vue` コンポーネントと ES2015、 Webpack、ホットリローティングを備えた Vue プロジェクトを手に入れられるはずです!
61+
これらのリソースに没頭した後は、[Vue CLI](https://cli.vuejs.org/)を確認することをお勧めします。 指示に従うことであっという間に `.vue` コンポーネントと ES2015、Webpack、ホットリローティングを備えた Vue プロジェクトを手に入れられるはずです!
6262

6363
### 上級ユーザ向け
6464

6565
CLI はツールの設定の大部分の面倒を見てくれますが、[設定オプション](https://cli.vuejs.org/config/)を通してよりきめ細かいカスタマイズをすることもできます。
6666

6767
あなたが独自のビルドセットアップをゼロから作ることを好む場合、webpack と [vue-loader](https://vue-loader.vuejs.org)を手動で設定する必要があるでしょう。webpack についてもっと学びたいときは、[公式ドキュメント](https://webpack.js.org/configuration/)[webpack learning academy](https://webpack.academy/p/the-core-concepts)を参照してください。
6868

69-
### Building with rollup
69+
### Rollup でビルド
7070

71-
Most of the time when developing a third-party library we want to build it in a way that allows the consumers of the library to [tree shake](https://webpack.js.org/guides/tree-shaking/) it. To enable tree-shaking we need to build `esm` modules. Since webpack and, in turn, vue-cli do not support building `esm` modules we need to rely on [rollup](https://rollupjs.org/).
71+
ほとんどの場合、サードパーティのライブラリを開発するときは、そのライブラリの利用者が [Tree Shaking](https://webpack.js.org/guides/tree-shaking/) できるような方法でビルドしたいと考えています。Tree Shaking を有効にするためには、`esm` モジュールをビルドする必要があります。 Webpack や Vue CLI は `esm` モジュールのビルドをサポートしていないため、[Rollup](https://rollupjs.org/) の依存が必要です。
7272

73-
#### Installing Rollup
73+
#### Rollup のインストール
7474

75-
We will need to install Rollup and a few dependencies:
75+
Rollup といくつかの依存関係をインストールする必要があります:
7676

7777
```bash
7878
npm install --save-dev rollup @rollup/plugin-commonjs rollup-plugin-vue
7979
```
8080

81-
These are the minimal amount of rollup plugins that we need to use to compile the code in an `esm` module. We may want to also add [rollup-plugin-babel](https://github.com/rollup/plugins/tree/master/packages/babel) to transpile their code and [node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) if we use dependencies that we want to bundle with our library.
81+
これらは `esm` モジュールのコードをコンパイルするために必要な最小限の Rollup プラグインです。コードをコンパイルするために [rollup-plugin-babel](https://github.com/rollup/plugins/tree/master/packages/babel) を、ライブラリにバンドルしたい依存関係を使うならば [node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) を追加できます。
8282

83-
#### Configuring Rollup
83+
#### Rollup の設定
8484

85-
To configure our build with Rollup we will need to create a `rollup.config.js` file in the root of our project:
85+
Rollup でビルドを設定するには、プロジェクトのルートに `rollup.config.js` ファイルを作成する必要があります:
8686

8787
```bash
8888
touch rollup.config.js
8989
```
9090

91-
Once the file is created we will need to open it with our editor of choice and add the following code.
91+
ファイルを作成したら、お好きなエディタで開き、以下のコードを追加します。
9292

9393
```js
94-
// import our third party plugins
94+
// サードパーティのプラグインをインポート
9595
import commonjs from 'rollup-plugin-commonjs'
9696
import VuePlugin from 'rollup-plugin-vue'
97-
import pkg from './package.json' // import our package.json file to re-use the naming
97+
import pkg from './package.json' // 名前を再利用するために package.json ファイルをインポート
9898

9999
export default {
100-
// this is the file containing all our exported components/functions
100+
// エクスポートされたすべてのコンポーネントや関数を含むファイル
101101
input: 'src/index.js',
102-
// this is an array of outputted formats
102+
// 出力されるフォーマットの配列
103103
output: [
104104
{
105-
file: pkg.module, // the name of our esm library
106-
format: 'esm', // the format of choice
107-
sourcemap: true, // ask rollup to include sourcemaps
105+
file: pkg.module, // esm ライブラリの名前
106+
format: 'esm', // フォーマットの選択
107+
sourcemap: true, // ソースマップを含めるか
108108
}
109109
],
110-
// this is an array of the plugins that we are including
110+
// 含めるプラグインの配列
111111
plugins: [
112112
commonjs(),
113113
VuePlugin()
114114
],
115-
// ask rollup to not bundle Vue in the library
115+
// ライブラリに Vue をバンドルしないように
116116
external: ['vue']
117117
}
118118
```
119119

120-
#### Configuring package.json
120+
#### package.json の設定
121121

122-
To take advantage of our newly created `esm` module we need to add a few fields in our `package.json` file:
122+
新しく作成した `esm` モジュールを利用するためには、`package.json` ファイルにいくつかのフィールドを追加する必要があります:
123123

124124
```json
125125
"scripts": {
@@ -133,15 +133,15 @@ To take advantage of our newly created `esm` module we need to add a few fields
133133
],
134134
```
135135

136-
Here we are specifying:
136+
ここで指定しています:
137137

138-
- how to build our package
139-
- what files we want to bundle in our package
140-
- what file represents our `esm` module
138+
- パッケージのビルド方法
139+
- パッケージにバンドルするファイル
140+
- `esm` モジュールを示すファイル
141141

142-
#### Bundling `umd` and `cjs` modules
142+
#### `umd` `cjs` のバンドル
143143

144-
To also build `umd` and `cjs` modules we can simply add a few lines of configuration to our `rollup.config.js` and `package.json`
144+
`umd` `cjs` モジュールを一緒にビルドするには、`rollup.config.js` `package.json` に数行の設定を追加するだけです。
145145

146146
##### rollup.config.js
147147
```js

0 commit comments

Comments
 (0)