Skip to content
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

docs: Translation Japanese #4934

Open
wants to merge 45 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b2b7d33
copy docs/ja/config/README.md
tiwuofficial Dec 4, 2019
9e8aacc
copy docs/ja/README.md
tiwuofficial Dec 4, 2019
930420e
copy docs/ja/core-plugins/babel.md
tiwuofficial Dec 4, 2019
506e7c1
copy docs/ja/core-plugins/README.md
tiwuofficial Dec 4, 2019
ef008d3
copy docs/ja/core-plugins/e2e-cypress.md
tiwuofficial Dec 5, 2019
1aa1984
copy docs/ja/core-plugins/e2e-nightwatch.md
tiwuofficial Dec 5, 2019
a85300b
copy docs/ja/core-plugins/eslint.md
tiwuofficial Dec 5, 2019
60e9789
copy docs/ja/core-plugins/pwa.md
tiwuofficial Dec 5, 2019
34512b0
copy docs/ja/core-plugins/router.md
tiwuofficial Dec 5, 2019
4f29567
copy docs/ja/core-plugins/typescript.md
tiwuofficial Dec 5, 2019
df3d8b6
copy docs/ja/core-plugins/unit-jest.md
tiwuofficial Dec 5, 2019
2c04e86
copy docs/ja/core-plugins/unit-mocha.md
tiwuofficial Dec 5, 2019
af1408f
copy docs/ja/core-plugins/vuex.md
tiwuofficial Dec 5, 2019
dde28df
copy docs/ja/dev-guide/generator-api.md
tiwuofficial Dec 5, 2019
87c2f32
copy docs/ja/dev-guide/plugin-api.md
tiwuofficial Dec 5, 2019
1c3d57f
copy docs/ja/dev-guide/plugin-dev.md
tiwuofficial Dec 6, 2019
0670cb0
copy docs/ja/dev-guide/ui-api.md
tiwuofficial Dec 6, 2019
8c0f57c
copy docs/ja/dev-guide/ui-info.md
tiwuofficial Dec 6, 2019
ffda3c0
copy docs/ja/dev-guide/ui-localization.md
tiwuofficial Dec 6, 2019
9de2ddb
copy docs/ja/guide/README.md
tiwuofficial Dec 6, 2019
b8bacb1
copy docs/ja/guide/browser-compatibility.md
tiwuofficial Dec 6, 2019
81a7ed5
copy docs/ja/guide/build-targets.md
tiwuofficial Dec 6, 2019
99114e1
copy docs/ja/guide/cli-service.md
tiwuofficial Dec 6, 2019
f558d1f
copy docs/ja/guide/creating-a-project.md
tiwuofficial Dec 6, 2019
4a0dd32
copy docs/ja/guide/css.md
tiwuofficial Dec 6, 2019
c48aafa
copy docs/ja/guide/deployment.md
tiwuofficial Dec 6, 2019
c57e63c
copy docs/ja/guide/html-and-static-assets.md
tiwuofficial Dec 6, 2019
e753088
copy docs/ja/guide/installation.md
tiwuofficial Dec 6, 2019
e09eaf5
copy docs/ja/guide/mode-and-env.md
tiwuofficial Dec 6, 2019
a3b7361
copy docs/ja/guide/plugins-and-presets.md
tiwuofficial Dec 6, 2019
e74403e
copy docs/ja/guide/prototyping.md
tiwuofficial Dec 6, 2019
9cc7469
copy docs/ja/guide/troubleshooting.md
tiwuofficial Dec 6, 2019
a787bd5
copy docs/ja/guide/webpack.md
tiwuofficial Dec 6, 2019
62e05a8
copy docs/ja/migrating-from-v3/README.md
tiwuofficial Dec 6, 2019
5bc4476
copy docs/.vuepress/config.js
tiwuofficial Dec 6, 2019
f822c12
translation from en into ja docs/.vuepress/config.js
tiwuofficial Dec 6, 2019
fa087c7
translation from en into ja docs/ja/README.md
tiwuofficial Dec 6, 2019
672849a
完全に構成可能 -> 設定可能
tiwuofficial Dec 10, 2019
bc67624
単一のVueファイル -> 単一ファイルコンポーネント
tiwuofficial Dec 10, 2019
3888872
将来の準備 -> 将来に向けて
tiwuofficial Dec 10, 2019
410a2b6
translation from en into ja docs/ja/core-plugins/README.md
tiwuofficial Dec 13, 2019
3028af4
Revert "translation from en into ja docs/ja/core-plugins/README.md"
tiwuofficial Dec 13, 2019
bd75e3e
translation from en into ja docs/ja/core-plugins/README.md
tiwuofficial Dec 13, 2019
1e8e701
translation from en into ja docs/ja/core-plugins/vuex.md
tiwuofficial Jan 8, 2020
7ed51a6
translation from en into ja docs/ja/core-plugins/router.md
tiwuofficial Jan 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
copy docs/ja/guide/browser-compatibility.md
  • Loading branch information
tiwuofficial committed Dec 6, 2019
commit b8bacb18d38a4acde9a6e65a02fccaca1eed3999
101 changes: 101 additions & 0 deletions docs/ja/guide/browser-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Browser Compatibility

## browserslist

You will notice a `browserslist` field in `package.json` (or a separate `.browserslistrc` file) specifying a range of browsers the project is targeting. This value will be used by [@babel/preset-env][babel-preset-env] and [autoprefixer][autoprefixer] to automatically determine the JavaScript features that need to be transpiled and the CSS vendor prefixes needed.

See [here][browserslist] for how to specify browser ranges.

## Polyfills

A default Vue CLI project uses [@vue/babel-preset-app][babel-preset-app], which uses `@babel/preset-env` and the `browserslist` config to determine the Polyfills needed for your project.

### useBuiltIns: 'usage'

By default, it passes [`useBuiltIns: 'usage'`](https://new.babeljs.io/docs/en/next/babel-preset-env.html#usebuiltins-usage) to `@babel/preset-env` which automatically detects the polyfills needed based on the language features used in your source code. This ensures only the minimum amount of polyfills are included in your final bundle. However, this also means **if one of your dependencies has specific requirements on polyfills, by default Babel won't be able to detect it.**

If one of your dependencies need polyfills, you have a few options:

1. **If the dependency is written in an ES version that your target environments do not support:** Add that dependency to the [`transpileDependencies`](../config/#transpiledependencies) option in `vue.config.js`. This would enable both syntax transforms and usage-based polyfill detection for that dependency.

2. **If the dependency ships ES5 code and explicitly lists the polyfills needed:** you can pre-include the needed polyfills using the [polyfills](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app#polyfills) option for `@vue/babel-preset-app`. **Note that `es6.promise` is included by default because it's very common for libs to depend on Promises.**

``` js
// babel.config.js
module.exports = {
presets: [
['@vue/app', {
polyfills: [
'es6.promise',
'es6.symbol'
]
}]
]
}
```

::: tip
It's recommended to add polyfills this way instead of directly importing them in your source code, because polyfills listed here can be automatically excluded if your `browserslist` targets don't need them.
:::

3. **If the dependency ships ES5 code, but uses ES6+ features without explicitly listing polyfill requirements (e.g. Vuetify):** Use `useBuiltIns: 'entry'` and then add `import '@babel/polyfill'` to your entry file. This will import **ALL** polyfills based on your `browserslist` targets so that you don't need to worry about dependency polyfills anymore, but will likely increase your final bundle size with some unused polyfills.

See [@babel-preset/env docs](https://new.babeljs.io/docs/en/next/babel-preset-env.html#usebuiltins-usage) for more details.

### Polyfills when Building as Library or Web Components

When using Vue CLI to [build a library or Web Components](./build-targets.md), it is recommended to pass `useBuiltIns: false` to `@vue/babel-preset-app` to disable automatic polyfill injection. This ensures you don't include unnecessary polyfills in your code, as it should be the responsibility of the consuming app to include polyfills.

## Modern Mode

With Babel we are able to leverage all the newest language features in ES2015+, but that also means we have to ship transpiled and polyfilled bundles in order to support older browsers. These transpiled bundles are often more verbose than the original native ES2015+ code, and also parse and run slower. Given that today a good majority of the modern browsers have decent support for native ES2015, it is a waste that we have to ship heavier and less efficient code to those browsers just because we have to support older ones.

Vue CLI offers a "Modern Mode" to help you solve this problem. When building for production with the following command:

``` bash
vue-cli-service build --modern
```

Vue CLI will produce two versions of your app: one modern bundle targeting modern browsers that support [ES modules](https://jakearchibald.com/2017/es-modules-in-browsers/), and one legacy bundle targeting older browsers that do not.

The cool part though is that there are no special deployment requirements. The generated HTML file automatically employs the techniques discussed in [Phillip Walton's excellent post](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/):

- The modern bundle is loaded with `<script type="module">`, in browsers that support it; they are also preloaded using `<link rel="modulepreload">` instead.

- The legacy bundle is loaded with `<script nomodule>`, which is ignored by browsers that support ES modules.

- A fix for `<script nomodule>` in Safari 10 is also automatically injected.

For a Hello World app, the modern bundle is already 16% smaller. In production, the modern bundle will typically result in significantly faster parsing and evaluation, improving your app's loading performance.

::: tip
`<script type="module">` is loaded [with CORS always enabled](https://jakearchibald.com/2017/es-modules-in-browsers/#always-cors). This means your server must return valid CORS headers such as `Access-Control-Allow-Origin: *`. If you want to fetch the scripts with credentials, set the [crossorigin](../config/#crossorigin) option to `use-credentials`.

Also, modern mode uses an inline script to avoid Safari 10 loading both bundles, so if you are using a strict CSP, you will need to explicitly allow the inline script with:

```
Content-Security-Policy: script-src 'self' 'sha256-4RS22DYeB7U14dra4KcQYxmwt5HkOInieXK1NUMBmQI='
```
:::

::: tip Detecting the Current Mode in Config
Sometimes you may need to change the webpack config only for the legacy build, or only for the modern build.

Vue CLI uses two environment variables to communicate this:

* `VUE_CLI_MODERN_MODE`: The build was started with the `--modern` flag
* `VUE_CLI_MODERN_BUILD`: when true, the current config is for the modern build. Otherwise it's for the legacy build.

**Important:** These variables are only accessible when/after `chainWebpack()` and `configureWebpack()` functions are evaluated, (so not directly in the `vue.config.js` module's root scope). That means it's also available in the postcss config file.
:::

::: warning Caveat: Adjusting webpack plugins
Some Plugins, i.e. `html-webpack-plugin`, `preload-plugin` etc. are only included in the config for modern mode. Trying to tap into their options in the legacy config can throw an error as the plugins don't exist.

Use the above tip about *Detecting the Current Mode* to manipulate plugins in the right mode only, and/or check if the plugin actually exists in the current mode's config before trying to tap into their options.
:::

[autoprefixer]: https://github.com/postcss/autoprefixer
[babel-preset-env]: https://new.babeljs.io/docs/en/next/babel-preset-env.html
[babel-preset-app]: https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app
[browserslist]: https://github.com/ai/browserslist