@yapyak/vite 0.0.15 → 0.0.16
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 +14 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
2
|
-
import { CorruptLocaleFileError, YAP_COMPILE, YAP_RUNTIME, autoTranslate, detectRenames, discoverLocales, extractFile, findTranslation, getDocsUrl, migrateLocales, readLocaleData, readLocaleFile, resolveProcessor, syncLocaleFiles, toMessageKey, toVariants, transformFile, validateLocaleCode, walkSourceFiles, writeRegister } from "yapyak/compiler/internal";
|
|
2
|
+
import { CorruptLocaleFileError, YAP_COMPILE, YAP_RUNTIME, autoTranslate, detectRenames, discoverLocales, extractFile, findTranslation, getDocsUrl, hasParseFailure, migrateLocales, readLocaleData, readLocaleFile, resolveProcessor, syncLocaleFiles, toMessageKey, toVariants, transformFile, validateLocaleCode, walkSourceFiles, writeRegister } from "yapyak/compiler/internal";
|
|
3
3
|
import { createFilter, defineRuntime, loadYapyakConfig } from "yapyak/config/internal";
|
|
4
4
|
import { buildPatches } from "yapyak/internal";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
@@ -229,9 +229,6 @@ function renderErrorDiagnostics(logger, result) {
|
|
|
229
229
|
}
|
|
230
230
|
return errors;
|
|
231
231
|
}
|
|
232
|
-
function hasParseFailure(result) {
|
|
233
|
-
return result.diagnostics.some((diagnostic) => diagnostic.code === YAP_COMPILE.PROCESSOR_PARSE_ERROR.code);
|
|
234
|
-
}
|
|
235
232
|
function formatDiagnostic(diagnostic) {
|
|
236
233
|
const location = `${diagnostic.fileId}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
|
|
237
234
|
return `[yapyak] ${diagnostic.code} ${location}: ${diagnostic.message}\nSee ${getDocsUrl(diagnostic.code)}`;
|
|
@@ -240,11 +237,14 @@ function formatDiagnostic(diagnostic) {
|
|
|
240
237
|
//#region src/plugin/extraction.ts
|
|
241
238
|
function resolveExtraction(state, fileId, source) {
|
|
242
239
|
const { processors } = getNormalized(state);
|
|
243
|
-
if (!source.includes("yapyak") && !hasAmbientBindings(processors))
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
240
|
+
if (!source.includes("yapyak") && !hasAmbientBindings(processors)) {
|
|
241
|
+
state.extractionCache.delete(fileId);
|
|
242
|
+
return {
|
|
243
|
+
callSites: [],
|
|
244
|
+
diagnostics: [],
|
|
245
|
+
messages: []
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
248
|
const entry = state.extractionCache.get(fileId);
|
|
249
249
|
if (entry && entry.source === source && entry.callSiteCount === 0) return {
|
|
250
250
|
callSites: [],
|
|
@@ -404,7 +404,7 @@ function syncAll(state) {
|
|
|
404
404
|
for (const list of state.messagesByFile.values()) allMessages.push(...list);
|
|
405
405
|
const { locales, sourceLocale } = getResolver(state).getProjectLocales();
|
|
406
406
|
emitSyncDiagnostics(state, syncLocaleFiles({
|
|
407
|
-
filter: state.filter,
|
|
407
|
+
filter: (fileId) => state.filter(fileId) && isParsed(state, fileId),
|
|
408
408
|
messages: allMessages
|
|
409
409
|
}, {
|
|
410
410
|
locales,
|
|
@@ -413,6 +413,10 @@ function syncAll(state) {
|
|
|
413
413
|
}, state.projectRoot, { yapyakDir: state.yapyakDir }));
|
|
414
414
|
getResolver(state).invalidateData();
|
|
415
415
|
}
|
|
416
|
+
function isParsed(state, fileId) {
|
|
417
|
+
const entry = state.extractionCache.get(fileId);
|
|
418
|
+
return entry === void 0 || !hasParseFailure(entry);
|
|
419
|
+
}
|
|
416
420
|
function emitSyncDiagnostics(state, result) {
|
|
417
421
|
for (const entry of result.orphaned) state.logger.warn(`[yapyak] preserved '${entry.source}' (${entry.locale}) — call site removed from ${entry.fileId}, translation saved in case it returns.`);
|
|
418
422
|
for (const entry of result.restored) state.logger.info(`[yapyak] restored '${entry.source}' (${entry.locale}) in ${entry.fileId} — translation kept from when the call site was removed earlier.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yapyak/vite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Vite plugin for yapyak.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"vite": ">=8",
|
|
45
|
-
"yapyak": "0.0.
|
|
45
|
+
"yapyak": "0.0.16"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=22.22"
|