@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 CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo-light.png" alt="Verbaly" width="300" />
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 '@verbaly/compiler';
2
- export { VerbalyConfig } from '@verbaly/compiler';
3
- import { UnpluginInstance } from 'unplugin';
4
-
5
- interface UnpluginVerbalyOptions extends VerbalyConfig {
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 UnpluginVerbalyOptions, verbaly as default, verbaly };
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
- // src/index.ts
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
- var RESOLVED = "\0" + VIRTUAL_ID;
16
- var LOCALE_PREFIX = `${RESOLVED}/locale/`;
17
- var SOURCE_RE = /\.[cm]?[jt]sx?$/;
18
- var factory = (options = {}) => {
19
- let cfg;
20
- let catalogs;
21
- const registry = new MessageRegistry();
22
- const ready = (async () => {
23
- cfg = await loadConfig(options.root ?? process.cwd(), options);
24
- catalogs = loadCatalogs(cfg);
25
- })();
26
- return {
27
- name: "verbaly",
28
- enforce: "pre",
29
- async buildStart() {
30
- await ready;
31
- },
32
- resolveId(id) {
33
- if (id === VIRTUAL_ID || id.startsWith(`${VIRTUAL_ID}/`)) return "\0" + id;
34
- return null;
35
- },
36
- loadInclude(id) {
37
- return id.startsWith(RESOLVED);
38
- },
39
- load(id) {
40
- if (id === RESOLVED) return generateRuntimeModule(cfg);
41
- if (id.startsWith(LOCALE_PREFIX)) {
42
- return generateLocaleModule(catalogs[id.slice(LOCALE_PREFIX.length)] ?? {});
43
- }
44
- return null;
45
- },
46
- transformInclude(id) {
47
- return SOURCE_RE.test(id) && !id.includes("node_modules") && !id.startsWith("\0");
48
- },
49
- transform(code, id) {
50
- const analysis = analyze(code, id);
51
- registry.update(id, analysis);
52
- return transformCode(code, id, analysis) ?? null;
53
- },
54
- buildEnd() {
55
- if (options.failOnMissing === false) return;
56
- const result = check(cfg, loadCatalogs(cfg), registry);
57
- if (!result.ok) {
58
- throw new Error(
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":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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KAAK,aAAa,GAAG,GAAG,QAAQ;AACrD,UAAI,CAAC,OAAO,IAAI;AACd,cAAM,IAAI;AAAA,UACR;AAAA,EAA4B,kBAAkB,MAAM,CAAC;AAAA;AAAA,QAEvD;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,UACX,eAAe,OAAO;AAExB,IAAO,gBAAQ;","names":[]}
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.11.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.11.0"
46
+ "@verbaly/compiler": "0.13.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "verbaly": "^0.11.0"
49
+ "verbaly": "^0.13.0"
50
50
  },
51
51
  "devDependencies": {
52
- "verbaly": "0.11.0"
52
+ "verbaly": "0.13.0"
53
53
  },
54
54
  "scripts": {
55
- "build": "tsup",
56
- "dev": "tsup --watch",
55
+ "build": "tsdown",
56
+ "dev": "tsdown --watch",
57
57
  "test": "vitest run --passWithNoTests",
58
58
  "typecheck": "tsc --noEmit"
59
59
  }