@wuchale/vite-plugin 0.15.4 → 0.15.5

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/dist/index.d.ts CHANGED
@@ -14,14 +14,14 @@ type HotUpdateCtx = {
14
14
  declare class Wuchale {
15
15
  #private;
16
16
  name: string;
17
- constructor(configPath: string);
17
+ constructor(configPath?: string);
18
18
  configResolved: (config: {
19
19
  env: {
20
20
  DEV?: boolean;
21
21
  };
22
22
  root: string;
23
23
  }) => Promise<void>;
24
- handleHotUpdate: (ctx: HotUpdateCtx) => Promise<any[]>;
24
+ handleHotUpdate: (ctx: HotUpdateCtx) => Promise<never[] | undefined>;
25
25
  transform: {
26
26
  order: "pre";
27
27
  handler: (code: string, id: string, options?: {
package/dist/index.js CHANGED
@@ -81,14 +81,18 @@ class Wuchale {
81
81
  await this.#init(mode);
82
82
  };
83
83
  handleHotUpdate = async (ctx) => {
84
+ // This is mainly to make sure that PO catalog changes result in a page reload with new catalogs
84
85
  if (!(ctx.file in this.#adaptersByCatalogPath)) {
86
+ // prevent reloading whole app because of a change in compiled catalog
87
+ // triggered by extraction from single file, hmr handled by embedding patch
85
88
  if (this.#singleCompiledCatalogs.has(ctx.file)) {
86
89
  return [];
87
90
  }
91
+ // for granular as well
88
92
  for (const adapter of this.#granularLoadAdapters) {
89
93
  for (const loc of this.#locales) {
90
94
  for (const id in adapter.granularStateByID) {
91
- if (resolve(adapter.getCompiledFilePath(loc, id)) === id) {
95
+ if (resolve(adapter.getCompiledFilePath(loc, id)) === ctx.file) {
92
96
  return [];
93
97
  }
94
98
  }
@@ -97,12 +101,13 @@ class Wuchale {
97
101
  this.#hmrVersion++;
98
102
  return;
99
103
  }
104
+ // catalog changed
100
105
  const sourceTriggered = performance.now() - this.#lastSourceTriggeredPOWrite < 1000; // long enough threshold
101
106
  const invalidatedModules = new Set();
102
107
  for (const adapter of this.#adaptersByCatalogPath[ctx.file]) {
103
108
  const loc = adapter.catalogPathsToLocales[ctx.file];
104
109
  if (!sourceTriggered) {
105
- await adapter.loadCatalogNCompile(loc);
110
+ await adapter.loadCatalogNCompile(loc, this.#hmrVersion);
106
111
  }
107
112
  for (const loadID of adapter.getLoadIDs()) {
108
113
  const fileID = resolve(adapter.getCompiledFilePath(loc, loadID));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/vite-plugin",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "Protobuf-like i18n from plain code: Vite plugin",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -40,7 +40,7 @@
40
40
  "author": "K1DV5",
41
41
  "license": "MIT",
42
42
  "dependencies": {
43
- "wuchale": "^0.18.6"
43
+ "wuchale": "^0.18.8"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.9.3"