You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/advanced/optimization.md
+21-15Lines changed: 21 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,31 +3,33 @@
3
3
4
4
## Performance
5
5
6
-
As described in "[installation](../installation##from-cdn-or-without-a-bundler)" section, Vue I18n offer the following two built ES modules for Bundler.
6
+
As described in "[Different Distribution files](../extra/dist##from-cdn-or-without-a-bundler)" section, Vue I18n offer the following two built ES modules for Bundler.
For bundler, it’s configured to bundle `vue-i18n.esm-bundler.js` with [`@intlify/bundle-tools`](https://github.com/intlify/bundle-tools#intlifybundle-tools) as default. If you want to reduce the bundle size further, you can configure the bundler to use `vue-i18n.runtime.esm-bundler.js`, which is runtime only.
11
+
For bundler, it’s configured to bundle `vue-i18n.esm-bundler.js` with [`@intlify/unplugin-vue-i18n`](https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n) as default. If you want to reduce the bundle size further, you can configure the bundler to use `vue-i18n.runtime.esm-bundler.js`, which is runtime only.
12
12
13
-
:::danger NOTE
14
-
IF [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) is enabled, `vue-i18n.esm-bundler.js` would not work with compiler due to `eval` statements. These statements violate the `default-src 'self'` header. Instead you need to use `vue-i18n.runtime.esm-bundler.js`.
15
-
:::
13
+
The use of ES Module `vue-i18n.runtime.esm-bundler.js` means that **all locale messages have to pre-compile to Message functions or AST resources**. what this means it improves performance because vue-i18n just only execute Message functions, so no compilation.
16
14
17
-
:::warning NOTICE
18
-
From v9.3, the CSP issue can be worked around by JIT compilation of the vue-i18n message compiler. See [JIT compilation for details](#jit-compilation).
15
+
:::tip NOTE
16
+
Before v9.3, the locale messages will be compiled to Message functions, after v9.3 or later these will be compiled to AST with `@intlify/bundle-tools`.
19
17
:::
20
18
21
-
The use of this ES Module means that **all locale messages have to pre-compile to Message functions**. what this means it improves performance because vue-i18n just only execute Message functions, so no compilation.
22
-
23
-
Also, the message compiler is not bundled, therefore **bundle size can be reduced**
19
+
:::tip NOTE
20
+
Before v9.3, all locale messages are compiled with `@intlify/unplugin-vue-i18n`, so the message compiler is not bundled, **bundle size can be reduced**.
24
21
25
-
:::warning NOTICE
26
-
If you are using the JIT compilation, all locale messages will not necessarily be compiled with the Message function.
22
+
After v9.3, since the message compiler is also bundled, the bundle size cannot be reduced. **This is a trade-off**.
23
+
About the reason, See [JIT compilation for details](#jit-compilation).
24
+
:::
27
25
28
-
Also, since the message compiler is also bundled, the bundle size cannot be reduced. **This is a trade-off**.
26
+
:::danger NOTE
27
+
If [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) is enabled in before v9.3, `vue-i18n.esm-bundler.js` would not work with compiler due to `eval` statements. These statements violate the `default-src 'self'` header. Instead you need to use `vue-i18n.runtime.esm-bundler.js`.
29
28
:::
30
29
30
+
:::warning NOTICE
31
+
From v9.3, the CSP issue can be worked around by JIT compilation of the vue-i18n message compiler. See [JIT compilation for details](#jit-compilation).
32
+
:::
31
33
32
34
## How to configure
33
35
@@ -132,14 +134,14 @@ About how to configure for bundler, see the [here](#configure-feature-flags-for-
132
134
:new: 9.3+
133
135
:::
134
136
135
-
Before v9.3, vue-i18n message compiler precompiled locale messages like AOT.
137
+
Before v9.3, vue-i18n message compiler precompiled locale messages like AOT (Ahead Of Time).
136
138
137
139
However, it had the following issues:
138
140
139
141
- CSP issues: hard to work on service/web workers, edge-side runtimes of CDNs and etc.
140
142
- Back-end integration: hard to get messages from back-end such as database via API and localize them dynamically
141
143
142
-
To solve these issues, JIT style compilation is supported message compiler.
144
+
To solve these issues, JIT (Just In Time) style compilation is supported message compiler.
143
145
144
146
Each time localization is performed in an application using `$t` or `t` functions, message resources will be compiled on message compiler.
145
147
@@ -152,6 +154,10 @@ You need to configure the following feature flag with `esm-bundler` build and bu
152
154
This feature is opted out as default, because compatibility with previous version before v9.3.
153
155
:::
154
156
157
+
:::warning NOTICE
158
+
From v10, JIT compilation is enabled by default, so it is no longer necessary to set the `__INTLIFY_JIT_COMPILATION__` flag in the bundler.
159
+
:::
160
+
155
161
About how to configure for bundler, see the [here](#configure-feature-flags-for-bundler).
0 commit comments