@yapyak/vite 0.0.1 → 0.0.2
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 +28 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CorruptLocaleFileError, YAP_RUNTIME, autoTranslate, detectRenames, discoverLocales, extractFile, findTranslation, getDocsUrl, migrateLocales, parseTemplate, readLocaleData, readLocaleFile, syncLocaleFiles, toMessageKey, toVariants, transformFile, validateLocaleCode, walkSourceFiles, writeRegister } from "yapyak/compiler/internal";
|
|
2
2
|
import { createFilter, defineRuntime, loadYapyakConfig } from "yapyak/config/internal";
|
|
3
|
-
import { basename, extname, join, relative, sep } from "node:path";
|
|
3
|
+
import { basename, extname, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
//#region src/locale-resolver.ts
|
|
6
6
|
function createLocaleResolver(context, projectRoot, options) {
|
|
@@ -54,6 +54,7 @@ function createLocaleResolver(context, projectRoot, options) {
|
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/virtual-runtime.ts
|
|
56
56
|
const RUNTIME_ID = "yapyak/runtime";
|
|
57
|
+
const RUNTIME_CORE_IDS = ["yapyak", "yapyak/internal"];
|
|
57
58
|
const RUNTIME_RESOLVED = "\0yapyak:runtime";
|
|
58
59
|
const RUNTIME_NO_EXTERNAL = ["yapyak", /^@yapyak\//];
|
|
59
60
|
function isRuntimeExternal(id) {
|
|
@@ -70,10 +71,16 @@ function renderLocaleWarning(warning, localesDir) {
|
|
|
70
71
|
//#endregion
|
|
71
72
|
//#region src/plugin/config.ts
|
|
72
73
|
function createConfigPlugin(state) {
|
|
74
|
+
const loads = /* @__PURE__ */ new Map();
|
|
73
75
|
return {
|
|
74
|
-
config() {
|
|
76
|
+
async config(userConfig) {
|
|
77
|
+
const result = await loadOnce(loads, resolve(userConfig.root ?? process.cwd()));
|
|
75
78
|
return {
|
|
76
|
-
optimizeDeps: { exclude: [
|
|
79
|
+
optimizeDeps: { exclude: [
|
|
80
|
+
RUNTIME_ID,
|
|
81
|
+
...RUNTIME_CORE_IDS,
|
|
82
|
+
...toRuntimeModules(result.config.processors)
|
|
83
|
+
] },
|
|
77
84
|
ssr: { noExternal: RUNTIME_NO_EXTERNAL }
|
|
78
85
|
};
|
|
79
86
|
},
|
|
@@ -82,7 +89,7 @@ function createConfigPlugin(state) {
|
|
|
82
89
|
state.yapyakDir = join(state.projectRoot, ".yapyak");
|
|
83
90
|
state.command = config.command;
|
|
84
91
|
state.logger = config.logger;
|
|
85
|
-
const result = await
|
|
92
|
+
const result = await loadOnce(loads, state.projectRoot);
|
|
86
93
|
state.normalized = result.config;
|
|
87
94
|
state.configFile = result.configFile;
|
|
88
95
|
state.filter = createFilter(result.config.include, result.config.exclude);
|
|
@@ -104,6 +111,23 @@ function createConfigPlugin(state) {
|
|
|
104
111
|
name: "yapyak:config"
|
|
105
112
|
};
|
|
106
113
|
}
|
|
114
|
+
function loadOnce(loads, root) {
|
|
115
|
+
const existing = loads.get(root);
|
|
116
|
+
if (existing === void 0) {
|
|
117
|
+
const pending = loadYapyakConfig(root);
|
|
118
|
+
loads.set(root, pending);
|
|
119
|
+
return pending;
|
|
120
|
+
}
|
|
121
|
+
return existing;
|
|
122
|
+
}
|
|
123
|
+
function toRuntimeModules(processors) {
|
|
124
|
+
const modules = [];
|
|
125
|
+
for (const processor of processors) {
|
|
126
|
+
if (processor.runtime === void 0) continue;
|
|
127
|
+
modules.push(processor.runtime.module);
|
|
128
|
+
}
|
|
129
|
+
return modules;
|
|
130
|
+
}
|
|
107
131
|
//#endregion
|
|
108
132
|
//#region src/plugin/file-id.ts
|
|
109
133
|
function toFileId(projectRoot, id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yapyak/vite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Vite plugin for yapyak.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vite": ">=8",
|
|
43
|
-
"yapyak": "0.0.
|
|
43
|
+
"yapyak": "0.0.2"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22.22"
|