@dyrected/nuxt 2.5.12 → 2.5.13
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.
|
@@ -2,15 +2,15 @@ import { defineEventHandler, getRequestURL } from "h3";
|
|
|
2
2
|
import { createDyrectedApp } from "@dyrected/core/server";
|
|
3
3
|
import { useRuntimeConfig } from "#imports";
|
|
4
4
|
let app;
|
|
5
|
+
let lastVersion = 0;
|
|
5
6
|
export default defineEventHandler(async (event) => {
|
|
6
7
|
const config = useRuntimeConfig().dyrected;
|
|
7
|
-
|
|
8
|
+
const currentVersion = globalThis.__dyrected_config_version || 0;
|
|
9
|
+
if (!app || currentVersion !== lastVersion) {
|
|
10
|
+
lastVersion = currentVersion;
|
|
8
11
|
let dyrectedConfig = { ...config };
|
|
9
12
|
if (globalThis.__dyrected_config) {
|
|
10
13
|
const gConfig = globalThis.__dyrected_config;
|
|
11
|
-
console.log("[dyrected/nuxt] raw __dyrected_config:", gConfig);
|
|
12
|
-
console.log("[dyrected/nuxt] raw __dyrected_config keys:", Object.keys(gConfig || {}));
|
|
13
|
-
console.log("[dyrected/nuxt] raw __dyrected_config default keys:", Object.keys(gConfig?.default || {}));
|
|
14
14
|
const configObj = gConfig.default && (gConfig.default.collections || gConfig.default.globals || gConfig.default.db) ? gConfig.default : gConfig;
|
|
15
15
|
console.log("[dyrected/nuxt] chosen configObj keys:", Object.keys(configObj || {}));
|
|
16
16
|
dyrectedConfig = { ...dyrectedConfig, ...configObj };
|
|
@@ -30,6 +30,7 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
30
30
|
const newConfig = await loadDyrectedConfig(configPath);
|
|
31
31
|
const newObj = newConfig.default && (newConfig.default.collections || newConfig.default.globals || newConfig.default.db) ? newConfig.default : newConfig;
|
|
32
32
|
globalThis.__dyrected_config = newObj;
|
|
33
|
+
globalThis.__dyrected_config_version = (globalThis.__dyrected_config_version || 0) + 1;
|
|
33
34
|
if (newObj.db) {
|
|
34
35
|
globalThis.__dyrected_db = newObj.db;
|
|
35
36
|
console.log("[dyrected/nuxt] Database hot\u2011reloaded");
|
|
@@ -38,6 +39,7 @@ export default defineNitroPlugin(async (nitroApp) => {
|
|
|
38
39
|
globalThis.__dyrected_storage = newObj.storage;
|
|
39
40
|
console.log("[dyrected/nuxt] Storage hot\u2011reloaded");
|
|
40
41
|
}
|
|
42
|
+
console.log("[dyrected/nuxt] Configuration hot-reloaded (version " + globalThis.__dyrected_config_version + ")");
|
|
41
43
|
} catch (e) {
|
|
42
44
|
console.error("[dyrected/nuxt] Hot\u2011reload failed:", e);
|
|
43
45
|
}
|
|
@@ -15,16 +15,32 @@ export async function loadDyrectedConfig(configPath) {
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
const jitiMod = await import("jiti");
|
|
18
|
-
|
|
18
|
+
const resolvedPath = path.resolve(configPath);
|
|
19
19
|
if (typeof jitiMod.createJiti === "function") {
|
|
20
20
|
const jitiInstance = jitiMod.createJiti(import.meta.url, {
|
|
21
21
|
esmResolve: true,
|
|
22
22
|
interopDefault: true
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
if (jitiInstance.cache) {
|
|
25
|
+
delete jitiInstance.cache[resolvedPath];
|
|
26
|
+
for (const k of Object.keys(jitiInstance.cache)) {
|
|
27
|
+
if (path.resolve(k) === resolvedPath) {
|
|
28
|
+
delete jitiInstance.cache[k];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return await jitiInstance.import(configPath);
|
|
25
33
|
} else {
|
|
26
34
|
const jitiDefault = jitiMod.default || jitiMod;
|
|
27
|
-
loader =
|
|
35
|
+
const loader = jitiDefault(import.meta.url, { esmResolve: true, interopDefault: true });
|
|
36
|
+
if (loader.cache) {
|
|
37
|
+
delete loader.cache[resolvedPath];
|
|
38
|
+
for (const k of Object.keys(loader.cache)) {
|
|
39
|
+
if (path.resolve(k) === resolvedPath) {
|
|
40
|
+
delete loader.cache[k];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return loader(configPath);
|
|
28
45
|
}
|
|
29
|
-
return await loader(configPath);
|
|
30
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/nuxt",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/module.mjs",
|
|
6
6
|
"types": "./dist/module.d.ts",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@nuxt/kit": "^3.11.2",
|
|
12
12
|
"h3": "^1.15.0",
|
|
13
|
-
"@dyrected/
|
|
14
|
-
"@dyrected/sdk": "2.5.
|
|
15
|
-
"@dyrected/
|
|
16
|
-
"@dyrected/
|
|
13
|
+
"@dyrected/core": "2.5.13",
|
|
14
|
+
"@dyrected/sdk": "2.5.13",
|
|
15
|
+
"@dyrected/vue": "2.5.13",
|
|
16
|
+
"@dyrected/admin": "2.5.13"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"nuxt": "^3.0.0",
|