@qwik.dev/router 2.0.0-beta.32 → 2.0.0-beta.34
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/lib/index.d.ts +49 -9
- package/lib/index.qwik.mjs +78 -31
- package/lib/middleware/node/index.mjs +71 -12
- package/lib/vite/index.mjs +22 -13
- package/package.json +3 -3
package/lib/index.d.ts
CHANGED
|
@@ -457,22 +457,39 @@ export declare const Link: Component<LinkProps>;
|
|
|
457
457
|
/** @public */
|
|
458
458
|
export declare interface LinkProps extends AnchorAttributes {
|
|
459
459
|
/**
|
|
460
|
-
*
|
|
460
|
+
* @deprecated Use `prefetchBundle` and `prefetchData` instead for more granular control over what
|
|
461
|
+
* is prefetched and when. This prop will be removed in a future major version.
|
|
461
462
|
*
|
|
462
|
-
*
|
|
463
|
-
* invoking any **`routeLoader$`**, **`onGet`**, etc.
|
|
463
|
+
* Legacy prefetch control for this **`Link`**.
|
|
464
464
|
*
|
|
465
|
-
*
|
|
465
|
+
* Setting this value to **`"js"`** will prefetch only javascript bundles required to render this
|
|
466
|
+
* page on the client when the link becomes visible. Setting this value to **`true`** will
|
|
467
|
+
* prefetch both javascript bundles and route data when the link becomes visible. Setting this
|
|
468
|
+
* value to **`false`** will disable prefetching altogether.
|
|
469
|
+
*/
|
|
470
|
+
prefetch?: boolean | 'js';
|
|
471
|
+
/**
|
|
472
|
+
* Controls when Qwik should prefetch the javascript bundles required to render this **`Link`**
|
|
473
|
+
* target during client-side navigation.
|
|
466
474
|
*
|
|
467
|
-
*
|
|
468
|
-
* with **`mouseover`/`focus`** during dev.
|
|
475
|
+
* Defaults to **`"visible"`**.
|
|
469
476
|
*
|
|
470
477
|
* Prefetching will not occur if the user has the **data saver** setting enabled.
|
|
478
|
+
*/
|
|
479
|
+
prefetchBundle?: PrefetchStrategy;
|
|
480
|
+
/**
|
|
481
|
+
* Controls when Qwik should prefetch and cache route data for this **`Link`** target, including
|
|
482
|
+
* invoking any **`routeLoader$`**, **`onGet`**, etc.
|
|
483
|
+
*
|
|
484
|
+
* Defaults to **`"intent"`**. When using the deprecated **`prefetch="js"`** prop, route data
|
|
485
|
+
* prefetching defaults to **`"off"`**.
|
|
486
|
+
*
|
|
487
|
+
* Prefetching route data can improve client-side navigation performance for pages that wait on
|
|
488
|
+
* loaders, server handlers, databases, or API calls.
|
|
471
489
|
*
|
|
472
|
-
*
|
|
473
|
-
* page on the client, **`false`** will disable prefetching altogether.
|
|
490
|
+
* Prefetching will not occur if the user has the **data saver** setting enabled.
|
|
474
491
|
*/
|
|
475
|
-
|
|
492
|
+
prefetchData?: PrefetchStrategy;
|
|
476
493
|
reload?: boolean;
|
|
477
494
|
replaceState?: boolean;
|
|
478
495
|
scroll?: boolean;
|
|
@@ -562,6 +579,29 @@ export declare type PageModule = RouteModule & {
|
|
|
562
579
|
/** @public */
|
|
563
580
|
export declare type PathParams = Record<string, string>;
|
|
564
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Defines when link prefetching should be triggered.
|
|
584
|
+
*
|
|
585
|
+
* @public
|
|
586
|
+
*/
|
|
587
|
+
export declare type PrefetchStrategy =
|
|
588
|
+
/**
|
|
589
|
+
* Prefetch when the user commits to navigating.
|
|
590
|
+
*
|
|
591
|
+
* Triggered by `pointerdown` or the `Enter` key.
|
|
592
|
+
*/
|
|
593
|
+
'commit'
|
|
594
|
+
/**
|
|
595
|
+
* Prefetch when the user shows navigation intent.
|
|
596
|
+
*
|
|
597
|
+
* Triggered by `pointerenter`, hover, or focus.
|
|
598
|
+
*/
|
|
599
|
+
| 'intent'
|
|
600
|
+
/** Prefetch when the link becomes visible in the viewport. */
|
|
601
|
+
| 'visible'
|
|
602
|
+
/** Disable link prefetching. */
|
|
603
|
+
| 'off';
|
|
604
|
+
|
|
565
605
|
declare type Prettify<T> = {} & {
|
|
566
606
|
[K in keyof T]: T[K];
|
|
567
607
|
};
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl,
|
|
1
|
+
import { componentQrl, inlinedQrl, useErrorBoundary, useOnWindow, _captures, _jsxSorted, Slot, useSignal, untrack, _qrlSync, useVisibleTaskQrl, _jsxSplit, _getConstProps, _getVarProps, isDev, eventQrl, isServer, useStylesQrl, useServerData, useStore, useContextProvider, useTaskQrl, getLocale, noSerialize, isBrowser, useContext, SkipRender, implicit$FirstArg, withLocale, _wrapProp, _restProps, _fnSignal, createElement } from '@qwik.dev/core';
|
|
2
2
|
import { Fragment } from '@qwik.dev/core/jsx-runtime';
|
|
3
3
|
import { g as getClientNavPath, s as shouldPreload, p as preloadRouteBundles, l as loadClientData, i as isSamePath, c as createLoaderSignal, a as createDocumentHead, b as loadRoute, r as resolveHead, C as CLIENT_DATA_CACHE, d as isSameOrigin, Q as Q_ROUTE, D as DEFAULT_LOADERS_SERIALIZATION_STRATEGY, t as toUrl, e as clientNavigate, f as toPath, h as QFN_KEY, j as QACTION_KEY, k as QDATA_KEY } from './chunks/routing.qwik.mjs';
|
|
4
4
|
import { u as useNavigate, a as useLocation, b as useQwikRouterEnv, C as ContentContext, c as ContentInternalContext, D as DocumentHeadContext, H as HttpStatusContext, R as RouteLocationContext, d as RouteNavigateContext, e as RouteStateContext, f as RouteActionContext, g as RoutePreventNavigateContext, h as useAction, i as useDocumentHead } from './chunks/use-functions.qwik.mjs';
|
|
@@ -31,34 +31,56 @@ const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
31
31
|
const loc = useLocation();
|
|
32
32
|
const originalHref = props.href;
|
|
33
33
|
const anchorRef = useSignal();
|
|
34
|
-
const { onClick$, prefetch: prefetchProp, reload, replaceState, scroll,
|
|
34
|
+
const { onClick$, prefetch: prefetchProp, reload, replaceState, scroll, prefetchBundle: prefetchBundleProp = "visible", prefetchData: prefetchDataProp = prefetchProp === "js" ? "off" : "intent", ...linkProps } = props;
|
|
35
35
|
const clientNavPath = untrack(getClientNavPath, {
|
|
36
36
|
...linkProps,
|
|
37
37
|
reload
|
|
38
38
|
}, loc);
|
|
39
39
|
linkProps.href = clientNavPath || originalHref;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
40
|
+
const isDepratedPrefetchDisabled = prefetchProp === false;
|
|
41
|
+
const shouldPrefetch = untrack(shouldPreload, clientNavPath, loc);
|
|
42
|
+
const shouldPrefetchBundle = !!clientNavPath && prefetchBundleProp !== "off" && shouldPrefetch && !isDepratedPrefetchDisabled;
|
|
43
|
+
const shouldPrefetchData = !!clientNavPath && prefetchDataProp !== "off" && shouldPrefetch && !isDepratedPrefetchDisabled;
|
|
44
|
+
const handleBundlePrefetch = shouldPrefetchBundle ? /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
43
45
|
if (navigator.connection?.saveData) {
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
48
|
if (elm && elm.href) {
|
|
47
49
|
const url = new URL(elm.href);
|
|
48
50
|
preloadRouteBundles(url.pathname);
|
|
49
|
-
if (elm.hasAttribute("data-prefetch")) {
|
|
50
|
-
loadClientData(url, {
|
|
51
|
-
preloadRouteBundles: false,
|
|
52
|
-
isPrefetch: true
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
51
|
}
|
|
56
|
-
}, "
|
|
52
|
+
}, "Link_component_handleBundlePrefetch_ZttUP0kLKj0") : null;
|
|
53
|
+
const handleDataPrefetch = shouldPrefetchData ? /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
54
|
+
if (navigator.connection?.saveData) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (elm && elm.href) {
|
|
58
|
+
const url = new URL(elm.href);
|
|
59
|
+
loadClientData(url, {
|
|
60
|
+
preloadRouteBundles: false,
|
|
61
|
+
isPrefetch: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, "Link_component_handleDataPrefetch_lcd4O9LHbbA") : null;
|
|
57
65
|
const preventDefault = clientNavPath ? _qrlSync((event) => {
|
|
58
66
|
if (!(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
|
|
59
67
|
event.preventDefault();
|
|
60
68
|
}
|
|
61
|
-
}, "event=>{if(!(event.metaKey||event.ctrlKey||event.shiftKey||event.altKey)){event.preventDefault();}}") :
|
|
69
|
+
}, "event=>{if(!(event.metaKey||event.ctrlKey||event.shiftKey||event.altKey)){event.preventDefault();}}") : null;
|
|
70
|
+
const prefetchData = /* @__PURE__ */ inlinedQrl(async (_, elm) => {
|
|
71
|
+
const handleDataPrefetch2 = _captures[0];
|
|
72
|
+
handleDataPrefetch2?.(null, elm);
|
|
73
|
+
}, "Link_component_prefetchData_UwVx4NhHkSo", [
|
|
74
|
+
handleDataPrefetch
|
|
75
|
+
]);
|
|
76
|
+
const onEnterKeyDown = /* @__PURE__ */ inlinedQrl((event, element) => {
|
|
77
|
+
const prefetchData2 = _captures[0];
|
|
78
|
+
if (event.key === "Enter") {
|
|
79
|
+
prefetchData2(null, element);
|
|
80
|
+
}
|
|
81
|
+
}, "Link_component_onEnterKeyDown_z274ws00irY", [
|
|
82
|
+
prefetchData
|
|
83
|
+
]);
|
|
62
84
|
const handleClientSideNavigation = clientNavPath ? /* @__PURE__ */ inlinedQrl((event, elm) => {
|
|
63
85
|
const nav2 = _captures[0], reload2 = _captures[1], replaceState2 = _captures[2], scroll2 = _captures[3];
|
|
64
86
|
if (event.defaultPrevented) {
|
|
@@ -78,13 +100,13 @@ const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
78
100
|
reload,
|
|
79
101
|
replaceState,
|
|
80
102
|
scroll
|
|
81
|
-
]) :
|
|
103
|
+
]) : null;
|
|
82
104
|
const handlePreload = /* @__PURE__ */ inlinedQrl((_, elm) => {
|
|
83
105
|
const url = new URL(elm.href);
|
|
84
106
|
preloadRouteBundles(url.pathname, 1);
|
|
85
107
|
}, "Link_component_handlePreload_AAemwtuBjsE");
|
|
86
108
|
useVisibleTaskQrl(/* @__PURE__ */ inlinedQrl(({ track }) => {
|
|
87
|
-
const anchorRef2 = _captures[0],
|
|
109
|
+
const anchorRef2 = _captures[0], handleBundlePrefetch2 = _captures[1], handleDataPrefetch2 = _captures[2], linkProps2 = _captures[3], loc2 = _captures[4], prefetchBundleProp2 = _captures[5], prefetchDataProp2 = _captures[6], prefetchProp2 = _captures[7];
|
|
88
110
|
track(() => loc2.url.pathname);
|
|
89
111
|
const handler = linkProps2.onQVisible$;
|
|
90
112
|
if (handler) {
|
|
@@ -95,14 +117,26 @@ const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
95
117
|
handler?.(event, anchorRef2.value);
|
|
96
118
|
}
|
|
97
119
|
}
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
const isProdOrTest = !isDev || undefined ;
|
|
121
|
+
if (isProdOrTest && anchorRef2.value) {
|
|
122
|
+
if (prefetchBundleProp2 === "visible" || // deprecated prop below, remove in favor of prefetchBundle
|
|
123
|
+
prefetchProp2 === "js" || prefetchProp2 === true) {
|
|
124
|
+
handleBundlePrefetch2?.(null, anchorRef2.value);
|
|
125
|
+
}
|
|
126
|
+
if (prefetchDataProp2 === "visible" || // deprecated prop below, remove in favor of prefetchData
|
|
127
|
+
prefetchProp2 === true) {
|
|
128
|
+
handleDataPrefetch2?.(null, anchorRef2.value);
|
|
129
|
+
}
|
|
100
130
|
}
|
|
101
131
|
}, "Link_component_useVisibleTask_xKeuRmnoNSA", [
|
|
102
132
|
anchorRef,
|
|
103
|
-
|
|
133
|
+
handleBundlePrefetch,
|
|
134
|
+
handleDataPrefetch,
|
|
104
135
|
linkProps,
|
|
105
|
-
loc
|
|
136
|
+
loc,
|
|
137
|
+
prefetchBundleProp,
|
|
138
|
+
prefetchDataProp,
|
|
139
|
+
prefetchProp
|
|
106
140
|
]));
|
|
107
141
|
return /* @__PURE__ */ _jsxSplit("a", {
|
|
108
142
|
ref: anchorRef,
|
|
@@ -115,14 +149,21 @@ const Link = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
115
149
|
onClick$,
|
|
116
150
|
handleClientSideNavigation
|
|
117
151
|
],
|
|
118
|
-
"
|
|
119
|
-
"q-e:mouseover": [
|
|
152
|
+
"q-e:pointerenter": [
|
|
120
153
|
linkProps.onMouseOver$,
|
|
121
|
-
|
|
154
|
+
prefetchDataProp === "intent" ? prefetchData : null
|
|
122
155
|
],
|
|
123
156
|
"q-e:focus": [
|
|
124
157
|
linkProps.onFocus$,
|
|
125
|
-
|
|
158
|
+
prefetchDataProp === "intent" ? prefetchData : null
|
|
159
|
+
],
|
|
160
|
+
"q-e:pointerdown": [
|
|
161
|
+
linkProps.onPointerDown$,
|
|
162
|
+
prefetchDataProp === "commit" ? prefetchData : null
|
|
163
|
+
],
|
|
164
|
+
"q-e:keydown": [
|
|
165
|
+
linkProps.onKeyDown$,
|
|
166
|
+
prefetchDataProp === "commit" ? onEnterKeyDown : null
|
|
126
167
|
]
|
|
127
168
|
}, {
|
|
128
169
|
// We need to prevent the onQVisible$ from being called twice since it is handled in the visible task
|
|
@@ -841,6 +882,9 @@ const useQwikRouter = (props) => {
|
|
|
841
882
|
};
|
|
842
883
|
_waitNextPage().catch((err) => {
|
|
843
884
|
navigate();
|
|
885
|
+
if (err instanceof DOMException && err.name === "TimeoutError") {
|
|
886
|
+
throw new Error('View transition timed out. This can happen if you have "disableCache" in your browser devtools enabled.');
|
|
887
|
+
}
|
|
844
888
|
throw err;
|
|
845
889
|
}).finally(() => {
|
|
846
890
|
container2.element.setAttribute?.(Q_ROUTE, $routeName$);
|
|
@@ -903,13 +947,16 @@ const useQwikMockRouter = (props) => {
|
|
|
903
947
|
}, {
|
|
904
948
|
deep: false
|
|
905
949
|
});
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
950
|
+
const container = _getContextContainer();
|
|
951
|
+
const loadersObject = {};
|
|
952
|
+
const loadersState = {};
|
|
953
|
+
if (props.loaders) {
|
|
954
|
+
for (const { loader, data } of props.loaders) {
|
|
955
|
+
const id = loader.__id;
|
|
956
|
+
loadersObject[id] = data;
|
|
957
|
+
loadersState[id] = createLoaderSignal(loadersObject, id, url, DEFAULT_LOADERS_SERIALIZATION_STRATEGY, container);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
913
960
|
const goto = props.goto ?? /* @__PURE__ */ inlinedQrl(async () => {
|
|
914
961
|
console.warn("QwikRouterMockProvider: goto not provided");
|
|
915
962
|
}, "useQwikMockRouter_goto_aViHFxQ1a3s");
|
|
@@ -934,7 +981,7 @@ const useQwikMockRouter = (props) => {
|
|
|
934
981
|
useContextProvider(HttpStatusContext, httpStatus);
|
|
935
982
|
useContextProvider(RouteLocationContext, routeLocation);
|
|
936
983
|
useContextProvider(RouteNavigateContext, goto);
|
|
937
|
-
useContextProvider(RouteStateContext,
|
|
984
|
+
useContextProvider(RouteStateContext, loadersState);
|
|
938
985
|
useContextProvider(RouteActionContext, actionState);
|
|
939
986
|
const actionsMocks = props.actions?.reduce((acc, { action, handler }) => {
|
|
940
987
|
acc[action.__id] = handler;
|
|
@@ -32,6 +32,71 @@ function normalizeUrl(url, base) {
|
|
|
32
32
|
function getUrl(req, origin) {
|
|
33
33
|
return normalizeUrl(req.originalUrl || req.url || "/", origin);
|
|
34
34
|
}
|
|
35
|
+
function createNodeResponseSink(res) {
|
|
36
|
+
let closed = res.closed || res.destroyed;
|
|
37
|
+
const closedPromise = closed ? Promise.resolve() : new Promise((resolve) => {
|
|
38
|
+
res.once("close", () => {
|
|
39
|
+
closed = true;
|
|
40
|
+
resolve();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
const write = (chunk) => {
|
|
44
|
+
if (closed || res.closed || res.destroyed) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
let settled = false;
|
|
49
|
+
const finish = () => {
|
|
50
|
+
if (settled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
settled = true;
|
|
54
|
+
setImmediate(resolve);
|
|
55
|
+
};
|
|
56
|
+
const fail = (error) => {
|
|
57
|
+
if (settled) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
settled = true;
|
|
61
|
+
reject(error);
|
|
62
|
+
};
|
|
63
|
+
closedPromise.then(finish);
|
|
64
|
+
try {
|
|
65
|
+
res.write(chunk, (error) => {
|
|
66
|
+
if (error) {
|
|
67
|
+
if (isIgnoredError(error.message)) {
|
|
68
|
+
finish();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
fail(error);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
finish();
|
|
75
|
+
});
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (error instanceof Error && isIgnoredError(error.message)) {
|
|
78
|
+
finish();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
fail(error);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const close = () => {
|
|
86
|
+
if (closed || res.closed || res.destroyed) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
res.end(() => {
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
write,
|
|
97
|
+
close
|
|
98
|
+
};
|
|
99
|
+
}
|
|
35
100
|
async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
36
101
|
const requestHeaders = new Headers();
|
|
37
102
|
const nodeRequestHeaders = req.headers;
|
|
@@ -79,6 +144,7 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
79
144
|
},
|
|
80
145
|
getWritableStream: (status, headers, cookies) => {
|
|
81
146
|
res.statusCode = status;
|
|
147
|
+
const sink = createNodeResponseSink(res);
|
|
82
148
|
try {
|
|
83
149
|
for (const [key, value] of headers) {
|
|
84
150
|
if (invalidHeadersPattern.test(key)) {
|
|
@@ -95,17 +161,10 @@ async function fromNodeHttp(url, req, res, mode, getClientConn) {
|
|
|
95
161
|
}
|
|
96
162
|
return new WritableStream({
|
|
97
163
|
write(chunk) {
|
|
98
|
-
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
res.write(chunk, (error) => {
|
|
102
|
-
if (error && !isIgnoredError(error.message)) {
|
|
103
|
-
console.error(error);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
164
|
+
return sink.write(chunk);
|
|
106
165
|
},
|
|
107
166
|
close() {
|
|
108
|
-
|
|
167
|
+
return sink.close();
|
|
109
168
|
}
|
|
110
169
|
});
|
|
111
170
|
},
|
|
@@ -139,12 +198,12 @@ function createQwikRouter(opts) {
|
|
|
139
198
|
const handled = await requestHandler(serverRequestEv, opts);
|
|
140
199
|
if (handled) {
|
|
141
200
|
const err = await handled.completion;
|
|
142
|
-
if (err) {
|
|
143
|
-
throw err;
|
|
144
|
-
}
|
|
145
201
|
if (handled.requestEv.headersSent) {
|
|
146
202
|
return;
|
|
147
203
|
}
|
|
204
|
+
if (err) {
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
148
207
|
}
|
|
149
208
|
next();
|
|
150
209
|
} catch (e) {
|
package/lib/vite/index.mjs
CHANGED
|
@@ -479,7 +479,7 @@ async function walkServerPlugins(opts) {
|
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
481
|
}));
|
|
482
|
-
return sourceFiles;
|
|
482
|
+
return sourceFiles.sort((a, b) => a.filePath < b.filePath ? -1 : 1);
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
function resolveEntry(opts, sourceFile) {
|
|
@@ -2010,13 +2010,13 @@ function imagePlugin(userOpts) {
|
|
|
2010
2010
|
];
|
|
2011
2011
|
}
|
|
2012
2012
|
|
|
2013
|
-
async function collectServerFnModuleIds(
|
|
2013
|
+
async function collectServerFnModuleIds(routingContext, resolvedVirtualId, pluginContext) {
|
|
2014
2014
|
const serverFnModules = /* @__PURE__ */ new Set();
|
|
2015
2015
|
const queuedModuleIds = /* @__PURE__ */ new Set();
|
|
2016
2016
|
const seenModuleIds = /* @__PURE__ */ new Set();
|
|
2017
|
-
const routes =
|
|
2018
|
-
const layouts =
|
|
2019
|
-
const serverPlugins =
|
|
2017
|
+
const routes = routingContext.routes;
|
|
2018
|
+
const layouts = routingContext.layouts;
|
|
2019
|
+
const serverPlugins = routingContext.serverPlugins;
|
|
2020
2020
|
for (let i = 0; i < routes.length; i++) {
|
|
2021
2021
|
const route = routes[i];
|
|
2022
2022
|
queuedModuleIds.add(route.filePath);
|
|
@@ -2038,15 +2038,26 @@ async function collectServerFnModuleIds(ctx, resolvedVirtualId, loadModule) {
|
|
|
2038
2038
|
continue;
|
|
2039
2039
|
}
|
|
2040
2040
|
seenModuleIds.add(id);
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2041
|
+
const resolved = await pluginContext.resolve(id, void 0, {
|
|
2042
|
+
skipSelf: true
|
|
2043
|
+
});
|
|
2044
|
+
if (!resolved || resolved.external) {
|
|
2045
|
+
continue;
|
|
2046
|
+
}
|
|
2047
|
+
const moduleInfo = await pluginContext.load({
|
|
2048
|
+
id: resolved.id
|
|
2049
|
+
});
|
|
2050
|
+
if (moduleInfo.code == null) {
|
|
2051
|
+
continue;
|
|
2052
|
+
}
|
|
2053
|
+
if (moduleInfo.code.includes("serverQrl(")) {
|
|
2043
2054
|
serverFnModules.add(moduleInfo.id);
|
|
2044
2055
|
}
|
|
2045
|
-
const resolvedImports = moduleInfo.
|
|
2056
|
+
const resolvedImports = moduleInfo.importedIds.concat(moduleInfo.dynamicallyImportedIds);
|
|
2046
2057
|
for (let i = 0; i < resolvedImports.length; i++) {
|
|
2047
2058
|
const resolvedImport = resolvedImports[i];
|
|
2048
|
-
if (
|
|
2049
|
-
queuedModuleIds.add(resolvedImport
|
|
2059
|
+
if (resolvedImport && !seenModuleIds.has(resolvedImport)) {
|
|
2060
|
+
queuedModuleIds.add(resolvedImport);
|
|
2050
2061
|
}
|
|
2051
2062
|
}
|
|
2052
2063
|
}
|
|
@@ -2723,9 +2734,7 @@ function serverFnsPlugin(buildContextRef) {
|
|
|
2723
2734
|
if (!ctx) {
|
|
2724
2735
|
return;
|
|
2725
2736
|
}
|
|
2726
|
-
const moduleIds = await collectServerFnModuleIds(ctx, RESOLVED_ID,
|
|
2727
|
-
id
|
|
2728
|
-
}));
|
|
2737
|
+
const moduleIds = await collectServerFnModuleIds(ctx, RESOLVED_ID, this);
|
|
2729
2738
|
for (let i = 0; i < moduleIds.length; i++) {
|
|
2730
2739
|
serverFnModules.add(moduleIds[i]);
|
|
2731
2740
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/router",
|
|
3
3
|
"description": "The router for Qwik.",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.34",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/qwik/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@azure/functions": "3.5.1",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsm": "2.3.0",
|
|
41
41
|
"typescript": "5.9.3",
|
|
42
42
|
"uvu": "0.5.6",
|
|
43
|
-
"@qwik.dev/core": "2.0.0-beta.
|
|
43
|
+
"@qwik.dev/core": "2.0.0-beta.34"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"main": "./lib/index.qwik.mjs",
|
|
170
170
|
"peerDependencies": {
|
|
171
171
|
"vite": ">=6 <9",
|
|
172
|
-
"@qwik.dev/core": "^2.0.0-beta.
|
|
172
|
+
"@qwik.dev/core": "^2.0.0-beta.34"
|
|
173
173
|
},
|
|
174
174
|
"publishConfig": {
|
|
175
175
|
"access": "public"
|