@yapyak/vite 0.0.6 → 0.0.7
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 +12 -3
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CorruptLocaleFileError, YAP_RUNTIME, autoTranslate,
|
|
1
|
+
import { CorruptLocaleFileError, YAP_COMPILE, YAP_RUNTIME, autoTranslate, detectRenames, discoverLocales, extractFile, findTranslation, getDocsUrl, migrateLocales, readLocaleData, readLocaleFile, syncLocaleFiles, toMessageKey, toVariants, transformFile, validateLocaleCode, walkSourceFiles, writeRegister } from "yapyak/compiler/internal";
|
|
2
2
|
import { createFilter, defineRuntime, loadYapyakConfig } from "yapyak/config/internal";
|
|
3
3
|
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { buildPatches } from "yapyak/internal";
|
|
4
5
|
import { readFileSync } from "node:fs";
|
|
5
6
|
//#region src/locale-resolver.ts
|
|
6
7
|
function createLocaleResolver(context, projectRoot, options) {
|
|
@@ -131,7 +132,8 @@ function toRuntimeModules(processors) {
|
|
|
131
132
|
//#endregion
|
|
132
133
|
//#region src/plugin/file-id.ts
|
|
133
134
|
function toFileId(projectRoot, id) {
|
|
134
|
-
|
|
135
|
+
const path = id.split("?")[0] ?? id;
|
|
136
|
+
return relative(projectRoot, path).replaceAll("\\", "/");
|
|
135
137
|
}
|
|
136
138
|
//#endregion
|
|
137
139
|
//#region src/plugin/candidate-id.ts
|
|
@@ -144,6 +146,7 @@ function isCandidateId(id, filter, projectRoot) {
|
|
|
144
146
|
function renderErrorDiagnostics(logger, result) {
|
|
145
147
|
const errors = [];
|
|
146
148
|
for (const diagnostic of result.diagnostics) {
|
|
149
|
+
if (diagnostic.code === YAP_COMPILE.PROCESSOR_PARSE_ERROR.code) continue;
|
|
147
150
|
if (diagnostic.severity === "error") {
|
|
148
151
|
errors.push(diagnostic);
|
|
149
152
|
continue;
|
|
@@ -152,6 +155,9 @@ function renderErrorDiagnostics(logger, result) {
|
|
|
152
155
|
}
|
|
153
156
|
return errors;
|
|
154
157
|
}
|
|
158
|
+
function hasParseFailure(result) {
|
|
159
|
+
return result.diagnostics.some((diagnostic) => diagnostic.code === YAP_COMPILE.PROCESSOR_PARSE_ERROR.code);
|
|
160
|
+
}
|
|
155
161
|
function formatDiagnostic(diagnostic) {
|
|
156
162
|
const location = `${diagnostic.fileId}:${diagnostic.range.start.line}:${diagnostic.range.start.column}`;
|
|
157
163
|
return `[yapyak] ${diagnostic.code} ${location}: ${diagnostic.message}\nSee ${getDocsUrl(diagnostic.code)}`;
|
|
@@ -225,7 +231,8 @@ function resolveExtraction(state, fileId, source) {
|
|
|
225
231
|
//#endregion
|
|
226
232
|
//#region src/plugin/locale-file.ts
|
|
227
233
|
function isLocaleFile(state, path) {
|
|
228
|
-
const
|
|
234
|
+
const directory = join(state.projectRoot, getNormalized(state).localesDir);
|
|
235
|
+
const relativePath = relative(directory, path);
|
|
229
236
|
if (relativePath === "" || relativePath.startsWith("..") || relativePath.includes(sep)) return false;
|
|
230
237
|
return extname(relativePath) === ".json";
|
|
231
238
|
}
|
|
@@ -405,6 +412,7 @@ function createDevServerPlugin(state) {
|
|
|
405
412
|
}
|
|
406
413
|
const result = resolveExtraction(state, fileId, code);
|
|
407
414
|
renderErrorDiagnostics(state.logger, result);
|
|
415
|
+
if (hasParseFailure(result)) continue;
|
|
408
416
|
if (result.messages.length > 0) state.messagesByFile.set(fileId, result.messages);
|
|
409
417
|
else state.messagesByFile.delete(fileId);
|
|
410
418
|
}
|
|
@@ -522,6 +530,7 @@ function createDevServerPlugin(state) {
|
|
|
522
530
|
const { defaultLocale, locales } = getResolver(state).getProjectLocales();
|
|
523
531
|
const result = resolveExtraction(state, fileId, code);
|
|
524
532
|
renderErrorDiagnostics(state.logger, result);
|
|
533
|
+
if (hasParseFailure(result)) return;
|
|
525
534
|
const before = state.messagesByFile.get(fileId) ?? [];
|
|
526
535
|
const after = result.messages;
|
|
527
536
|
if (areMessagesEqual(before, after)) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yapyak/vite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Vite plugin for yapyak.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/node": "26.1.
|
|
34
|
-
"tsdown": "0.22.
|
|
33
|
+
"@types/node": "26.1.2",
|
|
34
|
+
"tsdown": "0.22.14",
|
|
35
35
|
"typescript": "6.0.3",
|
|
36
|
-
"vite": "8.
|
|
36
|
+
"vite": "8.2.0",
|
|
37
37
|
"vitest": "4.1.10",
|
|
38
38
|
"@yapyak/tsdown-config": "0.0.0",
|
|
39
39
|
"@yapyak/typescript-config": "0.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vite": ">=8",
|
|
43
|
-
"yapyak": "0.0.
|
|
43
|
+
"yapyak": "0.0.7"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22.22"
|