@zachhandley/ez-i18n 0.3.10 → 0.3.11
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.js +18 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -894,15 +894,27 @@ function __deepMerge(target, ...sources) {
|
|
|
894
894
|
function getPublicLoaderCode() {
|
|
895
895
|
return `
|
|
896
896
|
async function __loadPublicJson(url, absolutePath) {
|
|
897
|
+
// Browser environment - use fetch
|
|
897
898
|
if (typeof window !== 'undefined') {
|
|
898
|
-
// Browser - use fetch with relative URL
|
|
899
899
|
return fetch(url).then(r => r.json());
|
|
900
|
-
} else {
|
|
901
|
-
// SSR/Node - read from filesystem
|
|
902
|
-
const fs = await import('node:fs');
|
|
903
|
-
const content = fs.readFileSync(absolutePath, 'utf-8');
|
|
904
|
-
return JSON.parse(content);
|
|
905
900
|
}
|
|
901
|
+
|
|
902
|
+
// Edge runtime detection (Cloudflare Workers, Vercel Edge, Deno, etc.)
|
|
903
|
+
// These environments have fetch but no filesystem access
|
|
904
|
+
const isEdgeRuntime = typeof globalThis.caches !== 'undefined' || // CF Workers / Service Workers
|
|
905
|
+
typeof globalThis.EdgeRuntime !== 'undefined' || // Vercel Edge
|
|
906
|
+
typeof Deno !== 'undefined' || // Deno
|
|
907
|
+
!globalThis.process?.versions?.node; // No Node.js process
|
|
908
|
+
|
|
909
|
+
if (isEdgeRuntime) {
|
|
910
|
+
// Edge runtime - use fetch (relative URLs work in request context)
|
|
911
|
+
return fetch(url).then(r => r.json());
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
// Traditional Node.js SSR - read from filesystem
|
|
915
|
+
const fs = await import('node:fs');
|
|
916
|
+
const content = fs.readFileSync(absolutePath, 'utf-8');
|
|
917
|
+
return JSON.parse(content);
|
|
906
918
|
}`;
|
|
907
919
|
}
|
|
908
920
|
function resolveConfig(config) {
|