@verbaly/vite 0.76.0 → 0.78.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,10 +37,11 @@ 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
- - **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.
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
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. `npx verbaly typegen` writes them on a fresh clone.
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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { PluginOptions, VerbalyConfig } from "@verbaly/compiler";
2
2
  import { Plugin } from "vite";
3
- //#region src/index.d.ts
4
3
  export type ViteVerbalyOptions = PluginOptions;
5
4
  export default function verbaly(options?: ViteVerbalyOptions): Plugin;
6
- //#endregion
7
5
  export type { VerbalyConfig };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
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, writeDts } from "@verbaly/compiler";
2
2
  import { readFileSync } from "node:fs";
3
- //#region src/index.ts
3
+ // src/index.ts
4
4
  function safeRead(file) {
5
5
  try {
6
6
  return readFileSync(file, "utf8");
@@ -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 = {}) {
@@ -64,9 +64,11 @@ function verbaly(options = {}) {
64
64
  registry,
65
65
  catalogs: loadCatalogs(cfg),
66
66
  confirm: true,
67
- write: "changed"
67
+ write: "changed",
68
+ dryRun: options.liveExtraction === false
68
69
  });
69
70
  catalogs = result.catalogs;
71
+ if (options.liveExtraction === false) flushDts();
70
72
  for (const [locale, serialized] of Object.entries(result.written)) selfWrites.set(locale, serialized);
71
73
  report(result, catalogEdit);
72
74
  invalidateVirtual();
@@ -157,5 +159,4 @@ function verbaly(options = {}) {
157
159
  }
158
160
  };
159
161
  }
160
- //#endregion
161
162
  export { verbaly as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/vite",
3
- "version": "0.76.0",
3
+ "version": "0.78.0",
4
4
  "description": "Zero-config Vite plugin for Verbaly: extraction, codegen and HMR.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -18,6 +18,10 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/AronSoto/verbaly/issues"
20
20
  },
21
+ "funding": {
22
+ "type": "github",
23
+ "url": "https://github.com/sponsors/AronSoto"
24
+ },
21
25
  "type": "module",
22
26
  "types": "./dist/index.d.ts",
23
27
  "exports": {
@@ -38,14 +42,14 @@
38
42
  "access": "public"
39
43
  },
40
44
  "dependencies": {
41
- "@verbaly/compiler": "0.76.0"
45
+ "@verbaly/compiler": "0.78.0"
42
46
  },
43
47
  "peerDependencies": {
44
- "verbaly": "^0.76.0",
48
+ "verbaly": "^0.78.0",
45
49
  "vite": "^7.0.0 || ^8.0.0"
46
50
  },
47
51
  "devDependencies": {
48
- "verbaly": "^0.76.0",
52
+ "verbaly": "^0.78.0",
49
53
  "vite": "^8.3.5"
50
54
  },
51
55
  "scripts": {