vike-lite 1.15.12 → 1.15.14
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.
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/__internal/client.d.ts
|
|
2
2
|
declare function createLinkClickHandler(onNavigate: (url: URL) => void): (e: MouseEvent) => void;
|
|
3
3
|
declare function createLinkPrefetchHandler(onPrefetch: (url: URL) => void): (e: Event) => void;
|
|
4
|
-
declare function finalizeNavigation(
|
|
5
|
-
[key: string]: boolean;
|
|
6
|
-
}, key: string): void;
|
|
4
|
+
declare function finalizeNavigation(scrollStateSetState: boolean): void;
|
|
7
5
|
interface ViewComponents {
|
|
8
6
|
Page: any | null;
|
|
9
7
|
Layout: any | null;
|
|
@@ -30,10 +30,10 @@ function createLinkPrefetchHandler(onPrefetch) {
|
|
|
30
30
|
onPrefetch(url);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function finalizeNavigation(
|
|
34
|
-
if (
|
|
33
|
+
function finalizeNavigation(scrollStateSetState) {
|
|
34
|
+
if (scrollStateSetState) {
|
|
35
35
|
globalThis.scrollTo(0, 0);
|
|
36
|
-
|
|
36
|
+
scrollStateSetState = false;
|
|
37
37
|
} else if (globalThis.location.hash) requestAnimationFrame(() => {
|
|
38
38
|
try {
|
|
39
39
|
document.querySelector(decodeURIComponent(globalThis.location.hash))?.scrollIntoView();
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
//#region src/__internal/vite.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates the Vite plugin that configures dev-server pre-bundling and SSR externalization
|
|
5
|
+
* for framework adapters (e.g. vike-lite-solid, vike-lite-vue) that export raw, uncompiled
|
|
6
|
+
* source files (.tsx/.vue) instead of a pre-built dist. Those adapters need:
|
|
7
|
+
* - `optimizeDeps.include`: eagerly pre-bundle the framework runtime (e.g. `solid-js`, `vue`)
|
|
8
|
+
* so the dev server doesn't re-bundle it on every page navigation.
|
|
9
|
+
* - `optimizeDeps.exclude` + `ssr.noExternal`: prevent Vite from treating the adapter package
|
|
10
|
+
* as an opaque, externalizable dependency, so its raw JSX/SFC source is instead processed
|
|
11
|
+
* by the framework's own Vite plugin (e.g. vite-plugin-solid, @vitejs/plugin-vue) both in
|
|
12
|
+
* dev and during the SSR build.
|
|
13
|
+
*
|
|
14
|
+
* This centralizes logic that is otherwise identical across every `vike-lite-*` package
|
|
15
|
+
* that ships raw source files.
|
|
16
|
+
*/
|
|
17
|
+
declare function createDepsConfigPlugin({ packageName, optimizeDepsInclude }: {
|
|
18
|
+
/** The framework adapter's package name, e.g. 'vike-lite-solid'. */
|
|
19
|
+
packageName: string;
|
|
20
|
+
/** Framework runtime packages to eagerly pre-bundle, e.g. ['solid-js']. */
|
|
21
|
+
optimizeDepsInclude: string[];
|
|
22
|
+
}): Plugin;
|
|
3
23
|
/**
|
|
4
24
|
* Creates the Vite plugin that wires a UI framework adapter (react/vue/solid) into vike-lite,
|
|
5
25
|
* by providing the virtual `virtual:vike-lite/client` and `virtual:vike-lite/server` modules
|
|
@@ -16,4 +36,4 @@ declare function createFrameworkAdapterPlugin({ packageName, hydration, wrapServ
|
|
|
16
36
|
wrapServerHydration?: boolean;
|
|
17
37
|
}): Plugin;
|
|
18
38
|
//#endregion
|
|
19
|
-
export { createFrameworkAdapterPlugin };
|
|
39
|
+
export { createDepsConfigPlugin, createFrameworkAdapterPlugin };
|
package/dist/__internal/vite.mjs
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
//#region src/__internal/vite.ts
|
|
2
2
|
/**
|
|
3
|
+
* Creates the Vite plugin that configures dev-server pre-bundling and SSR externalization
|
|
4
|
+
* for framework adapters (e.g. vike-lite-solid, vike-lite-vue) that export raw, uncompiled
|
|
5
|
+
* source files (.tsx/.vue) instead of a pre-built dist. Those adapters need:
|
|
6
|
+
* - `optimizeDeps.include`: eagerly pre-bundle the framework runtime (e.g. `solid-js`, `vue`)
|
|
7
|
+
* so the dev server doesn't re-bundle it on every page navigation.
|
|
8
|
+
* - `optimizeDeps.exclude` + `ssr.noExternal`: prevent Vite from treating the adapter package
|
|
9
|
+
* as an opaque, externalizable dependency, so its raw JSX/SFC source is instead processed
|
|
10
|
+
* by the framework's own Vite plugin (e.g. vite-plugin-solid, @vitejs/plugin-vue) both in
|
|
11
|
+
* dev and during the SSR build.
|
|
12
|
+
*
|
|
13
|
+
* This centralizes logic that is otherwise identical across every `vike-lite-*` package
|
|
14
|
+
* that ships raw source files.
|
|
15
|
+
*/
|
|
16
|
+
function createDepsConfigPlugin({ packageName, optimizeDepsInclude }) {
|
|
17
|
+
return {
|
|
18
|
+
name: `${packageName}-config`,
|
|
19
|
+
enforce: "pre",
|
|
20
|
+
config() {
|
|
21
|
+
return {
|
|
22
|
+
optimizeDeps: {
|
|
23
|
+
include: optimizeDepsInclude,
|
|
24
|
+
exclude: [packageName]
|
|
25
|
+
},
|
|
26
|
+
ssr: { noExternal: [packageName] }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
3
32
|
* Creates the Vite plugin that wires a UI framework adapter (react/vue/solid) into vike-lite,
|
|
4
33
|
* by providing the virtual `virtual:vike-lite/client` and `virtual:vike-lite/server` modules
|
|
5
34
|
* that vike-lite's core plugin reads to discover the framework's onRenderClient/onRenderHtml hooks.
|
|
@@ -25,4 +54,4 @@ function createFrameworkAdapterPlugin({ packageName, hydration = true, wrapServe
|
|
|
25
54
|
};
|
|
26
55
|
}
|
|
27
56
|
//#endregion
|
|
28
|
-
export { createFrameworkAdapterPlugin };
|
|
57
|
+
export { createDepsConfigPlugin, createFrameworkAdapterPlugin };
|
package/dist/vite.mjs
CHANGED
|
@@ -19,7 +19,8 @@ function generateRoutes(viteRoot, pagesDir) {
|
|
|
19
19
|
const routes = [];
|
|
20
20
|
let errorRoute;
|
|
21
21
|
function walk(dir, routePath, parentLayout, parentHead) {
|
|
22
|
-
const
|
|
22
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
23
|
+
const files = entries.map((entry) => entry.name);
|
|
23
24
|
const importPath = path.relative(viteRoot, dir).replaceAll("\\", "/");
|
|
24
25
|
const layoutFile = findFile(files, "+Layout", pageExtensions);
|
|
25
26
|
const currentLayout = layoutFile ? `${importPath}/${layoutFile}` : parentLayout;
|
|
@@ -41,9 +42,10 @@ function generateRoutes(viteRoot, pagesDir) {
|
|
|
41
42
|
if (currentHead) route.head = currentHead;
|
|
42
43
|
routes.push(route);
|
|
43
44
|
}
|
|
44
|
-
for (const
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
if (!entry.isDirectory()) continue;
|
|
47
|
+
const file = entry.name;
|
|
45
48
|
const fullPath = path.join(dir, file);
|
|
46
|
-
if (!fs.statSync(fullPath).isDirectory()) continue;
|
|
47
49
|
if (file === "_error") {
|
|
48
50
|
const errorPageFile = findFile(fs.readdirSync(fullPath), "+Page", pageExtensions);
|
|
49
51
|
if (errorPageFile) errorRoute = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-lite",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@types/node": "^26.1.1",
|
|
85
85
|
"tsdown": "^0.22.9",
|
|
86
|
-
"vite": "^8.1.5"
|
|
86
|
+
"vite": "^8.1.5",
|
|
87
|
+
"vitest": "^4.1.10"
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
90
|
"vite": ">=8"
|