@wuchale/vite-plugin 0.13.2 → 0.14.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/dist/index.d.ts CHANGED
@@ -26,7 +26,9 @@ declare class Plugin {
26
26
  load: (id: string) => string;
27
27
  transform: {
28
28
  order: "pre";
29
- handler: (code: string, id: string) => Promise<{
29
+ handler: (code: string, id: string, options?: {
30
+ ssr?: boolean;
31
+ }) => Promise<{
30
32
  code?: string;
31
33
  map?: any;
32
34
  }>;
package/dist/index.js CHANGED
@@ -31,15 +31,22 @@ class Plugin {
31
31
  const handler = new AdapterHandler(adapter, key, this.#config, mode, virtualPrefix, this.#projectRoot, this.#log);
32
32
  await handler.init(sharedState);
33
33
  this.#adapters[key] = handler;
34
- const loaderPath = resolve(handler.loaderPath);
35
- if (loaderPath in this.#adaptersByLoaderPath) {
36
- throw new Error([
37
- 'While catalogs can be shared, the same loader cannot be used by multiple adapters',
38
- `Conflicting: ${key} and ${this.#adaptersByLoaderPath[loaderPath].key}`,
39
- 'Specify a different loaderPath for one of them.'
40
- ].join('\n'));
34
+ for (const path of Object.values(handler.loaderPath)) {
35
+ const loaderPath = resolve(path);
36
+ if (loaderPath in this.#adaptersByLoaderPath) {
37
+ const otherKey = this.#adaptersByLoaderPath[loaderPath].key;
38
+ if (otherKey === key) {
39
+ // same loader for both ssr and client, no problem
40
+ continue;
41
+ }
42
+ throw new Error([
43
+ 'While catalogs can be shared, the same loader cannot be used by multiple adapters',
44
+ `Conflicting: ${key} and ${otherKey}`,
45
+ 'Specify a different loaderPath for one of them.'
46
+ ].join('\n'));
47
+ }
48
+ this.#adaptersByLoaderPath[loaderPath] = handler;
41
49
  }
42
- this.#adaptersByLoaderPath[loaderPath] = handler;
43
50
  for (const fname of Object.keys(handler.catalogPathsToLocales)) {
44
51
  this.#adaptersByCatalogPath[fname] ??= [];
45
52
  this.#adaptersByCatalogPath[fname].push(handler);
@@ -122,14 +129,14 @@ class Plugin {
122
129
  }
123
130
  return adapter.getProxy();
124
131
  };
125
- #transformHandler = async (code, id) => {
132
+ #transformHandler = async (code, id, options) => {
126
133
  if (!this.#config.hmr) {
127
134
  return {};
128
135
  }
129
136
  const filename = relative(this.#projectRoot, id);
130
137
  for (const adapter of Object.values(this.#adapters)) {
131
138
  if (adapter.fileMatches(filename)) {
132
- return await adapter.transform(code, filename, this.#hmrVersion);
139
+ return await adapter.transform(code, filename, this.#hmrVersion, options?.ssr);
133
140
  }
134
141
  }
135
142
  return {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/vite-plugin",
3
- "version": "0.13.2",
3
+ "version": "0.14.1",
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.14.2"
43
+ "wuchale": "^0.15.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.8.3"