vuelo-framework 1.0.0 → 1.0.1
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/package.json
CHANGED
package/vueloFramework/app.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { ViteDevServer } from "vite";
|
|
2
2
|
import { createSSRApp } from "vue";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
// Resolver el directorio del módulo actual (funciona tanto en desarrollo como en node_modules)
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
// El archivo por defecto está en vueloFramework/defaults/App.vue relativo a este archivo
|
|
10
|
+
const defaultAppPath = path.resolve(__dirname, "defaults", "App.vue");
|
|
3
11
|
|
|
4
12
|
export async function createApp(vite: ViteDevServer, component: any) {
|
|
5
13
|
let module;
|
|
@@ -7,7 +15,8 @@ export async function createApp(vite: ViteDevServer, component: any) {
|
|
|
7
15
|
module = await vite.ssrLoadModule("src/App.vue");
|
|
8
16
|
} catch (error) {
|
|
9
17
|
console.log("App.vue no found con src using default");
|
|
10
|
-
|
|
18
|
+
// Usar el formato /@fs/ para que Vite pueda resolver la ruta absoluta
|
|
19
|
+
module = await vite.ssrLoadModule(`/@fs/${defaultAppPath}`);
|
|
11
20
|
}
|
|
12
21
|
const app = createSSRApp(module.default);
|
|
13
22
|
if (component) {
|
|
@@ -85,12 +85,16 @@ function generateImportMap(
|
|
|
85
85
|
route = route.endsWith("/") ? route.slice(0, -1) : route; // Eliminar barra final si existe
|
|
86
86
|
route = `/${route}`; // Asegurar que empiece con '/'
|
|
87
87
|
|
|
88
|
-
//
|
|
89
|
-
|
|
88
|
+
// Usar la ruta absoluta directamente (page ya es absoluta desde path.resolve)
|
|
89
|
+
// Esto funciona tanto en desarrollo como cuando el paquete está en node_modules
|
|
90
|
+
let absolutePath = page;
|
|
91
|
+
if (!path.isAbsolute(absolutePath)) {
|
|
92
|
+
absolutePath = path.resolve(process.cwd(), absolutePath);
|
|
93
|
+
}
|
|
90
94
|
|
|
91
95
|
return {
|
|
92
96
|
name,
|
|
93
|
-
path:
|
|
97
|
+
path: absolutePath, // Usar la ruta absoluta
|
|
94
98
|
route,
|
|
95
99
|
};
|
|
96
100
|
}),
|
|
@@ -132,9 +136,19 @@ export async function pagesComponents(vite: any, pages: any[]) {
|
|
|
132
136
|
|
|
133
137
|
// Recopilar todas las promesas de los componentes junto con su ruta
|
|
134
138
|
routes.forEach((componentRoute) => {
|
|
139
|
+
// Asegurarse de que la ruta sea absoluta
|
|
140
|
+
let modulePath = componentRoute.path;
|
|
141
|
+
if (!path.isAbsolute(modulePath)) {
|
|
142
|
+
modulePath = path.resolve(process.cwd(), modulePath);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Vite puede resolver rutas absolutas usando el formato /@fs/
|
|
146
|
+
// Esto funciona tanto en desarrollo como cuando el paquete está en node_modules
|
|
147
|
+
const viteModulePath = `/@fs/${modulePath}`;
|
|
148
|
+
|
|
135
149
|
components.push({
|
|
136
150
|
route: componentRoute,
|
|
137
|
-
promise: vite.ssrLoadModule(
|
|
151
|
+
promise: vite.ssrLoadModule(viteModulePath),
|
|
138
152
|
});
|
|
139
153
|
});
|
|
140
154
|
|
package/vueloFramework/server.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { createServer } from "vite";
|
|
|
2
2
|
import { getImports, islandsComponents, pagesComponents } from "./autoImport";
|
|
3
3
|
import { type VueloConfig } from "./interfaces/vueloConfig";
|
|
4
4
|
import BunServer from "./servers/bun";
|
|
5
|
+
import path from "path";
|
|
5
6
|
|
|
6
7
|
export async function vuelo(config: VueloConfig = {}) {
|
|
7
8
|
const defaultConfig: VueloConfig = {
|
|
@@ -10,7 +11,13 @@ export async function vuelo(config: VueloConfig = {}) {
|
|
|
10
11
|
mode: "SSR",
|
|
11
12
|
};
|
|
12
13
|
const finalConfig = { ...defaultConfig, ...config };
|
|
14
|
+
|
|
15
|
+
// Asegurar que Vite use el root del proyecto del usuario, no del paquete
|
|
16
|
+
// Esto es crítico cuando el paquete está instalado en node_modules
|
|
17
|
+
const projectRoot = process.cwd();
|
|
18
|
+
|
|
13
19
|
const vite = await createServer({
|
|
20
|
+
root: projectRoot, // Especificar explícitamente el root del proyecto
|
|
14
21
|
server: { middlewareMode: true },
|
|
15
22
|
});
|
|
16
23
|
const autoImports = await getImports();
|