@wuchale/vite-plugin 0.15.5 → 0.15.6

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -14,13 +14,14 @@ class Wuchale {
14
14
  #singleCompiledCatalogs = new Set();
15
15
  #locales = [];
16
16
  #log;
17
+ #mode;
17
18
  #configPath;
18
19
  #hmrVersion = -1;
19
20
  #lastSourceTriggeredPOWrite = 0;
20
21
  constructor(configPath) {
21
22
  this.#configPath = configPath;
22
23
  }
23
- #init = async (mode) => {
24
+ #init = async () => {
24
25
  this.#config = await getConfig(this.#configPath);
25
26
  this.#log = new Logger(this.#config.logLevel);
26
27
  this.#locales = [this.#config.sourceLocale, ...this.#config.otherLocales];
@@ -29,7 +30,7 @@ class Wuchale {
29
30
  }
30
31
  const sharedState = {};
31
32
  for (const [key, adapter] of Object.entries(this.#config.adapters)) {
32
- const handler = new AdapterHandler(adapter, key, this.#config, mode, this.#projectRoot, this.#log);
33
+ const handler = new AdapterHandler(adapter, key, this.#config, this.#mode, this.#projectRoot, this.#log);
33
34
  await handler.init(sharedState);
34
35
  handler.onBeforeWritePO = () => {
35
36
  this.#lastSourceTriggeredPOWrite = performance.now();
@@ -70,17 +71,19 @@ class Wuchale {
70
71
  }
71
72
  };
72
73
  configResolved = async (config) => {
73
- let mode;
74
74
  if (config.env.DEV) {
75
- mode = 'dev';
75
+ this.#mode = 'dev';
76
76
  }
77
77
  else {
78
- mode = 'build';
78
+ this.#mode = 'build';
79
79
  }
80
80
  this.#projectRoot = config.root;
81
- await this.#init(mode);
81
+ await this.#init();
82
82
  };
83
83
  handleHotUpdate = async (ctx) => {
84
+ if (!this.#config.hmr) {
85
+ return;
86
+ }
84
87
  // This is mainly to make sure that PO catalog changes result in a page reload with new catalogs
85
88
  if (!(ctx.file in this.#adaptersByCatalogPath)) {
86
89
  // prevent reloading whole app because of a change in compiled catalog
@@ -122,7 +125,7 @@ class Wuchale {
122
125
  }
123
126
  };
124
127
  #transformHandler = async (code, id, options) => {
125
- if (!this.#config.hmr) {
128
+ if (this.#mode === 'dev' && !this.#config.hmr) {
126
129
  return {};
127
130
  }
128
131
  const filename = relative(this.#projectRoot, id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/vite-plugin",
3
- "version": "0.15.5",
3
+ "version": "0.15.6",
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.8"
43
+ "wuchale": "^0.18.9"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.9.3"