@tanstack/solid-router 1.114.25 → 1.114.29
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/dist/cjs/lazyRouteComponent.cjs +9 -10
- package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
- package/dist/esm/lazyRouteComponent.js +10 -11
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/source/lazyRouteComponent.jsx +9 -6
- package/dist/source/lazyRouteComponent.jsx.map +1 -1
- package/package.json +3 -3
- package/src/lazyRouteComponent.tsx +9 -6
|
@@ -48,10 +48,13 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
48
48
|
}
|
|
49
49
|
throw error;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
if (!comp) {
|
|
52
|
+
const [compResource] = Solid.createResource(load, {
|
|
53
|
+
initialValue: comp,
|
|
54
|
+
ssrLoadFrom: "initial"
|
|
55
|
+
});
|
|
56
|
+
return web.memo(compResource);
|
|
57
|
+
}
|
|
55
58
|
if ((ssr == null ? void 0 : ssr()) === false) {
|
|
56
59
|
return web.createComponent(ClientOnly, {
|
|
57
60
|
get fallback() {
|
|
@@ -59,17 +62,13 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
59
62
|
},
|
|
60
63
|
get children() {
|
|
61
64
|
return web.createComponent(web.Dynamic, web.mergeProps({
|
|
62
|
-
|
|
63
|
-
return compResource();
|
|
64
|
-
}
|
|
65
|
+
component: comp
|
|
65
66
|
}, props));
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
return web.createComponent(web.Dynamic, web.mergeProps({
|
|
70
|
-
|
|
71
|
-
return compResource();
|
|
72
|
-
}
|
|
71
|
+
component: comp
|
|
73
72
|
}, props));
|
|
74
73
|
};
|
|
75
74
|
lazyComp.preload = load;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.cjs","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic, isServer } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport { Outlet } from './Match'\nimport type * as Solid from 'solid-js'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n return (\n typeof error?.message === 'string' &&\n /Failed to fetch dynamically imported module/.test(error.message)\n )\n}\n\nexport function ClientOnly(\n props: Solid.ParentProps<{ fallback?: Solid.JSX.Element }>,\n) {\n return useHydrated() ? <>{props.children}</> : <>{props.fallback}</>\n}\n\nexport function useHydrated() {\n return isServer\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n // throw the error if it was a module not found error during preload\n if (error) {\n if (isModuleNotFoundError(error)) {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, recover the promise with a null return,\n // and we will attempt module not found resolution during the render path.\n\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n\n // Return empty component while we wait for window to reload\n return {\n default: () => null,\n }\n }\n }\n }\n\n // Otherwise, just throw the error\n throw error\n }\n\n const [compResource] = createResource(load, {\n
|
|
1
|
+
{"version":3,"file":"lazyRouteComponent.cjs","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic, isServer } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport { Outlet } from './Match'\nimport type * as Solid from 'solid-js'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n return (\n typeof error?.message === 'string' &&\n /Failed to fetch dynamically imported module/.test(error.message)\n )\n}\n\nexport function ClientOnly(\n props: Solid.ParentProps<{ fallback?: Solid.JSX.Element }>,\n) {\n return useHydrated() ? <>{props.children}</> : <>{props.fallback}</>\n}\n\nexport function useHydrated() {\n return isServer\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n // throw the error if it was a module not found error during preload\n if (error) {\n if (isModuleNotFoundError(error)) {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, recover the promise with a null return,\n // and we will attempt module not found resolution during the render path.\n\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n\n // Return empty component while we wait for window to reload\n return {\n default: () => null,\n }\n }\n }\n }\n\n // Otherwise, just throw the error\n throw error\n }\n\n if (!comp) {\n const [compResource] = createResource(load, {\n initialValue: comp,\n ssrLoadFrom: 'initial',\n })\n return <>{compResource()}</>\n }\n\n if (ssr?.() === false) {\n return (\n <ClientOnly fallback={<Outlet />}>\n <Dynamic component={comp} {...props} />\n </ClientOnly>\n )\n }\n return <Dynamic component={comp} {...props} />\n }\n\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["isModuleNotFoundError","error","message","test","ClientOnly","props","useHydrated","_$memo","children","fallback","isServer","lazyRouteComponent","importer","exportName","ssr","loadPromise","comp","load","document","Promise","resolve","then","res","undefined","catch","err","lazyComp","Lazy","Error","window","sessionStorage","storageKey","getItem","setItem","location","reload","default","compResource","createResource","initialValue","ssrLoadFrom","_$createComponent","Outlet","Dynamic","_$mergeProps","component","preload"],"mappings":";;;;;AAWA,SAASA,sBAAsBC,OAAqB;AAClD,SACE,QAAOA,+BAAOC,aAAY,YAC1B,8CAA8CC,KAAKF,MAAMC,OAAO;AAEpE;AAEO,SAASE,WACdC,OACA;AACOC,SAAAA,YAAAA,IAAaC,IAAAA,KAAMF,MAAAA,MAAMG,QAAQ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ACrB,aAAA2B,IAAAA,gBACGrC,YAAU;AAAA,QAAA,IAACK,WAAQ;AAAAgC,iBAAAA,IAAAA,gBAAGC,MAAM,QAAA,EAAA;AAAA,QAAA;AAAA,QAAA,IAAAlC,WAAA;AAAAiC,iBAAAA,IAAAA,gBAC1BE,aAAOC,eAAA;AAAA,YAACC,WAAW7B;AAAAA,UAAI,GAAMX,KAAK,CAAA;AAAA,QAAA;AAAA,MAAA,CAAA;AAAA,IAAA;AAIzCoC,WAAAA,IAAAA,gBAAQE,aAAOC,eAAA;AAAA,MAACC,WAAW7B;AAAAA,IAAI,GAAMX,KAAK,CAAA;AAAA,EAC5C;AAEEqB,WAAiBoB,UAAU7B;AAEtBS,SAAAA;AACT;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponent, Dynamic, mergeProps,
|
|
1
|
+
import { memo, createComponent, Dynamic, mergeProps, isServer } from "solid-js/web";
|
|
2
2
|
import { createResource } from "solid-js";
|
|
3
3
|
import { Outlet } from "./Match.js";
|
|
4
4
|
function isModuleNotFoundError(error) {
|
|
@@ -46,10 +46,13 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
46
46
|
}
|
|
47
47
|
throw error;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (!comp) {
|
|
50
|
+
const [compResource] = createResource(load, {
|
|
51
|
+
initialValue: comp,
|
|
52
|
+
ssrLoadFrom: "initial"
|
|
53
|
+
});
|
|
54
|
+
return memo(compResource);
|
|
55
|
+
}
|
|
53
56
|
if ((ssr == null ? void 0 : ssr()) === false) {
|
|
54
57
|
return createComponent(ClientOnly, {
|
|
55
58
|
get fallback() {
|
|
@@ -57,17 +60,13 @@ function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
57
60
|
},
|
|
58
61
|
get children() {
|
|
59
62
|
return createComponent(Dynamic, mergeProps({
|
|
60
|
-
|
|
61
|
-
return compResource();
|
|
62
|
-
}
|
|
63
|
+
component: comp
|
|
63
64
|
}, props));
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
return createComponent(Dynamic, mergeProps({
|
|
68
|
-
|
|
69
|
-
return compResource();
|
|
70
|
-
}
|
|
69
|
+
component: comp
|
|
71
70
|
}, props));
|
|
72
71
|
};
|
|
73
72
|
lazyComp.preload = load;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic, isServer } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport { Outlet } from './Match'\nimport type * as Solid from 'solid-js'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n return (\n typeof error?.message === 'string' &&\n /Failed to fetch dynamically imported module/.test(error.message)\n )\n}\n\nexport function ClientOnly(\n props: Solid.ParentProps<{ fallback?: Solid.JSX.Element }>,\n) {\n return useHydrated() ? <>{props.children}</> : <>{props.fallback}</>\n}\n\nexport function useHydrated() {\n return isServer\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n // throw the error if it was a module not found error during preload\n if (error) {\n if (isModuleNotFoundError(error)) {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, recover the promise with a null return,\n // and we will attempt module not found resolution during the render path.\n\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n\n // Return empty component while we wait for window to reload\n return {\n default: () => null,\n }\n }\n }\n }\n\n // Otherwise, just throw the error\n throw error\n }\n\n const [compResource] = createResource(load, {\n
|
|
1
|
+
{"version":3,"file":"lazyRouteComponent.js","sources":["../../src/lazyRouteComponent.tsx"],"sourcesContent":["import { Dynamic, isServer } from 'solid-js/web'\nimport { createResource } from 'solid-js'\nimport { Outlet } from './Match'\nimport type * as Solid from 'solid-js'\nimport type { AsyncRouteComponent } from './route'\n\n// If the load fails due to module not found, it may mean a new version of\n// the build was deployed and the user's browser is still using an old version.\n// If this happens, the old version in the user's browser would have an outdated\n// URL to the lazy module.\n// In that case, we want to attempt one window refresh to get the latest.\nfunction isModuleNotFoundError(error: any): boolean {\n return (\n typeof error?.message === 'string' &&\n /Failed to fetch dynamically imported module/.test(error.message)\n )\n}\n\nexport function ClientOnly(\n props: Solid.ParentProps<{ fallback?: Solid.JSX.Element }>,\n) {\n return useHydrated() ? <>{props.children}</> : <>{props.fallback}</>\n}\n\nexport function useHydrated() {\n return isServer\n}\n\nexport function lazyRouteComponent<\n T extends Record<string, any>,\n TKey extends keyof T = 'default',\n>(\n importer: () => Promise<T>,\n exportName?: TKey,\n ssr?: () => boolean,\n): T[TKey] extends (props: infer TProps) => any\n ? AsyncRouteComponent<TProps>\n : never {\n let loadPromise: Promise<any> | undefined\n let comp: T[TKey] | T['default']\n let error: any\n\n const load = () => {\n if (typeof document === 'undefined' && ssr?.() === false) {\n comp = (() => null) as any\n return Promise.resolve(comp)\n }\n if (!loadPromise) {\n loadPromise = importer()\n .then((res) => {\n loadPromise = undefined\n comp = res[exportName ?? 'default']\n return comp\n })\n .catch((err) => {\n error = err\n })\n }\n\n return loadPromise\n }\n\n const lazyComp = function Lazy(props: any) {\n // Now that we're out of preload and into actual render path,\n // throw the error if it was a module not found error during preload\n if (error) {\n if (isModuleNotFoundError(error)) {\n // We don't want an error thrown from preload in this case, because\n // there's nothing we want to do about module not found during preload.\n // Record the error, recover the promise with a null return,\n // and we will attempt module not found resolution during the render path.\n\n if (\n error instanceof Error &&\n typeof window !== 'undefined' &&\n typeof sessionStorage !== 'undefined'\n ) {\n // Again, we want to reload one time on module not found error and not enter\n // a reload loop if there is some other issue besides an old deploy.\n // That's why we store our reload attempt in sessionStorage.\n // Use error.message as key because it contains the module path that failed.\n const storageKey = `tanstack_router_reload:${error.message}`\n if (!sessionStorage.getItem(storageKey)) {\n sessionStorage.setItem(storageKey, '1')\n window.location.reload()\n\n // Return empty component while we wait for window to reload\n return {\n default: () => null,\n }\n }\n }\n }\n\n // Otherwise, just throw the error\n throw error\n }\n\n if (!comp) {\n const [compResource] = createResource(load, {\n initialValue: comp,\n ssrLoadFrom: 'initial',\n })\n return <>{compResource()}</>\n }\n\n if (ssr?.() === false) {\n return (\n <ClientOnly fallback={<Outlet />}>\n <Dynamic component={comp} {...props} />\n </ClientOnly>\n )\n }\n return <Dynamic component={comp} {...props} />\n }\n\n ;(lazyComp as any).preload = load\n\n return lazyComp as any\n}\n"],"names":["isModuleNotFoundError","error","message","test","ClientOnly","props","useHydrated","_$memo","children","fallback","isServer","lazyRouteComponent","importer","exportName","ssr","loadPromise","comp","load","document","Promise","resolve","then","res","undefined","catch","err","lazyComp","Lazy","Error","window","sessionStorage","storageKey","getItem","setItem","location","reload","default","compResource","createResource","initialValue","ssrLoadFrom","_$createComponent","Outlet","Dynamic","_$mergeProps","component","preload"],"mappings":";;;AAWA,SAASA,sBAAsBC,OAAqB;AAClD,SACE,QAAOA,+BAAOC,aAAY,YAC1B,8CAA8CC,KAAKF,MAAMC,OAAO;AAEpE;AAEO,SAASE,WACdC,OACA;AACOC,SAAAA,YAAAA,IAAaC,KAAMF,MAAAA,MAAMG,QAAQ,IAAAD,KAAA,MAAUF,MAAMI,QAAQ;AAClE;AAEO,SAASH,cAAc;AACrBI,SAAAA;AACT;AAEgBC,SAAAA,mBAIdC,UACAC,YACAC,KAGQ;AACJC,MAAAA;AACAC,MAAAA;AACAf,MAAAA;AAEJ,QAAMgB,OAAOA,MAAM;AACjB,QAAI,OAAOC,aAAa,gBAAeJ,kCAAY,OAAO;AACxDE,aAAQ,MAAM;AACPG,aAAAA,QAAQC,QAAQJ,IAAI;AAAA,IAAA;AAE7B,QAAI,CAACD,aAAa;AACFH,oBAAAA,SAAAA,EACXS,KAAMC,CAAQ,QAAA;AACCC,sBAAAA;AACPD,eAAAA,IAAIT,cAAc,SAAS;AAC3BG,eAAAA;AAAAA,MAAAA,CACR,EACAQ,MAAOC,CAAQ,QAAA;AACNA,gBAAAA;AAAAA,MAAAA,CACT;AAAA,IAAA;AAGEV,WAAAA;AAAAA,EACT;AAEMW,QAAAA,WAAW,SAASC,KAAKtB,OAAY;AAGzC,QAAIJ,OAAO;AACLD,UAAAA,sBAAsBC,KAAK,GAAG;AAMhC,YACEA,iBAAiB2B,SACjB,OAAOC,WAAW,eAClB,OAAOC,mBAAmB,aAC1B;AAKMC,gBAAAA,aAAa,0BAA0B9B,MAAMC,OAAO;AAC1D,cAAI,CAAC4B,eAAeE,QAAQD,UAAU,GAAG;AACxBE,2BAAAA,QAAQF,YAAY,GAAG;AACtCF,mBAAOK,SAASC,OAAO;AAGhB,mBAAA;AAAA,cACLC,SAASA,MAAM;AAAA,YACjB;AAAA,UAAA;AAAA,QACF;AAAA,MACF;AAIInC,YAAAA;AAAAA,IAAAA;AAGR,QAAI,CAACe,MAAM;AACT,YAAM,CAACqB,YAAY,IAAIC,eAAerB,MAAM;AAAA,QAC1CsB,cAAcvB;AAAAA,QACdwB,aAAa;AAAA,MAAA,CACd;AACD,aAAAjC,KAAU8B,YAAY;AAAA,IAAA;AAGpBvB,SAAAA,kCAAY,OAAO;AACrB,aAAA2B,gBACGrC,YAAU;AAAA,QAAA,IAACK,WAAQ;AAAAgC,iBAAAA,gBAAGC,QAAM,EAAA;AAAA,QAAA;AAAA,QAAA,IAAAlC,WAAA;AAAAiC,iBAAAA,gBAC1BE,SAAOC,WAAA;AAAA,YAACC,WAAW7B;AAAAA,UAAI,GAAMX,KAAK,CAAA;AAAA,QAAA;AAAA,MAAA,CAAA;AAAA,IAAA;AAIzCoC,WAAAA,gBAAQE,SAAOC,WAAA;AAAA,MAACC,WAAW7B;AAAAA,IAAI,GAAMX,KAAK,CAAA;AAAA,EAC5C;AAEEqB,WAAiBoB,UAAU7B;AAEtBS,SAAAA;AACT;"}
|
|
@@ -68,16 +68,19 @@ export function lazyRouteComponent(importer, exportName, ssr) {
|
|
|
68
68
|
// Otherwise, just throw the error
|
|
69
69
|
throw error;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if (!comp) {
|
|
72
|
+
const [compResource] = createResource(load, {
|
|
73
|
+
initialValue: comp,
|
|
74
|
+
ssrLoadFrom: 'initial',
|
|
75
|
+
});
|
|
76
|
+
return <>{compResource()}</>;
|
|
77
|
+
}
|
|
75
78
|
if (ssr?.() === false) {
|
|
76
79
|
return (<ClientOnly fallback={<Outlet />}>
|
|
77
|
-
<Dynamic component={
|
|
80
|
+
<Dynamic component={comp} {...props}/>
|
|
78
81
|
</ClientOnly>);
|
|
79
82
|
}
|
|
80
|
-
return <Dynamic component={
|
|
83
|
+
return <Dynamic component={comp} {...props}/>;
|
|
81
84
|
};
|
|
82
85
|
lazyComp.preload = load;
|
|
83
86
|
return lazyComp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyRouteComponent.jsx","sourceRoot":"","sources":["../../src/lazyRouteComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAIhC,0EAA0E;AAC1E,+EAA+E;AAC/E,gFAAgF;AAChF,0BAA0B;AAC1B,yEAAyE;AACzE,SAAS,qBAAqB,CAAC,KAAU;IACvC,OAAO,CACL,OAAO,KAAK,EAAE,OAAO,KAAK,QAAQ;QAClC,6CAA6C,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAClE,CAAA;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,KAA0D;IAE1D,OAAO,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAIhC,QAA0B,EAC1B,UAAiB,EACjB,GAAmB;IAInB,IAAI,WAAqC,CAAA;IACzC,IAAI,IAA4B,CAAA;IAChC,IAAI,KAAU,CAAA;IAEd,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,GAAG,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;YACzD,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAQ,CAAA;YAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC9B,CAAC;QACD,IAAI,CAAC,WAAW,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AAI;gBAClB,WAAW,EAAE,SAAS;aACvB,CAAC,CAAA;YACF,OAAO,EAAE,CAAC,YAAY,EAAE,CAAC,GAAG,CAAA;QAC9B,CAAC;QAED,IAAI,GAAG,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;YACtB,OAAO,CACL,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,AAAD,EAAG,CAAC,CAC/B;UAAA,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,EACtC;QAAA,EAAE,UAAU,CAAC,CACd,CAAA;QACH,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;IAChD,CAAC,CAEA;IAAC,QAAgB,CAAC,OAAO,GAAG,IAAI,CAAA;IAEjC,OAAO,QAAe,CAAA;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-router",
|
|
3
|
-
"version": "1.114.
|
|
3
|
+
"version": "1.114.29",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"jsesc": "^3.0.2",
|
|
61
61
|
"tiny-invariant": "^1.3.3",
|
|
62
62
|
"tiny-warning": "^1.0.3",
|
|
63
|
-
"@tanstack/history": "1.114.
|
|
64
|
-
"@tanstack/router-core": "1.114.
|
|
63
|
+
"@tanstack/history": "1.114.29",
|
|
64
|
+
"@tanstack/router-core": "1.114.29"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@solidjs/testing-library": "^0.8.10",
|
|
@@ -96,19 +96,22 @@ export function lazyRouteComponent<
|
|
|
96
96
|
throw error
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
if (!comp) {
|
|
100
|
+
const [compResource] = createResource(load, {
|
|
101
|
+
initialValue: comp,
|
|
102
|
+
ssrLoadFrom: 'initial',
|
|
103
|
+
})
|
|
104
|
+
return <>{compResource()}</>
|
|
105
|
+
}
|
|
103
106
|
|
|
104
107
|
if (ssr?.() === false) {
|
|
105
108
|
return (
|
|
106
109
|
<ClientOnly fallback={<Outlet />}>
|
|
107
|
-
<Dynamic component={
|
|
110
|
+
<Dynamic component={comp} {...props} />
|
|
108
111
|
</ClientOnly>
|
|
109
112
|
)
|
|
110
113
|
}
|
|
111
|
-
return <Dynamic component={
|
|
114
|
+
return <Dynamic component={comp} {...props} />
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
;(lazyComp as any).preload = load
|