lightnet 4.0.2 → 4.0.3
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# lightnet
|
|
2
2
|
|
|
3
|
+
## 4.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#372](https://github.com/LightNetDev/LightNet/pull/372) [`e5eb8b0`](https://github.com/LightNetDev/LightNet/commit/e5eb8b06a7684bf5d9090f885e04fcc5eea417ac) Thanks [@smn-cds](https://github.com/smn-cds)! - Fix dev translation HMR so editing `src/translations/*.yml` invalidates the full SSR importer chain and refreshes translated UI content.
|
|
8
|
+
|
|
9
|
+
- [#372](https://github.com/LightNetDev/LightNet/pull/372) [`e5eb8b0`](https://github.com/LightNetDev/LightNet/commit/e5eb8b06a7684bf5d9090f885e04fcc5eea417ac) Thanks [@smn-cds](https://github.com/smn-cds)! - Restore Language type export from "lightnet"
|
|
10
|
+
|
|
3
11
|
## 4.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/exports/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -40,22 +40,14 @@ export function vitePluginLightnetConfig(
|
|
|
40
40
|
const module = VIRTUAL_MODULES.find((m) => m === id)
|
|
41
41
|
if (module) return `\0${module}`
|
|
42
42
|
},
|
|
43
|
-
handleHotUpdate({ file,
|
|
43
|
+
handleHotUpdate({ file, server }) {
|
|
44
44
|
const srcPath = resolve(fileURLToPath(root), "src/translations/")
|
|
45
45
|
if (
|
|
46
46
|
(file.endsWith(".yml") || file.endsWith(".yaml")) &&
|
|
47
47
|
file.startsWith(srcPath)
|
|
48
48
|
) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
...TRANSLATION_RUNTIME_MODULES.flatMap((id) => {
|
|
52
|
-
const module = server.moduleGraph.getModuleById(id)
|
|
53
|
-
return module ? [module] : []
|
|
54
|
-
}),
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
for (const module of affectedModules) {
|
|
58
|
-
server.moduleGraph.invalidateModule(module)
|
|
49
|
+
for (const filePath of [file, ...TRANSLATION_RUNTIME_MODULES]) {
|
|
50
|
+
server.moduleGraph.onFileChange(filePath)
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
logger.info(`Update translations ${file.slice(srcPath.length)}`)
|
package/src/i18n/translate.ts
CHANGED
|
@@ -31,7 +31,11 @@ const languageCodes = [
|
|
|
31
31
|
),
|
|
32
32
|
]
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
// In dev we avoid memoizing translations so YAML edits are reflected after HMR.
|
|
35
|
+
const cacheInProduction = <TReturn>(compute: () => TReturn) =>
|
|
36
|
+
import.meta.env.DEV ? { get: compute } : lazy(compute)
|
|
37
|
+
|
|
38
|
+
const i18nextTranslations = cacheInProduction(async () => {
|
|
35
39
|
const result: Record<string, { translation: Record<string, string> }> = {}
|
|
36
40
|
for (const bcp47 of languageCodes) {
|
|
37
41
|
result[bcp47] = {
|
|
@@ -41,7 +45,7 @@ const i18nextTranslations = lazy(async () => {
|
|
|
41
45
|
return result
|
|
42
46
|
})
|
|
43
47
|
|
|
44
|
-
const translationKeys =
|
|
48
|
+
const translationKeys = cacheInProduction(async () => {
|
|
45
49
|
const translations = await i18nextTranslations.get()
|
|
46
50
|
return [
|
|
47
51
|
...new Set(
|