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/ref/snowpack-plugin.rst
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ API Reference - Snowpack Plugin (@lingui/snowpack-plugin)
5
5
It's a good practice to use compiled message catalogs during development. However,
6
6
running :cli:`compile` everytime messages are changed soon becomes tedious.
7
7
8
-
``@lingui/snowpack-plugin`` is a snowpack loader, which compiles messages on the fly:
8
+
``@lingui/snowpack-plugin`` is a Snowpack plugin, which compiles messages on the fly:
9
9
10
10
Installation
11
11
============
@@ -32,15 +32,30 @@ Simply add ``@lingui/snowpack-plugin`` inside your ``snowpack.config.js``:
32
32
],
33
33
}
34
34
35
-
Then in your code all you need is to use dynamic() import. Extension is mandatory. In case of using po format, use ``.po``.
35
+
Then in your code all you need is to use `dynamic imports <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports>`_ to load only necessary catalog. Extension is mandatory. In case of using po format, use ``.po``.
36
36
37
-
.. code-block:: jsx
37
+
.. code-block:: ts
38
38
39
39
export async function dynamicActivate(locale: string) {
Comparing to `Webpack instructions for dynamic loading <./loader.html>`_, code snippet above doesn't rely on variable ``locale`` to do the actual import. Instead, we manually check every possible value using ``switch/case`` and import final catalog by exact path. This is default behavior (or restriction?) of `esbuild <https://esbuild.github.io>`_ - *extremely fast JavaScript bundler* used by Snowpack under the hood. There is `an issue regarding this feature <https://github.com/evanw/esbuild/issues/700>`_
58
+
Similar restrictions apply to Babel macros or other non-standard features - they won't work with ``esbuild``
59
+
45
60
See the `guide about dynamic loading catalogs <../guides/dynamic-loading-catalogs.html>`_
0 commit comments