@lomray/vite-ssr-boost 6.2.1 → 6.3.0-beta.2
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/browser/entry.js +1 -1
- package/browser/entry.js.map +1 -1
- package/interfaces/route-object.d.ts +6 -3
- package/package.json +12 -12
package/browser/entry.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"react";import e from"react-dom/client";import{matchRoutes as o,createBrowserRouter as r,RouterProvider as a}from"react-router";import{IS_SSR_MODE as n}from"../constants/common.js";async function c(c,i,{init:l,routerOptions:m,createRouter:s=r,rootId:u="root"}={}){const d=o(i,window.location,m?.basename)?.filter((t=>t.route.lazy));d&&d?.length>0&&await Promise.all(d.map((async t=>{const
|
|
1
|
+
import t from"react";import e from"react-dom/client";import{matchRoutes as o,createBrowserRouter as r,RouterProvider as a}from"react-router";import{IS_SSR_MODE as n}from"../constants/common.js";async function c(c,i,{init:l,routerOptions:m,createRouter:s=r,rootId:u="root"}={}){const d=o(i,window.location,m?.basename)?.filter((t=>t.route.lazy));d&&d?.length>0&&await Promise.all(d.map((async t=>{const{lazy:e}=t.route;if("function"==typeof e){const o=await e();o&&Object.assign(t.route,{...o,lazy:void 0})}})));const f=s(i,m),p=document.getElementById(u),y=await(l?.({isSSRMode:n,router:f})),w=()=>t.createElement(c,{client:y},t.createElement(a,{router:f}));return n&&"1"!==p.dataset.forceSpa?e.hydrateRoot(p,t.createElement(w,null)):e.createRoot(p).render(t.createElement(w,null))}export{c as default};
|
|
2
2
|
//# sourceMappingURL=entry.js.map
|
package/browser/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport type { DataRouter, RouteObject } from 'react-router';\nimport { createBrowserRouter, matchRoutes, RouterProvider } from 'react-router';\nimport { IS_SSR_MODE } from '@constants/common';\nimport type { TRouteObject } from '@interfaces/route-object';\n\nexport interface IAppClientProps<T = undefined> {\n client: T;\n}\n\nexport interface IInitPropsParams {\n isSSRMode: boolean;\n router: DataRouter;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<IAppClientProps<T>>>;\n\nexport interface IEntryClientOptions<T> {\n init?: (params: IInitPropsParams) => Promise<T>;\n routerOptions?: Parameters<typeof createBrowserRouter>[1];\n createRouter?: typeof createBrowserRouter;\n rootId?: string;\n}\n\n/**\n * Render client side application\n */\nasync function entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: TRouteObject[],\n {\n init,\n routerOptions,\n createRouter = createBrowserRouter,\n rootId = 'root',\n }: IEntryClientOptions<TAppProps> = {},\n): Promise<ReactDOM.Root | void> {\n const lazyMatches = matchRoutes(\n routes as RouteObject[],\n window.location,\n routerOptions?.basename,\n )?.filter((m) => m.route.lazy);\n\n // Load the lazy matches and update the routes before creating router,\n // so we can hydrate the SSR-rendered content synchronously\n if (lazyMatches && lazyMatches?.length > 0) {\n await Promise.all(\n lazyMatches.map(async (m) => {\n const
|
|
1
|
+
{"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport type { DataRouter, RouteObject } from 'react-router';\nimport { createBrowserRouter, matchRoutes, RouterProvider } from 'react-router';\nimport { IS_SSR_MODE } from '@constants/common';\nimport type { TRouteObject } from '@interfaces/route-object';\n\nexport interface IAppClientProps<T = undefined> {\n client: T;\n}\n\nexport interface IInitPropsParams {\n isSSRMode: boolean;\n router: DataRouter;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<IAppClientProps<T>>>;\n\nexport interface IEntryClientOptions<T> {\n init?: (params: IInitPropsParams) => Promise<T>;\n routerOptions?: Parameters<typeof createBrowserRouter>[1];\n createRouter?: typeof createBrowserRouter;\n rootId?: string;\n}\n\n/**\n * Render client side application\n */\nasync function entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: TRouteObject[],\n {\n init,\n routerOptions,\n createRouter = createBrowserRouter,\n rootId = 'root',\n }: IEntryClientOptions<TAppProps> = {},\n): Promise<ReactDOM.Root | void> {\n const lazyMatches = matchRoutes(\n routes as RouteObject[],\n window.location,\n routerOptions?.basename,\n )?.filter((m) => m.route.lazy);\n\n // Load the lazy matches and update the routes before creating router,\n // so we can hydrate the SSR-rendered content synchronously\n if (lazyMatches && lazyMatches?.length > 0) {\n await Promise.all(\n lazyMatches.map(async (m) => {\n const { lazy } = m.route;\n\n if (typeof lazy === 'function') {\n const lazyResult = await lazy();\n\n if (lazyResult) {\n Object.assign(m.route, {\n ...lazyResult,\n lazy: undefined,\n });\n }\n }\n }),\n );\n }\n\n const router = createRouter(routes as RouteObject[], routerOptions);\n const root = document.getElementById(rootId) as HTMLElement;\n const appProps = (await init?.({ isSSRMode: IS_SSR_MODE, router })) as TAppProps;\n\n const AppComponent: FC = () => (\n <App client={appProps}>\n <RouterProvider router={router} />\n </App>\n );\n\n if (!IS_SSR_MODE || root.dataset['forceSpa'] === '1') {\n return ReactDOM.createRoot(root).render(<AppComponent />);\n }\n\n return ReactDOM.hydrateRoot(root, <AppComponent />);\n}\n\nexport default entry;\n"],"names":["async","entry","App","routes","init","routerOptions","createRouter","createBrowserRouter","rootId","lazyMatches","matchRoutes","window","location","basename","filter","m","route","lazy","length","Promise","all","map","lazyResult","Object","assign","undefined","router","root","document","getElementById","appProps","isSSRMode","IS_SSR_MODE","AppComponent","React","createElement","client","RouterProvider","dataset","ReactDOM","hydrateRoot","createRoot","render"],"mappings":"kMA6BAA,eAAeC,EACbC,EACAC,GACAC,KACEA,EAAIC,cACJA,EAAaC,aACbA,EAAeC,EAAmBC,OAClCA,EAAS,QACyB,CAAA,GAEpC,MAAMC,EAAcC,EAClBP,EACAQ,OAAOC,SACPP,GAAeQ,WACdC,QAAQC,GAAMA,EAAEC,MAAMC,OAIrBR,GAAeA,GAAaS,OAAS,SACjCC,QAAQC,IACZX,EAAYY,KAAIrB,MAAOe,IACrB,MAAME,KAAEA,GAASF,EAAEC,MAEnB,GAAoB,mBAATC,EAAqB,CAC9B,MAAMK,QAAmBL,IAErBK,GACFC,OAAOC,OAAOT,EAAEC,MAAO,IAClBM,EACHL,UAAMQ,SAQlB,MAAMC,EAASpB,EAAaH,EAAyBE,GAC/CsB,EAAOC,SAASC,eAAerB,GAC/BsB,QAAkB1B,IAAO,CAAE2B,UAAWC,EAAaN,YAEnDO,EAAmB,IACvBC,EAAAC,cAACjC,EAAG,CAACkC,OAAQN,GACXI,EAACC,cAAAE,GAAeX,OAAQA,KAI5B,OAAKM,GAA4C,MAA7BL,EAAKW,QAAkB,SAIpCC,EAASC,YAAYb,EAAMO,EAACC,cAAAF,EAAe,OAHzCM,EAASE,WAAWd,GAAMe,OAAOR,EAAAC,cAACF,EAAY,MAIzD"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { RouteObject } from 'react-router';
|
|
1
|
+
import { RouteObject, LazyRouteFunction, RouterInit } from 'react-router';
|
|
2
2
|
import { IDynamicRoute } from "../helpers/import-route.js";
|
|
3
|
+
type LazyRoute = LazyRouteFunction<RouterInit['routes'][number]>;
|
|
3
4
|
type TOnlyClientProp = RouteObject['Component'] | RouteObject['element'];
|
|
4
5
|
type TRouteObjectNR = Omit<RouteObject, 'lazy' | 'children'> & {
|
|
5
|
-
lazy?: IDynamicRoute |
|
|
6
|
+
lazy?: IDynamicRoute | LazyRoute;
|
|
6
7
|
onlyClient?: TOnlyClientProp;
|
|
7
8
|
children?: TRouteObject[];
|
|
8
9
|
};
|
|
9
|
-
type TRouteObject = RouteObject
|
|
10
|
+
type TRouteObject = (Omit<RouteObject, 'lazy'> & {
|
|
11
|
+
lazy: LazyRoute;
|
|
12
|
+
}) | TRouteObjectNR;
|
|
10
13
|
export { TOnlyClientProp, TRouteObjectNR, TRouteObject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lomray/vite-ssr-boost",
|
|
3
|
-
"version": "6.2
|
|
3
|
+
"version": "6.3.0-beta.2",
|
|
4
4
|
"description": "Vite plugin for create awesome SSR or SPA applications on React.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -35,36 +35,36 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"chalk": "^5.4.1",
|
|
38
|
-
"commander": "^
|
|
38
|
+
"commander": "^13.1.0",
|
|
39
39
|
"compression": "^1.8.0",
|
|
40
40
|
"express": "^4.21.2",
|
|
41
41
|
"hoist-non-react-statics": "^3.3.2",
|
|
42
42
|
"json5": "^2.2.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@commitlint/cli": "^19.8.
|
|
46
|
-
"@commitlint/config-conventional": "^19.8.
|
|
45
|
+
"@commitlint/cli": "^19.8.1",
|
|
46
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
47
47
|
"@lomray/eslint-config-react": "^5.0.6",
|
|
48
48
|
"@lomray/prettier-config": "^2.0.1",
|
|
49
49
|
"@rollup/plugin-terser": "^0.4.4",
|
|
50
50
|
"@testing-library/react": "^16.3.0",
|
|
51
51
|
"@types/babel__generator": "^7.6.8",
|
|
52
52
|
"@types/babel__traverse": "^7.20.6",
|
|
53
|
-
"@types/chai": "^5.2.
|
|
53
|
+
"@types/chai": "^5.2.2",
|
|
54
54
|
"@types/compression": "^1.7.5",
|
|
55
55
|
"@types/hoist-non-react-statics": "^3.3.6",
|
|
56
|
-
"@types/react-dom": "^18.3.
|
|
56
|
+
"@types/react-dom": "^18.3.7",
|
|
57
57
|
"@types/sinon": "^17.0.4",
|
|
58
58
|
"@types/sinon-chai": "^4.0.0",
|
|
59
|
-
"@vitest/coverage-v8": "^3.1.
|
|
59
|
+
"@vitest/coverage-v8": "^3.1.3",
|
|
60
60
|
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
61
61
|
"chai": "^5.2.0",
|
|
62
62
|
"eslint": "^8.57.1",
|
|
63
63
|
"husky": "^9.1.7",
|
|
64
|
-
"jsdom": "^26.
|
|
65
|
-
"lint-staged": "^
|
|
64
|
+
"jsdom": "^26.1.0",
|
|
65
|
+
"lint-staged": "^16.0.0",
|
|
66
66
|
"prettier": "^3.5.3",
|
|
67
|
-
"rollup": "^4.
|
|
67
|
+
"rollup": "^4.40.2",
|
|
68
68
|
"rollup-plugin-copy": "^3.5.0",
|
|
69
69
|
"rollup-plugin-folder-input": "^1.0.1",
|
|
70
70
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"sinon": "^20.0.0",
|
|
75
75
|
"sinon-chai": "^4.0.0",
|
|
76
76
|
"typescript": "^5.3.3",
|
|
77
|
-
"vitest": "^3.1.
|
|
77
|
+
"vitest": "^3.1.3"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
80
|
"@babel/generator": ">=7.23.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@babel/traverse": ">=7.23.0",
|
|
83
83
|
"@types/express": ">=4.17.21",
|
|
84
84
|
"react-dom": ">=18.2.0",
|
|
85
|
-
"react-router": "
|
|
85
|
+
"react-router": ">=7.0.1",
|
|
86
86
|
"vite": ">=5"
|
|
87
87
|
},
|
|
88
88
|
"bin": {
|