@verbaly/vite 0.77.0 → 0.79.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 CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ---
13
13
 
14
- The Vite plugin for [Verbaly](https://github.com/AronSoto/verbaly). Write natural text in your code; on save it extracts stable keys, syncs per-locale JSON catalogs, generates typed `virtual:verbaly` + `verbaly.d.ts`, and **fails `vite build` when a translation is missing**.
14
+ The Vite plugin for [Verbaly](https://github.com/AronSoto/verbaly). Write natural text in your code; on save it extracts stable keys, syncs per-locale JSON catalogs, generates `verbaly/app` (your project's typed module), and tells you in every build what `verbaly check` would fail on.
15
15
 
16
16
  ## 🚀 Install
17
17
 
@@ -37,11 +37,12 @@ export default { sourceLocale: 'en', locales: ['en', 'es', 'pt'] };
37
37
 
38
38
  ```ts
39
39
  // anywhere in your app, extracted + typed on save
40
- import { t, setLocale } from 'virtual:verbaly';
40
+ import { t, setLocale } from 'verbaly/app';
41
41
  ```
42
42
 
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.
43
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
- - **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. `npx verbaly typegen` writes them on a fresh clone.
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.
45
46
  - **Per-locale code-splitting**: `setLocale` lazy-loads only what's used.
46
47
  - **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.
47
48
  - **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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 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, 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, 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) {
@@ -8,7 +8,7 @@ function safeRead(file) {
8
8
  return;
9
9
  }
10
10
  }
11
- const VIRTUAL_ID_FILTER = new RegExp(`^${RESOLVED_VIRTUAL_ID.slice(1)}(?:/|$)`);
11
+ const VIRTUAL_ID_FILTER = new RegExp(`^(?:${RESOLVED_VIRTUAL_ID.slice(1)}(?:/|$)|${APP_ID}$|${LOCALE_IMPORT})`);
12
12
  const RESOLVED_ID_FILTER = new RegExp(`^${RESOLVED_VIRTUAL_ID}(?:/|$)`);
13
13
  const ANY_RESOLVED_ID = new RegExp(`^${RESOLVED_VIRTUAL_ID.charAt(0)}`);
14
14
  function verbaly(options = {}) {
@@ -118,6 +118,7 @@ function verbaly(options = {}) {
118
118
  if (!isBuild) return;
119
119
  scan = await extractProject(cfg, { keepSource: true });
120
120
  syncCatalogs(cfg, catalogs, scan);
121
+ writeBuildTypes(cfg, catalogs);
121
122
  },
122
123
  resolveId: {
123
124
  filter: { id: VIRTUAL_ID_FILTER },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/vite",
3
- "version": "0.77.0",
3
+ "version": "0.79.0",
4
4
  "description": "Zero-config Vite plugin for Verbaly: extraction, codegen and HMR.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -42,14 +42,14 @@
42
42
  "access": "public"
43
43
  },
44
44
  "dependencies": {
45
- "@verbaly/compiler": "0.77.0"
45
+ "@verbaly/compiler": "0.79.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "verbaly": "^0.77.0",
48
+ "verbaly": "^0.79.0",
49
49
  "vite": "^7.0.0 || ^8.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "verbaly": "^0.77.0",
52
+ "verbaly": "^0.79.0",
53
53
  "vite": "^8.3.5"
54
54
  },
55
55
  "scripts": {