@zachhandley/ez-i18n 0.1.7 → 0.1.9

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 CHANGED
@@ -152,8 +152,7 @@ function toRelativeImport(absolutePath, projectRoot) {
152
152
  }
153
153
  function toGlobPattern(baseDir, projectRoot) {
154
154
  const relativePath = path.relative(projectRoot, baseDir).replace(/\\/g, "/");
155
- const normalized = relativePath.startsWith(".") ? relativePath : "./" + relativePath;
156
- return `${normalized}/**/*.json`;
155
+ return `/${relativePath}/**/*.json`;
157
156
  }
158
157
  function getNamespaceFromPath(filePath, localeDir) {
159
158
  const relative2 = path.relative(localeDir, filePath);
@@ -268,7 +267,7 @@ function vitePlugin(config) {
268
267
  localeBaseDir: localeBaseDirs[locale]
269
268
  };
270
269
  if (isDev && config.translations) {
271
- const localeConfig = typeof config.translations === "string" ? path2.join(config.translations, locale) : config.translations[locale];
270
+ const localeConfig = typeof config.translations === "string" ? path2.join(config.translations, locale) + "/" : config.translations[locale];
272
271
  if (localeConfig && typeof localeConfig === "string") {
273
272
  const pathType = detectPathType(localeConfig);
274
273
  if (pathType === "folder" || pathType === "glob") {
@@ -52,7 +52,8 @@ declare function isCacheValid(cache: TranslationCache, projectRoot: string): boo
52
52
  */
53
53
  declare function toRelativeImport(absolutePath: string, projectRoot: string): string;
54
54
  /**
55
- * Generate a glob pattern for import.meta.glob from a base directory
55
+ * Generate a glob pattern for import.meta.glob from a base directory.
56
+ * In virtual modules, globs must start with '/' (project root relative).
56
57
  */
57
58
  declare function toGlobPattern(baseDir: string, projectRoot: string): string;
58
59
  /**
@@ -173,8 +173,7 @@ function toRelativeImport(absolutePath, projectRoot) {
173
173
  }
174
174
  function toGlobPattern(baseDir, projectRoot) {
175
175
  const relativePath = path.relative(projectRoot, baseDir).replace(/\\/g, "/");
176
- const normalized = relativePath.startsWith(".") ? relativePath : "./" + relativePath;
177
- return `${normalized}/**/*.json`;
176
+ return `/${relativePath}/**/*.json`;
178
177
  }
179
178
  function getNamespaceFromPath(filePath, localeDir) {
180
179
  const relative2 = path.relative(localeDir, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zachhandley/ez-i18n",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -302,12 +302,13 @@ export function toRelativeImport(absolutePath: string, projectRoot: string): str
302
302
  }
303
303
 
304
304
  /**
305
- * Generate a glob pattern for import.meta.glob from a base directory
305
+ * Generate a glob pattern for import.meta.glob from a base directory.
306
+ * In virtual modules, globs must start with '/' (project root relative).
306
307
  */
307
308
  export function toGlobPattern(baseDir: string, projectRoot: string): string {
308
309
  const relativePath = path.relative(projectRoot, baseDir).replace(/\\/g, '/');
309
- const normalized = relativePath.startsWith('.') ? relativePath : './' + relativePath;
310
- return `${normalized}/**/*.json`;
310
+ // Virtual modules require globs to start with '/' (project root relative)
311
+ return `/${relativePath}/**/*.json`;
311
312
  }
312
313
 
313
314
  /**
@@ -154,7 +154,7 @@ export function vitePlugin(config: EzI18nConfig): Plugin {
154
154
  // For dev mode, determine if we can use import.meta.glob
155
155
  if (isDev && config.translations) {
156
156
  const localeConfig = typeof config.translations === 'string'
157
- ? path.join(config.translations, locale)
157
+ ? path.join(config.translations, locale) + '/' // Trailing slash ensures detectPathType returns 'folder'
158
158
  : config.translations[locale];
159
159
 
160
160
  if (localeConfig && typeof localeConfig === 'string') {