@verbaly/vite 0.79.0 → 0.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.js +6 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -41,9 +41,11 @@ import { t, setLocale } from 'verbaly/app';
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
- **`verbaly/app` is your project**: the plugin writes it from your config and catalogs, so `locales`, `routing` and a bound `switchLocale` are already there. Its old name, `virtual:verbaly`, still works and is the same module.
|
|
44
|
-
- **Live extraction** with debounced catalog writes + HMR, from `.js/.ts/.jsx/.tsx` and `.svelte`/`.vue` files (script and markup). Every write starts from the files on disk, so a checkout or an `extract` run in another terminal is never undone with an older text, and a catalog saved half-typed is reported in one line while the server keeps running. The terminal says what `next dev` says, once each: a hand edit of a text your code owns, a key with two texts, a `t` under another name, a translation older than its source. To keep the dev server from writing your translation files, pass `liveExtraction: false`: new texts still render from memory, as in a build, and `npx verbaly extract` writes them when you choose.
|
|
44
|
+
- **Live extraction** with debounced catalog writes + HMR, from `.js/.ts/.jsx/.tsx` and `.svelte`/`.vue` files (script and markup). The first write takes the texts of every file in `include`, opened or not, as `extract` does. Every write starts from the files on disk, so a checkout or an `extract` run in another terminal is never undone with an older text, and a catalog saved half-typed is reported in one line while the server keeps running. The terminal says what `next dev` says, once each: a hand edit of a text your code owns, a key with two texts, a `t` under another name, a translation older than its source. To keep the dev server from writing your translation files, pass `liveExtraction: false`: new texts still render from memory, as in a build, and `npx verbaly extract` writes them when you choose.
|
|
45
45
|
- **Typed keys**: the types go to `src/verbaly.d.ts` (the root when there is no `src/`), the folder the Vite and SvelteKit templates' `tsconfig` includes, so `tsc -b` sees them with nothing to configure. The dev server and every `vite build` write them. A script that checks types before it builds (`tsc -b && vite build`, as the React template does) runs before either, so on a fresh clone run `npx verbaly typegen` first.
|
|
46
46
|
- **Per-locale code-splitting**: `setLocale` lazy-loads only what's used.
|
|
47
|
+
- **Hooks with no provider**: a file that imports `@verbaly/react`, `@verbaly/vue` or `@verbaly/svelte` also loads `verbaly/app`, so `useT()` finds its instance in a single-page app with no provider, plugin or `provideVerbaly` above it.
|
|
48
|
+
- **The language a visitor chose**: `switchLocale` and the adapters' `useLocale` save it in the browser, and they and `setLocale` set `<html lang>` and `<html dir>`. A single-page app starts in its source language, so read the choice back before the first render: `setLocale(resolveLocale({ supported: locales, path: false })).then(render)`, with `resolveLocale` from `verbaly` and the rest from `verbaly/app`.
|
|
47
49
|
- **Build report**: every `vite build` says what `verbaly check` would fail on (broken translations first, then missing ones and keys no catalog has) and goes on, since a text never stops a deploy; `verbaly check` is the gate for CI. `failOnMissing: true` stops the build instead.
|
|
48
50
|
- **Files outside `include`**: when the dev server or the build starts, it names once every file outside your `include` that writes a `` t`…` ``, since that text is never extracted and shows in the source language.
|
|
49
51
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { APP_ID, LOCALE_IMPORT, LOCALE_MODULE_PREFIX, MessageRegistry, RESOLVED_VIRTUAL_ID, SOURCE_FILE_RE, createDevReporter, createSourceFilter, extractProject, formatCliError, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, outdatedTranslations, reportOutsideInclude, resolveVirtualId, runBuildGate, syncCatalogs, syncProject, transformSource, writeBuildTypes, writeDts } from "@verbaly/compiler";
|
|
1
|
+
import { APP_ID, LOCALE_IMPORT, LOCALE_MODULE_PREFIX, MessageRegistry, RESOLVED_VIRTUAL_ID, SOURCE_FILE_RE, createDevReporter, createSourceFilter, extractProject, formatCliError, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, outdatedTranslations, reportOutsideInclude, resolveVirtualId, runBuildGate, shippedCatalogs, syncCatalogs, syncProject, transformSource, writeBuildTypes, writeDts } from "@verbaly/compiler";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
// src/index.ts
|
|
4
4
|
function safeRead(file) {
|
|
@@ -22,7 +22,7 @@ function verbaly(options = {}) {
|
|
|
22
22
|
let stateBroken = false;
|
|
23
23
|
let scan;
|
|
24
24
|
let writing = Promise.resolve();
|
|
25
|
-
|
|
25
|
+
let registry = new MessageRegistry();
|
|
26
26
|
const selfWrites = /* @__PURE__ */ new Map();
|
|
27
27
|
function invalidateVirtual() {
|
|
28
28
|
if (!server) return;
|
|
@@ -88,7 +88,10 @@ function verbaly(options = {}) {
|
|
|
88
88
|
cfg = await loadConfig(options.root ?? viteConfig.root, options, { plugin: true });
|
|
89
89
|
catalogs = loadCatalogs(cfg);
|
|
90
90
|
included = createSourceFilter(cfg);
|
|
91
|
-
if (!isBuild)
|
|
91
|
+
if (!isBuild) {
|
|
92
|
+
registry = await extractProject(cfg);
|
|
93
|
+
writeBuildTypes(cfg, shippedCatalogs(cfg, catalogs, registry));
|
|
94
|
+
}
|
|
92
95
|
},
|
|
93
96
|
configureServer(devServer) {
|
|
94
97
|
server = devServer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0",
|
|
4
4
|
"description": "Zero-config Vite plugin for Verbaly: extraction, codegen and HMR.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@verbaly/compiler": "0.
|
|
45
|
+
"@verbaly/compiler": "0.80.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"verbaly": "^0.
|
|
48
|
+
"verbaly": "^0.80.0",
|
|
49
49
|
"vite": "^7.0.0 || ^8.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"verbaly": "^0.
|
|
53
|
-
"vite": "^8.3.
|
|
52
|
+
"verbaly": "^0.80.0",
|
|
53
|
+
"vite": "^8.3.6"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown",
|