@verbaly/unplugin 0.68.0 → 0.69.1
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 +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,12 +42,13 @@ verbaly.rspack({ locales: ['en', 'es'] });
|
|
|
42
42
|
Extraction runs via the CLI: add it to your dev loop or CI:
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
npx verbaly extract # scan sources, sync catalogs, write verbaly.d.ts
|
|
45
|
+
npx verbaly extract # scan sources, sync catalogs, write the types (src/verbaly.d.ts)
|
|
46
46
|
npx verbaly extract --watch # keep extracting as you code (dev loop)
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
- **Same virtual module**: `import { t, setLocale } from 'virtual:verbaly'`.
|
|
50
50
|
- **Build gate**: missing translations fail the build (`failOnMissing: false` to opt out).
|
|
51
|
+
- **Files outside `include`**: the build names once, when it starts, every file outside your `include` that writes a `` t`…` ``, since that text ships untranslated.
|
|
51
52
|
- ESM-only, like the compiler. Use `webpack.config.mjs` (or `"type": "module"`).
|
|
52
53
|
|
|
53
54
|
📖 Docs: **https://verbaly-web.vercel.app/docs/frameworks/vite#unplugin**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageRegistry, RESOLVED_VIRTUAL_ID, createSourceFilter, extractProject, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, resolveVirtualId, runBuildGate, syncCatalogs, transformSource } from "@verbaly/compiler";
|
|
1
|
+
import { MessageRegistry, RESOLVED_VIRTUAL_ID, createSourceFilter, extractProject, isTransformTarget, loadCatalogs, loadConfig, loadVirtualModule, reportOutsideInclude, resolveVirtualId, runBuildGate, syncCatalogs, transformSource } from "@verbaly/compiler";
|
|
2
2
|
import { createUnplugin } from "unplugin";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const factory = (options = {}) => {
|
|
@@ -12,11 +12,13 @@ const factory = (options = {}) => {
|
|
|
12
12
|
included = createSourceFilter(cfg);
|
|
13
13
|
syncCatalogs(cfg, catalogs, await extractProject(cfg));
|
|
14
14
|
})();
|
|
15
|
+
ready.catch(() => {});
|
|
15
16
|
return {
|
|
16
17
|
name: "verbaly",
|
|
17
18
|
enforce: "pre",
|
|
18
19
|
async buildStart() {
|
|
19
20
|
await ready;
|
|
21
|
+
await reportOutsideInclude(cfg);
|
|
20
22
|
},
|
|
21
23
|
resolveId(id) {
|
|
22
24
|
return resolveVirtualId(id) ?? null;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n MessageRegistry,\n RESOLVED_VIRTUAL_ID,\n createSourceFilter,\n extractProject,\n isTransformTarget,\n loadCatalogs,\n loadConfig,\n loadVirtualModule,\n resolveVirtualId,\n runBuildGate,\n syncCatalogs,\n transformSource,\n type Catalogs,\n type PluginOptions,\n type ResolvedConfig,\n} from '@verbaly/compiler';\nimport { createUnplugin, type UnpluginFactory, type UnpluginInstance } from 'unplugin';\n\n// the shared bundler-plugin options (config + failOnMissing), named for this plugin\nexport type UnpluginVerbalyOptions = PluginOptions;\n\n// build-focused: virtual modules + transform + gate.\nconst factory: UnpluginFactory<UnpluginVerbalyOptions | undefined> = (options = {}) => {\n let cfg: ResolvedConfig;\n let catalogs: Catalogs;\n let included: (id: string) => boolean;\n const registry = new MessageRegistry();\n const ready = (async () => {\n cfg = await loadConfig(options.root ?? process.cwd(), options);\n catalogs = loadCatalogs(cfg);\n included = createSourceFilter(cfg);\n // the code's text ships: a text it owns that was edited in the catalog never reaches the bundle\n syncCatalogs(cfg, catalogs, await extractProject(cfg));\n })();\n\n return {\n name: 'verbaly',\n enforce: 'pre',\n\n async buildStart() {\n await ready;\n },\n\n resolveId(id) {\n return resolveVirtualId(id) ?? null;\n },\n\n loadInclude(id) {\n return id.startsWith(RESOLVED_VIRTUAL_ID);\n },\n\n load(id) {\n return loadVirtualModule(id, cfg, catalogs) ?? null;\n },\n\n transformInclude(id) {\n return isTransformTarget(id);\n },\n\n transform(code, id) {\n if (!included(id)) return null;\n return transformSource(code, id, registry).result;\n },\n\n buildEnd() {\n runBuildGate(cfg, registry, options.failOnMissing);\n },\n };\n};\n\nexport const verbaly: UnpluginInstance<UnpluginVerbalyOptions | undefined> =\n createUnplugin(factory);\n\nexport default verbaly;\n\nexport type { VerbalyConfig } from '@verbaly/compiler';\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n MessageRegistry,\n RESOLVED_VIRTUAL_ID,\n createSourceFilter,\n extractProject,\n isTransformTarget,\n loadCatalogs,\n loadConfig,\n loadVirtualModule,\n reportOutsideInclude,\n resolveVirtualId,\n runBuildGate,\n syncCatalogs,\n transformSource,\n type Catalogs,\n type PluginOptions,\n type ResolvedConfig,\n} from '@verbaly/compiler';\nimport { createUnplugin, type UnpluginFactory, type UnpluginInstance } from 'unplugin';\n\n// the shared bundler-plugin options (config + failOnMissing), named for this plugin\nexport type UnpluginVerbalyOptions = PluginOptions;\n\n// build-focused: virtual modules + transform + gate.\nconst factory: UnpluginFactory<UnpluginVerbalyOptions | undefined> = (options = {}) => {\n let cfg: ResolvedConfig;\n let catalogs: Catalogs;\n let included: (id: string) => boolean;\n const registry = new MessageRegistry();\n const ready = (async () => {\n cfg = await loadConfig(options.root ?? process.cwd(), options);\n catalogs = loadCatalogs(cfg);\n included = createSourceFilter(cfg);\n // the code's text ships: a text it owns that was edited in the catalog never reaches the bundle\n syncCatalogs(cfg, catalogs, await extractProject(cfg));\n })();\n // buildStart awaits it and reports the failure; unwatched till then, a rejection ends the process\n ready.catch(() => {});\n\n return {\n name: 'verbaly',\n enforce: 'pre',\n\n async buildStart() {\n await ready;\n // a file outside include writes a t`…` that no build translates: said once, at the start\n await reportOutsideInclude(cfg);\n },\n\n resolveId(id) {\n return resolveVirtualId(id) ?? null;\n },\n\n loadInclude(id) {\n return id.startsWith(RESOLVED_VIRTUAL_ID);\n },\n\n load(id) {\n return loadVirtualModule(id, cfg, catalogs) ?? null;\n },\n\n transformInclude(id) {\n return isTransformTarget(id);\n },\n\n transform(code, id) {\n if (!included(id)) return null;\n return transformSource(code, id, registry).result;\n },\n\n buildEnd() {\n runBuildGate(cfg, registry, options.failOnMissing);\n },\n };\n};\n\nexport const verbaly: UnpluginInstance<UnpluginVerbalyOptions | undefined> =\n createUnplugin(factory);\n\nexport default verbaly;\n\nexport type { VerbalyConfig } from '@verbaly/compiler';\n"],"mappings":";;;AAwBA,MAAM,WAAgE,UAAU,CAAC,MAAM;CACrF,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM,WAAW,IAAI,gBAAgB;CACrC,MAAM,SAAS,YAAY;EACzB,MAAM,MAAM,WAAW,QAAQ,QAAQ,QAAQ,IAAI,GAAG,OAAO;EAC7D,WAAW,aAAa,GAAG;EAC3B,WAAW,mBAAmB,GAAG;EAEjC,aAAa,KAAK,UAAU,MAAM,eAAe,GAAG,CAAC;CACvD,EAAA,CAAG;CAEH,MAAM,YAAY,CAAC,CAAC;CAEpB,OAAO;EACL,MAAM;EACN,SAAS;EAET,MAAM,aAAa;GACjB,MAAM;GAEN,MAAM,qBAAqB,GAAG;EAChC;EAEA,UAAU,IAAI;GACZ,OAAO,iBAAiB,EAAE,KAAK;EACjC;EAEA,YAAY,IAAI;GACd,OAAO,GAAG,WAAW,mBAAmB;EAC1C;EAEA,KAAK,IAAI;GACP,OAAO,kBAAkB,IAAI,KAAK,QAAQ,KAAK;EACjD;EAEA,iBAAiB,IAAI;GACnB,OAAO,kBAAkB,EAAE;EAC7B;EAEA,UAAU,MAAM,IAAI;GAClB,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO;GAC1B,OAAO,gBAAgB,MAAM,IAAI,QAAQ,CAAC,CAAC;EAC7C;EAEA,WAAW;GACT,aAAa,KAAK,UAAU,QAAQ,aAAa;EACnD;CACF;AACF;AAEA,MAAa,UACX,eAAe,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/unplugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.1",
|
|
4
4
|
"description": "Verbaly for webpack, Rollup, esbuild and Rspack: extraction, virtual modules and build gate via unplugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@verbaly/compiler": "0.
|
|
45
|
+
"@verbaly/compiler": "0.69.1",
|
|
46
46
|
"unplugin": "^3.4.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"verbaly": "^0.
|
|
49
|
+
"verbaly": "^0.69.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"verbaly": "^0.
|
|
52
|
+
"verbaly": "^0.69.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown",
|