@verbaly/unplugin 0.11.0 → 0.13.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 +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +49 -70
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo
|
|
2
|
+
<img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo.png" alt="Verbaly" width="300" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center"><em>Verbaly for webpack, Rollup, esbuild and Rspack — powered by unplugin.</em></p>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { VerbalyConfig } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
failOnMissing?: boolean;
|
|
1
|
+
import { VerbalyConfig, VerbalyConfig as VerbalyConfig$1 } from "@verbaly/compiler";
|
|
2
|
+
import { UnpluginInstance } from "unplugin";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface UnpluginVerbalyOptions extends VerbalyConfig$1 {
|
|
5
|
+
failOnMissing?: boolean;
|
|
7
6
|
}
|
|
8
7
|
declare const verbaly: UnpluginInstance<UnpluginVerbalyOptions | undefined>;
|
|
9
|
-
|
|
10
|
-
export { type
|
|
8
|
+
//#endregion
|
|
9
|
+
export { UnpluginVerbalyOptions, type VerbalyConfig, verbaly as default, verbaly };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,73 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
MessageRegistry,
|
|
4
|
-
VIRTUAL_ID,
|
|
5
|
-
analyze,
|
|
6
|
-
check,
|
|
7
|
-
formatCheckResult,
|
|
8
|
-
generateLocaleModule,
|
|
9
|
-
generateRuntimeModule,
|
|
10
|
-
loadCatalogs,
|
|
11
|
-
loadConfig,
|
|
12
|
-
transformCode
|
|
13
|
-
} from "@verbaly/compiler";
|
|
1
|
+
import { MessageRegistry, VIRTUAL_ID, analyze, check, formatCheckResult, generateLocaleModule, generateRuntimeModule, loadCatalogs, loadConfig, transformCode } from "@verbaly/compiler";
|
|
14
2
|
import { createUnplugin } from "unplugin";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
`[verbaly] build blocked
|
|
60
|
-
${formatCheckResult(result)}
|
|
61
|
-
Run \`npx verbaly extract\` and fill the missing translations.`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
var verbaly = createUnplugin(factory);
|
|
68
|
-
var index_default = verbaly;
|
|
69
|
-
export {
|
|
70
|
-
index_default as default,
|
|
71
|
-
verbaly
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const RESOLVED = "\0" + VIRTUAL_ID;
|
|
5
|
+
const LOCALE_PREFIX = `${RESOLVED}/locale/`;
|
|
6
|
+
const SOURCE_RE = /\.[cm]?[jt]sx?$/;
|
|
7
|
+
const factory = (options = {}) => {
|
|
8
|
+
let cfg;
|
|
9
|
+
let catalogs;
|
|
10
|
+
const registry = new MessageRegistry();
|
|
11
|
+
const ready = (async () => {
|
|
12
|
+
cfg = await loadConfig(options.root ?? process.cwd(), options);
|
|
13
|
+
catalogs = loadCatalogs(cfg);
|
|
14
|
+
})();
|
|
15
|
+
return {
|
|
16
|
+
name: "verbaly",
|
|
17
|
+
enforce: "pre",
|
|
18
|
+
async buildStart() {
|
|
19
|
+
await ready;
|
|
20
|
+
},
|
|
21
|
+
resolveId(id) {
|
|
22
|
+
if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return "\0" + id;
|
|
23
|
+
return null;
|
|
24
|
+
},
|
|
25
|
+
loadInclude(id) {
|
|
26
|
+
return id.startsWith(RESOLVED);
|
|
27
|
+
},
|
|
28
|
+
load(id) {
|
|
29
|
+
if (id === RESOLVED) return generateRuntimeModule(cfg);
|
|
30
|
+
if (id.startsWith(LOCALE_PREFIX)) return generateLocaleModule(catalogs[id.slice(LOCALE_PREFIX.length)] ?? {});
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
transformInclude(id) {
|
|
34
|
+
return SOURCE_RE.test(id) && !id.includes("node_modules") && !id.startsWith("\0");
|
|
35
|
+
},
|
|
36
|
+
transform(code, id) {
|
|
37
|
+
const analysis = analyze(code, id);
|
|
38
|
+
registry.update(id, analysis);
|
|
39
|
+
return transformCode(code, id, analysis) ?? null;
|
|
40
|
+
},
|
|
41
|
+
buildEnd() {
|
|
42
|
+
if (options.failOnMissing === false) return;
|
|
43
|
+
const result = check(cfg, loadCatalogs(cfg), registry);
|
|
44
|
+
if (!result.ok) throw new Error(`[verbaly] build blocked\n${formatCheckResult(result)}\nRun \`npx verbaly extract\` and fill the missing translations.`);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
72
47
|
};
|
|
48
|
+
const verbaly = createUnplugin(factory);
|
|
49
|
+
//#endregion
|
|
50
|
+
export { verbaly as default, verbaly };
|
|
51
|
+
|
|
73
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n MessageRegistry,\n VIRTUAL_ID,\n analyze,\n check,\n formatCheckResult,\n generateLocaleModule,\n generateRuntimeModule,\n loadCatalogs,\n loadConfig,\n transformCode,\n type Catalogs,\n type ResolvedConfig,\n type VerbalyConfig,\n} from '@verbaly/compiler';\nimport { createUnplugin, type UnpluginFactory, type UnpluginInstance } from 'unplugin';\n\nconst RESOLVED = '\\0' + VIRTUAL_ID;\nconst LOCALE_PREFIX = `${RESOLVED}/locale/`;\nconst SOURCE_RE = /\\.[cm]?[jt]sx?$/;\n\nexport interface UnpluginVerbalyOptions extends VerbalyConfig {\n failOnMissing?: boolean;\n}\n\n// build-focused: virtual modules + transform + gate.\nconst factory: UnpluginFactory<UnpluginVerbalyOptions | undefined> = (options = {}) => {\n let cfg: ResolvedConfig;\n let catalogs: Catalogs;\n const registry = new MessageRegistry();\n const ready = (async () => {\n cfg = await loadConfig(options.root ?? process.cwd(), options);\n catalogs = loadCatalogs(cfg);\n })();\n\n return {\n name: 'verbaly',\n enforce: 'pre',\n\n async buildStart() {\n await ready;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return '\\0' + id;\n return null;\n },\n\n loadInclude(id) {\n return id.startsWith(RESOLVED);\n },\n\n load(id) {\n if (id === RESOLVED) return generateRuntimeModule(cfg);\n if (id.startsWith(LOCALE_PREFIX)) {\n return generateLocaleModule(catalogs[id.slice(LOCALE_PREFIX.length)] ?? {});\n }\n return null;\n },\n\n transformInclude(id) {\n return SOURCE_RE.test(id) && !id.includes('node_modules') && !id.startsWith('\\0');\n },\n\n transform(code, id) {\n const analysis = analyze(code, id);\n registry.update(id, analysis);\n return transformCode(code, id, analysis) ?? null;\n },\n\n buildEnd() {\n if (options.failOnMissing === false) return;\n const result = check(cfg, loadCatalogs(cfg), registry);\n if (!result.ok) {\n throw new Error(\n `[verbaly] build blocked\\n${formatCheckResult(result)}\\n` +\n `Run \\`npx verbaly extract\\` and fill the missing translations.`,\n );\n }\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 VIRTUAL_ID,\n analyze,\n check,\n formatCheckResult,\n generateLocaleModule,\n generateRuntimeModule,\n loadCatalogs,\n loadConfig,\n transformCode,\n type Catalogs,\n type ResolvedConfig,\n type VerbalyConfig,\n} from '@verbaly/compiler';\nimport { createUnplugin, type UnpluginFactory, type UnpluginInstance } from 'unplugin';\n\nconst RESOLVED = '\\0' + VIRTUAL_ID;\nconst LOCALE_PREFIX = `${RESOLVED}/locale/`;\nconst SOURCE_RE = /\\.[cm]?[jt]sx?$/;\n\nexport interface UnpluginVerbalyOptions extends VerbalyConfig {\n failOnMissing?: boolean;\n}\n\n// build-focused: virtual modules + transform + gate.\nconst factory: UnpluginFactory<UnpluginVerbalyOptions | undefined> = (options = {}) => {\n let cfg: ResolvedConfig;\n let catalogs: Catalogs;\n const registry = new MessageRegistry();\n const ready = (async () => {\n cfg = await loadConfig(options.root ?? process.cwd(), options);\n catalogs = loadCatalogs(cfg);\n })();\n\n return {\n name: 'verbaly',\n enforce: 'pre',\n\n async buildStart() {\n await ready;\n },\n\n resolveId(id) {\n if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return '\\0' + id;\n return null;\n },\n\n loadInclude(id) {\n return id.startsWith(RESOLVED);\n },\n\n load(id) {\n if (id === RESOLVED) return generateRuntimeModule(cfg);\n if (id.startsWith(LOCALE_PREFIX)) {\n return generateLocaleModule(catalogs[id.slice(LOCALE_PREFIX.length)] ?? {});\n }\n return null;\n },\n\n transformInclude(id) {\n return SOURCE_RE.test(id) && !id.includes('node_modules') && !id.startsWith('\\0');\n },\n\n transform(code, id) {\n const analysis = analyze(code, id);\n registry.update(id, analysis);\n return transformCode(code, id, analysis) ?? null;\n },\n\n buildEnd() {\n if (options.failOnMissing === false) return;\n const result = check(cfg, loadCatalogs(cfg), registry);\n if (!result.ok) {\n throw new Error(\n `[verbaly] build blocked\\n${formatCheckResult(result)}\\n` +\n `Run \\`npx verbaly extract\\` and fill the missing translations.`,\n );\n }\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":";;;AAiBA,MAAM,WAAW,OAAO;AACxB,MAAM,gBAAgB,GAAG,SAAS;AAClC,MAAM,YAAY;AAOlB,MAAM,WAAgE,UAAU,CAAC,MAAM;CACrF,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;CAC7B,EAAA,CAAG;CAEH,OAAO;EACL,MAAM;EACN,SAAS;EAET,MAAM,aAAa;GACjB,MAAM;EACR;EAEA,UAAU,IAAI;GACZ,IAAI,OAAO,cAAc,GAAG,WAAW,GAAG,WAAW,EAAE,GAAG,OAAO,OAAO;GACxE,OAAO;EACT;EAEA,YAAY,IAAI;GACd,OAAO,GAAG,WAAW,QAAQ;EAC/B;EAEA,KAAK,IAAI;GACP,IAAI,OAAO,UAAU,OAAO,sBAAsB,GAAG;GACrD,IAAI,GAAG,WAAW,aAAa,GAC7B,OAAO,qBAAqB,SAAS,GAAG,MAAM,cAAc,MAAM,MAAM,CAAC,CAAC;GAE5E,OAAO;EACT;EAEA,iBAAiB,IAAI;GACnB,OAAO,UAAU,KAAK,EAAE,KAAK,CAAC,GAAG,SAAS,cAAc,KAAK,CAAC,GAAG,WAAW,IAAI;EAClF;EAEA,UAAU,MAAM,IAAI;GAClB,MAAM,WAAW,QAAQ,MAAM,EAAE;GACjC,SAAS,OAAO,IAAI,QAAQ;GAC5B,OAAO,cAAc,MAAM,IAAI,QAAQ,KAAK;EAC9C;EAEA,WAAW;GACT,IAAI,QAAQ,kBAAkB,OAAO;GACrC,MAAM,SAAS,MAAM,KAAK,aAAa,GAAG,GAAG,QAAQ;GACrD,IAAI,CAAC,OAAO,IACV,MAAM,IAAI,MACR,4BAA4B,kBAAkB,MAAM,EAAE,iEAExD;EAEJ;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.13.0",
|
|
4
4
|
"description": "Verbaly for webpack, Rollup, esbuild and Rspack — extraction, virtual modules and build gate via unplugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"unplugin": "^3.3.0",
|
|
46
|
-
"@verbaly/compiler": "0.
|
|
46
|
+
"@verbaly/compiler": "0.13.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"verbaly": "^0.
|
|
49
|
+
"verbaly": "^0.13.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"verbaly": "0.
|
|
52
|
+
"verbaly": "0.13.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
|
-
"build": "
|
|
56
|
-
"dev": "
|
|
55
|
+
"build": "tsdown",
|
|
56
|
+
"dev": "tsdown --watch",
|
|
57
57
|
"test": "vitest run --passWithNoTests",
|
|
58
58
|
"typecheck": "tsc --noEmit"
|
|
59
59
|
}
|